mirror of
https://github.com/storytold/spark.git
synced 2026-10-09 00:09:53 +00:00
Make hello world rotation animation framerate independent
This commit is contained in:
@@ -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;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user