WebXRExperienceHelper

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

see

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

Hierarchy

  • WebXRExperienceHelper

Implements

Index

Properties

camera

Find examples in Playground
camera: WebXRCamera

Camera used to render xr content

container

Find examples in Playground
container: AbstractMesh

Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device

onStateChangedObservable

Find examples in Playground
onStateChangedObservable: Observable<WebXRState>

Fires when the state of the experience helper has changed

sessionManager

Find examples in Playground
sessionManager: WebXRSessionManager

Session manager used to keep track of xr session

state

Find examples in Playground
state: WebXRState

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

Methods

dispose

Find examples in Playground
  • dispose(): void

enterXRAsync

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

    Parameters

    Returns any

    promise that resolves after xr mode has entered

exitXRAsync

Find examples in Playground
  • exitXRAsync(): Promise<unknown>
  • Exits XR mode and returns the scene to its original state

    Returns Promise<unknown>

    promise that resolves after xr mode has exited

rotateCameraByQuaternionUsingContainer

Find examples in Playground
  • rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void
  • Rotates the xr camera by rotating the camera's container around the camera's position This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame

    Parameters

    • rotation: Quaternion

      the desired quaternion rotation to apply to the camera

    Returns void

setPositionOfCameraUsingContainer

Find examples in Playground
  • setPositionOfCameraUsingContainer(position: Vector3): void
  • Updates the global position of the camera by moving the camera's container This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame

    Parameters

    • position: Vector3

      The desired global position of the camera

    Returns void

Static CreateAsync

Find examples in Playground
  • Creates the experience helper

    Parameters

    • scene: Scene

      the scene to attach the experience helper to

    Returns Promise<WebXRExperienceHelper>

    a promise for the experience helper

Generated using TypeDoc