Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The read-only depthUsage
property of an immersive-ar
XRSession
describes which depth-sensing usage is used.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The read-only depthUsage
property of an immersive-ar
XRSession
describes which depth-sensing usage is used.
This property can return the following values:
cpu-optimized
The depth data is intended to be used on the CPU; see the XRCPUDepthInformation
interface.
gpu-optimized
The depth data is intended to be used on the GPU; see the XRWebGLDepthInformation
interface.
To request the desired usage method, you need to specify a usagePreference
when requesting a session using XRSystem.requestSession()
. Here, the caller is able to handle both CPU- and GPU-optimized usage. The order indicates preference for CPU:
js
navigator.xr.requestSession("immersive-ar", { requiredFeatures: ["depth-sensing"], depthSensing: { usagePreference: ["cpu-optimized", "gpu-optimized"], formatPreference: ["luminance-alpha", "float32"], }, });
To check which usage was selected by the user agent, you can call the depthUsage
property:
js
console.log(session.depthUsage); // either "cpu-optimized" or "gpu-optimized"
Specification |
---|
WebXR Depth Sensing Module # dom-xrsession-depthusage |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
depthUsage |
90 | 90 | No | No | 76 | No | No | 90 | No | 64 | No | 15.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRSession/depthUsage