Running the Animation

The animate function passes the sceneTime variable to the update method of every ball in the ball array. Then, sceneTime updates by a fixed amount. The code looks like this:

function animate() {
balls.forEach(ball => ball.update(sceneTime));
sceneTime += 33 / 1000;
draw();
}

Again, parametric curves are very helpful because they don’t require us to know the location of every object that we want to move beforehand. We just apply a parametric equation that gives us the location based on the current time. This occurs for every ball inside its update method.