Module: mouse

Pointer lock and mouse actions add-on. Provides support for mouse pointer lock and low-level movement. For more generic cases use sensor-based API.

Summary

Methods

Type Definitions

Detailed Description

Methods

check_pointerlock(elem) → {Boolean}

Check the pointer lock.
Parameters:
Name Type Description
elem HTMLElement Element
Returns:
Check result
Type
Boolean
Source:

disable_mouse_hover_outline()

Disable objects outlining by mouse hover.
Source:

enable_mouse_hover_outline()

Enable objects outlining by mouse hover.
Source:

exit_mouse_drag(elem)

Exit drag mode.
Parameters:
Name Type Description
elem HTMLElement Element
Source:

exit_pointerlock()

Exit the pointer lock mode.
Source:

get_coords_x(event, target_touchesopt) → {Number}

Get mouse/touch X coordinate.
Parameters:
Name Type Attributes Default Description
event MouseEvent | TouchEvent Mouse/touch event
target_touches Boolean <optional>
false Use only those touches that were started on the event target element (the targetTouches property).
Returns:
Client area horizontal coordinate or -1 if not defined
Type
Number
Source:

get_coords_y(event, target_touchesopt) → {Number}

Get mouse/touch Y coordinate.
Parameters:
Name Type Attributes Default Description
event MouseEvent | TouchEvent Mouse/touch event
target_touches Boolean <optional>
false Use only those touches that were started on the event target element (the targetTouches property).
Returns:
Client area vertical coordinate or -1 if not defined
Type
Number
Source:

get_plock_smooth_factor() → {Number}

Get smooth factor for camera rotation while in pointerlock mode.
Returns:
Smooth factor
Type
Number
Source:

request_mouse_drag(elem, use_mouse_control_cbopt, rotation_cbopt)

Request drag mode.
Parameters:
Name Type Attributes Description
elem HTMLElement Element
use_mouse_control_cb UseMouseControlCallback <optional>
Callback to check the mouse control
rotation_cb RotationCallback <optional>
Callback for camera rotation. If not specified, the default one will be used.
Source:

request_pointerlock(elem, enabled_cbopt, disabled_cbopt, mouse_move_cbopt, use_mouse_control_cbopt, rotation_cbopt)

Request pointer lock mode. Security issues: execute by user event.
Parameters:
Name Type Attributes Description
elem HTMLElement Element
enabled_cb PointerlockEnabledCallback <optional>
Enabled callback
disabled_cb PointerlockDisabledCallback <optional>
Disabled callback
mouse_move_cb PointerlockMouseMoveCallback <optional>
Mouse movement event callback
use_mouse_control_cb UseMouseControlCallback <optional>
Callback to check the camera/character control
rotation_cb RotationCallback <optional>
Callback for camera rotation. If not specified, the default one will be used.
Source:

set_plock_smooth_factor(value)

Set smooth factor for camera rotation while in pointerlock mode.
Parameters:
Name Type Description
value Number New smooth factor
Source:

Type Definitions

PointerlockDisabledCallback()

Callback which will be executed when pointer lock is disabled.
Source:

PointerlockEnabledCallback()

Callback which will be executed when pointer lock is enable.
Source:

PointerlockMouseMoveCallback(e)

Mouse movement event callback
Parameters:
Name Type Description
e MouseEvent mousemove event
Source:

RotationCallback(x, y)

Callback for camera/characters rotation
Parameters:
Name Type Description
x rot_x rotation around X-axis
y rot_y rotation around Y-axis
Source:

UseMouseControlCallback() → {Boolean}

Callback which allows user to specify whether the camera/character movement is controlled by mouse module or not.
Returns:
False to disable mouse control of active camera/character
Type
Boolean
Source: