Skip to main content

Class: Input

Defined in: src/input/Input.ts:29

The XRInput class holds all the controllers and performs raycasts through the scene each frame.

Constructors

Constructor

new Input(): Input

Returns

Input

Properties

activeControllers

activeControllers: ActiveControllers

Defined in: src/input/Input.ts:43


controllerGrips

controllerGrips: Group<Object3DEventMap>[] = []

Defined in: src/input/Input.ts:32


controllers

controllers: Controller[] = []

Defined in: src/input/Input.ts:31


controllersEnabled

controllersEnabled: boolean = true

Defined in: src/input/Input.ts:39


gazeController

gazeController: GazeController

Defined in: src/input/Input.ts:37


hands

hands: XRHandSpace[] = []

Defined in: src/input/Input.ts:33


initialized

initialized: boolean = false

Defined in: src/input/Input.ts:35


intersections

intersections: never[] = []

Defined in: src/input/Input.ts:42


intersectionsForController

intersectionsForController: Map<Controller, Intersection<Object3D<Object3DEventMap>>[]>

Defined in: src/input/Input.ts:41


leftController?

optional leftController: Controller

Defined in: src/input/Input.ts:44


listeners

listeners: Map<any, any>

Defined in: src/input/Input.ts:40


mouseController

mouseController: MouseController

Defined in: src/input/Input.ts:38


options

options: Options

Defined in: src/input/Input.ts:30


pivotsEnabled

pivotsEnabled: boolean = false

Defined in: src/input/Input.ts:36


raycaster

raycaster: Raycaster

Defined in: src/input/Input.ts:34


rightController?

optional rightController: Controller

Defined in: src/input/Input.ts:45


scene

scene: Scene

Defined in: src/input/Input.ts:46

Methods

addObject()

addObject(obj): void

Defined in: src/input/Input.ts:150

Adds an object to both controllers by creating a new group and cloning it.

Parameters

obj

Object3D

The object to add to each controller.

Returns

void


addReticles()

addReticles(): void

Defined in: src/input/Input.ts:176

Adds reticles to the controllers and scene, with initial visibility set to false.

Returns

void


bindKeyDown()

bindKeyDown(event): void

Defined in: src/input/Input.ts:337

Parameters

event

(event) => void

Returns

void


bindKeyUp()

bindKeyUp(event): void

Defined in: src/input/Input.ts:341

Parameters

event

(event) => void

Returns

void


bindListener()

bindListener(listenerName, listener): void

Defined in: src/input/Input.ts:256

Binds a listener to both controllers.

Parameters

listenerName

keyof ControllerEventMap

Event name

listener

(event) => void

Function to call

Returns

void


bindSelect()

bindSelect(event): void

Defined in: src/input/Input.ts:312

Binds an event listener to handle 'select' events for both controllers.

Parameters

event

(event) => void

The event listener function.

Returns

void


bindSelectEnd()

bindSelectEnd(event): void

Defined in: src/input/Input.ts:304

Binds an event listener to handle 'selectend' events for both controllers.

Parameters

event

(event) => void

The event listener function.

Returns

void


bindSelectStart()

bindSelectStart(event): void

Defined in: src/input/Input.ts:296

Binds an event listener to handle 'selectstart' events for both controllers.

Parameters

event

(event) => void

The event listener function.

Returns

void


bindSqueeze()

bindSqueeze(event): void

Defined in: src/input/Input.ts:333

Parameters

event

(event) => void

Returns

void


bindSqueezeEnd()

bindSqueezeEnd(event): void

Defined in: src/input/Input.ts:329

Binds an event listener to handle 'squeezeend' events for both controllers.

Parameters

event

(event) => void

The event listener function.

Returns

void


bindSqueezeStart()

bindSqueezeStart(event): void

Defined in: src/input/Input.ts:321

Binds an event listener to handle 'squeezestart' events for both controllers.

Parameters

event

(event) => void

The event listener function.

Returns

void


defaultOnConnected()

defaultOnConnected(event): void

Defined in: src/input/Input.ts:219

Parameters

event

ControllerEvent

Returns

void


defaultOnDisconnected()

defaultOnDisconnected(event): void

Defined in: src/input/Input.ts:234

Parameters

event

