A NeedleXRController wraps a connected XRInputDevice that is either a physical controller or a hand
You can access specific buttons using getButton and getStick
To get spatial data in rig space (position, rotation) use the gripPosition, gripQuaternion, rayPosition and rayQuaternion properties
To get spatial data in world space use the gripWorldPosition, gripWorldQuaternion, rayWorldPosition and rayWorldQuaternion properties
Inputs will also be emitted as pointer events on this.context.input - so you can receive controller inputs on objects using the appropriate input events on your components (e.g. onPointerDown, onPointerUp etc) - use the pointerType property to check if the event is from a controller or not

Constructors

Properties

emitEvents: boolean = true

When enabled the controller will create input events in the Needle Engine input system (e.g. when a button is pressed or the controller is moved)
You can disable this if you don't want inputs to go through the input system but be aware that this will result in onPointerDown component callbacks to not be invoked anymore for this XRController

index: number = 0

the input source index

inputSource: XRInputSource

the Needle XR Session

Accessors

  • get connected(): boolean
  • Is the controller still connected?

    Returns boolean

  • get gamepad(): any
  • the input source gamepad giving raw access to the gamepad values
    You should usually use the getButton and getStick methods instead to get access to named buttons and sticks

    Returns any

  • get gripPosition(): any
  • Grip position in rig space

    Returns any

  • get gripQuaternion(): any
  • Grip rotation in rig space

    Returns any

  • get gripSpace(): any
  • shorthand for inputSource.gripSpace

    Returns any

  • get gripWorldPosition(): any
  • Controller grip position in worldspace

    Returns any

  • get gripWorldQuaternion(): any
  • Controller grip rotation in wordspace

    Returns any

  • get isHand(): boolean
  • Returns boolean

    true if this is a hand (otherwise this is a controller)

  • get isLeft(): boolean
  • is left side. shorthand for side === 'left'

    Returns boolean

  • get isRight(): boolean
  • is right side. shorthand for side === 'right'

    Returns boolean

  • get isTracking(): boolean
  • Returns boolean

  • get layout(): InputDeviceLayout
  • The device input layout

    Returns InputDeviceLayout

  • get object(): IGameObject
  • The controller object space.
    You can use it to attach objects to the controller.
    Children will be automatically detached and put into the scene when the controller disconnects

    Returns IGameObject

  • get profiles(): any
  • The input source profiles

    Returns any

  • get ray(): Ray
  • The controller ray in worldspace

    Returns Ray

  • get rayPosition(): any
  • Ray position in rig space

    Returns any

  • get rayQuaternion(): any
  • Ray rotation in rig space

    Returns any

  • get rayWorldPosition(): any
  • Controller ray position in worldspace (this value is calculated once per frame by default - call updateRayWorldPosition to force an update)

    Returns any

  • get rayWorldQuaternion(): any
  • Controller ray rotation in wordspace (this value is calculated once per frame by default - call updateRayWorldQuaternion to force an update)

    Returns any

  • get side(): any
  • If the controller if held in the left or right hand (or if it's a left or right hand)

    Returns any

  • get targetRayMode(): any
  • shorthand for inputSource.targetRayMode

    Returns any

  • get targetRaySpace(): any
  • shorthand for inputSource.targetRaySpace

    Returns any

Methods

  • Get a gesture state

    Parameters

    • key: "pinch"

    Returns NeedleGamepadButton

  • Get the hand joint pose from the current XRFrame. Results are cached for a frame to avoid calling getJointPose multiple times

    Parameters

    Returns any

  • Perform a hit test against the XR planes or meshes. shorthand for xr.getHitTest(controller)

    Returns NeedleXRHitTestResult

    the hit test result (with position and rotation in worldspace) or null if no hit was found

  • returns the URL of the default controller model

    Returns Promise<string>

  • Called when the input source disconnects

    Returns void

  • Returns void

  • Parameters

    Returns void

  • Recalculates the ray world position

    Returns void

  • Recalculates the ray world quaternion

    Returns void

Generated using TypeDoc