Unexpected camera rotation - lateral views - solved



I am trying to get laterals views on a second camera attached to a moving object.
While the object is moving and the primary camera is facing front I want to lookAt left, right, up … with a second camera without attached controls.
Both cameras have the same position and should have the same z rotation.
My first approach was to copy the rotation of the primary camera in the second and then rotate by PI/2 the x or y or z depending on where I want the second camera to look at.
This is working fine only when no rotation applied to the primary camera or if you move left/right and look at left/right.
In all other cases where rotation is applied to the primary camera the second camera have wrong z rotation.
The second approach was to lookAt specific points attached to the object by calculating their new position after applying the position and rotation of the primary camera to these points.
Again the results was the same.

Any idea about what I am doing wrong or the proper way to do it ?



Hello Gianni, have you a source code like on codepen or similar ?

I think I have an approaching problem :

Push camera 1 button and you’ll see it triggers an extra rotation of 45 degrees

Is it the same issue?


a link to a working draft …


Ok, so, what’s the wrong views ? (when we press 5 ? )


After loading and without pressing any keys that will change the capsule rotation …
press numpad 4 or 6 to get a left or right view
then use the arrow left/right keys to rotate the capsule
you will see that everything looks ok
While rotating left or right you can change views by pressing numpad 4,6,5 back, 5 front without any problem, but if you select 2,8 to get an up or down view you will notice that the axes are rotating and the views are wrong.
If after loading, instead of right/left you choose to rotate the capsule up or down, you will notice that up/down views are ok and all others views are a mesh.

The camera is looking correctly at the point that should look but the z rotation is wrong.


ok, solved.
Nothing unexpected here after calculating and setting the camera.up correctly.