@sage-rsc/talking-head-react 1.1.9 → 1.2.0
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.cjs +2 -2
- package/dist/index.js +338 -332
- package/package.json +1 -1
- package/src/lib/talkinghead.mjs +23 -14
package/package.json
CHANGED
package/src/lib/talkinghead.mjs
CHANGED
|
@@ -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
|
|
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,26 @@ class TalkingHead {
|
|
|
5679
5685
|
let z = newTrack.values[baseIdx + 2];
|
|
5680
5686
|
let w = newTrack.values[baseIdx + 3];
|
|
5681
5687
|
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5688
|
+
const q = new THREE.Quaternion(x, y, z, w);
|
|
5689
|
+
|
|
5690
|
+
// For Ready Player Me, hands may need coordinate system correction
|
|
5691
|
+
// Hands folding behind suggests we need to rotate around Y axis
|
|
5692
|
+
if (isHand) {
|
|
5693
|
+
// Rotate 180 degrees around Y axis to fix hands folding behind
|
|
5686
5694
|
const flipY = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
|
|
5687
|
-
|
|
5695
|
+
// Apply rotation: q_result = q_original * q_flip (post-multiply)
|
|
5688
5696
|
q.multiply(flipY);
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5697
|
+
} else if (isForearm) {
|
|
5698
|
+
// For forearms, try a smaller correction - rotate 90 degrees around Z axis
|
|
5699
|
+
// This might help with the twisting
|
|
5700
|
+
const adjustZ = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 0, 1), Math.PI / 2);
|
|
5701
|
+
q.multiply(adjustZ);
|
|
5693
5702
|
}
|
|
5694
5703
|
|
|
5695
|
-
newTrack.values[baseIdx] = x;
|
|
5696
|
-
newTrack.values[baseIdx + 1] = y;
|
|
5697
|
-
newTrack.values[baseIdx + 2] = z;
|
|
5698
|
-
newTrack.values[baseIdx + 3] = w;
|
|
5704
|
+
newTrack.values[baseIdx] = q.x;
|
|
5705
|
+
newTrack.values[baseIdx + 1] = q.y;
|
|
5706
|
+
newTrack.values[baseIdx + 2] = q.z;
|
|
5707
|
+
newTrack.values[baseIdx + 3] = q.w;
|
|
5699
5708
|
}
|
|
5700
5709
|
}
|
|
5701
5710
|
}
|