WebXRSessionManager

Manages an XRSession to work with Babylon's engine

see

https://doc.babylonjs.com/how_to/webxr_session_manager

Hierarchy

  • WebXRSessionManager

Implements

Index

Constructors

constructor

Find examples in Playground
  • Constructs a WebXRSessionManager, this must be initialized within a user action before usage

    Parameters

    • scene: Scene

      The scene which the session should be created for

    Returns WebXRSessionManager

Properties

baseReferenceSpace

Find examples in Playground
baseReferenceSpace: XRReferenceSpace

The base reference space from which the session started. good if you want to reset your reference space

currentFrame

Find examples in Playground
currentFrame: Nullable<XRFrame>

Current XR frame

currentTimestamp

Find examples in Playground
currentTimestamp: number

WebXR timestamp updated every frame

defaultHeightCompensation

Find examples in Playground
defaultHeightCompensation: number

Used just in case of a failure to initialize an immersive session. The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space

onXRFrameObservable

Find examples in Playground
onXRFrameObservable: Observable<XRFrame>

Fires every time a new xrFrame arrives which can be used to update the camera

onXRReferenceSpaceChanged

Find examples in Playground
onXRReferenceSpaceChanged: Observable<XRReferenceSpace>

Fires when the reference space changed

onXRSessionEnded

Find examples in Playground
onXRSessionEnded: Observable<any>

Fires when the xr session is ended either by the device or manually done

onXRSessionInit

Find examples in Playground
onXRSessionInit: Observable<XRSession>

Fires when the xr session is ended either by the device or manually done

scene

Find examples in Playground
scene: Scene

The scene which the session should be created for

session

Find examples in Playground
session: XRSession

Underlying xr session

viewerReferenceSpace

Find examples in Playground
viewerReferenceSpace: XRReferenceSpace

The viewer (head position) reference space. This can be used to get the XR world coordinates or get the offset the player is currently at.

Accessors

referenceSpace

Find examples in Playground
  • The current reference space used in this session. This reference space can constantly change! It is mainly used to offset the camera's position.

    Returns XRReferenceSpace

  • Set a new reference space and triggers the observable

    Parameters

    Returns any

Methods

dispose

Find examples in Playground
  • dispose(): void

exitXRAsync

Find examples in Playground
  • exitXRAsync(): Promise<void>
  • Stops the xrSession and restores the render loop

    Returns Promise<void>

    Promise which resolves after it exits XR

getRenderTargetTextureForEye

Find examples in Playground
  • Gets the correct render target texture to be rendered this frame for this eye

    Parameters

    • eye: XREye

      the eye for which to get the render target

    Returns RenderTargetTexture

    the render target for the specified eye

getWebXRRenderTarget

Find examples in Playground
  • Creates a WebXRRenderTarget object for the XR session

    Parameters

    Returns WebXRRenderTarget

    a WebXR render target to which the session can render

initializeAsync

Find examples in Playground
  • initializeAsync(): Promise<void>
  • Initializes the manager After initialization enterXR can be called to start an XR session

    Returns Promise<void>

    Promise which resolves after it is initialized

initializeSessionAsync

Find examples in Playground
  • Initializes an xr session

    Parameters

    • Optional xrSessionMode: XRSessionMode

      mode to initialize

    • Optional xrSessionInit: XRSessionInit

      defines optional and required values to pass to the session builder

    Returns Promise<XRSession>

    a promise which will resolve once the session has been initialized

isSessionSupportedAsync

Find examples in Playground
  • isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>
  • Checks if a session would be supported for the creation options specified

    Parameters

    • sessionMode: XRSessionMode

      session mode to check if supported eg. immersive-vr

    Returns Promise<boolean>

    A Promise that resolves to true if supported and false if not

resetReferenceSpace

Find examples in Playground
  • resetReferenceSpace(): void
  • Resets the reference space to the one started the session

    Returns void

runXRRenderLoop

Find examples in Playground
  • runXRRenderLoop(): void
  • Starts rendering to the xr layer

    Returns void

setReferenceSpaceTypeAsync

Find examples in Playground
  • Sets the reference space on the xr session

    Parameters

    Returns Promise<XRReferenceSpace>

    a promise that will resolve once the reference space has been set

updateRenderStateAsync

Find examples in Playground
  • Updates the render state of the session

    Parameters

    Returns Promise<void>

    a promise that resolves once the render state has been updated

Static IsSessionSupportedAsync

Find examples in Playground
  • IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>
  • Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser

    Parameters

    Returns Promise<boolean>

    a promise with boolean as final value

Generated using TypeDoc