# Move bones dynamically

I am using Fullik Library to create a mathematically based skeleton and move it. Fullik renders nothing, just gives me the math. Now that the math is correct, I need to visualize it.

On the other hand, I have a skinned mesh that has a “real” Threejs skeleton and bones and that I need to move given the math from Fullik.
Given that I know the rotation and position of each of the bones of the Fullik skeleton,
how can I make the skinned mesh skeleton move exactly like the Fullik Skeleton?

In other words, how can I dynamically move bones of a skinned mesh so that they have exactly the same rotation and position of another object?

Thank you!

Hello rodrix,

As you may already know, bones are THREE.Object3D objects and should be treated as such. You could traverse the root bone and apply the same position/rotation at once:

object.traverse( function(child) {
if (child.isBone) {
object.position.set(x,y,z);

}
}
Here is the docs: https://threejs.org/docs/#api/objects/Bone

GL&HF

Hi @INF1N1T, thanks so much for the reply!

However your suggestion does not seems to work, or I am doing something wrong…

`character.skeleton.bones[5].position.x = solver.chains[0].bones[0].getStartLocation().x; character.skeleton.bones[5].position.y = solver.chains[0].bones[0].getStartLocation().y; character.skeleton.bones[5].position.z = solver.chains[0].bones[0].getStartLocation().z;`

The problem seems to be that the bones.position works with a local reference to previous bone; while the solver’s getStartLocation() is an absolute world position.

I need a way to be able to set the bone position in absolute world coordinates.
Same issue with rotation. The rotation I can set with character.skeleton.bones[5].rotation is a local rotation reference to the previous bone. I need to set the rotation in absolute world coordinates, using
`solver.chains[0].bones[0].getDirectionUV()`

So the question is: How do I set the position and rotation of a bone in absolute coordinates / world referenced coordinates?

Thanks so much!!!

To do “absolute updates” without skeleton constrain, you will need to work on the bones before they are added to THREE.Skeleton objects, or you will need to set THREE.Skeleton.bones=[], apply your transforms and re-assign the bones array to the skeleton object.

What if I just want a bone to point (lookAt) into a certain absolute direction? (not modify the position).

Is it possible?

I know I can set the rotation of the bone, but again, the rotation is defined in local coordinates.
I already tried bone.lookAt(), but again it seems to work with local coordinates, not world coordinates.

Is it possible to make the bone rotate pointing into an absolute direction?

With just this code… I could solve the problem.

Rod

(P.S: I need to update the bones rotations on every frame according to my solver.)

Ok I realize now that my problem can be generalized. The same problem I have applies to anyone having children under Object3d (because as you mention, bones are in fact Object3D)

Given this, then the question can be generalized as:
How can I make an object 3d rotate (lookAt) into a specific world direction given that it is a child of a child of a child… of an Object3D?

Can anyone help?
Thanks!

Hi, I am having the same problem when dealing with skeleton bone’s rotation. Any update on this?

Thank you.

I am having a similar issue about moving bones dynamically. In my instance, I am using a kinect sensor so have world coordinates (x,y,z) for bones that would represent ends and joints, but can think of how to map that to a 3d model. Might be nice to use the Fullik library (which I have just read about here) so I am only worrying about hands, feet and a couple of other points, rather than dynamically moving 27 different points. Has anyone found a solution?