Skip to content

DampedAnimation

Overview

WARNING: PROTOTYPE, see https://github.com/phetsims/twixt/issues/3 before using! Not fully documented or stabilized. May be deleted.

Handles a single dimension of damped harmonic-oscillator motion (like a damped spring pulling towards the target).

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class DampedAnimation

import { DampedAnimation } from 'scenerystack/twixt';

Constructor

new DampedAnimation( providedOptions? : DampedAnimationOptions )

Instance Methods

step( dt : number )

Steps the animation forward in time.

Instance Properties

valueProperty : TProperty<number>

(readonly)

velocityProperty : TProperty<number>

(readonly)

timeElapsed

Type DampedAnimationOptions

import type { DampedAnimationOptions } from 'scenerystack/twixt';
  • valueProperty?: TProperty<number>
    The current value/position.
  • velocityProperty?: TProperty<number>
    The current derivative of the value
  • damping?: number
    Proportion of damping applied, relative to critical damping. Thus:
  • damping = 1: Critically damped (fastest approach towards the target without overshooting)
  • damping < 1: Underdamped (will overshoot the target with exponentially-decaying oscillation)
  • damping > 1: Overdamped (will approach with an exponential curve)
  • force?: number
    Coefficient that determines the amount of force "pushing" towards the target (will be proportional to the distance from the target).
  • targetValue?: number
    The target value that we are animating towards.

Source Code

See the source for DampedAnimation.ts in the twixt repository.