I’m having an issue about saving and loading the camera’s position and up (the direction in which the camera is looking at). I’m looking for help.
I’m sorry I cannot reproduce the same context. I’m working on a project using ReactJS, in the canvas component, I have:
- Canvas
- TrackballControls
- PerspectiveCamera (staticMoving is required)
To extract the values of position, up, quaternion and rotation of the camera, I use:
const { camera } = useThree(); const { position, up, quaternion, rotation } = camera;
I save those 4 values of the camera to the store when the component canvas unmounts and load them to the perspectiveCamera when I initialize the component.
The issue is: On the canvas, if I just rotate (By clicking left mouse and moving mouse) and zoom only (By scrolling), I will be at the camera’s last position and up (direction) when I reinitialize the component. But if I move the camera up, down to the left, right (By clicking, holding right mouse and moving mouse), those 4 values will still be saved but when I reinitialize the component, I will not be at the camera’s last position and up (direction).
Am I missing any thing after dragging with right mouse ? How should I save the camera’s position and up (direction) after rotating, zooming and dragging (moving) ?
Thank you !
I tried reading the document but I still haven't found any solution. I expect to receive a solution to load the camera's right position and up (direction) when the component is initialized.