• Public
  • Public/Protected
  • All

Class WebVRController

Defines the WebVRController object that represents controllers tracked in 3D space






  • Creates a new WebVRController from a gamepad


    • vrGamepad: any

      the gamepad that the WebVRController should be created from

    Returns WebVRController


browserGamepadSearch playground for browserGamepad

browserGamepad: any

The browser gamepad

controllerTypeSearch playground for controllerType

The type of controller (Eg. Windows mixed reality)

devicePositionSearch playground for devicePosition

devicePosition: Vector3

The device position in babylon space

deviceRotationQuaternionSearch playground for deviceRotationQuaternion

deviceRotationQuaternion: Quaternion

The device rotation in babylon space

deviceScaleFactorSearch playground for deviceScaleFactor

deviceScaleFactor: number

The scale factor of the device in babylon space

handSearch playground for hand

hand: string

idSearch playground for id

id: string

The id of the gamepad

indexSearch playground for index

index: number

The index of the gamepad

isXRSearch playground for isXR

isXR: boolean

If the controller is used in a webXR session

onMainButtonStateChangedObservableSearch playground for onMainButtonStateChangedObservable

onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>

Fired when the main button state has changed

onPadStateChangedObservableSearch playground for onPadStateChangedObservable

onPadStateChangedObservable: Observable<ExtendedGamepadButton>

Fired when the pad state has changed

onPadValuesChangedObservableSearch playground for onPadValuesChangedObservable

onPadValuesChangedObservable: Observable<StickValues>

Fired when controllers stick values have changed

onSecondaryButtonStateChangedObservableSearch playground for onSecondaryButtonStateChangedObservable

onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>

Fired when the secondary button state has changed

onTriggerStateChangedObservableSearch playground for onTriggerStateChangedObservable

onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>

Fired when the trigger state has changed

padSearch playground for pad

X and Y axis corresponding to the controllers joystick

positionSearch playground for position

position: Vector3

(Likely devicePosition should be used instead) The device position in its room space

rawPoseSearch playground for rawPose

rawPose: DevicePose

The raw pose from the device

rotationQuaternionSearch playground for rotationQuaternion

rotationQuaternion: Quaternion

(Likely deviceRotationQuaternion should be used instead) The device rotation in its room space

typeSearch playground for type

type: number

Specifies what type of gamepad this represents

Static DUALSHOCKSearch playground for DUALSHOCK


Represents an Dual Shock controller

Static GAMEPADSearch playground for GAMEPAD

GAMEPAD: number

Represents a gamepad controller

Static GENERICSearch playground for GENERIC

GENERIC: number

Represents a generic controller

Static Readonly POINTING_POSESearch playground for POINTING_POSE


Name of the child mesh that can be used to cast a ray from the controller

Static POSE_ENABLEDSearch playground for POSE_ENABLED


Represents a pose-enabled controller

Static XBOXSearch playground for XBOX

XBOX: number

Represents an XBox controller



  • The default controller model for the controller

    Returns Nullable<AbstractMesh>


  • get isConnected(): boolean
  • Specifies if the gamepad has been connected

    Returns boolean


  • Gets the left joystick

    Returns StickValues

  • Sets the left joystick values


    Returns any




attachToMeshSearch playground for attachToMesh

attachToPoseControlledCameraSearch playground for attachToPoseControlledCamera

disposeSearch playground for dispose

  • dispose(): void

getForwardRaySearch playground for getForwardRay

  • getForwardRay(length?: number): Ray
  • Gets the ray of the controller in the direction the controller is pointing


    • Optional length: number

      the length the resulting ray should be

    Returns Ray

    a ray in the direction the controller is pointing

Abstract initControllerMeshSearch playground for initControllerMesh

  • Loads a mesh and attaches it to the controller


    • scene: Scene

      the scene the mesh should be added to

    • Optional meshLoaded: (mesh: AbstractMesh) => void

      callback for when the mesh has been loaded

    Returns void

onButtonStateChangeSearch playground for onButtonStateChange

  • onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void
  • Fired when a controller button's state has changed


    • callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void

      the callback containing the button that was modified

        • (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton): void
        • Parameters

          • controlledIndex: number
          • buttonIndex: number
          • state: ExtendedGamepadButton

          Returns void

    Returns void

onleftstickchangedSearch playground for onleftstickchanged

  • onleftstickchanged(callback: (values: StickValues) => void): void

onrightstickchangedSearch playground for onrightstickchanged

  • onrightstickchanged(callback: (values: StickValues) => void): void

updateSearch playground for update

  • update(): void
  • Updates the state of the controller and mesh based on the current position and rotation of the controller

    Returns void

updateFromDeviceSearch playground for updateFromDevice


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