WebXRExperienceHelper

Helper class used to enable XR

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

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

    • sessionCreationOptions: XRSessionCreationOptions

      options for the XR session

    • frameOfReference: string

      frame of reference of the XR session

    Returns Promise<void>

    promise that resolves after xr mode has entered

environmentPointHitTestAsync

Find examples in Playground
  • Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR

    Parameters

    • ray: Ray

      ray to cast into the environment

    Returns Promise<Nullable<Vector3>>

    Promise which resolves with a collision point in the environment if it exists

exitXRAsync

Find examples in Playground
  • 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

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

supportsSessionAsync

Find examples in Playground
  • Checks if the creation options are supported by the xr session

    Parameters

    Returns Promise<boolean>

    true if supported

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