progressThroughAnimation method

Future progressThroughAnimation(
  1. Animation animation
)

Implementation

Future progressThroughAnimation(Animation animation) async {
  //* NOTE:
  //* In Manim, all non-moving mobjects are rendered before the animation
  //* such that they don't have to be rerendered every frame of animation
  //* However, here, non-moving mobjects are rerendered every frame
  // TODO: Stop rerendering non moving mobjects (maybe ?)

  var t = 0.0;

  while (t < animation.runTime) {
    var dt = await display.nextFrame();
    t += dt;

    var alpha = t / animation.runTime;
    animation
      ..updateMobjects(dt)
      ..interpolate(alpha);

    updateMobjects(dt);
    updateFrame(dt);
  }
}