大网数据广告活动
Web 标准与前端开发

XRWebGLLayer: ignoreDepthValues property

· 52CE 我爱测

The read-only XRWebGLLayer property **`ignoreDepthValues`** is a Boolean value which is `true` if the session has been configured to ignore the values in the depth buffer while rendering the scene. If the depth buffer is being used to determine the position of vertices, this prop

WebXR Device API

The read-only XRWebGLLayer property ignoreDepthValues is a Boolean value which is true if the session has been configured to ignore the values in the depth buffer while rendering the scene. If the depth buffer is being used to determine the position of vertices, this property is false.

The value of ignoreDepthValues can only be set when the XRWebGLLayer is instantiated, by setting the corresponding value in the constructor's options parameter.

Value

A Boolean value which is true if the WebGL context's depth buffer is being used while computing the locations of points in the 3D world. Otherwise, if this is true, the depth buffer's values are being used to assist in placing objects in the scene. Since the XR compositor uses the depth buffer by default, this value is false unless explicitly set otherwise when creating the XRWebGLLayer using its constructor, XRWebGLLayer.XRWebGLLayer.

Usage notes

When the ignoreDepthValues property is false, the XR compositor uses the values found in the depth buffer, which should be accurate for the scene, in order to potentially improve the quality or the output as well as the comfort level for the viewer.

The depth buffer is XRWebGLLayer.framebufferWidth entries wide and XRWebGLLayer.framebufferHeight entries tall. Each entry in the buffer specifies the depth at which the corresponding pixel is located, and has a value between 0.0 and 1.0.

A depth buffer pixel value of 0.0 corresponds to the depth given by the session's XRRenderState.depthNear and a value of 1.0 corresponds to the depth given by XRRenderState.depthFar.

The depth, in tandem with the coordinates of each point being rendered, makes it possible to more accurately represent the scene in the 3D space.

Examples

If the Web application which is using WeXR is rendering its content without using a depth buffer—or if the depth buffer's contents are invalid—you should disable the use of the depth buffer for WebXR rendering by setting ignoreDepthValues to true when creating the XRWebGLLayer. This is demonstrated in the snippet of code below:

const glLayerOptions = {
  ignoreDepthValues: true,
};

let glLayer = new XRWebGLLayer(xrSession, gl, glLayerOptions);

Specifications

Browser compatibility

See also

  • WebXR Device API
  • WebGL depth buffer related methods: WebGLRenderingContext.depthFunc, WebGLRenderingContext.clearDepth

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。