From c65bbcfefb238c0e65863f5a9f4630b879665442 Mon Sep 17 00:00:00 2001 From: Diego Marcos Segura Date: Fri, 4 Jul 2025 08:24:55 -0500 Subject: [PATCH] Make hello world rotation animation framerate independent --- examples/hello-world/index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/hello-world/index.html b/examples/hello-world/index.html index 838e14e..94eab44 100644 --- a/examples/hello-world/index.html +++ b/examples/hello-world/index.html @@ -37,9 +37,12 @@ butterfly.position.set(0, 0, -3); scene.add(butterfly); + let lastTime; renderer.setAnimationLoop(function animate(time) { + const deltaTime = time - (lastTime || time); + lastTime = time; renderer.render(scene, camera); - butterfly.rotation.y += 0.01; + butterfly.rotation.y += deltaTime / 2500; });