refactor: replace clock with Timer for animation updates
This commit is contained in:
+5
-2
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user