From 1a69ddf08de4e6ffbf767e566759e5cf1906a0c1 Mon Sep 17 00:00:00 2001 From: AmyangXYZ Date: Thu, 26 Sep 2024 00:06:13 -0400 Subject: [PATCH] fixing head tilt direction --- src/MMDScene.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MMDScene.tsx b/src/MMDScene.tsx index 2c20fb5..3f9a147 100644 --- a/src/MMDScene.tsx +++ b/src/MMDScene.tsx @@ -191,6 +191,7 @@ function MMDScene({ const point = pose[keypointIndexByName[name]] return point.visibility > visibilityThreshold ? new Vector3(point.x, point.y, point.z) : null } + const getBone = (name: string): IMmdRuntimeLinkedBone | undefined => { return mmdModel!.skeleton.bones.find((bone) => bone.name === name) } @@ -204,10 +205,11 @@ function MMDScene({ if (nose && leftShoulder && rightShoulder && neckBone && upperBodyBone) { const neckPos = leftShoulder.add(rightShoulder).scale(0.5) const headDir = nose.subtract(neckPos).normalize() + headDir.y = -headDir.y const upperBodyRotation = Quaternion.Slerp( upperBodyBone.rotationQuaternion || new Quaternion(), - Quaternion.FromLookDirectionLH(headDir, Vector3.Up()), + Quaternion.FromLookDirectionLH(headDir, Vector3.Forward()), lerpFactor ) const upperBodyRotationMatrix = new Matrix()