UNPKG

spatial-controls

Version:

Configurable 3D movement controls.

55 lines (54 loc) 1.64 kB
/** * A scalar damper that retains velocity. * * Based on Game Programming Gems 4 Chapter 1.10. * * @group Math */ export declare class ScalarDamper { /** * The maximum speed. */ private maxSpeed; /** * The current velocity. */ private velocity; /** * Constructs a new scalar damper. * * @param maxSpeed - The maximum speed at which the value can change. */ constructor(maxSpeed?: number); /** * Resets the velocity. */ resetVelocity(): void; /** * Smooth interpolation with exponential velocity gain/decay. * * @param a - The start value. * @param b - The target value. * @param lambda - A smoothing factor. * @param omega - See {@link ScalarDamper.calculateOmega}. * @param exp - See {@link ScalarDamper.calculateExp}. * @param dt - The delta time in seconds. * @return The interpolated value. */ interpolate(a: number, b: number, lambda: number, omega: number, exp: number, dt: number): number; /** * Calculates the Omega coefficient which can be reused for interpolations during the same frame. * * @param lambda - A smoothing factor. * @return Omega. */ static calculateOmega(lambda: number): number; /** * Calculates the exponentional factor which can be reused for interpolations during the same frame. * * @param omega - See {@link ScalarDamper.calculateOmega}. * @param dt - The delta time in seconds. * @return The exponentional interpolation factor. */ static calculateExp(omega: number, dt: number): number; }