XRWebGLBinding.createQuadLayer()
The createQuadLayer() method of the XRWebGLBinding interface returns an XRQuadLayer object which is a layer that takes up a flat rectangular space in the virtual environment.
Syntax
createQuadLayer(init)
Parameters
init-
An object to configure the
XRQuadLayer. It must have thespace,viewPixelHeight, andviewPixelWidthproperties.inithas the following properties:colorFormat: Optional. AGLenumdefining the data type of the color texture data. Possible values:gl.RGBgl.RGBA
EXT_sRGBextension enabled:ext.SRGB_EXText.SRGB_ALPHA_EXT
WebGL2RenderingContextcontexts:gl.RGBA8gl.RGB8gl.SRGB8gl.RGB8_ALPHA8
WEBGL_compressed_texture_etcextension 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
WEBGL_compressed_texture_astcextension enabled:- All of the formats the extension supports.
gl.RGBA.-
depthFormat: Optional. AGLenumdefining the data type of the depth texture data or0indicating that the layer should not provide a depth texture (in that caseXRProjectionLayer.ignoreDepthValueswill betrue). Possible values withinWebGLRenderingContextcontexts with theWEBGL_depth_textureextension enabled, or withinWebGL2RenderingContextcontexts (no extension required):gl.DEPTH_COMPONENTgl.DEPTH_STENCIL
WebGL2RenderingContextcontexts:gl.DEPTH_COMPONENT24gl.DEPTH24_STENCIL24
gl.DEPTH_COMPONENT. height: Optional. A number specifying the height of the layer in meters. The default value is1.0.isStatic: Optional. A boolean that, if true, indicates you can only draw to this layer whenneedsRedrawistrue. The default value isfalse.layout: Optional. A string indicating the layout of the layer. Possible values:default: The layer accommodates all views of the session.mono: A singleXRSubImageis allocated and presented to both eyes.stereo: The user agent decides how it allocates theXRSubImage(one or two) and the layout (top/bottom or left/right).stereo-left-right: A singleXRSubImageis allocated. Left eye gets the left area of the texture, right eye the right.stereo-top-bottom: A singleXRSubImageis allocated. Left eye gets the top area of the texture, right eye the bottom.
mono.mipLevels: Optional. A number specifying desired number of mip levels. The default value is1.space: Required. AnXRSpaceobject defining the layer's spatial relationship with the user's physical environment.textureType: Optional. A string defining the type of texture the layer will have. Possible values:texture: The textures ofXRWebGLSubImagewill be of typegl.TEXTURE_2D.texture-array: the textures ofXRWebGLSubImagewill be of typegl.TEXTURE_2D_ARRAY(WebGL 2 contexts only).
texture.transform: Optional. AnXRRigidTransformobject defining the offset and orientation relative tospace.viewPixelHeight: Required. A number specifying the pixel height of the layer view.viewPixelWidth: Required. A number specifying the pixel width of the layer view.width: Optional. A number specifying the width of the layer in meters. The default value is1.0.
Return value
An XRQuadLayer object.
Examples
Creating an XRQuadLayer
Configure the quad layer using the properties listed above in a call to createQuadLayer(). 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 quadLayer = xrGlBinding.createQuadLayer({
space: xrReferenceSpace,
viewPixelHeight: 512,
viewPixelWidth: 512,
transform: new XRRigidTransform({z: -2});
});
xrSession.updateRenderState({
layers: [quadLayer]
});
}
Specifications
No specification found
No specification data found for api.XRWebGLBinding.createQuadLayer.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
Browser compatibility
No compatibility data found for api.XRWebGLBinding.createQuadLayer.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.