Strange things with camera

Could somebody please explain me why camera is acting like this:

So you can see, camera disappears on 90* and turns to other side of model on 91*.

Can you share a link to the project or create a new project with the same problem please?

Yea, sure.
https://playcanvas.com/project/441016/

I suppose it’s because of entity.lookAt function’s behavior.

I removed clamp for x-axis

Thanks for paying attention.

If you are using lookAt, you have to be careful about gimbal lock.

lookAt by default uses the world’s up vector so if you are trying to lookAt at a point that is directly above or directly below, you will have problems as the function relies on cross product to calculate the new matrix values.

To get around this, check if Z position of the entity and the point it is trying to look at is the same and if they are, pass a different up vector to the lookAt vector to use.

1 Like