A DefaultCameraController is an extension of Controller that provides a simple way to move a Camera Urbject with mouse and keyboard controls.
| DefaultCameraController( ): DefaultCameraController | Initializes a fully working Controller with default attribute values. | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DefaultCameraController( { minSpeed?: number, maxSpeed?: number, accelerationTime?: number, accelerationType?: number, controlFace?: HTMLElement | Window } ): DefaultCameraController |
Initializes with the given attribute values. Default values are:
|
| accelerationTime: number | The time in seconds that is will take for the Camera to reach its max speed. |
|---|---|
| accelerationType: number | The type of Interpolation that the speed of the Camera will use to reach its max speed. |
| controlFace: HTMLElement | Window | The HTML element that will be used to listen for user inputs. |
| maxSpeed: number | The maximum speed in units per second that the Camera will accelerate to. |
| minSpeed: number | The minimum speed in units per second that the Camera starts moving at. |
| b: boolean | Whether the 'back' key is currently being pressed. |
|---|---|
| d: boolean | Whether the 'down' key is currently being pressed. |
| dFov: number | The change in FOV based on mouse wheel inputs since the last move() call. |
| f: boolean | Whether the 'forward' key is currently being pressed. |
| l: boolean | Whether the 'left' key is currently being pressed. |
| lastMove: number | Timestamp in milliseconds to keep track of the time since the last move() call. |
| mousePressed: boolean | Whether a mouse button is currently being pressed. |
| r: boolean | Whether the 'right' key is currently being pressed. |
| speed: number | The current speed of the Camera. |
| startMove: number | Timestamp in milliseconds to keep track of the start of a Controller move. |
| u: boolean | Whether the 'up' key is currently being pressed. |
| x: number | The horizontal difference in screen position of the mouse since the last move() call. |
| y: number | The vertical difference in screen position of the mouse since the last move() call. |
| keyDown(e: KeyboardEvent): void | Registers keyDown events. | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| keyUp(e: KeyboardEvent): void | Registers keyUp events. | ||||||||||||
| mouseDown(e: MouseEvent): void | Registers mouseDown events. | ||||||||||||
| mouseMove(e: MouseEvent): void | Registers mouseMove events. | ||||||||||||
| mouseUp(e: MouseEvent): void | Registers mouseUp events. | ||||||||||||
| move(target: Camera): void |
Moves the Camera Urbject with the Controller based on the user inputs since the last time the move function was called.
Moving the mouse while a mouse button is pressed will rotate the camera and pressing the following keys will move the camera:
|
||||||||||||
| mouseWheel(e: WheelEvent): void | Registers mouse wheel events. |
| getSpeed(t: number): number | Returns the interpolation between the minimum speed and maximum speed based off of the time in milliseconds given. |
|---|
Copyright © 2020 Trevor Richard