Animating the Orbits
BJS has many different ways of accomplishing any given task; animating objects in a scene is no different. Some of the different ways to animate in BJS include the following:
- Define a reusable
BABYLON.Animation
object that will interpolate specified properties between an array of keyframes. - Import pre-built Animations from a file –
BABYLON
,GLTF
,GLB
,OBJ
, and so on. - Use
OnPreRenderObservable
to update object properties (e.g., position, rotation, color, and so on) before each frame is rendered.
For our title screen animations, we will be using the first and third methods to animate the rotations and circular orbits of our little solar system, respectively. In later chapters, we will see more of the second.
Putting Spin on the Star and Planets
The rotation of stars and planets is pretty simple, but it can serve as a good review of the principle and practice of keyframe animation. Since animations can be looped or cycled, it&...