Options
All
  • Public
  • Public/Protected
  • All
Menu

Manages an XRSession to work with Babylon's engine

see

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

Hierarchy

  • WebXRSessionManager

Implements

Index

Constructors

  • 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: XRReferenceSpace

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

currentFrame: Nullable<XRFrame>

Current XR frame

currentTimestamp: number

WebXR timestamp updated every frame

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

inXRFrameLoop: boolean

Are we currently in the XR loop?

inXRSession: boolean

Are we in an XR session?

onXRFrameObservable: Observable<XRFrame>

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

onXRReferenceSpaceChanged: Observable<XRReferenceSpace>

Fires when the reference space changed

onXRSessionEnded: Observable<any>

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

onXRSessionInit: Observable<XRSession>

Fires when the xr session is initialized: right after requestSession was called and returned with a successful result

scene: Scene

The scene which the session should be created for

session: XRSession

Underlying xr session

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

  • get currentFrameRate(): undefined | number
  • The current frame rate as reported by the device

    Returns undefined | number

  • get fixedFoveation(): Nullable<number>
  • set fixedFoveation(value: Nullable<number>): void
  • Get the fixed foveation currently set, as specified by the webxr specs If this returns null, then fixed foveation is not supported

    Returns Nullable<number>

  • Set the fixed foveation to the specified value, as specified by the webxr specs This value will be normalized to be between 0 and 1, 1 being max foveation, 0 being no foveation

    Parameters

    Returns void

  • get isFixedFoveationSupported(): boolean
  • Check if fixed foveation is supported on this device

    Returns boolean

  • get isNative(): boolean
  • Returns true if Babylon.js is using the BabylonNative backend, otherwise false

    Returns boolean

  • 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 void

  • The mode for the managed XR session

    Returns XRSessionMode

  • get supportedFrameRates(): undefined | Float32Array
  • A list of supported frame rates (only available in-session!

    Returns undefined | Float32Array

Methods

  • dispose(): void
  • Disposes of the session manager This should be called explicitly by the dev, if required.

    Returns void

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

    Returns Promise<void>

    Promise which resolves after it exits XR

  • Creates a WebXRRenderTarget object for the XR session

    Parameters

    Returns WebXRRenderTarget

    a WebXR render target to which the session can render

  • 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

  • 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(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(): void
  • Resets the reference space to the one started the session

    Returns void

  • runInXRFrame(callback: () => void, ignoreIfNotInSession?: boolean): void
  • Run a callback in the xr render loop

    Parameters

    • callback: () => void

      the callback to call when in XR Frame

        • (): void
        • Returns void

    • Optional ignoreIfNotInSession: boolean

      if no session is currently running, run it first thing on the next session

    Returns void

  • runXRRenderLoop(): void
  • Starts rendering to the xr layer

    Returns void

  • Sets the reference space on the xr session

    Parameters

    Returns Promise<XRReferenceSpace>

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

  • Attempts to set the framebuffer-size-normalized viewport to be rendered this frame for this view. In the event of a failure, the supplied viewport is not updated.

    Parameters

    • viewport: Viewport

      the viewport to which the view will be rendered

    • view: XRView

      the view for which to set the viewport

    Returns boolean

    whether the operation was successful

  • Updates the render state of the session

    Parameters

    Returns void

  • Updates the render state of the session. Note that this is deprecated in favor of WebXRSessionManager.updateRenderState().

    deprecated

    Parameters

    Returns Promise<void>

    a promise that resolves once the render state has been updated

  • updateTargetFrameRate(rate: number): Promise<void>
  • Set the framerate of the session.

    Parameters

    • rate: number

      the new framerate. This value needs to be in the supportedFrameRates array

    Returns Promise<void>

    a promise that resolves once the framerate has been set

  • 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

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Inherited constructor
  • Static method

Settings

Theme