The createEquirectLayer()
method of the XRWebGLBinding
interface returns an XREquirectLayer
object, which is a layer that maps equirectangular coded data onto the inside of a sphere.
createEquirectLayer(options)
Configure the equirect layer using the properties listed above in a call to createEquirect()
. 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 equirectLayer = xrGlBinding.createEquirectLayer({
space: xrReferenceSpace,
viewPixelWidth: 1200,
viewPixelHeight: 600,
centralHorizontalAngle: 2 * Math.PI,
upperVerticalAngle: Math.PI / 2.0,
lowerVerticalAngle: -Math.PI / 2.0,
radius: 0,
});
xrSession.updateRenderState({
layers: [equirectLayer],
});
}