XRWebGLDepthInformation: texture-Eigenschaft
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Die schreibgeschützte texture-Eigenschaft des XRWebGLDepthInformation-Interfaces ist ein WebGLTexture, das Tiefenpufferinformationen als undurchsichtige Textur enthält.
Wert
Eine WebGLTexture.
Beispiele
Verwenden Sie XRWebGLBinding.getDepthInformation(), um GPU-Tiefeninformationen zu erhalten. Das zurückgegebene XRWebGLDepthInformation-Objekt enthält den texture-Puffer, der dann an eine Textur gebunden werden kann, und Tiefenpufferinformationen können einem WebGL-Fragment-Shader zur Verfügung gestellt werden.
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);
// UV transform to correctly index into the depth map
gl.uniformMatrix4fv(uUVTransformLocation, false, uvTransform);
// scaling factor to convert from the raw number to meters
gl.uniform1f(uRawValueToMeters, depthInfo.rawValueToMeters);
Spezifikationen
| Specification |
|---|
| WebXR Depth Sensing Module> # dom-xrwebgldepthinformation-texture> |