Skip to main content

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

NameTypeDescription
cameraCameraThe camera to control
canvasHTMLCanvasElementThe 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

NameTypeDescription
eKeyboardEventThe 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

NameTypeDescription
eMouseEventThe 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

NameTypeDescription
eMouseEventThe 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

NameTypeDescription
eMouseEventThe mouse event

Returns

void

Defined in

src/dropins/camera/editorControls.ts:63


onWheel

โ–ธ Private onWheel(e): void

Zooms/unzooms the camera.

Parameters

NameTypeDescription
eWheelEventThe 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

NameTypeDescription
canvasHTMLCanvasElementThe {@link HTMLCanvasElement} to attach event listeners to

Returns

void

Defined in

src/dropins/camera/editorControls.ts:121