The WebXR Device API's XRWebGLLayerInit
dictionary is used to provide configuration options when creating a new XRWebGLLayer
object with the XRWebGLLayer()
constructor. The constructor's optional layerInit
parameter takes an object which must conform to this dictionary.
Properties
alpha
Optional- The frame buffer's color buffer will be established with an alpha channel if the
alpha
Boolean property istrue
. Otherwise, the color buffer will not have an alpha channel. The default value istrue
. antialias
Optional- A Boolean value which is
true
if anti-aliasing is to be used when rendering in the context; otherwisefalse
. The browser selects the anti-aliasing method to use; there is no support for requesting a specific mode yet. The default value istrue
. depth
Optional- A Boolean value which, if
true
, requests that the new layer have a depth buffer; otherwise, no depth layer is allocated. The default istrue
. framebufferScaleFactor
Optional- A floating-point value which is used to scale the image during compositing, with a value of 1.0 represents the default pixel size for the frame buffer. The static
XRWebGLLayer
functionXRWebGLLayer.getNativeFramebufferScaleFactor()
returns the scale that would result in a 1:1 pixel ratio, thereby ensuring that the rendering is occurring at the device's native resolution. The default is 1.0. ignoreDepthValues
Optional- A Boolean value which indicates whether or not to ignore the contents of the depth buffer while compositing the scene. The default is
false
. stencil
Optional- A Boolean value which, if
true
, requests that the new layer include a stencil buffer. Otherwise, no stencil buffer is allocated. The default isfalse
.
Examples
Given an XRSession
, xrSession
, and a WebGL rendering context, gl
, this snippet sets the rendering layer for the session, specifying the ignoreDepthValues
option, indicating that the depth buffer should not be used (or should not exist at all), and that the only source for distance information of any given point is its position relative to the viewer.
const layerOptions = {
ignoreDepthValues: true
};
xrSession.updateRenderState({
baseLayer: new XRWebGLLayer(xrSession, gl, layerOptions);
});
Specifications
Specification | Status | Comment |
WebXR Device APIThe definition of 'XRWebGLLayerInit' in that specification. | Working Draft | Initial definition. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
XRWebGLLayerInit
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
alpha
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
antialias
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
depth
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
framebufferScaleFactor
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
ignoreDepthValues
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
stencil
|
Chrome
Full support 79 |
Edge
Full support 79 |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 79 |
Chrome Android
Full support 79 |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.2 |
Legend
- Full support
- Full support
- No support
- No support
See also
XRWebGLLayerInit by Mozilla Contributors is licensed under CC-BY-SA 2.5.