Hey, I am trying to give users an option to switch between the controls by clicking on a button.
I have tried doing this
{isOrbitControl ? <OrbitControls
ref={orbitControls}
enableZoom={false}
enablePan={false}
enableDamping
dampingFactor={0.1}
autoRotate={false}
rotateSpeed={-0.5}
autoRotateSpeed={1.0}
/> : <DeviceOrientationControls/>}
this is not working. The controls get stuck when shifting to DeviceOrientationControls.
I got it working by rendering both controls and using the enable property on both controls. I set enable=true
on the component which is currently selected and enable=false
on the other in useEffect
. Now when on mobile if I don’t move the mobile for 2 seconds the deviceorientationcontrol gets stuck.
Can someone guide me on what is the proper way to do this.
I have also created this sandbox which can reproduce the above issue. Sandbox
Open the sandbox on mobile and click on change controls to switch. Keep your mobile static for 2 to 3 seconds on orientation controls to see it get stuck.