Custom Camera/Object Axis In Three Js? (For First Person)
I have a possibly beginner question regarding camera rotation in threejs, I am beginning to work on a first person game, the camera controls however have a small issue: if I look up and down they seem to work fine, but if I step to the side of my object and use them then the object (cube) does a circle around the center of my screen.
A breakdown of my code:
Pointer lock tells me when the mouse moves, and I use it for back and forth movement:
camera.rotation.y += movementX;
this works fine, because the y axis will always be up and down, but it doesn't work for side to side:
camera.rotation.x += movementY;
like I said, if I don't move from the starting position then it works fine, otherwise it gets messed up.
I am basically looking for something like: camera.rotateX(a number);
which is like translateX(), it uses local object axis, not parallel to world axis.
I know about first person controls, but I would prefer to not use them, I would prefer code that is longer but more understandable (if possible/necessary).
Sorry For length of question :)