-
Notifications
You must be signed in to change notification settings - Fork 408
Description
Description
We're currently using animation features in 3 examples:
- SunSimulation
- TestMovingSurfaceShapes
- StarField
The first two utilize Window.setInterval as a mechanism to update their animations, while the latter uses WorldWindow.redrawCallbacks.
Neither mechanism is fitting for the task at hand (animation). SetInterval leaves the developer with the burden of defining a rate at which the animation will happen, which will always be arbitrary and will never synchronize the animation with the monitor's refresh rate.
WorldWindow.redrawCallbacks used in the last example on the list, happens to be very opaque to the developer, being difficult to understand without diving deep into the innards of Web WorldWind.
After touching base with @pdavidc , it has been decided to change both of these approaches to the requestAnimationFrame browser mechanism. This provides a standarized way to do animations without the opaqueness of WorldWindow.redrawCallbacks (which internally also uses requestAnimationFrame). Compared to setInterval, requestAnimationFrame maintains synchronization with the monitor's refresh rate. It also has some nice bonuses, like suspending the animation work if the browser's window is not on focus.
We will be refactoring the examples listed above to utilize requestAnimationFrame, as part of the ongoing work on improving our Examples and documentation (#539).