DefaultCameraController

Home

A DefaultCameraController is an extension of Controller that provides a simple way to move a Camera Urbject with mouse and keyboard controls.

See also: Controller, Camera

Constructors

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:

minSpeed 0.5 The minimum speed in units per second that the Camera starts moving at.
maxSpeed 2 The maximum speed in units per second that the Camera will accelerate to.
accelerationTime 1.0 The time in seconds that is will take for the Camera to reach its max speed.
accelerationType Interpolate.EASE_OUT The type of Interpolation that the speed of the Camera will use to reach its max speed. See also: Interpolate
controlFace window The HTML element that will be used to listen for user inputs.

Variables

Public Variables

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. See also: Interpolate
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.

Private Variables

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. See also: Camera
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. See also: 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.

Functions

Public Functions

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:

W Forward
A Left
S Backwards
D Right
E Up
Q Down
mouseWheel(e: WheelEvent): void Registers mouse wheel events.

Private Functions

getSpeed(t: number): number Returns the interpolation between the minimum speed and maximum speed based off of the time in milliseconds given.

Home

Copyright © 2020 Trevor Richard