Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebXRExperienceHelper

Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)

see

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

Hierarchy

  • WebXRExperienceHelper

Implements

Index

Properties

cameraSearch playground for camera

camera: WebXRCamera

Camera used to render xr content

featuresManagerSearch playground for featuresManager

featuresManager: WebXRFeaturesManager

A features manager for this xr session

onInitialXRPoseSetObservableSearch playground for onInitialXRPoseSetObservable

onInitialXRPoseSetObservable: Observable<WebXRCamera>

Observers registered here will be triggered after the camera's initial transformation is set This can be used to set a different ground level or an extra rotation.

Note that ground level is considered to be at 0. The height defined by the XR camera will be added to the position set after this observable is done executing.

onStateChangedObservableSearch playground for onStateChangedObservable

onStateChangedObservable: Observable<WebXRState>

Fires when the state of the experience helper has changed

sessionManagerSearch playground for sessionManager

sessionManager: WebXRSessionManager

Session manager used to keep track of xr session

stateSearch playground for state

state: WebXRState

The current state of the XR experience (eg. transitioning, in XR or not in XR)

Methods

disposeSearch playground for dispose

  • dispose(): void
  • Disposes of the experience helper

    Returns void

enableSpectatorModeSearch playground for enableSpectatorMode

  • enableSpectatorMode(): void
  • Enable spectator mode for desktop VR experiences. When spectator mode is enabled a camera will be attached to the desktop canvas and will display the first rig camera's view on the desktop canvas. Please note that this will degrade performance, as it requires another camera render. It is also not recommended to enable this in devices like the quest, as it brings no benefit there.

    Returns void

enterXRAsyncSearch playground for enterXRAsync

  • Enters XR mode (This must be done within a user interaction in most browsers eg. button click)

    Parameters

    • sessionMode: XRSessionMode

      options for the XR session

    • referenceSpaceType: XRReferenceSpaceType

      frame of reference of the XR session

    • Optional renderTarget: WebXRRenderTarget

      the output canvas that will be used to enter XR mode

    • Optional sessionCreationOptions: XRSessionInit

      optional XRSessionInit object to init the session with

    Returns Promise<WebXRSessionManager>

    promise that resolves after xr mode has entered

exitXRAsyncSearch playground for exitXRAsync

  • exitXRAsync(): Promise<void>
  • Exits XR mode and returns the scene to its original state

    Returns Promise<void>

    promise that resolves after xr mode has exited

Static CreateAsyncSearch playground for CreateAsync

  • Creates the experience helper

    Parameters

    • scene: Scene

      the scene to attach the experience helper to

    Returns Promise<WebXRExperienceHelper>

    a promise for the experience helper

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method