|
|
@@ -32,10 +32,11 @@
|
|
|
import { bloom } from 'three/addons/tsl/display/BloomNode.js';
|
|
|
|
|
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
|
+ import { Timer } from 'three/addons/misc/Timer.js';
|
|
|
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
|
|
|
import WebGPU from 'three/addons/capabilities/WebGPU.js';
|
|
|
|
|
|
- let camera, scene, renderer, postProcessing, controls, clock, light;
|
|
|
+ let camera, scene, renderer, postProcessing, controls, timer, light;
|
|
|
|
|
|
let updateParticles, spawnParticles; // TSL compute nodes
|
|
|
let getInstanceColor; // TSL function
|
|
|
@@ -85,7 +86,7 @@
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
|
|
|
|
- clock = new THREE.Clock();
|
|
|
+ timer = new Timer();
|
|
|
|
|
|
// renderer
|
|
|
|
|
|
@@ -421,6 +422,8 @@
|
|
|
|
|
|
function animate() {
|
|
|
|
|
|
+ timer.update();
|
|
|
+
|
|
|
// compute particles
|
|
|
renderer.compute( updateParticles );
|
|
|
renderer.compute( spawnParticles );
|
|
|
@@ -437,9 +440,9 @@
|
|
|
spawnPosition.value.lerp( scenePointer, 0.1 );
|
|
|
|
|
|
// rotating colors
|
|
|
- colorOffset.value += clock.getDelta() * colorRotationSpeed.value * timeScale.value;
|
|
|
+ colorOffset.value += timer.getDelta() * colorRotationSpeed.value * timeScale.value;
|
|
|
|
|
|
- const elapsedTime = clock.getElapsedTime();
|
|
|
+ const elapsedTime = timer.getElapsed();
|
|
|
light.position.set(
|
|
|
Math.sin( elapsedTime * 0.5 ) * 30,
|
|
|
Math.cos( elapsedTime * 0.3 ) * 30,
|