XRDepthInformation: width 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

实验性: 这是一项实验性技术
在生产中使用此技术之前,请仔细检查浏览器兼容性表格

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

XRDepthInformation 接口的只读 width 属性包含深度缓冲区的宽度(列数)。

无符号长整型。

示例

使用 XRFrame.getDepthInformation() (CPU) 或 XRWebGLBinding.getDepthInformation() (WebGL) 来获取深度信息。返回的对象将包含深度缓冲区的 width,您可以使用它进行进一步的计算。

js
const smallerDepthDimension = Math.min(depthInfo.width, depthInfo.height);
const largerDepthDimension = Math.max(depthInfo.width, depthInfo.height);

规范

规范
WebXR Depth Sensing 模块
# dom-xrdepthinformation-width

浏览器兼容性