A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/XRSession/updateRenderState below:

XRSession: updateRenderState() method - Web APIs

XRSession: updateRenderState() method

Limited availability

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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 the WebXR API schedules changes to be applied to the active render state (XRRenderState) prior to rendering of the next frame.

Syntax
updateRenderState()
updateRenderState(state)
Parameters
state Optional

An optional object to configure the XRRenderState. If none is provided, a default configuration will be used.

Return value

None (undefined).

Exceptions
InvalidStateError DOMException

Thrown in any of the following situations:

NotSupportedError DOMException

Thrown in any of the following situations:

TypeError

Thrown if the layers option contains duplicate instances.

Examples Adding a baseLayer

This example creates a WebGL context that is compatible with an immersive XR device and then uses it to create an XRWebGLLayer. The method updateRenderState() is then called to associate the new XRWebGLLayer.

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

  loadWebGLResources();

  xrSession.updateRenderState({
    baseLayer: new XRWebGLLayer(xrSession, gl),
  });
}
Setting the layers array

To use WebXR layers, the XR session needs to be created with the layers feature descriptor (see XRSystem.requestSession()). You can then create various WebXR layers such as

Other layers, such as XRProjectionLayer or XRWebGLLayer are also available.

Layers will be presented in the order they are given in the layers array, with layers being given in "back-to-front" order.

const xrSession = navigator.xr.requestSession("immersive-ar", {
  optionalFeatures: ["layers"],
});

function onXRSessionStarted(xrSession) {
  const glCanvas = document.createElement("canvas");
  const gl = glCanvas.getContext("webgl", { xrCompatible: true });
  const xrGlBinding = new XRWebGLBinding(xrSession, gl);
  const projectionLayer = new XRWebGLLayer(xrSession, gl);
  const quadLayer = xrGlBinding.createQuadLayer({
    pixelWidth: 1024,
    pixelHeight: 1024,
  });

  xrSession.updateRenderState({
    layers: [projectionLayer, quadLayer],
  });
}
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4