Im working with React and R3F. I have the enabled property set according to the showMenu state as shown below (toggled on button click). console.log() statements show the enabled property being changed but even when the property is set to false, I am still able to pan around using the mouse. Any help is appreciated
i would suggest you don’t use orbitcontrols like that, and im guessing you’re using three/examples/jsm/controls which would be worse. all three controls are bugged. they have constructor side effects, therefore a class cannot be safely created and discarded without knowing implementation details, it is considered an anti pattern. you can end up with multiple controls running at the same time bc of that. the issue is known and there’s a fix, but hasn’t been merged.
i would suggest to always use three-stdlib instead of jsm. this a pmndrs fork of three/examples/jsm. it was made to allow the react eco system to be stable and independent from threejs maintenance. all of drei uses that.
or better, there’s a ready-made abstraction in drei:
import { OrbitControls } from '@react-three/drei'
<OrbitControls enabled={condition} />