Capítulo 794 de 859

Chapter 794: XRManager

Core Idea

The XR manager is built on top of the WebXR Device API to manage XR sessions with renderer backends.

Key Concepts

  • cameraAutoUpdate : boolean: Whether the XR camera should automatically be updated or not.
  • enabled : boolean: This flag globally enables XR rendering.
  • isPresenting : boolean (readonly): Whether the XR device is currently presenting or not.

Reference Tables

Constructor

Signature
new XRManager( renderer : Renderer, multiview : boolean )

Properties

PropertyDescription
.cameraAutoUpdate : booleanWhether the XR camera should automatically be updated or not.
.enabled : booleanThis flag globally enables XR rendering.
.isPresenting : boolean (readonly)Whether the XR device is currently presenting or not.

Methods

MethodDescription
.createCylinderLayer( radius : number, centralAngle : number, aspectratio : number, translation : Vector3, quaternion : Quaternion, pixelwidth : number, pixelheight : number, rendercall : function, attributes : Object ) : MeshThis method can be used in XR applications to create a cylindrical layer that presents a separate rendered scene.
.createQuadLayer( width : number, height : number, translation : Vector3, quaternion : Quaternion, pixelwidth : number, pixelheight : number, rendercall : function, attributes : Object ) : MeshThis method can be used in XR applications to create a quadratic layer that presents a separate rendered scene.
.foveateBoundTexture( renderTarget : RenderTarget )Applies WebXR fixed foveation to the internal post-processing render target used by the first XR render pass before compositing into a projection layer.
`.getBaseLayer() : XRWebGLLayerXRProjectionLayer`
.getBinding() : XRWebGLBindingReturns the current XR binding.
.getCamera() : ArrayCameraReturns the XR camera.
.getController( index : number ) : GroupReturns an instance of THREE.Group that represents the transformation of a XR controller in target ray space. The requested controller is defined by the given index.
.getControllerGrip( index : number ) : GroupReturns an instance of THREE.Group that represents the transformation of a XR controller in grip space. The requested controller is defined by the given index.
`.getEnvironmentBlendMode() : 'opaque''additive'
`.getFoveation() : numberundefined`
.getFrame() : XRFrameReturns the current XR frame.
.getFramebufferScaleFactor() : numberReturns the framebuffer scale factor.
.getHand( index : number ) : GroupReturns an instance of THREE.Group that represents the transformation of a XR controller in hand space. The requested controller is defined by the given index.
.getReferenceSpace() : XRReferenceSpaceReturns the XR reference space.
.getReferenceSpaceType() : XRReferenceSpaceTypeReturns the reference space type.
.getSession() : XRSessionReturns the current XR session.
.getWebGPUBinding() : XRGPUBindingReturns the current XR WebGPU binding.
.renderLayers()Renders the XR layers that have been previously added to the scene.
.setFoveation( foveation : number )Sets the foveation value.
.setFramebufferScaleFactor( factor : number )Sets the framebuffer scale factor.
.setReferenceSpace( space : XRReferenceSpace )Sets a custom XR reference space.
.setReferenceSpaceType( type : XRReferenceSpaceType )Sets the reference space type.
.setSession( session : 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 : PerspectiveCamera )This method is called by the renderer per frame and updates the XR camera and it sub cameras based on the given camera. The given camera is the "user" camera created on application level and used for…
.useMultiview() : booleanReturns true if the engine renders to a multiview target.

Key Takeaways

  1. XRManager extends: EventDispatcher
  2. Most relevant properties: cameraAutoUpdate, enabled, isPresenting.
  3. Key methods: createCylinderLayer, createQuadLayer, foveateBoundTexture, getBaseLayer.

Connects To