WebXR no point events on Android?

Clicking in the screen works ok on PC and Android devices, but when the XR session starts any click using the PC and a WebXR emulator is properly readed and printed into the label but it doesn’t log any touch on android, without that I cannot find how to interact with WebXR and Android (Google glasses and so)

As always the mandatory sample https://playground.babylonjs.com/#F41V6N#457

Thank you in advance.

that is because, AFAIK, android doesn’t support touch events on the canvas when in XR. (But I might be mistaken). There is already an issue to track that - WebXR simple pointer support for touch/select events when in gaze mode · Issue #10186 · BabylonJS/Babylon.js (github.com)

What are you using to test? cardboard-style device?

I’ve tried it with a cardboard style glasses and just clicking on the screen itself (also with quest 2 but it works perfectly there)

It doesn’t seem to be a technology limitation since for example this one WebXR UI Interaction - PLAYCANVAS works flawlessly.

I assume you only need the click effect. You will not try to actually select a mesh when in a cardboard scene, i assume.

Is gaze mode activated? can you see the gaze point? are you only looking for a way to trigger the pointer down/up events?

The weird thing is that window.onclick is not triggered either https://playground.babylonjs.com/#F41V6N#460

I assume you only need the click effect.

You will not try to actually select a mesh when in a cardboard scene, i assume.
I need it but I can make a raycast from the center of the screen to select them.

Is gaze mode activated?
Yes, without that mode it gets the trigger without problems

can you see the gaze point?
You mean the white dot? If so, yes.

Are you only looking for a way to trigger the pointer down/up events?

Btw the webxr in my Android seems to be laterally offset I mean I can see the “two views” and a white line that I imagine that should be between both but it is not.

System OnePlus 8T + Chrome.

That’s my point.

If clicking on the canvas triggers an input-source creation, than it is already supported.
I assume that the canvas does trigger the select event (xrSession select), and this would be the way for you to get the click from the canvas.

Try doing this:

xrSessionManager.session.addEventListener("selectstart", () => { console.log('clicked') });

It works but only once (probably my bad) https://playground.babylonjs.com/#F41V6N#468

Only once you mean that it only triggers once? from your code it is hard to tell, as you change it to the same text every time you click.
This event is a native webxr event, if must be triggered every time a selection was made. what “selection” means is different from one system to the other. In the oculus quest it is a tap of the fingers or click on the controller’s main component. on mobile devices it is a canvas touch.

I mean that if I exit the WebXR mode and enter again it doesn’t work until I reload the page.

Try using the sessionManager’s onSessionInitObservable. You won’t need the flag. You can also remove the event listener in onSessionEnded to stay callback-clean :slight_smile:

That’s weird even the simpler sample (not my own sample but the original one) is not longer working on PC Babylon.js Playground

VM177:1284 TypeError: Cannot read property 'textures' of null
    at e._createRenderTargetTexture (babylon.js:16)
    at Object.getRenderTargetForEye (babylon.js:16)
    at e.getRenderTargetTextureForEye (babylon.js:16)
    at babylon.js:16
    at Array.forEach (<anonymous>)
    at t._updateFromXRSession (babylon.js:16)
    at r.callback (babylon.js:16)
    at e.notifyObservers (babylon.js:16)
    at Object.renderFunction [as callback] (babylon.js:16)
    at XRSession$1.<computed>.onDeviceFrame (<anonymous>:1281:42)

Something broken on preview headers?

Yes, working on that. latest build has an issue with XR init.

1 Like

Thank you!

1 Like