Skip to content

Commit b776aef

Browse files
authored
Global: Replace Clock with Timer. (#32793)
1 parent 9d91428 commit b776aef

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

editor/js/Viewport.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,14 @@ function Viewport( editor ) {
777777

778778
let prevActionsInUse = 0;
779779

780-
const clock = new THREE.Clock(); // only used for animations
780+
const timer = new THREE.Timer(); // only used for animations
781781

782782
function animate() {
783783

784+
timer.update();
785+
784786
const mixer = editor.mixer;
785-
const delta = clock.getDelta();
787+
const delta = timer.getDelta();
786788

787789
let needsUpdate = false;
788790

examples/jsm/objects/Water2.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Clock,
2+
Timer,
33
Color,
44
Matrix4,
55
Mesh,
@@ -74,7 +74,7 @@ class Water extends Mesh {
7474
const cycle = 0.15; // a cycle of a flow map phase
7575
const halfCycle = cycle * 0.5;
7676
const textureMatrix = new Matrix4();
77-
const clock = new Clock();
77+
const timer = new Timer();
7878

7979
// internal components
8080

@@ -180,7 +180,7 @@ class Water extends Mesh {
180180

181181
function updateFlow() {
182182

183-
const delta = clock.getDelta();
183+
const delta = timer.getDelta();
184184
const config = scope.material.uniforms[ 'config' ];
185185

186186
config.value.x += flowSpeed * delta; // flowMapOffset0
@@ -207,6 +207,8 @@ class Water extends Mesh {
207207

208208
this.onBeforeRender = function ( renderer, scene, camera ) {
209209

210+
timer.update();
211+
210212
updateTextureMatrix( camera );
211213
updateFlow();
212214

examples/jsm/physics/JoltPhysics.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
1+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
22

33
const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@1.0.0/dist/jolt-physics.wasm-compat.js';
44

@@ -222,11 +222,13 @@ async function JoltPhysics() {
222222

223223
//
224224

225-
const clock = new Clock();
225+
const timer = new Timer();
226226

227227
function step() {
228228

229-
let deltaTime = clock.getDelta();
229+
timer.update();
230+
231+
let deltaTime = timer.getDelta();
230232

231233
// Don't go below 30 Hz to prevent spiral of death
232234
deltaTime = Math.min( deltaTime, 1.0 / 30.0 );

examples/jsm/physics/RapierPhysics.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
1+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
22

33
const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.17.3';
44

@@ -301,11 +301,13 @@ async function RapierPhysics() {
301301

302302
//
303303

304-
const clock = new Clock();
304+
const timer = new Timer();
305305

306306
function step() {
307307

308-
world.timestep = clock.getDelta();
308+
timer.update();
309+
310+
world.timestep = timer.getDelta();
309311
world.step();
310312

311313
//

examples/jsm/postprocessing/EffectComposer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2-
Clock,
32
HalfFloatType,
43
NoBlending,
4+
Timer,
55
Vector2,
66
WebGLRenderTarget
77
} from 'three';
@@ -121,12 +121,12 @@ class EffectComposer {
121121
this.copyPass.material.blending = NoBlending;
122122

123123
/**
124-
* The internal clock for managing time data.
124+
* The internal timer for managing time data.
125125
*
126126
* @private
127-
* @type {Clock}
127+
* @type {Timer}
128128
*/
129-
this.clock = new Clock();
129+
this.timer = new Timer();
130130

131131
}
132132

@@ -215,9 +215,11 @@ class EffectComposer {
215215

216216
// deltaTime value is in seconds
217217

218+
this.timer.update();
219+
218220
if ( deltaTime === undefined ) {
219221

220-
deltaTime = this.clock.getDelta();
222+
deltaTime = this.timer.getDelta();
221223

222224
}
223225

0 commit comments

Comments
 (0)