Class: EditorCameraControls
dropins/camera/editorControls.EditorCameraControls
Allows the camera to be panned, zoomed and rotated.
By default the middle mouse button is used for panning, scroll for zoom and arrow keys for rotation.
Constructors
constructor
โข new EditorCameraControls(camera
, canvas
)
Create an EditorCameraControls instance.
Parameters
Name | Type | Description |
---|---|---|
camera | Camera | The camera to control |
canvas | HTMLCanvasElement | The canvas to attach event listeners to |
Defined in
src/dropins/camera/editorControls.ts:36
Properties
camera
โข camera: Camera
Defined in
src/dropins/camera/editorControls.ts:12
canvas
โข Private
canvas: HTMLCanvasElement
Defined in
src/dropins/camera/editorControls.ts:13
disabled
โข disabled: boolean
= false
Defined in
src/dropins/camera/editorControls.ts:28
isPanPressed
โข Private
isPanPressed: boolean
= false
Defined in
src/dropins/camera/editorControls.ts:17
last
โข Private
last: vec2
Defined in
src/dropins/camera/editorControls.ts:18
negRotateKey
โข negRotateKey: string
= "ArrowLeft"
Defined in
src/dropins/camera/editorControls.ts:26
panButton
โข panButton: Mouse
= Mouse.MIDDLE
Defined in
src/dropins/camera/editorControls.ts:16
posRotateKey
โข posRotateKey: string
= "ArrowRight"
Defined in
src/dropins/camera/editorControls.ts:25
rotateSpeed
โข rotateSpeed: number
= 1
Defined in
src/dropins/camera/editorControls.ts:24
zoomSensitivity
โข zoomSensitivity: number
= 0.005
Defined in
src/dropins/camera/editorControls.ts:21
Methods
getCanvas
โธ getCanvas(): HTMLCanvasElement
Get the canvas that event listeners are on.
Returns
HTMLCanvasElement
The canvas that event listeners are attached to
Defined in
src/dropins/camera/editorControls.ts:149
onKeydown
โธ Private
onKeydown(e
): void
Rotates the camera on key down.
Parameters
Name | Type | Description |
---|---|---|
e | KeyboardEvent | The keyboard event |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:106
onMousedown
โธ Private
onMousedown(e
): void
Enables panning when the mouse button is pressed.
Parameters
Name | Type | Description |
---|---|---|
e | MouseEvent | The mouse event |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:46
onMousemove
โธ Private
onMousemove(e
): void
Moves the camera by the difference between the current and last mouse position.
Parameters
Name | Type | Description |
---|---|---|
e | MouseEvent | The mouse event |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:74
onMouseup
โธ Private
onMouseup(e
): void
Disables panning when the mouse button is released.
Parameters
Name | Type | Description |
---|---|---|
e | MouseEvent | The mouse event |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:63
onWheel
โธ Private
onWheel(e
): void
Zooms/unzooms the camera.
Parameters
Name | Type | Description |
---|---|---|
e | WheelEvent | The wheel event |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:95
setCanvas
โธ setCanvas(canvas
): void
Set the canvas to be attach event listeners to.
Parameters
Name | Type | Description |
---|---|---|
canvas | HTMLCanvasElement | The {@link HTMLCanvasElement} to attach event listeners to |
Returns
void
Defined in
src/dropins/camera/editorControls.ts:121