@sage-rsc/talking-head-react 1.6.9 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/talkinghead.mjs +1 -87
package/package.json
CHANGED
package/src/lib/talkinghead.mjs
CHANGED
|
@@ -1658,94 +1658,8 @@ class TalkingHead {
|
|
|
1658
1658
|
* and rotation should be dampened to prevent freakishly high positions
|
|
1659
1659
|
*/
|
|
1660
1660
|
applyShoulderAdjustmentToBones() {
|
|
1661
|
-
//
|
|
1661
|
+
// Arm/shoulder adjustments disabled - no modifications applied
|
|
1662
1662
|
return;
|
|
1663
|
-
|
|
1664
|
-
if (!this.armature) return;
|
|
1665
|
-
|
|
1666
|
-
// Only apply shoulder adjustment when FBX animations are playing
|
|
1667
|
-
// This prevents interference with normal pose system (idle, wide, side, etc.)
|
|
1668
|
-
const isFBXPlaying = this.mixer && this.currentFBXAction && this.currentFBXAction.isRunning();
|
|
1669
|
-
if (!isFBXPlaying) {
|
|
1670
|
-
return; // Don't adjust shoulders during normal poses
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
// Get shoulder bones directly from armature
|
|
1674
|
-
const leftShoulderBone = this.armature.getObjectByName('LeftShoulder');
|
|
1675
|
-
const rightShoulderBone = this.armature.getObjectByName('RightShoulder');
|
|
1676
|
-
|
|
1677
|
-
if (!leftShoulderBone || !rightShoulderBone) return;
|
|
1678
|
-
|
|
1679
|
-
const tempEuler = new THREE.Euler();
|
|
1680
|
-
const tempQuaternion = new THREE.Quaternion();
|
|
1681
|
-
|
|
1682
|
-
// Research-based relaxed shoulder rotation values
|
|
1683
|
-
// Natural relaxed shoulders: X rotation ~0.5-0.7 radians (much lower for natural look)
|
|
1684
|
-
// High/stiff shoulders: X rotation ~1.5-1.8 radians
|
|
1685
|
-
// We aggressively clamp to a very relaxed position
|
|
1686
|
-
// Only apply this during FBX animations to prevent high shoulders from animation data
|
|
1687
|
-
const targetX = 0.6; // Target X rotation for relaxed, natural shoulders (radians) - lowered significantly
|
|
1688
|
-
const maxX = 0.7; // Maximum allowed X rotation - lowered significantly
|
|
1689
|
-
|
|
1690
|
-
// Adjust left shoulder bone directly
|
|
1691
|
-
if (leftShoulderBone.quaternion) {
|
|
1692
|
-
tempEuler.setFromQuaternion(leftShoulderBone.quaternion, 'XYZ');
|
|
1693
|
-
const originalX = tempEuler.x;
|
|
1694
|
-
|
|
1695
|
-
// Aggressively clamp X rotation to relaxed position
|
|
1696
|
-
if (tempEuler.x > maxX) {
|
|
1697
|
-
// Force to target relaxed position
|
|
1698
|
-
tempEuler.x = targetX;
|
|
1699
|
-
} else if (tempEuler.x > targetX) {
|
|
1700
|
-
// Smoothly reduce if slightly above target
|
|
1701
|
-
tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// Only update if we actually changed something
|
|
1705
|
-
if (Math.abs(tempEuler.x - originalX) > 0.01) {
|
|
1706
|
-
tempQuaternion.setFromEuler(tempEuler, 'XYZ');
|
|
1707
|
-
leftShoulderBone.quaternion.copy(tempQuaternion);
|
|
1708
|
-
// Update only the shoulder bone's matrix, NOT children
|
|
1709
|
-
// This prevents interference with arm/hand animations
|
|
1710
|
-
leftShoulderBone.updateMatrix();
|
|
1711
|
-
if (leftShoulderBone.parent) {
|
|
1712
|
-
leftShoulderBone.matrixWorld.multiplyMatrices(leftShoulderBone.parent.matrixWorld, leftShoulderBone.matrix);
|
|
1713
|
-
} else {
|
|
1714
|
-
leftShoulderBone.matrixWorld.copy(leftShoulderBone.matrix);
|
|
1715
|
-
}
|
|
1716
|
-
// DO NOT call updateMatrixWorld(true) as it propagates to children and interferes with FBX animations
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
// Adjust right shoulder bone directly
|
|
1721
|
-
if (rightShoulderBone.quaternion) {
|
|
1722
|
-
tempEuler.setFromQuaternion(rightShoulderBone.quaternion, 'XYZ');
|
|
1723
|
-
const originalX = tempEuler.x;
|
|
1724
|
-
|
|
1725
|
-
// Aggressively clamp X rotation to relaxed position
|
|
1726
|
-
if (tempEuler.x > maxX) {
|
|
1727
|
-
// Force to target relaxed position
|
|
1728
|
-
tempEuler.x = targetX;
|
|
1729
|
-
} else if (tempEuler.x > targetX) {
|
|
1730
|
-
// Smoothly reduce if slightly above target
|
|
1731
|
-
tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
// Only update if we actually changed something
|
|
1735
|
-
if (Math.abs(tempEuler.x - originalX) > 0.01) {
|
|
1736
|
-
tempQuaternion.setFromEuler(tempEuler, 'XYZ');
|
|
1737
|
-
rightShoulderBone.quaternion.copy(tempQuaternion);
|
|
1738
|
-
// Update only the shoulder bone's matrix, NOT children
|
|
1739
|
-
// This prevents interference with arm/hand animations
|
|
1740
|
-
rightShoulderBone.updateMatrix();
|
|
1741
|
-
if (rightShoulderBone.parent) {
|
|
1742
|
-
rightShoulderBone.matrixWorld.multiplyMatrices(rightShoulderBone.parent.matrixWorld, rightShoulderBone.matrix);
|
|
1743
|
-
} else {
|
|
1744
|
-
rightShoulderBone.matrixWorld.copy(rightShoulderBone.matrix);
|
|
1745
|
-
}
|
|
1746
|
-
// DO NOT call updateMatrixWorld(true) as it propagates to children and interferes with FBX animations
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
1663
|
}
|
|
1750
1664
|
|
|
1751
1665
|
/**
|