Class: TouchControls
controls/touchControls.TouchControls
Hierarchy
โณ
TouchControls
Constructors
constructor
โข new TouchControls(element
, camera
, object?
, sensitivity?
)
Creates a TouchControls instance and sets up it's event handlers.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
element | HTMLElement | undefined | The element to use when handling control events |
camera | Camera | undefined | The camera to control |
object? | Object2D | undefined | An optional object to follow the camera's yaw |
sensitivity | number | 0.7 | Movement sensitivity |
Overrides
Defined in
src/controls/touchControls.ts:16
Properties
anchor
โข anchor: Touch
Defined in
src/controls/touchControls.ts:6
camera
โข camera: Camera
Inherited from
Defined in
src/controls/controls.ts:14
element
โข element: HTMLElement
Inherited from
Defined in
src/controls/controls.ts:8
movementX
โข movementX: number
= 0
Inherited from
Defined in
src/controls/controls.ts:10
movementY
โข movementY: number
= 0
Inherited from
Defined in
src/controls/controls.ts:11
object
โข object: Object2D
Inherited from
Defined in
src/controls/controls.ts:13
sensitivity
โข sensitivity: number
Inherited from
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
Defined in
src/controls/touchControls.ts:92
findTouchTargetingElement
โธ Private
findTouchTargetingElement(touches
): Touch
Finds the first touch targeting this.element
.
Parameters
Name | Type | Description |
---|---|---|
touches | TouchList | The 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
Name | Type | Description |
---|---|---|
e | TouchEvent | The 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
Name | Type | Description |
---|---|---|
e | TouchEvent | The 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
Name | Type | Description |
---|---|---|
e | TouchEvent | The 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
Defined in
src/controls/touchControls.ts:88