new ViewportControls(viewport)
Viewport controls are used to allow the user to control the viewport.
The user controls the viewport using pointer input (e.g. mouse, touchscreen)
Parameters:
Name | Type | Description |
---|---|---|
viewport |
Viewport |
- Source:
Members
(static) RECENTER_CANVAS :number
Recenter the viewport automatically to the canvas.
This will ensure that rotation and scaling will not cause the viewport to move around.
Type:
- number
- Source:
(static) RECENTER_NONE :number
Viewport is not automatically recentered.
The center point can be set manually by the developer.
Type:
- number
- Source:
(static) RECENTER_POINTER :number
Viewport should automatically cente ron the pointer position.
The viewport will simulataniously move to the pointer position while scalling.
For some application its easier to focus the target if the viewport moves to the pointer location while scalling.
Type:
- number
- Source:
allowRotation :boolean
If true allows the viewport to be rotated.
Rotation is performed by holding the RIGHT and LEFT pointer buttons and rotating around the initial point.
Type:
- boolean
- Source:
allowScale :boolean
Is set to true allow the viewport to be scalled.
Scaling is performed using the pointer scroll.
Type:
- boolean
- Source:
dragButton :number
Button used to drag and viewport around.
On touch enabled devices the touch event is represented as a LEFT button.
Type:
- number
- Source:
recenterViewport :number
Flag to indicate if the viewport should automatically be recentered.
This will cause the viewport center property to be automatically set based on an heuristic defined by the user.
Type:
- number
- Source:
rotateButton :number
Button used to rotate the viewport.
Type:
- number
- Source:
rotationInitial :number
Initial rotation of the viewport.
Is set to the current rotation of the viewport when the rotation starts.
Type:
- number
- Source:
rotationPoint :Vector2|null
Value of the initial point of rotation if the viewport is being rotated.
Is the value of the pointer position when the rotation starts.
Is set to null when the viewport is not being rotated.
Type:
- Vector2 | null
- Source:
viewport :Viewport
Viewport being controlled by this object.
Type:
- Source:
Methods
update(pointer)
Update the viewport controls using the pointer object.
Should be called every frame before rendering.
Parameters:
Name | Type | Description |
---|---|---|
pointer |
Pointer | Pointer used to control the viewport. |
- Source: