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?
Asked
Active
Viewed 1,044 times
1 Answers
2
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
-
I run the animation and change the rotation of the arm with skinMesh.skeleton.bones[6].rotation.set(0.903,0.248,-0.284). But the arm doesnt rotate – Ivan Oct 21 '14 at 05:13
-
@Ivan You forgot the "XYZ": 'skinMesh.skeleton.bones[6].rotation.set(0.903,0.248,-0.284, "XYZ")' – kdrnic Oct 21 '14 at 17:49
-
But still it wasnt work. When the animation doesnt play, i can rotate the bone, but when the animation is playing the bone becomes the same as in the animation. Why? – Ivan Oct 21 '14 at 21:05
-
@ivan did you add the XYZ, and the line of code AFTER updating the animation? it must be something like "THREE.AnimationHandler.update(delta); skinMesh.skeleton.bones[6].rotation.set(0.903,0.248,-0.284, "XYZ");". Also, are you using the latest version of three.js (r68)? – kdrnic Oct 22 '14 at 00:13
-
sorry. It is my fail=) Is a good practice to double work? Rotate bones during the animation and then rotated by using code skinMesh.skeleton.bones[6].rotation.set(0.903,0.248,-0.284, "XYZ"); – Ivan Oct 22 '14 at 05:22
-
it is the standard way of achieving this, yes, and it is barely "double work", since the processing here is negligible. – kdrnic Oct 22 '14 at 19:55
-
Thank you for answering all my questions! – Ivan Oct 22 '14 at 21:17