值
一個包含 物件的有序陣列。圖層的順序是“從後向前”。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 |
瀏覽器相容性
載入中…