Skip to content

Commit

Permalink
fixing head tilt direction
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyangXYZ committed Sep 26, 2024
1 parent e016e84 commit 1a69ddf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/MMDScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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()
Expand Down

0 comments on commit 1a69ddf

Please sign in to comment.