Skip to main content

Class: TouchControls

controls/touchControls.TouchControls

Hierarchy

Constructors

constructor

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

Creates a TouchControls 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.7Movement sensitivity

Overrides

Controls.constructor

Defined in

src/controls/touchControls.ts:16

Properties

anchor

โ€ข anchor: Touch

Defined in

src/controls/touchControls.ts:6


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


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

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/touchControls.ts:92


findTouchTargetingElement

โ–ธ Private findTouchTargetingElement(touches): Touch

Finds the first touch targeting this.element.

Parameters

NameTypeDescription
touchesTouchListThe list of touches to choose from

Returns

Touch

The first touch targeting this.element or undefined

Defined in

src/controls/touchControls.ts:30


touchEndHandler

โ–ธ Private touchEndHandler(e): void

Removes the touch anchor.

Parameters

NameTypeDescription
eTouchEventThe touch event

Returns

void

Defined in

src/controls/touchControls.ts:77


touchMoveHandler

โ–ธ Private touchMoveHandler(e): void

Calculates the difference in position from the last anchor and the current touch point.

These values are then set in movementX and movementY.

Parameters

NameTypeDescription
eTouchEventThe touch event

Returns

void

Defined in

src/controls/touchControls.ts:58


touchStartHandler

โ–ธ Private touchStartHandler(e): void

Sets the anchor point to the first touch detected when anchor has not already been set.

Parameters

NameTypeDescription
eTouchEventThe touch event

Returns

void

Defined in

src/controls/touchControls.ts:47


update

โ–ธ update(): void

Calculates the new camera direction from movementX and movementY.

Called every tick.

Returns

void

Overrides

Controls.update

Defined in

src/controls/touchControls.ts:88