This example uses JavaScript's requestAnimationFrame(), which is more efficient than setInterval().