spatial-controls
Version:
Configurable 3D movement controls.
96 lines (95 loc) • 2.33 kB
TypeScript
import { EventDispatcher, Quaternion, Vector3 } from "three";
import { Updatable } from "../core/Updatable.js";
import { Settings } from "../settings/Settings.js";
import { MovementState } from "./MovementState.js";
import { ManagerEventMap } from "./ManagerEventMap.js";
/**
* A translation manager.
*
* @group Managers
*/
export declare class TranslationManager 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 movement state.
*/
readonly movementState: MovementState;
/**
* The current velocity.
*/
private readonly velocity0;
/**
* The target velocity.
*/
private readonly velocity1;
/**
* Scalar dampers.
*/
private readonly scalarDampers;
/**
* A timestamp.
*/
private timestamp;
/**
* A reusable update event.
*/
private readonly updateEvent;
/**
* Constructs a new translation 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);
/**
* Resets the current velocity.
*/
resetVelocity(): void;
/**
* Changes the position based on the current velocity and elapsed time.
*
* @param position - The position to translate.
* @param velocity - The velocity.
* @param elapsed - The time since the last frame in seconds.
*/
private translate;
update(timestamp: number): void;
}