enableInteractions equivalent in XR

I’m trying to implement XR to include the “lowest common denominator” i.e. Google Cardboard.

Before I reinvent the wheel, and implement gaze selection with pick and projection, does XR implement an equivalent of enableInteractions?


pinging @RaananW

The WebXR polyfill is your friend.

I solved an issue that prevented it from working correctly (in general - canvas resizing) and it should now be supported. It does have cardboard support and it is maintained by the great people at the immersive web group - GitHub - immersive-web/webxr-polyfill: Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard

I think there’s been a bit of a misunderstanding.

I would like to know whether WebXRExperienceHelper has an equivalent to VREXperienceHelper's enableInteractions.

Or am I misunderstanding what enableInteractions did?


Oh! Sorry!!

The pointer selection feature should take care of every type of XR interaction - screen, gaze and tracker-pointer. It is enabling per default. A few changes are planned - [XR] changes to PointerSelection behavior · Issue #7974 · BabylonJS/Babylon.js · GitHub, but in general it is stable and ready to go.

So how does gaze actually work (I’m trying to work it out but getting nowhere)?

Gaze mode is enabled to gaze enabled devices (devices that state their input type to be gaze). Some devices like the cardboard might be recognized as screen instead of gaze, which might complicate things a bit.
If the device is a tracked-pointer and you want gaze support you can force gaze mode when (re)enabling the pointer selection feature.

Hmm, this simple playground (https://playground.babylonjs.com/#M1HAX5) doesn’t seem to exhibit gaze behaviour (unless I’ve missed something out or misunderstood).

What device are you testing on?

Every device uses a different pointer-selection feature. tracked pointer have their controllers, screen has touch-enabled, and gaze devices have a gaze ring. If you want gaze mode enabled instead of the controllers, you can force it. If you want gaze on screen-mode devices (usually smartphones) I can add it as a feature

Early days so on PC only for now until I have something a bit more functional… soon. Then testing on Samsung Edge, and Google.

Unless custom-defined by you, a PC (both real devices and the emulator) work in tracked-pointer mode. The controllers, in that case, are still the real controllers, to the WebXR xrInput object (the one that is being tracked) can be enabled to be in “gaze” mode (no need to press the trigger, 3 seconds delay for selection) - example is here - https://playground.babylonjs.com/#M1HAX5#3

The github link I pasted before has a feature proposed to have the xrCamera enabled in gaze mode, which is not yet available. I do hope to finish it by 4.2’s release

I’m learning WebXR and designing the game at the same time. So I don’t know what I’ll need or use until I need or use it. :grimacing: I’m sure there will be a few dead ends.

It doesn’t seem to work I select cardboard. :frowning_face:

I am not quote sure which part doesn’t work… cardboard is probably working in screen mode, but this is an uneducated guess. unless it is gaze-enabled (xr definition), the pointer selection will work differently. share an updated playground if you can, so I will know what part isn’t working

I’m not sure how it’s supposed to work but with your example here’s what I’m seeing.

For VIVE a set of co-ordinates to the console, for Cardboard nothing.

I’ve rotated through 360º and “gazed” at the GUI element but with no feedbck.

Am I even doing it right?

The cardboard on the emulator does not report any controller (not even the screen), so the pointer selection xr feature simply doesn’t get triggered. And this is what I mean when I saw that it all depends on the controller type your device supports.

We don’t (and neither native WebXR) currently have camera-based gaze support, unless WebXR (native, not babylon) reports a gaze mode controller. If you want to add that to the pointer selection github ticket, please go right a head, and I will add the feature when I work on the ticket.

For now, at least, I think I’ll just implement something myself.

I was looking at the pointer selection and realized it won’t be a hard task to add the camera gaze mode , so… [XR] Optional (xr)camera gaze mode by RaananW · Pull Request #8605 · BabylonJS/Babylon.js · GitHub

Once merged you will be able to add gaze support to the camera (on top of the controllers, if available) using:

    const xrHelper = await scene.createDefaultXRExperienceAsync();
    xrHelper.pointerSelection = xrHelper.baseExperience.featuresManager.enableFeature(BABYLON.WebXRControllerPointerSelection, 'latest', {
        gazeCamera: xrHelper.baseExperience.camera,
        xrInput: xrHelper.input