The createCylinderLayer() method of the XRWebGLBinding interface returns an XRCylinderLayer object, which is a layer that takes up a curved rectangular space in the virtual environment.
createCylinderLayer(init)
Configure the cylinder layer using the properties listed above in a call to createCylinderLayer(). 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 cylinderLayer = xrGlBinding.createCylinderLayer({
space: xrReferenceSpace,
viewPixelWidth: 1200,
viewPixelHeight: 600,
centralAngle: (60 * Math.PI) / 180,
aspectRatio: 2,
radius: 2,
transform: new XRRigidTransform(),
});
xrSession.updateRenderState({
layers: [cylinderLayer],
});
}