@sage-rsc/talking-head-react 1.4.5 → 1.4.6

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/dist/index.js CHANGED
@@ -4398,14 +4398,14 @@ class Be {
4398
4398
  * This is called from updatePoseBase for pose-based animations
4399
4399
  */
4400
4400
  applyShoulderAdjustment() {
4401
- const t = new y.Euler(), e = 0.8, n = 0.9;
4401
+ const t = new y.Euler(), e = 0.6, n = 0.7;
4402
4402
  if (this.poseAvatar.props["LeftShoulder.quaternion"]) {
4403
4403
  const i = this.poseAvatar.props["LeftShoulder.quaternion"];
4404
- t.setFromQuaternion(i, "XYZ"), t.x > n ? t.x = e : t.x > e && (t.x = e + (t.x - e) * 0.3), i.setFromEuler(t, "XYZ");
4404
+ t.setFromQuaternion(i, "XYZ"), t.x > n ? t.x = e : t.x > e && (t.x = e + (t.x - e) * 0.2), i.setFromEuler(t, "XYZ");
4405
4405
  }
4406
4406
  if (this.poseAvatar.props["RightShoulder.quaternion"]) {
4407
4407
  const i = this.poseAvatar.props["RightShoulder.quaternion"];
4408
- t.setFromQuaternion(i, "XYZ"), t.x > n ? t.x = e : t.x > e && (t.x = e + (t.x - e) * 0.3), i.setFromEuler(t, "XYZ");
4408
+ t.setFromQuaternion(i, "XYZ"), t.x > n ? t.x = e : t.x > e && (t.x = e + (t.x - e) * 0.2), i.setFromEuler(t, "XYZ");
4409
4409
  }
4410
4410
  }
4411
4411
  /**
@@ -4418,8 +4418,17 @@ class Be {
4418
4418
  if (!this.armature) return;
4419
4419
  const t = this.armature.getObjectByName("LeftShoulder"), e = this.armature.getObjectByName("RightShoulder");
4420
4420
  if (!t || !e) return;
4421
- const n = new y.Euler(), i = new y.Quaternion(), s = 0.8, o = 0.9;
4422
- t.quaternion && (n.setFromQuaternion(t.quaternion, "XYZ"), n.x > o ? n.x = s : n.x > s && (n.x = s + (n.x - s) * 0.3), i.setFromEuler(n, "XYZ"), t.quaternion.copy(i), t.updateMatrixWorld(!0)), e.quaternion && (n.setFromQuaternion(e.quaternion, "XYZ"), n.x > o ? n.x = s : n.x > s && (n.x = s + (n.x - s) * 0.3), i.setFromEuler(n, "XYZ"), e.quaternion.copy(i), e.updateMatrixWorld(!0));
4421
+ const n = new y.Euler(), i = new y.Quaternion(), s = 0.6, o = 0.7;
4422
+ if (t.quaternion) {
4423
+ n.setFromQuaternion(t.quaternion, "XYZ");
4424
+ const l = n.x;
4425
+ n.x > o ? n.x = s : n.x > s && (n.x = s + (n.x - s) * 0.2), Math.abs(n.x - l) > 0.01 && (i.setFromEuler(n, "XYZ"), t.quaternion.copy(i), t.updateMatrixWorld(!0));
4426
+ }
4427
+ if (e.quaternion) {
4428
+ n.setFromQuaternion(e.quaternion, "XYZ");
4429
+ const l = n.x;
4430
+ n.x > o ? n.x = s : n.x > s && (n.x = s + (n.x - s) * 0.2), Math.abs(n.x - l) > 0.01 && (i.setFromEuler(n, "XYZ"), e.quaternion.copy(i), e.updateMatrixWorld(!0));
4431
+ }
4423
4432
  }
4424
4433
  /**
4425
4434
  * Update avatar pose deltas
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "A reusable React component for 3D talking avatars with lip-sync and text-to-speech",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -1619,8 +1619,8 @@ class TalkingHead {
1619
1619
  */
1620
1620
  applyShoulderAdjustment() {
1621
1621
  const tempEuler = new THREE.Euler();
1622
- const targetX = 0.8; // Target X rotation for relaxed shoulders
1623
- const maxX = 0.9; // Maximum X rotation
1622
+ const targetX = 0.6; // Target X rotation for relaxed shoulders - lowered significantly
1623
+ const maxX = 0.7; // Maximum X rotation - lowered significantly
1624
1624
 
1625
1625
  // Adjust left shoulder
1626
1626
  if (this.poseAvatar.props['LeftShoulder.quaternion']) {
@@ -1630,7 +1630,7 @@ class TalkingHead {
1630
1630
  if (tempEuler.x > maxX) {
1631
1631
  tempEuler.x = targetX;
1632
1632
  } else if (tempEuler.x > targetX) {
1633
- tempEuler.x = targetX + (tempEuler.x - targetX) * 0.3;
1633
+ tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
1634
1634
  }
1635
1635
  leftShoulder.setFromEuler(tempEuler, 'XYZ');
1636
1636
  }
@@ -1643,7 +1643,7 @@ class TalkingHead {
1643
1643
  if (tempEuler.x > maxX) {
1644
1644
  tempEuler.x = targetX;
1645
1645
  } else if (tempEuler.x > targetX) {
1646
- tempEuler.x = targetX + (tempEuler.x - targetX) * 0.3;
1646
+ tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
1647
1647
  }
1648
1648
  rightShoulder.setFromEuler(tempEuler, 'XYZ');
1649
1649
  }
@@ -1668,15 +1668,16 @@ class TalkingHead {
1668
1668
  const tempQuaternion = new THREE.Quaternion();
1669
1669
 
1670
1670
  // Research-based relaxed shoulder rotation values
1671
- // Natural relaxed shoulders: X rotation ~0.7-0.9 radians
1671
+ // Natural relaxed shoulders: X rotation ~0.5-0.7 radians (much lower for natural look)
1672
1672
  // High/stiff shoulders: X rotation ~1.5-1.8 radians
1673
- // We clamp to a natural relaxed position
1674
- const targetX = 0.8; // Target X rotation for relaxed, natural shoulders (radians)
1675
- const maxX = 0.9; // Maximum allowed X rotation
1673
+ // We aggressively clamp to a very relaxed position
1674
+ const targetX = 0.6; // Target X rotation for relaxed, natural shoulders (radians) - lowered significantly
1675
+ const maxX = 0.7; // Maximum allowed X rotation - lowered significantly
1676
1676
 
1677
1677
  // Adjust left shoulder bone directly
1678
1678
  if (leftShoulderBone.quaternion) {
1679
1679
  tempEuler.setFromQuaternion(leftShoulderBone.quaternion, 'XYZ');
1680
+ const originalX = tempEuler.x;
1680
1681
 
1681
1682
  // Aggressively clamp X rotation to relaxed position
1682
1683
  if (tempEuler.x > maxX) {
@@ -1684,17 +1685,21 @@ class TalkingHead {
1684
1685
  tempEuler.x = targetX;
1685
1686
  } else if (tempEuler.x > targetX) {
1686
1687
  // Smoothly reduce if slightly above target
1687
- tempEuler.x = targetX + (tempEuler.x - targetX) * 0.3;
1688
+ tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
1688
1689
  }
1689
1690
 
1690
- tempQuaternion.setFromEuler(tempEuler, 'XYZ');
1691
- leftShoulderBone.quaternion.copy(tempQuaternion);
1692
- leftShoulderBone.updateMatrixWorld(true);
1691
+ // Only update if we actually changed something
1692
+ if (Math.abs(tempEuler.x - originalX) > 0.01) {
1693
+ tempQuaternion.setFromEuler(tempEuler, 'XYZ');
1694
+ leftShoulderBone.quaternion.copy(tempQuaternion);
1695
+ leftShoulderBone.updateMatrixWorld(true);
1696
+ }
1693
1697
  }
1694
1698
 
1695
1699
  // Adjust right shoulder bone directly
1696
1700
  if (rightShoulderBone.quaternion) {
1697
1701
  tempEuler.setFromQuaternion(rightShoulderBone.quaternion, 'XYZ');
1702
+ const originalX = tempEuler.x;
1698
1703
 
1699
1704
  // Aggressively clamp X rotation to relaxed position
1700
1705
  if (tempEuler.x > maxX) {
@@ -1702,12 +1707,15 @@ class TalkingHead {
1702
1707
  tempEuler.x = targetX;
1703
1708
  } else if (tempEuler.x > targetX) {
1704
1709
  // Smoothly reduce if slightly above target
1705
- tempEuler.x = targetX + (tempEuler.x - targetX) * 0.3;
1710
+ tempEuler.x = targetX + (tempEuler.x - targetX) * 0.2; // More aggressive reduction
1706
1711
  }
1707
1712
 
1708
- tempQuaternion.setFromEuler(tempEuler, 'XYZ');
1709
- rightShoulderBone.quaternion.copy(tempQuaternion);
1710
- rightShoulderBone.updateMatrixWorld(true);
1713
+ // Only update if we actually changed something
1714
+ if (Math.abs(tempEuler.x - originalX) > 0.01) {
1715
+ tempQuaternion.setFromEuler(tempEuler, 'XYZ');
1716
+ rightShoulderBone.quaternion.copy(tempQuaternion);
1717
+ rightShoulderBone.updateMatrixWorld(true);
1718
+ }
1711
1719
  }
1712
1720
  }
1713
1721