files/en-us/web/api/xrwebglbinding/createequirectlayer/index.md
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}
The createEquirectLayer() method of the {{domxref("XRWebGLBinding")}} interface returns an {{domxref("XREquirectLayer")}} object, which is a layer that maps equirectangular coded data onto the inside of a sphere.
createEquirectLayer(options)
options
space, viewPixelHeight, and viewPixelWidth properties. init has the following properties:
centralHorizontalAngle {{optional_inline}}
6.28318 (2π).colorFormat {{optional_inline}}
gl.RGBgl.RGBA
Additionally, for contexts with the {{domxref("EXT_sRGB")}} extension enabled:ext.SRGB_EXText.SRGB_ALPHA_EXT
Additionally, for {{domxref("WebGL2RenderingContext")}} contexts:gl.RGBA8gl.RGB8gl.SRGB8gl.RGB8_ALPHA8
Additionally, for contexts with the {{domxref("WEBGL_compressed_texture_etc")}} extension enabled:ext.COMPRESSED_RGB8_ETC2ext.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2ext.COMPRESSED_RGBA8_ETC2_EACext.COMPRESSED_SRGB8_ETC2ext.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2ext.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
Additionally, for contexts with the {{domxref("WEBGL_compressed_texture_astc")}} extension enabled:All of the formats the extension supports.
The default value is gl.RGBA.depthFormat {{optional_inline}}
0 to indicate that the layer should not provide a depth texture (in that case {{domxref("XRProjectionLayer.ignoreDepthValues")}} will be true).
Possible values within {{domxref("WebGLRenderingContext")}} contexts with the {{domxref("WEBGL_depth_texture")}} extension enabled, or within {{domxref("WebGL2RenderingContext")}} contexts (no extension required):
gl.DEPTH_COMPONENTgl.DEPTH_STENCIL
Additionally, for {{domxref("WebGL2RenderingContext")}} contexts:gl.DEPTH_COMPONENT24gl.DEPTH24_STENCIL24
The default value is gl.DEPTH_COMPONENT.isStatic {{optional_inline}}
true. The default value is false.layout {{optional_inline}}
default
mono
stereo
stereo-left-right
stereo-top-bottom
mono.lowerVerticalAngle {{optional_inline}}
-1.570795 (-π/2).mipLevels {{optional_inline}}
1.radius {{optional_inline}}
0 (infinite sphere).space Required
textureType {{optional_inline}}
texture
gl.TEXTURE_2D.texture-array
gl.TEXTURE_2D_ARRAY (WebGL 2 contexts only).
The default value is texture.transform {{optional_inline}}
space.upperVerticalAngle {{optional_inline}}
1.570795 (π/2).viewPixelHeight Required
viewPixelWidth Required
An {{domxref("XREquirectLayer")}} object.
XREquirectLayerConfigure 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 {{domxref("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],
});
}
{{Specifications}}
{{Compat}}