WebXR picking of meshes (double click)

Hello,

I’m trying to somewhat convert my scene to work in VR. This code works in browser desktop/mobile but not in VR:

mesh.actionManager = new BABYLON.ActionManager(scene);
mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger, myFunction));

Is there another way to do this? I saw this post, but before I rewrite my code I wanted to know If I’m missing something.

I’ll add @RaananW, since he seems to be the VR head. :innocent:
I’m using the DefaultXRExperience by the way.

great question! :slight_smile:

Does it work with different events? pointer down? pointer up?

XR doesn’t have the concept of double click. I assume that if you click fast enough on your controller it might work (as babylon actually emulates doubleclick events when two consecutive pointerdown events are triggered). But if you want to support all scenarios, doubleclick won’t do. Hands can’t doubleclick for sure. certain controllers might also have a delay between the two clicks (you will need to be very exact to execute two consecutive clicks on a trigger)

TL;dr - try with a different event and see if it works. It should as XR emulates pointer down/move/and up events.

Indeed, double clicks don’t seem to work. Clicking twice real quick does not work either.
However, same action manager, same everything, but the event being OnPickUpTrigger works as expected.

I had double clicks beforehand to still be able to rotate on single clicks, but since now it’s VR and I don’t even rotate anymore there’s no need for that anymore. Maybe there’s other use cases where double clicks are important, but for me this is working well now!

1 Like