apply method
void
apply(
- Skeleton skeleton,
- double lastTime,
- double time,
- List<
Event?> firedEvents, - double alpha,
- MixPose pose,
- MixDirection direction,
override
Implementation
@override
void apply(
Skeleton skeleton,
double lastTime,
double time,
List<Event?> firedEvents,
double alpha,
MixPose pose,
MixDirection direction) {
final Float32List frames = this.frames;
final PathConstraint constraint =
skeleton.pathConstraints[pathConstraintIndex];
if (time < frames[0]) {
if (pose == MixPose.setup) {
constraint.spacing = constraint.data.spacing;
} else if (pose == MixPose.current) {
constraint.spacing = constraint.spacing +
(constraint.data.spacing - constraint.spacing) * alpha;
}
return;
}
double spacing = 0.0;
if (time >=
frames[frames.length - PathConstraintPositionTimeline.entries]) {
spacing =
frames[frames.length + PathConstraintPositionTimeline.prevValue];
} else {
// Interpolate between the previous frame and the current frame.
final int frame = Animation.binarySearch(
frames, time, PathConstraintPositionTimeline.entries);
spacing = frames[frame + PathConstraintPositionTimeline.prevValue];
final double frameTime = frames[frame];
final double percent = getCurvePercent(
frame ~/ PathConstraintPositionTimeline.entries - 1,
1 -
(time - frameTime) /
(frames[frame + PathConstraintPositionTimeline.prevTime] -
frameTime));
spacing +=
(frames[frame + PathConstraintPositionTimeline.value] - spacing) *
percent;
}
if (pose == MixPose.setup) {
constraint.spacing =
constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
} else {
constraint.spacing =
constraint.spacing + (spacing - constraint.spacing) * alpha;
}
}