I am trying to get a 3D object to follow a 3D path so that it always faces the direction in which it is traveling. I try to do this by doing:
fishObject.quaternion.setFromAxisAngle(axis, radians)
where radians
is the angle between an up
vector and the direction of travel
In the following pen, the axes are depicted for clarity. The blue line is the axis
, the purple one is just up
, and the moving red line is the direction the fish should be facing (tangent
). They all move in the right way, but when I set the quaternion, the rotation of the object does not seem to follow its axis
There is a bit of clutter in the pen (to build the fish), but all I am looking at is line 281 and its arguments:
fishObject.quaternion.setFromAxisAngle(axis, radians)
I am just new to this. Should be simple to someone familiar with 3D rotation.
https://codepen.io/nth-chile/pen/ELQqqb
Thanks, and please let me know if I can be more clear.