XRWebGLLayer.ignoreDepthValues - Web APIs 编辑

Secure context

This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

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 XRWebGLLayerInit object specified as the constructor's layerInit parameter. As a parameter you're likely to set yourself, it is unlikely you'll need to read it later, but it's available if the need arises.

Syntax

let ignoringDepthBuffer = xrWebGLLayer.ignoreDepthValues;

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().

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 framebufferWidth entires wide and framebuffer 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 depthNear and a value of 1.0 corresponds to the depth given by 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

SpecificationStatusComment
WebXR Device API
The definition of 'XRWebGLLayer.ignoreDepthValues' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:72 次

字数:5524

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文