Skip to content

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

Constructors

Properties

Methods

Constructors

constructor

new InputSystem(): InputSystem

Returns

InputSystem

Inherited from

CEventDispatcher.constructor

Properties

canvasX

canvasX: number = 0

coord x of canvas

Defined in

src/io/InputSystem.ts:22


canvasY

canvasY: number = 0

coord y of canvas

Defined in

src/io/InputSystem.ts:26


isMouseDown

isMouseDown: boolean = false

whether the mouse is down now

Defined in

src/io/InputSystem.ts:31


isRightMouseDown

isRightMouseDown: boolean = false

whether the mouse right key is down now

Defined in

src/io/InputSystem.ts:36


canvas

canvas: HTMLCanvasElement

reference of canvas

Defined in

src/io/InputSystem.ts:41


mouseX

mouseX: number = 0

current mouse coordinate x of Canvas

Defined in

src/io/InputSystem.ts:46


mouseY

mouseY: number = 0

current mouse coordinate y of Canvas

Defined in

src/io/InputSystem.ts:51


wheelDelta

wheelDelta: number = 0

the delta value when mouse wheeled

Defined in

src/io/InputSystem.ts:56


mouseOffsetX

mouseOffsetX: number = 0

the delta value of mouse x

Defined in

src/io/InputSystem.ts:61


mouseOffsetY

mouseOffsetY: number = 0

the delta value of mouse y

Defined in

src/io/InputSystem.ts:66


mouseLastX

mouseLastX: number = 0

the history value of mouse x

Defined in

src/io/InputSystem.ts:71


mouseLastY

mouseLastY: number = 0

the history value of mouse y

Defined in

src/io/InputSystem.ts:78


mouseLock

mouseLock: boolean = false

Defined in

src/io/InputSystem.ts:88

Methods

dispatchEvent

dispatchEvent(event): void

Dispatch an event to all registered objects with a specific type of listener.

Parameters

NameType
eventCEvent

Returns

void

Inherited from

CEventDispatcher.dispatchEvent

Defined in

src/event/CEventDispatcher.ts:24


destroy

destroy(): void

release all registered event.

Returns

void

Inherited from

CEventDispatcher.destroy

Defined in

src/event/CEventDispatcher.ts:55


addEventListener

addEventListener(type, callback, thisObject, param?, priority?): number

register an event listener to event distancher.

Parameters

NameTypeDefault valueDescription
typestring | numberundefined{string} event type.
callbackFunctionundefined{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.
thisObjectanyundefined{any} Current registration object, it'll call callback function.
paramanynull{any} the data binded to registered event, the default value is null.
prioritynumber0{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

NameTypeDescription
typestring | number{string} event type
callbackFunction{Function} callback function of event register
thisObjectany{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

NameType
idnumber

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

NameTypeDefault value
eventTypestring | numbernull

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

NameTypeDescription
typestring{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

NameTypeDefault valueDescription
typestring | numberundefined{string} event name.
callbackFunctionnull{Function} callback function of event register.
thisObjectanynull{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

NameTypeDescription
canvasHTMLCanvasElementthe reference of canvas

Returns

void

Defined in

src/io/InputSystem.ts:96


useMouseLock

useMouseLock(): void

Returns

void

Defined in

src/io/InputSystem.ts:177


releaseMouseLock

releaseMouseLock(): void

Returns

void

Defined in

src/io/InputSystem.ts:184


onMouseLockMove

onMouseLockMove(e): void

Parameters

NameType
eMouseEvent

Returns

void

Defined in

src/io/InputSystem.ts:190


GetSlideDirection

GetSlideDirection(startX, startY, endX, endY): number

Parameters

NameTypeDescription
startXnumber{Number}
startYnumber{Number}
endXnumber{Number}
endYnumber{Number}

Returns

number

result {number} 1: up, 2: down, 3: left, 4: right, 0: not move

Defined in

src/io/InputSystem.ts:493

Released under the MIT License