@sage-rsc/talking-head-react 1.1.9 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-rsc/talking-head-react",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
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",
@@ -5664,8 +5664,14 @@ class TalkingHead {
5664
5664
  newTrack.name = newTrackName;
5665
5665
 
5666
5666
  // Fix rotations for Ready Player Me arm bones (coordinate system correction)
5667
+ // Ready Player Me uses a different coordinate system, so we need to adjust rotations
5667
5668
  const isArmBone = mappedBoneName.includes('Arm') || mappedBoneName.includes('Hand') || mappedBoneName.includes('Shoulder');
5668
- const isLeftArm = mappedBoneName.includes('Left');
5669
+ const isLeftSide = mappedBoneName.includes('Left');
5670
+ const isRightSide = mappedBoneName.includes('Right');
5671
+ const isForearm = mappedBoneName.includes('ForeArm') || mappedBoneName.includes('Forearm');
5672
+ const isHand = mappedBoneName.includes('Hand') && !mappedBoneName.includes('Index') &&
5673
+ !mappedBoneName.includes('Thumb') && !mappedBoneName.includes('Middle') &&
5674
+ !mappedBoneName.includes('Ring') && !mappedBoneName.includes('Pinky');
5669
5675
 
5670
5676
  if (isArmBone && (property === 'quaternion' || property === 'rotation')) {
5671
5677
  if (property === 'quaternion' && newTrack.values && newTrack.values.length >= 4) {
@@ -5679,23 +5685,32 @@ class TalkingHead {
5679
5685
  let z = newTrack.values[baseIdx + 2];
5680
5686
  let w = newTrack.values[baseIdx + 3];
5681
5687
 
5682
- // For Ready Player Me, we may need to flip certain axes
5683
- // Try rotating 180 degrees around Y axis for left arm
5684
- if (isLeftArm && mappedBoneName.includes('ForeArm')) {
5685
- // Left forearm might need Y-axis flip
5686
- const flipY = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
5687
- const q = new THREE.Quaternion(x, y, z, w);
5688
- q.multiply(flipY);
5689
- x = q.x;
5690
- y = q.y;
5691
- z = q.z;
5692
- w = q.w;
5688
+ let q = new THREE.Quaternion(x, y, z, w);
5689
+
5690
+ // For Ready Player Me, left side bones may need coordinate system correction
5691
+ // Try multiple approaches: invert quaternion or rotate around different axes
5692
+ if (isLeftSide) {
5693
+ if (isHand) {
5694
+ // Left hand: Try inverting the quaternion (conjugate) to flip orientation
5695
+ // This might fix the "folding behind" issue
5696
+ q.conjugate();
5697
+ // Then rotate 180 degrees around Y axis
5698
+ const flipY = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
5699
+ q = flipY.multiply(q);
5700
+ } else if (isForearm) {
5701
+ // Left forearm: Try rotating 180 degrees around Y axis first
5702
+ const flipY = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
5703
+ q = flipY.multiply(q);
5704
+ // Then rotate 90 degrees around X axis
5705
+ const adjustX = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1, 0, 0), Math.PI / 2);
5706
+ q = adjustX.multiply(q);
5707
+ }
5693
5708
  }
5694
5709
 
5695
- newTrack.values[baseIdx] = x;
5696
- newTrack.values[baseIdx + 1] = y;
5697
- newTrack.values[baseIdx + 2] = z;
5698
- newTrack.values[baseIdx + 3] = w;
5710
+ newTrack.values[baseIdx] = q.x;
5711
+ newTrack.values[baseIdx + 1] = q.y;
5712
+ newTrack.values[baseIdx + 2] = q.z;
5713
+ newTrack.values[baseIdx + 3] = q.w;
5699
5714
  }
5700
5715
  }
5701
5716
  }