Skip to main content

Class: PointerLockControls

controls/pointerLock.PointerLockControls

Hierarchy

Constructors

constructor

โ€ข new PointerLockControls(element, camera, object?, sensitivity?)

Creates a PointerLockControls instance and sets up it's event handlers.

Parameters

NameTypeDefault valueDescription
elementHTMLElementundefinedThe element to use when handling control events
cameraCameraundefinedThe camera to control
object?Object2DundefinedAn optional object to follow the camera's yaw
sensitivitynumber0.1Movement sensitivity

Overrides

Controls.constructor

Defined in

src/controls/pointerLock.ts:17

Properties

camera

โ€ข camera: Camera

Inherited from

Controls.camera

Defined in

src/controls/controls.ts:14


element

โ€ข element: HTMLElement

Inherited from

Controls.element

Defined in

src/controls/controls.ts:8


isLocked

โ€ข isLocked: boolean = false

Defined in

src/controls/pointerLock.ts:7


movementX

โ€ข movementX: number = 0

Inherited from

Controls.movementX

Defined in

src/controls/controls.ts:10


movementY

โ€ข movementY: number = 0

Inherited from

Controls.movementY

Defined in

src/controls/controls.ts:11


object

โ€ข object: Object2D

Inherited from

Controls.object

Defined in

src/controls/controls.ts:13


sensitivity

โ€ข sensitivity: number

Inherited from

Controls.sensitivity

Defined in

src/controls/controls.ts:9

Methods

clickHandler

โ–ธ Private clickHandler(): void

Requests pointer lock if the control's are not already locked.

Returns

void

Defined in

src/controls/pointerLock.ts:28


dispose

โ–ธ dispose(): void

Removes all events used for the controls and deals with any extra cleanup needed.

Returns

void

Overrides

Controls.dispose

Defined in

src/controls/pointerLock.ts:65


mouseMoveHandler

โ–ธ Private mouseMoveHandler(e): void

Syncs this.movementX and this.movementY with the event's movement properties.

Parameters

NameTypeDescription
eMouseEventThe mouse event

Returns

void

Defined in

src/controls/pointerLock.ts:49


pointerLockChangeHandler

โ–ธ Private pointerLockChangeHandler(): void

Resets movementX and movementY if the controls has been unlocked.

Returns

void

Defined in

src/controls/pointerLock.ts:35


update

โ–ธ update(): void

Calculates the new camera direction from movementX and movementY.

Called every tick.

Returns

void

Overrides

Controls.update

Defined in

src/controls/pointerLock.ts:61