值
此属性可以返回以下值
luminance-alpha-
2 字节无符号整数数据缓冲区(
LUMINANCE_ALPHAGLEnum)。CPU 使用:将XRCPUDepthInformation.data解释为Uint8Array。GPU 使用:检查亮度(Luminance)和 Alpha 通道以重新组合单个值。 float32-
4 字节浮点数数据缓冲区(
R32FGLEnum)。CPU 使用:将XRCPUDepthInformation.data解释为Float32Array。GPU 使用:检查红色(Red)通道并使用该值。
示例
要请求所需的数据格式,您需要在调用 XRSystem.requestSession() 请求会话时指定 dataFormatPreference。在此示例中,调用者可以处理 "luminance-alpha" 和 "float32" 格式。顺序表示对 "luminance-alpha" 的偏好。
js
navigator.xr.requestSession("immersive-ar", {
requiredFeatures: ["depth-sensing"],
depthSensing: {
usagePreference: ["cpu-optimized", "gpu-optimized"],
formatPreference: ["luminance-alpha", "float32"],
},
});
要检查用户代理选择了哪种数据格式,您可以调用 depthDataFormat 属性。
js
console.log(session.depthDataFormat); // either "luminance-alpha" or "float32"
规范
| 规范 |
|---|
| WebXR Depth Sensing 模块 # dom-xrsession-depthdataformat |
浏览器兼容性
加载中…