|
|
@@ -42,7 +42,7 @@
|
|
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
|
|
|
|
let camera, scene, renderer;
|
|
|
- let mixer, objects, clock;
|
|
|
+ let mixer, objects, timer;
|
|
|
let model, floor, floorPosition;
|
|
|
let postProcessing;
|
|
|
let controls;
|
|
|
@@ -69,7 +69,8 @@
|
|
|
scene.add( skyAmbientLight );
|
|
|
scene.add( waterAmbientLight );
|
|
|
|
|
|
- clock = new THREE.Clock();
|
|
|
+ timer = new THREE.Timer();
|
|
|
+ timer.connect( document );
|
|
|
|
|
|
// animated model
|
|
|
|
|
|
@@ -128,11 +129,11 @@
|
|
|
|
|
|
// water
|
|
|
|
|
|
- const timer = time.mul( .8 );
|
|
|
+ const t = time.mul( .8 );
|
|
|
const floorUV = positionWorld.xzy;
|
|
|
|
|
|
- const waterLayer0 = mx_worley_noise_float( floorUV.mul( 4 ).add( timer ) );
|
|
|
- const waterLayer1 = mx_worley_noise_float( floorUV.mul( 2 ).add( timer ) );
|
|
|
+ const waterLayer0 = mx_worley_noise_float( floorUV.mul( 4 ).add( t ) );
|
|
|
+ const waterLayer1 = mx_worley_noise_float( floorUV.mul( 2 ).add( t ) );
|
|
|
|
|
|
const waterIntensity = waterLayer0.mul( waterLayer1 );
|
|
|
const waterColor = waterIntensity.mul( 1.4 ).mix( color( 0x0487e2 ), color( 0x74ccf4 ) );
|
|
|
@@ -240,9 +241,11 @@
|
|
|
|
|
|
function animate() {
|
|
|
|
|
|
+ timer.update();
|
|
|
+
|
|
|
controls.update();
|
|
|
|
|
|
- const delta = clock.getDelta();
|
|
|
+ const delta = timer.getDelta();
|
|
|
|
|
|
floor.position.y = floorPosition.y - 5;
|
|
|
|
|
|
@@ -256,7 +259,7 @@
|
|
|
|
|
|
for ( const object of objects.children ) {
|
|
|
|
|
|
- object.position.y = Math.sin( clock.elapsedTime + object.id ) * .3;
|
|
|
+ object.position.y = Math.sin( timer.getElapsed() + object.id ) * .3;
|
|
|
object.rotation.y += delta * .3;
|
|
|
|
|
|
}
|