Currently, I am in the process of creating a basic framework for a first-person-shooter game to gain a deeper understanding of all its components, particularly focusing on 3D mathematics.
I have stumbled upon an issue that seems to only arise when using Three.js.
The problem occurs when I rotate the camera along the y-axis by 90 degrees (looking to the left); rotating along the x and z axes produce a similar effect, causing the camera to "roll."
Why is this phenomenon happening? Shouldn't rotation around the x-axis result in a different outcome compared to rotating around the z-axis?
I have provided an example showcasing this behavior. Note that this issue isn't limited to this specific instance (use the up and down arrow keys to rotate):
Rotation along the x-axis: Source code:
Rotation along the z-axis: Source code:
The following line was the only change made in both examples:
When rotating along the x-axis:
camera.rotation.x += degToRad(upRot);
When rotating along the z-axis:
camera.rotation.z += degToRad(upRot);