AnimationTarget¶
Overview¶
Controls a specific animated value for an Animation.
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class AnimationTarget¶
Constructor¶
new AnimationTarget( providedConfig : AnimationTargetOptions<T, Obj> )¶
Instance Methods¶
computeStartEnd()¶
Computes the starting and ending values of this target.
Generally called when the animation is just about to begin, so it can look up the current value if necessary.
update( ratio : number )¶
Updates the value of this target.
@param ratio - How far along (from 0 to 1) in the animation.
hasPreferredDuration() : boolean¶
Whether this target can define the duration of an animation.
getPreferredDuration() : number | null¶
Returns the preferred duration of this target (or null if not defined).
Static Methods¶
DEFAULT_BLEND( a : number, b : number, ratio : number ) : number¶
Default blending function for the blend
function.
DEFAULT_BLEND( a : Color, b : Color, ratio : number ) : Color¶
DEFAULT_BLEND( a : Vector2, b : Vector2, ratio : number ) : Vector2¶
DEFAULT_BLEND( a : Vector3, b : Vector3, ratio : number ) : Vector3¶
DEFAULT_BLEND( a : Vector4, b : Vector4, ratio : number ) : Vector4¶
DEFAULT_BLEND( a : T, b : T, ratio : number ) : T¶
DEFAULT_DISTANCE( a : number, b : number ) : number¶
Default distance function for the distance
option (used for the speed
option)
DEFAULT_DISTANCE( a : Vector2, b : Vector2 ) : number¶
DEFAULT_DISTANCE( a : Vector3, b : Vector3 ) : number¶
DEFAULT_DISTANCE( a : Vector4, b : Vector4 ) : number¶
DEFAULT_DISTANCE( a : T, b : T ) : number¶
DEFAULT_ADD( a : number, b : number ) : number¶
Default addition function for the add
option (used for the delta
option)
DEFAULT_ADD( a : Vector2, b : Vector2 ) : Vector2¶
DEFAULT_ADD( a : Vector3, b : Vector3 ) : Vector3¶
DEFAULT_ADD( a : Vector4, b : Vector4 ) : Vector4¶
DEFAULT_ADD( a : T, b : T ) : T¶
Type AnimationTargetOptions¶
- setValue?: ( ( value: T ) => void ) | null
If provided, it should be a function that acts as "setting" the value of the animation. NOTE: do not provide this and property/object. - getValue?: ( () => T ) | null
If provided, it should be a function that returns the current value that will be animated. NOTE: This can be omitted, even if setValue is provided, if thefrom
option is set (as the current value would just be ignored). - property?: TProperty<T> | null
If provided, it should be an axon Property with the current value. It will be modified by the animation. NOTE: do not provide this and setValue/object - object?: Obj | null
If provided, it should point to an object whereobject[ attribute ]
is the value to be modified by the animation. NOTE: do not provide this and setValue/property - attribute?: KeysMatching<Obj, T> | null
Ifobject
is provided, it should be a string such thatobject[ attribute ]
is the value to be modified. - to?: T | null
If provided, the animation will treat this as the end value (what it animates toward). - delta?: T | null
If provided, the animation will treat the ending value of the animation as the starting value plus this delta value. To determine the exact value, theadd
option will be used (which by default handles number/Vector2/Vector3/Vector4 as expected). The animation can be run multiple times, and each time it will use the "starting" value from last time (unless thefrom
option is used). - speed?: number | null
If provided, the animation's length will be this value (seconds/unit) times the "distance" between the start and end value of the animation. Thedistance
option can be used to specify a way to compute the distance, and works by default as expected for number/Vector2/Vector3/Vector4. - from?: T | null
If provided, the animation will start from this value (instead of getting the current value to start from). - easing?: Easing
Controls the relative motion from the starting value to the ending value. See Easing.js for info. - blend?: BlendFunction<T>
Should be of the formfunction( start: {*}, end: {*}, ratio: {number} ): {*}
where the ratio will be between 0 and 1 (inclusive). If the ratio is 0, it should return the starting value, if the ratio is 1, it should return the ending value, and otherwise it should return the best interpolation possible between the two values. The default should work for number/Vector2/Vector3/Vector4/Color, but for other types eitherstart.blend( end, ratio )
should be defined and work, or this function should be overridden. - distance?: DistanceFunction<T>
Should be of the formfunction( start: {*}, end: {*} ): {number}
, and it should return a measure of distance (a metric) between the two values. This is only used for if thespeed
option is provided (so it can determine the length of the animation). The default should work for number/Vector2/Vector3/Vector4. - add?: AddFunction<T>
Should be of the formfunction( start: {*}, delta: {*} ): {*}
where it adds together a value and a "delta" (usually just a value of the same type) and returns the result. This is used for thedelta
option. The default should work for number/Vector2/Vector3/Vector4.
Source Code¶
See the source for AnimationTarget.ts in the twixt repository.