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

瀏覽器相容性