You can use animations to create smooth transitions between viewpoints, fade-in and fade-out effects, and so on.

The animation framework consists of two main components:

  • The animation manager provides global timing and bookkeeping.

  • Animations are implemented by the user and submitted for playback to the animation manager.

The animation manager is implemented by AnimationManager, which is a singleton.

The animation manager uses an internal clock to keep track of time. At every clock tick, the manager tells all currently running animations what the current time is, allowing the animations to take appropriate action.

When you submit an animation to the animation manager with the putAnimation method, it is associated with a particular key. This is a convenience mechanism that is used to prevent simultaneously running animations from interfering with each other. If putAnimation is called with the same key twice, the animation manager terminates the first animation associated with the object before starting the second one.

Animations are defined by Animation. An animation is essentially a class that gets notified by the manager when the clock has ticked. When the animation starts, the 'onStart' functions is called. Afterwards, to notify the animation, the animation’s update function is called. The current time is passed to this function as an argument to determine the elapsed time relative to the time at which the animation was started. What happens in the update function is entirely up to the developer of the animation. Typically, some properties of an object, such as position, color and transparency, are interpolated from an initial state to a target state over the duration of the animation.

An animation can specify its own duration. If an animation has reached the end of its duration the 'onStop' function will be called.

If you want to repeat an animation in a loop, you can configure that when passing the Animation to the AnimationManager. A looping animation stops only if you explicitly remove it from the AnimationManager. To remove it, call removeAnimation with the key that was used to add the animation.