AbsAnimationGroup constructor
AbsAnimationGroup({
- required List<
AnimationPart> parts,
Implementation
AbsAnimationGroup({required List<AnimationPart> parts})
: assert(parts.isNotEmpty && parts.length > 1,
"AnimationPart list must be not null and size > 1") {
_currentXYZ = _initXYZ();
//动画序列调整
_parts = parts;
_parts.sort((a, b) {
return a.moment.compareTo(b.moment);
});
// 第一个起步值是否存在
// 初始化值设置
AnimationPart tempPart = AnimationPart(moment: 0);
tempPart.xyz = _currentXYZ;
Iterator<AnimationPart> iterator = _parts.iterator;
while (iterator.moveNext()) {
AnimationPart animationPart = iterator.current;
if (animationPart.isAddPart) {
animationPart.xyz = tempPart.xyz + animationPart.xyzAdd;
} else {
Vector3? vector3 = animationPart.xyz;
if (vector3!.x == double.infinity) vector3.x = tempPart.xyz!.x;
if (vector3!.y == double.infinity) vector3.y = tempPart.xyz!.y;
if (vector3!.z == double.infinity) vector3.z = tempPart.xyz!.z;
}
tempPart = animationPart;
}
//计算得到时长
_duration = _parts.last.moment;
_startMoment = _parts.first.moment;
_endMoment = _duration;
}