The createCubeLayer()
method of the XRWebGLBinding
interface returns an XRCubeLayer
object, which is a layer that renders directly from a cubemap, and projects it onto the inside faces of a cube.
Configure the cube layer using the properties listed above in a call to createCubeLayer()
. To present layers to the XR device, add them to the layers
render state using XRSession.updateRenderState()
.
function onXRSessionStarted(xrSession) {
const glCanvas = document.createElement("canvas");
const gl = glCanvas.getContext("webgl2", { xrCompatible: true });
const xrGlBinding = new XRWebGLBinding(xrSession, gl);
const cubeLayer = xrGlBinding.createCubeLayer({
space: xrReferenceSpace,
viewPixelHeight: 512,
viewPixelWidth: 512,
});
xrSession.updateRenderState({
layers: [cubeLayer],
});
}