Skip to content

Customize parameters to WebXR requestSession? #4315

@klausw

Description

@klausw

Currently, AFrame uses hardcoded parameters for navigator.xr.requestSession:
https://github.com/aframevr/aframe/blob/master/src/core/scene/a-scene.js#L286

            navigator.xr.requestSession(useAR ? 'immersive-ar' : 'immersive-vr', {
              requiredFeatures: ['local-floor'],
              optionalFeatures: ['bounded-floor']
            }).then(...)

Currently, the WebXR features just correspond to reference space names, but in the future it's likely that there will be additional feature names to activate additional functionality, or potentially additional direct attributes for the init dictionary.

For example, I'm currently experimenting with using a DOM Overlay in AR mode, and the current prototype builds are using a feature named dom-overlay-for-handheld-ar for that. I've hardcoded this in a modified aframe-master.js in https://klausw.github.io/a-frame-car-sample/index.html , but I think there should be a way to add such options without needing core source modifications.

What would be an appropriate way to do that? Something like this maybe (handwaving on the syntax)?

<a-scene webxr="addOptionalFeatures: dom-overlay-for-handheld-ar;
                addInitAttribute: domOverlayElement=#example">

resulting in this call:

            navigator.xr.requestSession('immersive-ar', {
              requiredFeatures: ['local-floor'],
              optionalFeatures: ['bounded-floor', 'dom-overlay-for-handheld-ar'],
              domOverlayElement: '#example"
            })

Alternatively, specific features could get enabled by a component, while the component implementation sets appropriate values in scene properties through JS APIs, for example for DOM overlay:

<a-scene dom-overlay="element: #example">

In any case, as long as new WebXR features are still in flux, I think it would be most useful to have a generic mechanism that allows enabling and testing features without needing to change core a-frame source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions