Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/css2d_label.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@

};

const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );
const textureLoader = new THREE.TextureLoader();

let moon;
Expand Down Expand Up @@ -206,9 +207,11 @@

function animate() {

timer.update();

requestAnimationFrame( animate );

const elapsed = clock.getElapsedTime();
const elapsed = timer.getElapsed();

moon.position.set( Math.sin( elapsed ) * 5, 0, Math.cos( elapsed ) * 5 );

Expand Down
7 changes: 5 additions & 2 deletions examples/games_fps.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

const scene = new THREE.Scene();
scene.background = new THREE.Color( 0x88ccee );
Expand Down Expand Up @@ -467,7 +468,9 @@

function animate() {

const deltaTime = Math.min( 0.05, clock.getDelta() ) / STEPS_PER_FRAME;
timer.update();

const deltaTime = Math.min( 0.05, timer.getDelta() ) / STEPS_PER_FRAME;

// we look for collisions in substeps to mitigate the risk of
// an object traversing another too quickly for detection.
Expand Down
9 changes: 6 additions & 3 deletions examples/misc_animation_groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import Stats from 'three/addons/libs/stats.module.js';

let stats, clock;
let stats, timer;
let scene, camera, renderer, mixer;

init();
Expand Down Expand Up @@ -106,7 +106,8 @@

//

clock = new THREE.Clock();
timer = new THREE.Timer();
timer.connect( document );

//

Expand All @@ -125,7 +126,9 @@

function animate() {

const delta = clock.getDelta();
timer.update();

const delta = timer.getDelta();

if ( mixer ) {

Expand Down
9 changes: 6 additions & 3 deletions examples/misc_animation_keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import Stats from 'three/addons/libs/stats.module.js';

let stats, clock;
let stats, timer;
let scene, camera, renderer, mixer;

init();
Expand Down Expand Up @@ -106,7 +106,8 @@

//

clock = new THREE.Clock();
timer = new THREE.Timer();
timer.connect( document );

//

Expand All @@ -125,7 +126,9 @@

function animate() {

const delta = clock.getDelta();
timer.update();

const delta = timer.getDelta();

if ( mixer ) {

Expand Down
7 changes: 5 additions & 2 deletions examples/misc_controls_fly.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
let d, dPlanet, dMoon;
const dMoonVec = new THREE.Vector3();

const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

init();

Expand Down Expand Up @@ -241,6 +242,8 @@

function animate() {

timer.update();

render();
stats.update();

Expand All @@ -250,7 +253,7 @@

// rotate the planet and clouds

const delta = clock.getDelta();
const delta = timer.getDelta();

meshPlanet.rotation.y += rotationSpeed * delta;
meshClouds.rotation.y += 1.25 * rotationSpeed * delta;
Expand Down
7 changes: 5 additions & 2 deletions examples/physics_ammo_break.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
let container, stats;
let camera, controls, scene, renderer;
let textureLoader;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

const mouseCoords = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
Expand Down Expand Up @@ -432,14 +433,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

updatePhysics( deltaTime );

Expand Down
7 changes: 5 additions & 2 deletions examples/physics_ammo_cloth.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
let container, stats;
let camera, controls, scene, renderer;
let textureLoader;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

// Physics variables
const gravityConstant = - 9.8;
Expand Down Expand Up @@ -396,14 +397,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

updatePhysics( deltaTime );

Expand Down
7 changes: 5 additions & 2 deletions examples/physics_ammo_rope.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
let container, stats;
let camera, controls, scene, renderer;
let textureLoader;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

// Physics variables
const gravityConstant = - 9.8;
Expand Down Expand Up @@ -419,14 +420,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

updatePhysics( deltaTime );

Expand Down
7 changes: 5 additions & 2 deletions examples/physics_ammo_terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
let container, stats;
let camera, scene, renderer;
let terrainMesh;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

// Physics variables
let collisionConfiguration;
Expand Down Expand Up @@ -391,14 +392,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

if ( dynamicObjects.length < maxNumObjects && time > timeNextSpawn ) {

Expand Down
7 changes: 5 additions & 2 deletions examples/physics_ammo_volume.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
let container, stats;
let camera, controls, scene, renderer;
let textureLoader;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );
let clickRequest = false;
const mouseCoords = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
Expand Down Expand Up @@ -414,14 +415,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

updatePhysics( deltaTime );

Expand Down
7 changes: 5 additions & 2 deletions examples/physics_rapier_terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
let container, stats;
let camera, scene, renderer;
let terrainMesh;
const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

// Physics variables
let physics;
Expand Down Expand Up @@ -262,14 +263,16 @@

function animate() {

timer.update();

render();
stats.update();

}

function render() {

const deltaTime = clock.getDelta();
const deltaTime = timer.getDelta();

// Generate new objects with a delay between them
if ( dynamicObjects.length < maxNumObjects && time > timeNextSpawn ) {
Expand Down
7 changes: 5 additions & 2 deletions examples/webaudio_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@

let analyser1, analyser2, analyser3;

const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );

const startButton = document.getElementById( 'startButton' );
startButton.addEventListener( 'click', init );
Expand Down Expand Up @@ -244,7 +245,9 @@

function animate() {

const delta = clock.getDelta();
timer.update();

const delta = timer.getDelta();

controls.update( delta );

Expand Down
9 changes: 6 additions & 3 deletions examples/webaudio_timing.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

let scene, camera, renderer, clock;
let scene, camera, renderer, timer;

const objects = [];

Expand All @@ -51,7 +51,8 @@

scene = new THREE.Scene();

clock = new THREE.Clock();
timer = new THREE.Timer();
timer.connect( document );

//

Expand Down Expand Up @@ -165,7 +166,9 @@

function animate() {

const time = clock.getElapsedTime();
timer.update();

const time = timer.getElapsed();

for ( let i = 0; i < objects.length; i ++ ) {

Expand Down
7 changes: 5 additions & 2 deletions examples/webgl_animation_keyframes.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@

let mixer;

const clock = new THREE.Clock();
const timer = new THREE.Timer();
timer.connect( document );
const container = document.getElementById( 'container' );

const stats = new Stats();
Expand Down Expand Up @@ -122,7 +123,9 @@

function animate() {

const delta = clock.getDelta();
timer.update();

const delta = timer.getDelta();

mixer.update( delta );

Expand Down
Loading