Class
Mouse
View sourceProvides the current mouse-pointer motion and wheel state as a world resource.
The pointer position is local to the input target. Movement and wheel values describe the mouse input received during the current update.
If there is no mouse input during an update, the pointer position stays
unchanged and the movement and wheel values are zero. Use
MouseButtons for mouse-button state.
Examples
// Read the current mouse state:
function readMouse(world) {
const mouse = world.getResource(Mouse)
if (mouse.moved()) {
console.log(mouse.position.x, mouse.position.y, mouse.delta.x, mouse.delta.y)
}
}Constructor
Properties
lastPosition: Vector2
View sourcePointer position from the previous update.
This can be used with Mouse#position to compare the pointer’s
position across updates.
Default: ...
position: Vector2
View sourceCurrent pointer position in the input target’s local coordinates.
It remains unchanged when the pointer does not move.
Default: ...
delta: Vector2
View sourceMouse movement during the current update.
It is Vector2.Zero when the mouse does not move.
Default: ...
wheelDelta: Vector3
View sourceMouse-wheel movement during the current update.
The value is Vector3.Zero when the wheel does not move and includes
horizontal, vertical, and depth-axis scroll movement.
Default: ...
Methods
moved(): boolean
View sourceReports whether the current update contains non-zero pointer movement.
This is exactly !this.delta.equals(Vector2.Zero), so either non-zero
component makes the result true; equal zero components make it false.
