-
So I have scene with camera as a first person perspective and you can rotate camera by moving the camera while pointer is down (basically drag kinda event) but I have lots of objects in scene with click even and evertime I have pan/roatate the camera using the mouse and as I leave the right click at the end and if its on object with click event that click event excutes and its kinda really distracting so is there a way to know when user is panning and deactivate the click events? My idea was too add pointer down and pointer up even on window and add setTimeout on pointerdown and in pointer up the cleartime out
it does works but I have to remove the e.stopPropagation() to make it workProperly and I can not do that for obvious reasons. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
this box switches between two controls: https://codesandbox.io/s/mixing-controls-hf1cs i think you could repurpose it. you can also switch off the raycaster: function Controls() {
const ref = useRef()
const raycaster = useThree(state => state.raycaster)
useEffect(() => {
ref.current.addEeventListener('?????', () => raycaster.enabled = true / false
...
return () => // remove the handlers! or else, race condition
}, [])
return <OrbitControls ref={ref} />
} you have to consult three docs for the correct event names |
Beta Was this translation helpful? Give feedback.
-
Found out the solution and realized i am dumb af. XD anyway just what I did is set the global state of pan and the event listener where camera is panning im setting pan to true and other wise false and when put the if statement on all click events and it worked |
Beta Was this translation helpful? Give feedback.
Found out the solution and realized i am dumb af. XD anyway just what I did is set the global state of pan and the event listener where camera is panning im setting pan to true and other wise false and when put the if statement on all click events and it worked