title: React Three Fiber: How to switch between TrackballControls and OrbitControls?
body: <p>I'm trying to create a viewer in <a href="https://github.com/pmndrs/react-three-fiber" rel="nofollow noreferrer">react-three-fiber</a> with <a href="https://github.com/pmndrs/drei" rel="nofollow noreferrer">react-three/drei</a> where I can switch between <code>OrbitControls</code> and <code>TrackballControls</code>.
  The problem is that when switching from <code>TrackballControls</code> to <code>OrbitControls</code>, the axis that the camera rotates around changes as of course the TrackballControls change the up-vector when moving around.</p>
  <p>I created a couple of minimal examples in codesandbox to explain my approach to solve this and to show where I'm stuck.</p>
  <h2>Base Case</h2>
  <p>This shows the initial attempt to switch between the different control types:<br>
  <a href="https://codesandbox.io/s/r3f-camera-controllers-base-neu07" rel="nofollow noreferrer">https://codesandbox.io/s/r3f-camera-controllers-base-neu07</a></p>
  <h2>Attempt #1</h2>
  <p>Obviously, this does not work as it is, so I tried resetting the up-vector to <code>(0, 1, 0)</code> and calling <code>lookAt()</code>. This seems to work initially as the camera reorients itself correctly (this is how it should look like). However, it does not rotate around the correct axis and instead moves in strange arcs. See here:<br>
  <a href="https://codesandbox.io/s/r3f-camera-controllers-set-up-vector-yps4k" rel="nofollow noreferrer">https://codesandbox.io/s/r3f-camera-controllers-set-up-vector-yps4k</a></p>
  <h2>Attempt #2</h2>
  <p>For <a href="https://stackoverflow.com/a/11309504/17572872">this question</a> it was suggested to create a new camera which I also tried but ultimately it lead to the same result. This here is my attempt at creating a new camera and copying some values to the new camera:<br>
  <a href="https://codesandbox.io/s/r3f-camera-controllers-reset-camera-3cih0" rel="nofollow noreferrer">https://codesandbox.io/s/r3f-camera-controllers-reset-camera-3cih0</a></p>
  <p>Any help appreciated. Thanks!</p>