files/en-us/web/api/xrsession/depthdataformat/index.md
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The read-only depthDataFormat property of an immersive-ar
{{DOMxRef("XRSession")}} describes which depth sensing data format is used.
This property can return the following values:
luminance-alpha
LUMINANCE_ALPHA GLEnum).
CPU usage: interpret {{domxref("XRCPUDepthInformation.data")}} as {{jsxref("Uint8Array")}}.
GPU usage: inspect Luminance and Alpha channels to reassemble single value.float32
R32F GLEnum).
CPU usage: interpret {{domxref("XRCPUDepthInformation.data")}} as {{jsxref("Float32Array")}}.
GPU usage: inspect Red channel and use the value.To request the desired data format, you need to specify a dataFormatPreference when requesting a session using {{domxref("XRSystem.requestSession()")}}. Here, the caller is able to handle both "luminance-alpha" and "float32" formats. The order indicates preference for "luminance-alpha":
navigator.xr.requestSession("immersive-ar", {
requiredFeatures: ["depth-sensing"],
depthSensing: {
usagePreference: ["cpu-optimized", "gpu-optimized"],
formatPreference: ["luminance-alpha", "float32"],
},
});
To check which data format was selected by the user agent, you can call the depthDataFormat property:
console.log(session.depthDataFormat); // either "luminance-alpha" or "float32"
{{Specifications}}
{{Compat}}