commit
Use THREE.Timer instead of the deprecated Clock
Clears the deprecation warning on model pages. The timer also pauses while the tab is hidden, so animations don't jump when it comes back. Co-Authored-By: Sandrone <[email protected]>
diff --git a/web/src/lib/ModelViewer.svelte b/web/src/lib/ModelViewer.svelte
index db9362b..5606463 100644
--- a/web/src/lib/ModelViewer.svelte
+++ b/web/src/lib/ModelViewer.svelte
@@ -109,16 +109,21 @@
},
);
- const clock = new THREE.Clock();
- renderer.setAnimationLoop(() => {
+ // Pauses while the tab is hidden, so animations don't jump on return
+ const timer = new THREE.Timer();
+ timer.connect(document);
+
+ renderer.setAnimationLoop((timestamp) => {
+ timer.update(timestamp);
controls.autoRotate = spinning;
controls.update();
- mixer?.update(clock.getDelta());
+ mixer?.update(timer.getDelta());
renderer.render(scene, camera);
});
return () => {
renderer.setAnimationLoop(null);
+ timer.dispose();
observer.disconnect();
controls.dispose();
draco.dispose();