Ivan
Ivan

Reputation: 23

Three.js Skeletal animations, bons recalculate

I have some questions about skeletal animation blending. I have the walking animation and I want to change the position of the arm in this animation. I think that I need to recalculate the position of the arm in all keyframes. Is this a common practice or is there another, more common and easier way?

Upvotes: 1

Views: 1095

Answers (1)

kdrnic
kdrnic

Reputation: 511

You don't need to change the position of the arm in the keyframes. Apply the animation, then change the position of the arm dynamically by setting the arm bone directly with

skinMesh.skeleton.bones[i].position.set(xPos, yPos, zPos);        // sets the position Vector3
skinMesh.skeleton.bones[i].rotation.set(xRot, yRot, zRot, "XYZ"); // sets the rotation Euler

where "xPos,yPos,zPos" is the new position of the arm and "xRot,yRot,zRot" is the new rotation and "i" is the index of the bone.

Please see this question, and my answer, on dynamic animation: Dynamic bones animation in Three.js

Upvotes: 2

Related Questions