Stores settings and other state for the playback of an animation on an AnimationState
track.
References to a track entry must not be kept after the AnimationStateListener.dispose
event occurs.
Variables
alpha:Float
Values < 1 mix this animation with the skeleton's current pose (usually the pose resulting from lower tracks). Defaults to 1, which overwrites the skeleton's current pose with this animation.
Typically track 0 is used to completely pose the skeleton, then alpha is used on higher tracks. It doesn't make sense to use alpha on track 0 if the skeleton pose is from the last frame render.
animationEnd:Float
Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
loop back to animationStart
at this time. Defaults to the animation Animation.duration
.
animationLast:Float
The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
animation is applied, event timelines will fire all events between the animationLast
time (exclusive) and
getAnimationTime()
(inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation
is applied.
animationStart:Float
Seconds when this animation starts, both initially and after looping. Defaults to 0.
When changing the animationStart
time, it often makes sense to set animationLast
to the same
value to prevent timeline keys before the start time from triggering.
attachmentThreshold:Float
When the mix percentage (mixtime
/ mixDuration
) is less than the
attachmentThreshold
, attachment timelines are applied while this animation is being mixed out. Defaults to
0, so attachment timelines are not applied while this animation is being mixed out.
delay:Float
Seconds to postpone playing the animation. When this track entry is the current track entry, delay
postpones incrementing the trackTime
. When this track entry is queued, delay
is the time from
the start of the previous animation to when this track entry will become the current track entry (ie when the previous
track entry TrackEntry.trackTime
>= this track entry's delay
).
timeScale
affects the delay.
drawOrderThreshold:Float
When the mix percentage (mixTime
/ mixDuration
) is less than the
drawOrderThreshold
, draw order timelines are applied while this animation is being mixed out. Defaults to 0,
so draw order timelines are not applied while this animation is being mixed out.
eventThreshold:Float
When the mix percentage (mixTime
/ mixDuration
) is less than the
eventThreshold
, event timelines are applied while this animation is being mixed out. Defaults to 0, so event
timelines are not applied while this animation is being mixed out.
holdPrevious:Bool
If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead of being mixed out.
When mixing between animations that key the same property, if a lower track also keys that property then the value will
briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
while the second animation mixes from 0% to 100%. Setting holdPrevious
to true applies the first animation
at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
keys the property, only when a higher track also keys the property.
Snapping will occur if holdPrevious
is true and this animation does not key all the same properties as the
previous animation.
listener:Null<AnimationStateListener>
The listener for events generated by this track entry, or null.
A track entry returned from AnimationState.setAnimation
is already the current animation
for the track, so the track entry listener AnimationStateListener.start
will not be called.
loop:Bool
If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its duration.
mixBlend:MixBlend = replace
Controls how properties keyed in the animation are mixed with lower tracks. Defaults to MixBlend.replace
, which
replaces the values from the lower tracks with the animation values. MixBlend.add
adds the animation values to
the values from the lower tracks.
The mixBlend
can be set for a new track entry only before AnimationState.apply
is first called.
mixDuration:Float
Seconds for mixing from the previous animation to this animation. Defaults to the value provided by
AnimationStateData.getMix
based on the animation before this animation (if any).
A mix duration of 0 still mixes out over one frame to provide the track entry being mixed out a chance to revert the properties it was animating.
The mixDuration
can be set manually rather than use the value from
AnimationStateData.getMix
. In that case, the mixDuration
can be set for a new
track entry only before AnimationState.update
is first called.
When using AnimationState.addAnimation
with a delay
<= 0, note the
delay
is set using the mix duration from the AnimationStateData
, not a mix duration set
afterward.
mixTime:Float
Seconds from 0 to the mixDuration
when mixing from the previous animation to this animation. May be
slightly more than mixDuration
when the mix is complete.
read onlymixingFrom:Null<TrackEntry>
The track entry for the previous animation when mixing from the previous animation to this animation, or null if no
mixing is currently occuring. When mixing from multiple animations, mixingFrom
makes up a linked list.
read onlymixingTo:Null<TrackEntry>
The track entry for the next animation when mixing from this animation to the next animation, or null if no mixing is
currently occuring. When mixing to multiple animations, mixingTo
makes up a linked list.
read onlynext:Null<TrackEntry>
The animation queued to start after this animation, or null. next
makes up a linked list.
timeScale:Float
Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or faster. Defaults to 1.
mixTime
is not affected by track entry time scale, so mixDuration
may need to be adjusted to
match the animation speed.
When using AnimationState.addAnimation
with a delay
<= 0, note the
delay
is set using the mix duration from the AnimationStateData
, assuming time scale to be 1. If
the time scale is not 1, the delay may need to be adjusted.
See AnimationState.timeScale
for affecting all animations.
trackEnd:Float
The track time in seconds when this animation will be removed from the track. Defaults to the highest possible float value, meaning the animation will be applied until a new animation is set or the track is cleared. If the track end time is reached, no other animations are queued for playback, and mixing from any previous animations is complete, then the properties keyed by the animation are set to the setup pose and the track is cleared.
It may be desired to use AnimationState.addEmptyAnimation
rather than have the animation
abruptly cease being applied.
trackTime:Float
Current time in seconds this track entry has been the current track entry. The track time determines
getAnimationTime()
. The track time can be set to start the animation at a time other than 0, without affecting
looping.
Methods
getAnimationTime():Float
Uses trackTime
to compute the animationTime
, which is between animationStart
and animationEnd
. When the trackTime
is 0, the animationTime
is equal to the
animationStart
time.
isComplete():Bool
resetRotationDirections():Void
Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
long way around when using alpha
and starting animations on other tracks.
Mixing with MixBlend.replace
involves finding a rotation between two others, which has two possible solutions:
the short way or the long way around. The two rotations likely change over time, so which direction is the short or long
way also changes. If the short way was always chosen, bones would flip to the other side when that direction became the
long way. TrackEntry chooses the short way the first time it is applied and remembers that direction.