How to save the exact position of camera?

Hey y’all :raised_hands:

I’m having a bit trouble with camera position. For example, I’m saving rotation and position of camera when the camera is not looking at the center of the scene. And then when I load the saved position and rotation I get different result. I’m guessing I need to save something else than rotation and position but I could not find what exactly.

To reproduce:

  1. Go to: boring-austin-3vu1s - CodeSandbox
  2. Move the camera with “right click and hold and move” gesture (or double touch press and hold and move gesture with touchpad)
  3. Then save the position via “Cmd + S”
  4. Reload the page

What else I need to do to save the exact state/position of camera (even tho it’s not looking at the center)?

You also have to save the focus point of OrbitControls (its target property). This property is modulated when you perform panning.

BTW: No need to call updateProjectionMatrix() when restoring the camera’s transformation.

1 Like