Dynamic bones animation

Hello, another dynamic animation question on a ragdoll I’m trying to build in three from a skinned mesh using cannonjs simulation.
I cant figure out how to solve my issue.

I Have a skinned mesh, with some “chains” of bones that I animate dynamically.
I created a cannon body for every bone in the mesh, constrained them, and it works.
Adding some cubes in the same position of the cannon bodies, the cubes take the correct position and quaternion as the cannon bodies.

then I go through every bones chain, starting from the parent, and for each bone I lookAt the first children. This way the bones rotate towards the following one ( I have to rotateX( Math.PI / 2) ).
This is all good. BUT

the issue is that the bones also “spin” around the axis defined by the line connecting the two bones.

and this is how bones rotate just after “lookAt” the next bone, before rotateX( Math.PI / 2 );

I can’t find a way to make them bones align / rotate correctly towards the following one and not spinning…

Any ideas?
Thanks!

Just to give “an” answer, would you be able to use on of the animated models from a three.js example and modify it to your purpose? That is what I plan to do when I get around to creating animated characters. So let me know if you think that is a bad idea.

My second choice would be to create the animated character using Blender - since Blender is made for that - and then trying to figure out how to export the animation to three.js. I have been able to create animated parts in Blender and export them to three.js, but not characters.

yes, I’m still working on a skinned mesh exported from blender. It’s not a skinned animation issue, it’s a dynamic animation one. and I just found what the issue is.

problem is in how lookAt is conceived. it “mirrors” the camera when facing the spherical north and south poles, so the object or camera looks never upside down.
BUT, while this is correct behaviour for a camera, it is not in my case.
GIven that gravity pulls bones and joints down, mostly aligned, if i rotate the parent bone towards the first child, that is just under itself, the intended lookAt behaviour makes the joints “spin”.

I still don’t have a solution, but I’m starting from here [Solved] OrbitControls max polar angle = Infinity?

Thanks for the explanation. I have had problems with “LookAt” in the past. For a long time, I thought that three.js did not allow Z-rotation of the camera because I was using LookAt. Apparently, it forces a viewpoint that is level with the horizon, so any camera Z-rotation is negated.