immersive-web / webxr-polyfill

Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Apache License 2.0
378 stars 84 forks source link

Configurable the number of views #142

Open takahirox opened 4 years ago

takahirox commented 4 years ago

Hi. I've been making WebXR emulator extension on top of webxr-polyfill.js.

I faced a problem while I'm trying to add AR support to the extension. I want to emulate monoscopic AR device (eg. Android phone) but XRSession constructor defines two views left and right for immersive-session (mode != 'inline') although I want one 'none' view.

So I want to suggest that we make the number of views configurable depending on device. For example XRSession constructor takes device argument so we may add a method or property to XRDevice which creates (or defines) view spaces.

device.initViewSpaces(this[PRIVATE].viewSpaces);
if (this[PRIVATE].viewSpaces.length === 0) {
  if (immersive) {
    this[PRIVATE].viewSpaces.push(new XRViewSpace('left'), new XRViewSpace('right'));
  } else {
    this[PRIVATE].viewSpaces.push(new XRViewSpace('none'));
  }
}