XRCPUDepthInformation: phương thức getDepthInMeters()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Phương thức getDepthInMeters() của giao diện XRCPUDepthInformation trả về độ sâu tính bằng mét tại (x, y) trong tọa độ view chuẩn hóa (gốc tọa độ ở góc trên bên trái).

Cú pháp

js
getDepthInMeters(x, y)

Tham số

x

Tọa độ X (gốc tọa độ bên trái, tăng sang phải).

y

Tọa độ Y (gốc tọa độ ở trên cùng, tăng xuống dưới).

Giá trị trả về

Không có (undefined).

Ngoại lệ

  • Một RangeError được ném ra nếu x hoặc y lớn hơn 1.0 hoặc nhỏ hơn 0.0.

Ví dụ

js
const distance = depthInfo.getDepthInMeters(x, y);

Thông số kỹ thuật

Specification
WebXR Depth Sensing Module
# dom-xrcpudepthinformation-getdepthinmeters

Tương thích trình duyệt