Orbitcontrols 'mousedown' event when rotating interfering with 'mousedown' event in webapp

I’m using a ‘mousedown’ event in my app w/ a raycaster to select objects in the viewer. the rotate function for orbitcontrols(using mouseclick and dragging) seems to interfere with mousedown event i use for selection of an element. Each time i rotate using orbitcontrols, the mouse click selects the element while also rotating. Is there a way to limit this behavior in orbitcontrols. The selection uses a firing of mousedown event on DOM element of viewer. Just trying to get some clarity if someone has experienced this sort of a problem before.

If the objects are selected actively the entire time you rotate the scene with controls, sounds to me more like you are using mousemove to select objects? mousedown is fired only once per click, so at most it would select object once and the let you rotate the scene without further selecting.

Try the following:

  • In your mousedown event set controls.enabled = false, this will disable rotating.
  • In your mousemove event set controls.enabled = true, so if user presses mouse and moves it, start rotating the scene.
  • In your mouseup event select the object over which cursor is only if controls.enabled === false, also set controls.enabled back to true.
1 Like