Class: InputSystem
Processing input devices, such as mouse, keyboard, and touch. If the current event does not occur within the View3D, it will not be dispatched
Hierarchy
↳
InputSystem
Constructors
Properties
- canvasX
- canvasY
- isMouseDown
- isRightMouseDown
- canvas
- mouseX
- mouseY
- wheelDelta
- mouseOffsetX
- mouseOffsetY
- mouseLastX
- mouseLastY
- mouseLock
Methods
- dispatchEvent
- destroy
- addEventListener
- removeEventListener
- removeEventListenerAt
- removeAllEventListener
- containEventListener
- hasEventListener
- initCanvas
- useMouseLock
- releaseMouseLock
- onMouseLockMove
- GetSlideDirection
Constructors
constructor
• new InputSystem(): InputSystem
Returns
Inherited from
Properties
canvasX
• canvasX: number
= 0
coord x of canvas
Defined in
canvasY
• canvasY: number
= 0
coord y of canvas
Defined in
isMouseDown
• isMouseDown: boolean
= false
whether the mouse is down now
Defined in
isRightMouseDown
• isRightMouseDown: boolean
= false
whether the mouse right key is down now
Defined in
canvas
• canvas: HTMLCanvasElement
reference of canvas
Defined in
mouseX
• mouseX: number
= 0
current mouse coordinate x of Canvas
Defined in
mouseY
• mouseY: number
= 0
current mouse coordinate y of Canvas
Defined in
wheelDelta
• wheelDelta: number
= 0
the delta value when mouse wheeled
Defined in
mouseOffsetX
• mouseOffsetX: number
= 0
the delta value of mouse x
Defined in
mouseOffsetY
• mouseOffsetY: number
= 0
the delta value of mouse y
Defined in
mouseLastX
• mouseLastX: number
= 0
the history value of mouse x
Defined in
mouseLastY
• mouseLastY: number
= 0
the history value of mouse y
Defined in
mouseLock
• mouseLock: boolean
= false
Defined in
Methods
dispatchEvent
▸ dispatchEvent(event
): void
Dispatch an event to all registered objects with a specific type of listener.
Parameters
Name | Type |
---|---|
event | CEvent |
Returns
void
Inherited from
CEventDispatcher.dispatchEvent
Defined in
src/event/CEventDispatcher.ts:24
destroy
▸ destroy(): void
release all registered event.
Returns
void
Inherited from
Defined in
src/event/CEventDispatcher.ts:55
addEventListener
▸ addEventListener(type
, callback
, thisObject
, param?
, priority?
): number
register an event listener to event distancher.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
type | string | number | undefined | {string} event type. |
callback | Function | undefined | {Function} The callback function that handles events. This function must accept an Event3D object as its unique parameter and cannot return any result. for example: function(evt:Event3D):void. |
thisObject | any | undefined | {any} Current registration object, it'll call callback function. |
param | any | null | {any} the data binded to registered event, the default value is null. |
priority | number | 0 | {number} The priority of callback function execution, with a larger set value having priority to call |
Returns
number
Returns register event id
Inherited from
CEventDispatcher.addEventListener
Defined in
src/event/CEventDispatcher.ts:79
removeEventListener
▸ removeEventListener(type
, callback
, thisObject
): void
Remove Event Listening
Parameters
Name | Type | Description |
---|---|---|
type | string | number | {string} event type |
callback | Function | {Function} callback function of event register |
thisObject | any | {any} The current registered object. |
Returns
void
Inherited from
CEventDispatcher.removeEventListener
Defined in
src/event/CEventDispatcher.ts:113
removeEventListenerAt
▸ removeEventListenerAt(id
): boolean
Remove an event Listening with id
Parameters
Name | Type |
---|---|
id | number |
Returns
boolean
Inherited from
CEventDispatcher.removeEventListenerAt
Defined in
src/event/CEventDispatcher.ts:133
removeAllEventListener
▸ removeAllEventListener(eventType?
): void
Specify a event type to remove all related event listeners eventType event type, set null to remove all event listeners
Parameters
Name | Type | Default value |
---|---|---|
eventType | string | number | null |
Returns
void
Inherited from
CEventDispatcher.removeAllEventListener
Defined in
src/event/CEventDispatcher.ts:153
containEventListener
▸ containEventListener(type
): boolean
whether the target presence of a listener with event type.
Parameters
Name | Type | Description |
---|---|---|
type | string | {string} event type. |
Returns
boolean
Returns a boolean.
Inherited from
CEventDispatcher.containEventListener
Defined in
src/event/CEventDispatcher.ts:185
hasEventListener
▸ hasEventListener(type
, callback?
, thisObject?
): boolean
whether the target presence of a listener with event type. it associate more registration parameters.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
type | string | number | undefined | {string} event name. |
callback | Function | null | {Function} callback function of event register. |
thisObject | any | null | {any} The registered object. |
Returns
boolean
Returns a boolean.
Inherited from
CEventDispatcher.hasEventListener
Defined in
src/event/CEventDispatcher.ts:198
initCanvas
▸ initCanvas(canvas
): void
init the input system
Parameters
Name | Type | Description |
---|---|---|
canvas | HTMLCanvasElement | the reference of canvas |
Returns
void
Defined in
useMouseLock
▸ useMouseLock(): void
Returns
void
Defined in
releaseMouseLock
▸ releaseMouseLock(): void
Returns
void
Defined in
onMouseLockMove
▸ onMouseLockMove(e
): void
Parameters
Name | Type |
---|---|
e | MouseEvent |
Returns
void
Defined in
GetSlideDirection
▸ GetSlideDirection(startX
, startY
, endX
, endY
): number
Parameters
Name | Type | Description |
---|---|---|
startX | number | {Number} |
startY | number | {Number} |
endX | number | {Number} |
endY | number | {Number} |
Returns
number
result {number} 1: up, 2: down, 3: left, 4: right, 0: not move