diff --git a/src/index.ts b/src/index.ts index 37953861f..a756bfb68 100644 --- a/src/index.ts +++ b/src/index.ts @@ -99,21 +99,6 @@ window.addEventListener("DOMContentLoaded", () => { const clock = new THREE.Clock(); clock.start(); - const update = () => { - - controls.update(); - requestAnimationFrame(update); - const deltaTime = clock.getDelta(); - if (currentMixer) { - currentMixer.update(deltaTime); - } - if (currentVrm) { - currentVrm.update(deltaTime); - } - - renderer.render(scene, camera); - } - scene.background = new THREE.Color( 0xffffff ); const directionalLight = new THREE.DirectionalLight(0xffffff); directionalLight.position.set(1, 1, 1); @@ -157,9 +142,15 @@ window.addEventListener("DOMContentLoaded", () => { floor_grid(); floor_bg(); - update(); - function animate() { + controls.update(); + const delta = clock.getDelta(); + if (currentMixer) { + currentMixer.update(delta); + } + if (currentVrm) { + currentVrm.update(delta); + } requestAnimationFrame(animate); scene.rotation.y += 0.005; renderer.render(scene, camera);