Switch camera (Orthographic <=> Perspective) with OrbitControls and keep all view parameter


I made a button for switching camera to Perspective and Orthographic and inversely.
I manage to pass from one camera to the other the controls target, the camera look at and its position.

But i am not able to pass the zoom from perspective to orthographic. From orthographic to perspective it works. I saw that .zoom on perspective doesn’t change when zooming.

How to keep the zoom attribute from one to the other ?

Thanks a lot

Zoom only works for the orthographic camera, for the perspective camera you need to do some math to calculate the correct zoom level. See Camera perspective <-> orthographic toggle comparison in r3f and three.js · GitHub for a working implementation.