值
一个包含 对象的有序数组。图层的顺序是“从后向前”。XRLayer
示例
获取渲染状态图层
要读取 WebXR 图层数组,请使用 上的 XRRenderStatelayers 属性。可以使用 方法设置图层。XRSession.updateRenderState()
js
const xrSession = navigator.xr.requestSession("immersive-ar", {
optionalFeatures: ["layers"],
});
function onXRSessionStarted(xrSession) {
const glCanvas = document.createElement("canvas");
const gl = glCanvas.getContext("webgl", { xrCompatible: true });
const xrGlBinding = new XRWebGLBinding(xrSession, gl);
const projectionLayer = new XRWebGLLayer(xrSession, gl);
const quadLayer = xrGlBinding.createQuadLayer({
pixelWidth: 1024,
pixelHeight: 1024,
});
xrSession.updateRenderState({
layers: [projectionLayer, quadLayer],
});
xrSession.renderState.layers; // [projectionLayer, quadLayer]
}
规范
| 规范 |
|---|
| WebXR Layers API Level 1 # dom-xrrenderstate-layers |
浏览器兼容性
加载中…