Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize parameters to WebXR requestSession? #4315

Closed
klausw opened this issue Nov 12, 2019 · 7 comments
Closed

Customize parameters to WebXR requestSession? #4315

klausw opened this issue Nov 12, 2019 · 7 comments
Milestone

Comments

@klausw
Copy link
Contributor

klausw commented Nov 12, 2019

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.

@dmarcos
Copy link
Member

dmarcos commented Nov 12, 2019

There's a precendent of this with requestPresent and the renderer system to set the foveationLevel and enable 72fps mode on the Oculus Browser. Maybe consolidating the webxr flags on a system / component would be cleaner.

@dmarcos dmarcos added this to the 0.9.3 milestone Nov 20, 2019
@dmarcos
Copy link
Member

dmarcos commented Dec 9, 2019

I'm going to move this for next milestone since it's for experimental purposes.

@dmarcos dmarcos removed this from the 0.9.3 milestone Dec 9, 2019
@dmarcos dmarcos added this to the 1.1.0 milestone Dec 20, 2019
@sneha-belkhale
Copy link

@dmarcos hey, is there any update on this? I'm looking for a way to set the foveationLevel in WebXR + Oculus Browser.

@dmarcos
Copy link
Member

dmarcos commented Apr 21, 2020

You can already adjust foveation level https://aframe.io/docs/1.0.0/components/renderer.html#sidebar

@marlon360
Copy link

This would be nice for additional features like the new 'hand-tracking' 👍

@klausw
Copy link
Contributor Author

klausw commented 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.

@dmarcos
Copy link
Member

dmarcos commented Oct 23, 2020

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

@dmarcos dmarcos closed this as completed Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants