question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customize parameters to WebXR requestSession?

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
klauswcommented, Jul 22, 2020

There’s now a “webxr” system in master that can be used to configure required/optional features: https://aframe.io/docs/master/components/webxr.html

If you only need to request a feature, you can simply specify that:

<a-scene webxr="optionalFeatures: hand-tracking"></a-scene>

Beyond that, it’s intended to be extensible for more complex feature requests, for example it supports a WebXR DOM overlay element directly. Internally, it sets up a sessionConfiguration object that’s used as the init arg for the requestSession call.

If you have a new feature, you can access that for experiments, for example in a custom system that modifies this.el.sceneEl.systems.webxr.sessionConfiguration before session start.

0reactions
dmarcoscommented, Oct 23, 2020

It looks like A-Frame master now supports the functionality originally proposed. I’m closing this but can reopen if necessary

Read more comments on GitHub >

github_iconTop Results From Across the Web

XRSystem: requestSession() - Web APIs | MDN
... requestSession() method returns a promise which resolves to an XRSession object through which you can manage the requested type of WebXR session....
Read more >
XRSystem: requestSession() - Web APIs
See Specifying session options for details on how to configure a WebXR session. Return value. A Promise that resolves with an XRSession object...
Read more >
WebXR Device API - W3C
The requestSession( mode , options ) method attempts to initialize an XRSession for the given mode if possible, entering immersive mode if ...
Read more >
WebXR Device API Explained - Immersive Web
The WebXR Device API provides access to input and output capabilities commonly associated with Virtual Reality (VR) and Augmented Reality (AR) devices.
Read more >
WebXR Session Manager - Babylon.js Documentation
Learn all about the WebXR session manager in Babylon.js. ... but if you don't use the experience helper, you can create a session...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found