Go back from setting camera.lookAt()

I need to alternate before two states of the camera: when it’s focused on something with a certain position and when it’s not focused at something.
I noticed that after I do camera.lookAt(x, y, z) it’s impossible to unset it even if I change camera’s position.

Would it be better to create two cameras then and activate/deactivate them whenever needed?

Hello.
When you changed your lookAt, did you updated your projection matrix? Try calling the method “updateProjectionMatrix()” of your camera after changing the lookat to see if it works for you.

The problem is that lookAt() changes the orientation of the camera. You have to save Object3D.rotation if you want to restore it at a later point. Try it with:

const oldRotation = new THREE.Euler();
oldRotation.copy( camera.rotation );

Using lookAt() is unrelated to projection matrices.

3 Likes

i think it’ll work, will try it out a bit later
thank you :slight_smile:

1 Like

It worked but for some reason WASD keys are changed after I set rotation back to what it was before applying .lookAt()