The WebXR Device API XRWebGLLayer()
constructor creates and returns a new XRWebGLLayer
object, providing the linkage between the WebXR device and the WebGL graphics layer used to render the 3D scene.
new XRWebGLLayer(session, context)
new XRWebGLLayer(session, context, options)
A newly-created XRWebGLLayer
which links the specified XRSession
to the WebGL context given by context
, which will be used as the renderer for the session. Any options specified in layerInit
are used to tailor the rendering system's configuration.
In this example, a new XRWebGLLayer
is created for a WebXR session, xrSession
.
xrSession.updateRenderState({
baseLayer: new XRWebGLLayer(xrSession, gl, {
alpha: false,
antialias: false,
depth: false,
framebufferScaleFactor: 0.5,
ignoreDepthValues: true,
stencil: false,
}),
});