refactor: replace clock with Timer for animation updates

This commit is contained in:
sayudhalw
2026-08-24 07:32:53 +07:00
parent 9c52c11d90
commit cda633bea1
+5 -2
View File
@@ -1,5 +1,6 @@
import * as THREE from 'three' import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js' import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
import { Timer } from 'three/examples/jsm/misc/Timer.js'
/** /**
* Base * Base
@@ -49,11 +50,13 @@ renderer.setSize(sizes.width, sizes.height)
/** /**
* Animate * Animate
*/ */
const clock = new THREE.Clock() const timer = new Timer()
timer.connect(document) // pause otomatis saat tab tidak aktif
const tick = () => const tick = () =>
{ {
const elapsedTime = clock.getElapsedTime() timer.update()
const elapsedTime = timer.getElapsed()
// Update controls // Update controls
controls.update() controls.update()