XRSession.updateRenderState()

Draft
This page is not complete.

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The updateRenderState() method of the XRSession interface of WebXR API queues an update to the active render state which will be applied on the next frame.

Syntax

XRSession.updateRenderState([xrRenderStateInit])

Parameter attributes

XRRenderState.baseLayer Read only
The XRWebGLLayer from which the User Agent's XR compositor obtains images.
XRRenderState.depthFar Read only
The distance, in meters, of the far clip plane from the viewer. A clip plane is the edge of the field of view in an AR or VR environment.
XRRenderState.depthNear Read only
The distance, in meters, of the near clip plane from the viewer. A clip plane is the edge of the field of view in an AR or VR environment.
XRRenderState.inlineVerticalFieldOfView Read only
The default vertical field of view, in radians, used when computing projection matrices. Use this value if and only if the session mode is "inline". (xr.requestSession() was called with "inline" as the mode argument.)

Return value

None.

Errors

  • If the XR Session has already ended.
  • If the specified baseLayer is not associated with the current XR Session.
  • If inlineVerticalFieldOfView is set for the immersive experience.
InvalidStateError
Thrown in the following cases:

Examples

This example creates a WebGL context that is compatible with an immersive XR device and then uses it to create an XRWebGLLayer.

function onXRSessionStarted(xrSession) {
  let glCanvas = document.createElement("canvas");
  let gl = glCanvas.getContext("webgl", { xrCompatible: true });

  loadWebGLResources();

  xrSession.updateRenderState({ baseLayer: new XRWebGLLayer(xrSession, gl) });
}

Specifications

Specification Status Comment
WebXR Device API
The definition of 'XRSession.updateRenderState' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
updateRenderState()Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

No support  
No support