FocalPointController

Home

A FocalPointController is an extension of Controller that provides a simple way to move a Camera Urbject around a fixed point with mouse events.

See also: Controller, Camera

Constructors

FocalPointController( ): FocalPointController Initializes a fully working Controller with default attribute values.
FocalPointController( { sensitivity?: number, friction?: number, zoomMultiplier?: number, focalPoint?: Vector, minDist?: number, maxDist?: number, controlFace?: HTMLElement | Window } ): FocalPointController Initializes with the given attribute values. Default values are:

sensitivity 1 The sensitivity multiplier of mouse movements for the controller.
friction 0.9 The amount of friction that slows down the Camera movement over time. Range: [0, 1]
zoomMultiplier 1 The zoom multiplier of mouse wheel movements for the controller.
focalPoint new Vector() The focal point in 3D space for the controller. The Camera will always be looking directly at this point. See also: Vector, Camera
minDist 1 The minimum distance in units that the camera can be from the focalPoint.
maxDist 20 The maximum distance in units that the camera can be from the focalPoint.
controlFace window The HTML element that will be used to listen for user inputs.

Variables

Public Variables

controlFace: HTMLElement | Window The HTML element that will be used to listen for user inputs.
focalPoint: Vector The focal point in 3D space for the controller. The Camera will always be looking directly at this point. See also: Vector, Camera
friction: number The amount of friction that slows down the Camera movement over time. Expected range: [0, 1]
maxDist: number The maximum distance in units that the camera can be from the focalPoint.
minDist: number The minimum distance in units that the camera can be from the focalPoint.
sensitivity: number The sensitivity multiplier of mouse movements for the controller.
zoomMultiplier: number The zoom multiplier of mouse wheel movements for the controller.

Private Variables

dist: number The current distance of the Camera from the focalPoint.
dMouse: Vector The relative mouse distance from its last position when move() was called. See also: Vector
mousePressed: boolean The state of a mouse button being pressed.
timer: Stats The Stats object used to find the time since the last move() call. See also: Stats
velocity: Vector The Current mouse "velocity" that is effecting the controller rotation. See also: Vector

Functions

Public Functions

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 mouse inputs recorded since the last move() call. Moving the mouse up will move the Camera down and below the focalPoint. Likewise, moving the mouse down will move the Camera up and above the focalPoint. Moving the mouse left will rotate the Camera to the right around the focalPoint and moving the mouse right will do the opposite.

This function should be called every animation frame for the best results.
wheel(e: WheelEvent): void Registers mouse wheel events.

Home

Copyright © 2020 Trevor Richard