Class: Controller

Controller

Base class that handles user interaction via device events (mouse/touch events). Provides an abstract user interface to define interaction actions such as panning, pinching, tapping, etc... The actions are implemented by pre-defined callback functions:

  • panStart(e) intercepts the initial pan event (movement of the mouse after pressing a mouse button or moving a finger). The event is captured calling e.preventDefault().
  • panMove(e) receives and handles the pan event.
  • panEnd(e) intercepts the final pan event (the user releases the left mouse button or removes his finger from the screen).
  • pinchStart(e1, e2) intercepts the initial pinch event (a continuous gesture that tracks the positions between the first two fingers that touch the screen). The event is captured calling e1.preventDefault().
  • pinchMove(e1,e2) receives and handles the pinch event.
  • pinchEnd(e1,e2) intercepts the final pinch event (the user removes one of their two fingers from the screen).
  • mouseWheel(e) receives and handles the mouse wheel event (the user rotates the mouse wheel button).
  • fingerSingleTap(e) receives and handles the single-tap event (the user presses a mouse button quickly or touches the screen shortly with a finger).
  • fingerDoubleTap(e) receives and handles the double-tap event (the user quickly presses a mouse button twice or shortly touches the screen with a finger twice).

e.preventDefault() will capture the event and wont be propagated to other controllers.

This class only describes user interactions by implementing actions or callbacks. A Controller works in concert with a PointerManager object that emits events and links them to actions.


<abstract> new Controller( [options])

Creates a new Controller instance.

Parameters:
Name Type Argument Description
options Object <optional>

Configuration options

Properties
Name Type Argument Default Description
active boolean <optional>
true

Whether the controller is initially active

debug boolean <optional>
false

Enable debug logging

panDelay number <optional>
50

Inertial value for panning movements in milliseconds

zoomDelay number <optional>
200

Delay for smoothing zoom events in milliseconds

priority number <optional>
0

Controllers with higher priority are invoked first

activeModifiers Array.<number> <optional>
[0]

Array of modifier states that activate this controller

Source:
Example
// Create a pan-zoom controller and associate it with the viewer's pointer manager
const panzoom = new OpenLIME.ControllerPanZoom(viewer.camera, {
    priority: -1000,
    activeModifiers: [0, 1]
});
viewer.pointerManager.onEvent(panzoom);

Methods


<abstract> fingerDoubleTap(e)

Called for quick double mouse press or double finger touch.

Parameters:
Name Type Description
e Event

The double tap event

Source:

<abstract> fingerSingleTap(e)

Called for quick mouse press or short finger touch.

Parameters:
Name Type Description
e Event

The tap event

Source:

modifierState(e)

Gets the modifier state from an event.

Parameters:
Name Type Description
e Event

The event to check

Source:
Returns:

Modifier state bitmask where:

  • 0 = No modifiers
  • 1 = Ctrl key
  • 2 = Shift key
  • 4 = Alt key Multiple modifiers combine their values (e.g., Ctrl+Shift = 3)
Type
number

<abstract> mouseWheel(e)

Called when user rotates mouse wheel.

Parameters:
Name Type Description
e WheelEvent

The wheel event

Source:

<abstract> panEnd(e)

Called when panning ends (mouse up or finger lift).

Parameters:
Name Type Description
e Event

The pan end event

Source:

<abstract> panMove(e)

Called continuously during panning.

Parameters:
Name Type Description
e Event

The pan move event

Source:

<abstract> panStart(e)

Called when user starts panning (mouse down or finger touch). Call e.preventDefault() to capture the event.

Parameters:
Name Type Description
e Event

The pan start event

Source:

<abstract> pinchEnd(e1, e2)

Called when pinch ends (finger lift).

Parameters:
Name Type Description
e1 Event

First finger event

e2 Event

Second finger event

Source:

<abstract> pinchMove(e1, e2)

Called continuously during pinching.

Parameters:
Name Type Description
e1 Event

First finger event

e2 Event

Second finger event

Source:

<abstract> pinchStart(e1, e2)

Called when user starts a two-finger pinch. Call e1.preventDefault() to capture the event.

Parameters:
Name Type Description
e1 Event

First finger event

e2 Event

Second finger event

Source: