ArcRotateCamera's inputs - Detach the left button only when the pointer is over the mesh

Hello,

I want to disable the left button only when the pointer is over the mesh :

If

  • pointer is over the mesh you can only use the middle button to rotate around the model.
  • pointer is outside the mesh you can use the left button and the middle button to rotate around the model.
scene.onPointerObservable.add(eventData => {
      if(eventData.type ===  BABYLON.PointerEventTypes.POINTERMOVE) {
          let pickInfo = scene.pick(scene.pointerX, scene.pointerY);
          if(pickInfo.hit) {
              camera.inputs.attached.pointers.buttons = [1];
          }
          else {
              camera.inputs.attached.pointers.buttons = [0, 1];
          }
      }
  });

I made a playground :

It works excepts a strange behavior I notices when you ‘drag’ from outside the mesh to over the mesh the rotation continue even after you release the left button

  1. Pointer down at |1| and move to |2|
  2. Pointer up at |2|
  3. Camera continue to rotate when the pointer move.
  4. The only way to stop the rotation is to pick once outside the mesh.

I don’t understand where this behavior come from, do I miss something ?

ping @PolygonalSun

The thing is as you change the button while in drag mode I bet it does not detect up anymore which sounds correct. Could you instead wait for the next pointer up to adapt your list ?

Hello @sharp just checking in if you’re still having issues