Capítulo 790 de 859

Chapter 790: WebXRManager

Core Idea

This class represents an abstraction of the WebXR Device API and is internally used by WebGLRenderer. WebXRManager also provides a public interface that allows users to enable/disable XR and perform XR related tasks like for instance retrieving controllers.

Key Concepts

  • cameraAutoUpdate : boolean: Whether the manager's XR camera should be automatically updated or not.
  • enabled : boolean: This flag notifies the renderer to be ready for XR rendering. Set it to true if you are going to use XR in your app.
  • isPresenting : boolean (readonly): Whether XR presentation is active or not.

Reference Tables

Properties

PropertyDescription
.cameraAutoUpdate : booleanWhether the manager's XR camera should be automatically updated or not.
.enabled : booleanThis flag notifies the renderer to be ready for XR rendering. Set it to true if you are going to use XR in your app.
.isPresenting : boolean (readonly)Whether XR presentation is active or not.

Methods

MethodDescription
`.getBaseLayer() : XRWebGLLayerXRProjectionLayer`
.getBinding() : XRWebGLBindingReturns the current XR binding.
.getCamera() : ArrayCameraReturns an instance of ArrayCamera which represents the XR camera of the active XR session. For each view it holds a separate camera object.
.getCameraTexture( xrCamera : XRCamera ) : TextureRetrieves an opaque texture from the view-aligned XRCamera. Only available during the current animation loop.
.getController( index : number ) : GroupReturns a group representing the target ray space of the XR controller. Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction.
.getControllerGrip( index : number ) : GroupReturns a group representing the grip space of the XR controller. Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction.
.getDepthSensingMesh() : MeshReturns the depth sensing mesh.
.getDepthTexture() : TextureReturns the current depth texture computed via depth sensing.
`.getEnvironmentBlendMode() : 'opaque''additive'
`.getFoveation() : numberundefined`
.getFrame() : XRFrameReturns the current XR frame.
.getHand( index : number ) : GroupReturns a group representing the hand space of the XR controller. Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction.
.getReferenceSpace() : XRReferenceSpaceReturns the XR reference space.
.getSession() : XRSessionReturns the current XR session.
.hasDepthSensing() : booleanReturns true if depth sensing is supported.
.setFoveation( value : number )Sets the foveation value.
.setFramebufferScaleFactor( value : number )Sets the framebuffer scale factor.
.setReferenceSpace( space : XRReferenceSpace )Sets a custom XR reference space.
.setReferenceSpaceType( value : string )Sets the reference space type. Can be used to configure a spatial relationship with the user's physical environment. Depending on how the user moves in 3D space, setting an appropriate reference spac…
.setSession( value : XRSession ) : Promise (async)After a XR session has been requested usually with one of the *Button modules, it is injected into the renderer with this method. This method triggers the start of the actual XR rendering.
.updateCamera( camera : Camera )Updates the state of the XR camera. Use this method on app level if you set cameraAutoUpdate to false. The method requires the non-XR camera of the scene as a parameter. The passed in camera's tr…

Key Takeaways

  1. WebXRManager extends: EventDispatcher
  2. Most relevant properties: cameraAutoUpdate, enabled, isPresenting.
  3. Key methods: getBaseLayer, getBinding, getCamera, getCameraTexture.

Connects To