I'm a bit stuck implementing rotation of the avatar (Ready Player Me) that follows user's perspective camera controlled by PointerLockControls.
Avatar has the following hierarchy: -bone Neck (parent) -bone Head (child)
The goal is to take the current camera rotation and split it between the Head and Neck.
I want the head to rotate not more than PI/2 (or even PI/4) each direction (XYZ). The rest of the rotation should be managed by the Neck. It should be fine even if the Neck will be static for X and Z and rotate only around Y.
If I do a simple subtraction following the formula (I skip the logic for signs): neckRotationY = cameraRotationY < PI/2 ? 0 : cameraRotationY - (cameraRotation % PI/2); headRotationY = cameraRotation % PI/2;
everything works until camera starts looking backwards. Instead of rotating around Y to look behind at 2PI, the camera is rotated around X and Z, so the simple formula doesn't work.
Could smdy get me any idea of how can I separate camera rotation into neck and head rotations?
Thanks!