PointerDragBehavior / Multi-Touch & Picking

Dear community,

I have two questions regarding the pointer drag behavior:

First, I’m using both the PointerDragBehavior to move some meshes as well as camera inputs with panning and pinching. It works completely fine, I can move the camera via panning and pinching and I can move the meshes by panning / dragging them around. However, I would like to prevent dragging the meshes when the user is pinching, that is, when two or more pointers are detected (a multitouch gesture). Is there any option to prevent the pointer drag behavior from activating if there is more than one pointer detected (or stopping it as soon as there is a second pointer)? I checked “currentDraggingPointerID”, but it never changes during a drag action.

Second, I also added an action manager and perform some actions when a mesh is picked. Picking and dragging works, however, the pointer drag behavior always fires even if it is only a tap/click. Are there built-in methods to start dragging only after a given threshold? So far I built it myself, but it seems a bit clunky.

Kind regards

@Cedric is the king of this area :slight_smile:


I have no idea for the 1st question, maybe @PolygonalSun has some answer as it concerns the input system.

For the 2nd question, I would accumulate delta coming from the onDrag and I would not add it to the object position until the cumulated length reaches some threshold.


Thank you for your quick answer, that’s about what I did as well. I’ll leave it open for now until the first question is addressed. :sweat_smile:


Hey @zacherl, you might be able to create that desired behavior by just keeping track of the number of active touch inputs and using something like releaseDrag when there are more than one active touch input. Here’s a crude example: Babylon.js Playground (babylonjs.com)


Hi @PolygonalSun, thank’s a lot for this example. I checked it out on my phone - the dragging stops as soon as I add a second finger. However, I expected the camera to start zooming via pinch (I replaced it with an ArcRotateCamera for simplicity), which does not happen (it behaves quite strangely instead). If I do not detach the camera controls, I have the expected behavior (I can pinch even though the pointers are on the sphere), but then the dragging of the sphere naturally manipulates the camera again, which I do not want. Do you have any other idea to improve it?


Another info: In the “real” application I also do not use a standard camera input, but extended BaseCameraPointersInput to control an orthographic camera - not sure if it matters.

We solved it for the moment by selecting the meshes before enabling the drag behavior, but it’s not ideal. @PolygonalSun , do you think there might be another solution?