XRSession: thuộc tính depthDataFormat
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.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc depthDataFormat của một XRSession immersive-ar mô tả định dạng dữ liệu cảm biến độ sâu nào được sử dụng.
Giá trị
Thuộc tính này có thể trả về các giá trị sau:
luminance-alpha-
Bộ đệm dữ liệu số nguyên không dấu 2 byte (
LUMINANCE_ALPHAGLEnum). Sử dụng CPU: diễn giảiXRCPUDepthInformation.datalàUint8Array. Sử dụng GPU: kiểm tra các kênh Luminance và Alpha để lắp ráp lại giá trị đơn. float32-
Bộ đệm dữ liệu dấu phẩy động 4 byte (
R32FGLEnum). Sử dụng CPU: diễn giảiXRCPUDepthInformation.datalàFloat32Array. Sử dụng GPU: kiểm tra kênh Red và sử dụng giá trị.
Ví dụ
Để yêu cầu định dạng dữ liệu mong muốn, bạn cần chỉ định dataFormatPreference khi yêu cầu một phiên bằng XRSystem.requestSession(). Ở đây, người gọi có thể xử lý cả định dạng "luminance-alpha" và "float32". Thứ tự thể hiện ưu tiên cho "luminance-alpha":
navigator.xr.requestSession("immersive-ar", {
requiredFeatures: ["depth-sensing"],
depthSensing: {
usagePreference: ["cpu-optimized", "gpu-optimized"],
formatPreference: ["luminance-alpha", "float32"],
},
});
Để kiểm tra định dạng dữ liệu nào đã được chọn bởi tác nhân người dùng, bạn có thể gọi thuộc tính depthDataFormat:
console.log(session.depthDataFormat); // either "luminance-alpha" or "float32"
Thông số kỹ thuật
| Specification |
|---|
| WebXR Depth Sensing Module> # dom-xrsession-depthdataformat> |