Mouse Class

Module: Input

Mouse instance for input in sync with the running 3D application.

The mouse object provided by scripts is automatically updated by the runtime handler.

Constructor

Mouse

()

Methods

buttonDoubleClicked

() Boolean

Check if Mouse button was double clicked.

Returns:

Boolean:

True if some mouse button was just double clicked

buttonJustPressed

(
  • button
)
Boolean

Check if a mouse button was just pressed.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button was just pressed

buttonJustReleased

(
  • button
)
Boolean

Check if a mouse button was just released.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button was just released

buttonPressed

(
  • button
)
Boolean

Check if mouse button is currently pressed.

Parameters:

  • button Number

    Button to check status of

Returns:

Boolean:

True if button is currently pressed

dispose

()

Dispose mouse events.

insideCanvas

() Boolean

Check if mouse is inside attached canvas (updated async).

Returns:

Boolean:

True if mouse is currently inside the canvas

setCanvas

(
  • canvas
)

Canvas to be used for coordinates calculation relative to that canvas.

Parameters:

  • canvas DOM

    Canvas to be attached to the Mouse instance

setLock

(
  • value
)

Set mouse lock state.

Parameters:

  • value Boolean

    If true pointer lock will be requested for the canvas attached to the Mouse instance

update

()

Update mouse buttons state, position, wheel and delta synchronously.

updateKey

(
  • button
  • action
)

Update a mouse button.

Automatically called by the runtime.

Parameters:

  • button Number
  • action Number

updatePosition

(
  • x
  • y
  • xDiff
  • yDiff
)

Update mouse position.

Automatically called by the runtime.

Parameters:

  • x Number
  • y Number
  • xDiff Number
  • yDiff Number

Properties

canvas

DOM

Canvas attached to this mouse instance used to calculate position and delta in canvas space coordinates

delta

Vector2

Mouse movement (coordinates in window space)

keys

Array

Array with mouse buttons status

position

Vector2

Mouse position inside of the window (coordinates in window space)

wheel

Number

Mouse scroll wheel movement

Attributes

LEFT

Number

LEFT mouse button

MIDDLE

Number

MIDDLE mouse button

RIGHT

Number

RIGHT mouse button