I have a skinned mesh of a 'snake', exported from blender. The snake has bones (like a spine) which I want to animate along a curve (SplineCurve3)
I can calculate points along the spline, and the angles between those points, but I'm struggling setting the rotations of the bones correctly.
The problem is that each bone is a child of the previous bone, so rotating one also rotates the others.
Here's an image:
The outer shape is the snake.
The pink line is a section of a SplineCurve3.
The blue/green lines are the bones (THREE.SkeletonHelper).
Each bone is rotated using SplineCurve3.getTangentAt. Because the parent is rotated too, the snake curls up. I basically need the bones to be where the pink line is.
How can I 'compensate' for the rotation of the parent(s) when calculating the rotation of a bone?
Also, in the image the path is flat, but my goal is to move the snake in 3 dimensions. It's a flying snake.