Skip to content

Commit 929619a

Browse files
author
Avaer Kazmer
committed
Compute rig flipY
1 parent 2b284c5 commit 929619a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vrarmik/Rig.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,12 @@ class Rig {
257257
const armature = _findArmature(Hips);
258258

259259
const eyeDirection = modelBones.Eye_L.getWorldPosition(new Vector3()).sub(modelBones.Head.getWorldPosition(new Vector3()));
260-
const flipZ = eyeDirection.z < 0;
260+
let flipZ = eyeDirection.z < 0;
261+
const armatureDirection = new THREE.Vector3(0, 1, 0).applyQuaternion(armature.quaternion);
262+
const flipY = armatureDirection.z < -0.5;
263+
console.log('flip', flipZ, flipY, eyeDirection.toArray().join(','), armatureDirection.toArray().join(','));
261264
this.flipZ = flipZ;
265+
this.flipY = flipY;
262266

263267
const preRotations = {};
264268
if (!flipZ) {
@@ -342,6 +346,7 @@ class Rig {
342346
const rigObject = new GameObject('rig');
343347
this.poseManager = rigObject.AddComponent(PoseManager);
344348
this.poseManager.flipZ = flipZ;
349+
this.poseManager.flipY = flipY;
345350
this.shoulderTransforms = rigObject.AddComponent(ShoulderTransforms);
346351
this.legsManager = rigObject.AddComponent(LegsManager);
347352

0 commit comments

Comments
 (0)