/**
 * A scalar damper that retains velocity.
 *
 * Based on Game Programming Gems 4 Chapter 1.10.
 */ export class ScalarDamper { /**
     * The maximum speed.
     */ private maxSpeed : number ; /**
     * The current velocity.
     */ private velocity : number ; param maxSpeed constructor ( maxSpeed = Number . POSITIVE_INFINITY ) { this . maxSpeed = maxSpeed ; this . velocity = 0.0 ; } /**
     * Resets the velocity.
     */ resetVelocity ( ) { this . velocity = 0.0 ; } param a param b param lambda param omega - See  ScalarDamper . calculateOmega .
     *  param exp - See  ScalarDamper . calculateExp .
     *  param dt return interpolate ( a , b , lambda , omega , exp , dt ) { const maxChange = this . maxSpeed * Math . max ( lambda , 1e-4 ) ; const change = Math . min ( Math . max ( a - b , - maxChange ) , maxChange ) ; const c = a - change ; const velocity = this . velocity ; const t = ( velocity + omega * change ) * dt ; this . velocity = ( velocity - omega * t ) * exp ; let result = c + ( change + t ) * exp ; if ( Math . abs ( change ) < 1e-6 ) { result = b ; this . velocity = 0.0 ; } else if ( ( ( b - a ) > 0.0 ) === ( result > b ) ) { this . velocity = ( result - b ) / dt ; result = b ; } return result ; } param lambda return static calculateOmega ( lambda ) { return 2.0 / Math . max ( lambda , 1e-4 ) ; } param omega - See  ScalarDamper . calculateOmega .
     *  param dt return static calculateExp ( omega , dt ) { const x = omega * dt ; const x2 = x * x ; return 1.0 / ( 1.0 + x + 0.48 * x2 + 0.235 * x * x2 ) ; } }