XRWebGLDepthInformation: thuộc tính texture

Khả dụng hạn chế

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.

Thuộc tính chỉ đọc texture của giao diện XRWebGLDepthInformation là một WebGLTexture chứa thông tin bộ đệm độ sâu dưới dạng texture mờ đục.

Giá trị

Một WebGLTexture.

Ví dụ

Sử dụng XRWebGLBinding.getDepthInformation() để lấy thông tin độ sâu GPU. Đối tượng XRWebGLDepthInformation trả về sẽ chứa bộ đệm texture có thể được liên kết với texture và thông tin bộ đệm độ sâu có thể được cung cấp cho fragment shader WebGL.

js
const depthInfo = glBinding.getDepthInformation(view);
const uvTransform = depthInfo.normDepthBufferFromNormView.matrix;

const uDepthTextureLocation = gl.getUniformLocation(program, "u_DepthTexture");
const uUVTransformLocation = gl.getUniformLocation(program, "u_UVTransform");
const uRawValueToMeters = gl.getUniformLocation(program, "u_RawValueToMeters");

gl.bindTexture(gl.TEXTURE_2D, depthInfo.texture);
gl.activeTexture(gl.TEXTURE0);
gl.uniform1i(uDepthTextureLocation, 0);

// Phép biến đổi UV để lập chỉ mục đúng vào bản đồ độ sâu
gl.uniformMatrix4fv(uUVTransformLocation, false, uvTransform);

// Hệ số tỷ lệ để chuyển đổi từ số thô sang mét
gl.uniform1f(uRawValueToMeters, depthInfo.rawValueToMeters);

Thông số kỹ thuật

Thông số kỹ thuật
WebXR Depth Sensing Module
# dom-xrwebgldepthinformation-texture

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

Xem thêm