Skip to content

Commit d63a4fd

Browse files
author
Avaer Kazmer
committed
Reduce hair craziness
1 parent 15bdfe1 commit d63a4fd

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

vrarmik/avatars.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const zeroVector = new THREE.Vector3();
77
const upRotation = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1, 0, 0), Math.PI/2);
88
const leftRotation = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI/2);
99
const rightRotation = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), -Math.PI/2);
10+
const z180Quaternion = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
1011

1112
const localVector = new THREE.Vector3();
1213
const localVector2 = new THREE.Vector3();
@@ -824,14 +825,10 @@ class Avatar {
824825
childHairBone.velocity.lerp(zeroVector, 0.2 * timeDiff/32);
825826

826827
const p2 = localVector5.copy(px).add(childHairBone.velocity);
827-
const q2 = localQuaternion.multiplyQuaternions(
828-
localQuaternion2.setFromRotationMatrix(localMatrix.lookAt(
829-
zeroVector,
830-
hairDirection,
831-
localVector6.set(0, 0, -1).applyQuaternion(hipsRotation),
832-
)),
833-
childHairBone.initialWorldQuaternion
834-
);
828+
const q2 = localQuaternion.copy(childHairBone.initialWorldQuaternion).premultiply(hipsRotation);
829+
if (this.flipZ) {
830+
q2.premultiply(z180Quaternion);
831+
}
835832
_getMatrixWorld(childHairBone).compose(p2, q2, scale);
836833
}
837834
for (let i = 0; i < children.length; i++) {

0 commit comments

Comments
 (0)