It all works fine except the head inclination (RotZ) isn’t applying to the local rotation somehow. It is supposed to inclinate the “head” (camera) when you strafe left or right as it gives a nice feeling of movement, and it does it correctly when the forward vector of the Camera is matching the world forward vector, but it sticks like that when you move the mouse around.
I have made a small drawing to explain myself better:
Bear in mind that we apply rotations in a XYZ order and setLocalEulerAngles sets the local transformation of the entity. So when you set the local rotation, it does so in the transformation space of the parent (in this case, the world) and in the order of X, Y then Z.
To get the behaviour you want (as long as I’ve understood you correctly), you have two methods:
Set an entity hierarchy where the camera entity is a child of another entity (call it ‘head’ for this example). You set the Z rotation on the camera entity and the XY on the ‘head’ entity.
Do the matrix transformations to calculate the correct local euler angles (one mat4 that just has the Z rotation, the other with the XY, multiple them together and extract the eular angles from the resulting mat4).
If you are still having problems, can you provide a project which shows your problem and an example of the effect you are trying to achieve?