immersive-web / depth-sensing

Specification: https://immersive-web.github.io/depth-sensing/ Explainer: https://github.com/immersive-web/depth-sensing/blob/main/explainer.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to read the 'dataFormatPreference' property from 'XRDepthStateInit'

akirchmeyer opened this issue · comments

Hello,
When I try to request an XR session with depth support using the code provided in explainer.md, namely:

const session = await navigator.xr.requestSession("immersive-ar", {
  requiredFeatures: ["depth-sensing"],
  depthSensing: {
    usagePreference: ["cpu-optimized", "gpu-optimized"],
    formatPreference: ["luminance-alpha", "float32"]
  }
});

the browser (Chrome Canary 98 on Android 11) complains that:

TypeError: Failed to execute 'requestSession' on 'XRSystem': Failed to read the 'depthSensing' property from 'XRSessionInit': Failed to read the 'dataFormatPreference' property from 'XRDepthStateInit': Failed to read the 'dataFormatPreference' property from 'XRDepthStateInit': Required member is undefined.

There seems to have been a change in naming conventions.
The fix is to replace the line:

formatPreference: ["luminance-alpha", "float32"]

with the following:

dataFormatPreference: ["luminance-alpha", "float32"]

I haven't studied the behavior for other browsers / browser versions.
Could you update the explainer.md file accordingly?
Thank you!

And thank you for your great work and documentation! There is no document that explains the Depth API as clearly as explainer.md does (and by far).

Didn't see the pull request ><