three.js dynamic skinned mesh bones animation / ragdoll or FPS dynamic aim

137 views Asked by At

I have a dynamic animation question on a ragdoll I’m trying to build in three from a skinned mesh using cannonjs simulation. I can't figure out how to solve my issue.

I got 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 at fixed distance between ancestors, 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 and show ok.

then I go through every bone of a chain, starting from the parent, and for each bone I lookAt the first children. This way the bones rotate towards the following one, but they are rotated by 90 degrees. I have to rotateX( Math.PI / 2) them after the lookAt make them align right, BUT, after i transform the bones, they also “spin” around the axis defined by the line connecting the two bones, because of the original "lookAt" transform.

here are examples of what happens: before rotation Before Rotation Video

After rotation After Rotation Video

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

Any ideas? Thanks!

0

There are 0 answers