AnimationLayer class final
A clip played over part of a skeleton, on top of whatever the base is doing.
The thing a crossfade cannot do. AnimationPlayer.crossFadeTo moves the
whole skeleton from one clip to another; a layer leaves the base playing and
takes over the joints its mask names. That is the difference between a
monster that stops walking in order to flinch and one that flinches while it
keeps walking, and between a soldier who must stand still to reload and one
who reloads on the move.
Override by default, additive when asked — blend, gfx-10n. Where a
layer covers a joint and has a track for it, the layer's value replaces the
base's, faded by weight. AnimationBlend.additive instead takes the
distance between the clip at this moment and the clip at its own
AnimationClip.referenceTime and lays that on top of the base — which is
what a breath over a walk, a recoil over an aim and a lean over a run all
want, and what an override can never be: an overriding breath stops the
walk for as long as it lasts.
The reference frame was the whole of why this was override-only. glTF has nowhere to say which frame is the rest pose, so the clip carries it now; a clip that does not name one cannot be blended additively and the player leaves it to the override path rather than guessing at zero.
A joint the layer's clip does not animate keeps the base's value, even inside the mask. A mask says where a layer may write, not where it must: an upper-body clip that animates the arms and not the head leaves the head to the walk, which is what a hand-authored upper-body clip expects.
weight is not faded by this class. A layer that snapped from nothing to
everything would pop, so a caller ramps it — fadeTo is the ramp, and it is
here rather than in the caller because every caller would write the same
four lines and one of them would forget to clamp.
Constructors
- AnimationLayer({required int clip, AnimationMask? mask, double weight = 1.0, AnimationWrap wrap = AnimationWrap.loop, double speed = 1.0, AnimationBlend blend = AnimationBlend.override})
Properties
- blend ↔ AnimationBlend
-
Whether this layer replaces the base's pose or adds to it —
gfx-10n.getter/setter pair - clip ↔ int
-
Index into the player's clips.
getter/setter pair
- effectiveWeight → double
-
What this layer contributes, from 0 to 1, with the clamp applied.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFinished → bool
-
Whether the layer has finished a
onceclip and gone quiet.no setter - isPlaying → bool
-
no setter
- mask ↔ AnimationMask
-
The joints this layer may write.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- speed ↔ double
-
Playback rate, independent of the base's.
getter/setter pair
- time → double
-
Where the layer's own playhead is, in seconds.
no setter
- weight ↔ double
-
How much of this layer's pose is used, from 0 (none) to 1 (all of it).
getter/setter pair
- wrap ↔ AnimationWrap
-
How the clip behaves at its end.
onceis the usual one for a layer: a reload or a flinch happens and is over.getter/setter pair
Methods
-
advance(
double deltaSeconds, double clipDuration) → void - Advances the playhead and the weight ramp. Called by the player.
-
fadeTo(
double to, {double seconds = 0.15}) → void -
Moves weight to
tooverseconds, or immediately when that is zero. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
restart(
) → void - Rewinds to the start and plays again.
-
toString(
) → String -
A string representation of this object.
inherited
-
tracksOf(
AnimationClip source) → Map< int, AnimationTrack> - This layer's tracks by animationTrackKey, built once per clip.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited