草案
此页面不完整。

安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

只读 baseLayer 特性为 XRRenderState interface returns the XRWebGLLayer instance that is the source of bitmap images and a description of how the image is to be rendered in the device.

This property is read-only; however, you can indirectly change its value using XRSession.updateRenderState .

句法

var xrWebGLLayer = xrRenderState.baseLayer;
					

A XRWebGLLayer object which is used as the source of the world's contents when rendering each frame of the scene.

See the examples below to see how to use updateRenderState() to set the current XRWebGLLayer used for rendering the scene.

范例

可以设置 XRWebGLLayer used for rendering by calling updateRenderState() ,像这样:

let canvas = document.querySelector("canvas");
gl = canvas.getContext("webgl", { xrCompatible: true });
setNewWebGLLayer();
function setNewWebGLLayer(gl) {
  if (!gl) {
    /* WebGL not available */
    return;
  }
  xrSession.updateRenderState({
    baseLayer: new XRWebGLLayer(xrSession, gl);
  });
};
					

Here, the canvas obtained in the first line is the canvas into which WebGL is going to draw. That context is passed into new XRWebGLLayer() to create an XRWebGLLayer which uses the contents of the WebGL context gl as the source of the world's image during presentation.

规范

规范 状态 注释
WebXR 设备 API
The definition of 'XRRenderState.baseLayer' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "api.XRRenderState.baseLayer" (depth: 1) to the MDN 兼容性数据存储库 .

元数据

  • 最后修改: