Class: Mouse

Mouse(pos, scene, isTouch, overrideGrid)

The Mouse class encapsulates the state of the mouse within the scene.

Constructor

new Mouse(pos, scene, isTouch, overrideGrid)

Create a Mouse object.

Parameters:
Name Type Default Description
pos geometry.point

The position of the mouse within the scene.

scene Scene

The scene in which the mouse operates.

isTouch boolean false

Indicates whether the mouse input comes from a touch screen.

overrideGrid number 0

Indicates how the grid is overridden (0: not overridden, 1: invert the on/off of the grid, 2: always off).

Source:

Methods

getClickExtent(isPoint) → {number}

Calculates the effective click extent based on whether the target is a point or a line, and adjusts for touchscreen input if applicable.

Parameters:
Name Type Description
isPoint boolean

Specifies whether the target is a point (true) or a line (false).

Source:
Returns:

The calculated click extent.

Type
number

getPosSnappedToDirection(basePoint, directions, snapContext) → {geometry.point}

Get the mouse position snapped to a set of suggested directions.

Parameters:
Name Type Description
basePoint geometry.point

The base point for the snapping.

directions Array

The directions to snap to, each a vector with x and y components.

snapContext Object

The object storing the internal state of the snapping process.

Source:
Returns:

The mouse position snapped to some direction.

Type
geometry.point

getPosSnappedToGrid() → {geometry.point}

Get the mouse position snapped to the grid if the grid is enabled.

Source:
Returns:

The mouse position snapped to the grid.

Type
geometry.point

isOnLine(line) → {boolean}

Determines if the mouse is currently over a given line.

Parameters:
Name Type Description
line geometry.line

The line to check against the mouse position.

Source:
Returns:

True if the mouse is on the given line, false otherwise.

Type
boolean

isOnPoint(point) → {boolean}

Determines if the mouse is currently over a given point.

Parameters:
Name Type Description
point geometry.point

The point to check against the mouse position.

Source:
Returns:

True if the mouse is on the given point, false otherwise.

Type
boolean

isOnSegment(segment) → {boolean}

Determines if the mouse is currently over a given line segment.

Parameters:
Name Type Description
segment geometry.line

The line segment to check against the mouse position.

Source:
Returns:

True if the mouse is on the given line segment, false otherwise.

Type
boolean

snapsOnPoint(point) → {boolean}

Determines if the snapped mouse is currently over a given point.

Parameters:
Name Type Description
point geometry.point

The point to check against the snapped mouse position.

Source:
Returns:

True if the snapped mouse is on the given point, false otherwise.

Type
boolean