ControllerEvent

Returns

void


defaultOnSelectEnd()

defaultOnSelectEnd(event): void

Defined in: src/input/Input.ts:204

Default action to handle the end of a selection, setting the selecting state to false.

Parameters

event

ControllerEvent

Returns

void


defaultOnSelectStart()

defaultOnSelectStart(event): void

Defined in: src/input/Input.ts:193

Default action to handle the start of a selection, setting the selecting state to true.

Parameters

event

ControllerEvent

Returns

void


defaultOnSqueezeEnd()

defaultOnSqueezeEnd(event): void

Defined in: src/input/Input.ts:214

Parameters

event

ControllerEvent

Returns

void


defaultOnSqueezeStart()

defaultOnSqueezeStart(event): void

Defined in: src/input/Input.ts:209

Parameters

event

ControllerEvent

Returns

void


disableControllers()

disableControllers(): void

Defined in: src/input/Input.ts:473

Returns

void


disableGazeController()

disableGazeController(): void

Defined in: src/input/Input.ts:468

Returns

void


dispatchEvent()

dispatchEvent(event): void

Defined in: src/input/Input.ts:283

Parameters

event

ControllerEvent

Returns

void


enableControllers()

enableControllers(): void

Defined in: src/input/Input.ts:484

Returns

void


enableGazeController()

enableGazeController(): void

Defined in: src/input/Input.ts:463

Returns

void


enablePivots()

enablePivots(): void

Defined in: src/input/Input.ts:163

Creates a pivot point for each hand, primarily used as a reference point.

Returns

void


get()

get(id): Object3D

Defined in: src/input/Input.ts:142

Retrieves the controller object by its ID.

Parameters

id

number

The ID of the controller.

Returns

Object3D

The controller with the specified ID.


init()

init(__namedParameters): void

Defined in: src/input/Input.ts:52

Initializes an instance with XR controllers, grips, hands, raycaster, and default options. Only called by Core.

Parameters

__namedParameters
options

Options

renderer

WebGLRenderer

scene

Scene

Returns

void


intersectObject()

intersectObject(obj): Intersection<Object3D<Object3DEventMap>>[]

Defined in: src/input/Input.ts:383

Finds intersections with an object from either controller.

Parameters

obj

Object3D

The object to intersect.

Returns

Intersection<Object3D<Object3DEventMap>>[]

Array of intersection points, if any.


intersectObjectByController()

intersectObjectByController(controller, obj): Intersection<Object3D<Object3DEventMap>>[]

Defined in: src/input/Input.ts:359

Finds intersections between a controller's ray and a specified object.

Parameters

controller

Object3D

The controller casting the ray.

obj

Object3D

The object to intersect.

Returns

Intersection<Object3D<Object3DEventMap>>[]

Array of intersection points, if any.


intersectObjectByEvent()

intersectObjectByEvent(event, obj): Intersection<Object3D<Object3DEventMap>>[]

Defined in: src/input/Input.ts:373

Finds intersections based on an event's target controller and a specified object.

Parameters

event

ControllerEvent

The event containing the controller reference.

obj

Object3D

The object to intersect.

Returns

Intersection<Object3D<Object3DEventMap>>[]

Array of intersection points, if any.


performRaycastOnScene()

performRaycastOnScene(controller): void

Defined in: src/input/Input.ts:489

Parameters

controller

Controller

Returns

void


unbindKeyDown()

unbindKeyDown(event): void

Defined in: src/input/Input.ts:345

Parameters

event

(event) => void

Returns

void


unbindKeyUp()

unbindKeyUp(event): void

Defined in: src/input/Input.ts:349

Parameters

event

(event) => void

Returns

void


unbindListener()

unbindListener(listenerName, listener): void

Defined in: src/input/Input.ts:268

Parameters

listenerName

keyof ControllerEventMap

listener

(event) => void

Returns

void


update()

update(): void

Defined in: src/input/Input.ts:395

Returns

void


updateController()

updateController(controller): void

Defined in: src/input/Input.ts:403

Parameters

controller

Controller

Returns

void


updateReticleFromIntersections()

updateReticleFromIntersections(controller): void

Defined in: src/input/Input.ts:428

Parameters

controller

Controller

Returns

void