spatial-controls
Version:
Configurable 3D movement controls.
162 lines (161 loc) • 4.05 kB
TypeScript
import { EventDispatcher, Quaternion, Vector3 } from "three";
import { Updatable } from "../core/Updatable.js";
import { Settings } from "../settings/Settings.js";
import { ManagerEventMap } from "./ManagerEventMap.js";
/**
* A rotation manager.
*
* @group Managers
*/
export declare class RotationManager extends EventDispatcher<ManagerEventMap> implements Updatable {
/**
* Triggers when the position or quaternion is changed.
*
* @event
*/
static readonly EVENT_UPDATE = "update";
/**
* @see {@link position}
*/
private _position;
/**
* @see {@link quaternion}
*/
private _quaternion;
/**
* @see {@link target}
*/
private _target;
/**
* The settings.
*/
private readonly settings;
/**
* The current spherical coordinates.
*/
private readonly spherical0;
/**
* The spherical target coordinates.
*/
private readonly spherical1;
/**
* Scalar dampers.
*/
private readonly scalarDampers;
/**
* A timestamp.
*/
private timestamp;
/**
* A reusable update event.
*/
private readonly updateEvent;
/**
* Constructs a new rotation manager.
*
* @param position - The position.
* @param quaternion - The quaternion.
* @param target - The target.
* @param settings - The settings.
*/
constructor(position: Vector3, quaternion: Quaternion, target: Vector3, settings: Settings);
/**
* The position.
*/
get position(): Vector3;
set position(value: Vector3);
/**
* The quaternion.
*/
get quaternion(): Quaternion;
set quaternion(value: Quaternion);
/**
* The target.
*/
get target(): Vector3;
set target(value: Vector3);
/**
* The current radius.
*/
get radius(): number;
/**
* Resets the current velocity.
*/
resetVelocity(): void;
/**
* Restricts the spherical angles.
*
* @return This manager.
*/
private restrictAngles;
/**
* Restricts the spherical radius.
*
* @return This manager.
*/
private restrictRadius;
/**
* Restricts the spherical system.
*
* @return This manager.
*/
restrictSpherical(): this;
/**
* Updates the spherical coordinates based on the position and target.
*
* @return This manager.
*/
updateSpherical(): this;
/**
* Updates the position based on the spherical coordinates.
*
* @return This manager.
*/
updatePosition(): this;
/**
* Updates the quaternion.
*
* @return This manager.
*/
updateQuaternion(): this;
/**
* Adjusts the spherical system.
*
* @param theta - The angle to add to theta in radians.
* @param phi - The angle to add to phi in radians.
* @return This manager.
*/
adjustSpherical(theta: number, phi: number): this;
/**
* Zooms in or out. Only applies in third person mode.
*
* @param sign - The zoom sign. Possible values are [-1, 0, 1].
* @return This manager.
*/
zoom(sign: number): this;
/**
* Looks at the given point.
*
* @param point - The target point.
* @return This manager.
*/
lookAt(point: Vector3): this;
/**
* Returns the current view direction.
*
* @param view - A vector to store the direction in.
* @return The normalized view direction.
*/
getViewDirection(view: Vector3): Vector3;
/**
* Returns the projected view direction.
*
* The projected direction will be reached if there are no further rotation adjustments. If damping is disabled,
* the vector will be equal to the direction returned by {@link getViewDirection}.
*
* @param view - A vector to store the direction in.
* @return The normalized view direction.
*/
getProjectedViewDirection(view: Vector3): Vector3;
update(timestamp: number): void;
}