The approach that PointerLockControls
uses is to create a hierarchy of objects: yawObject
contains pitchObject
contains camera
. Then horizontal mouse (or joystick) movement would change the Y-rotation of the yaw object, vertical mouse (or joystick) movement would change the X-rotation of the pitch object, and the camera's rotation would stay fixed at the default (0, 0, -1)
. This just manually simulates Euler YXZ
ordering but it may work better for you. It does create some awkwardness if you need to get the overall rotation.
In a custom controller I wrote recently, I achieved the same result by add()
ing the camera to a single parent object and setting the parent object's Euler order to YXZ
. I don't remember why this worked better than setting it on the camera directly, but it did.