WebXR domoverlay pointer event triggered the same time on dom element and XR scene

Hi,
@RaananW it’s me again thanks a lot for helping me previously with WebXR questions! and… it seems I found another one that might need a little bit of your help. On my local repo, I enabled the WebXRDomOverlay and POINTER_SELECTION feature, and I found out that it seems when I touch the dom element and fire a click event, the WebXR pointer event seems also fired at the same time. I wonder if there is a way to prevent the pointer event in the XR scene when touching the dom element.
I did some research myself and do found sth that seems super relevant, WebXR DOM Overlays Module. see 2.1 onbeforexrselected, I did add the preventdefault to my dom element but it turns out not working. Also, I’ve set up a playground demo but I can’t get the dom element rendered on WebXR scene https://playground.babylonjs.com/#9K3MRA#711 could you please help me set up this and see if you also get the event fired twice(or if you can help me get the dom element rendered in XR scene I can also try to reproduce the problem)? Thank you very much!

We emulate pointer events using the pointer selection module. it’s actually not entirely part of the specs, so there won’t be anything in the specs about preventing that from happening.

What you can do is disable the pointer selection feature, especially if you have a different UI. if you use the default xr experience it’s as simple as calling xr.pointerSelection.detach(). You can always re-attach it (attach()) when you need it again

1 Like

Hi @RaananW Thanks for the advice and I’ve figured out a way by using it. So I’ve attached beforexrselect event to the domElement and call pointerSelection.detach() when this event is fired, and reattach the pointerSelection when click on the canvas. But I think generally it would be good if we can add something in pointer selection module that check if in WebXR session and WebXRDomOverlay is enabled, when user click the domElement don’t fire XR selection event(or a bool to enable and disable if XR pointer event will be fired). WebXR DOM Overlays Module WebXR already provide a solution and and I think there is a good reason for that? Let me know what’s ur thoughts!