Skip to content

Commit

Permalink
Revert "Examples: More usage of setAnimationLoop(). (mrdoob#28236)"
Browse files Browse the repository at this point in the history
This reverts commit b8d79b8.
  • Loading branch information
Mugen87 committed May 9, 2024
1 parent 94da2af commit 7e32b8f
Show file tree
Hide file tree
Showing 50 changed files with 355 additions and 156 deletions.
7 changes: 5 additions & 2 deletions examples/games_fps.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
const renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.VSMShadowMap;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
Expand Down Expand Up @@ -443,7 +442,9 @@
helper.visible = value;

} );


animate();

} );

function teleportPlayerIfOob() {
Expand Down Expand Up @@ -484,6 +485,8 @@

stats.update();

requestAnimationFrame( animate );

}

</script>
Expand Down
10 changes: 9 additions & 1 deletion examples/misc_animation_groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
let scene, camera, renderer, mixer;

init();
animate();

function init() {

Expand Down Expand Up @@ -96,7 +97,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

//
Expand Down Expand Up @@ -125,6 +125,14 @@

function animate() {

requestAnimationFrame( animate );

render();

}

function render() {

const delta = clock.getDelta();

if ( mixer ) {
Expand Down
10 changes: 9 additions & 1 deletion examples/misc_animation_keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
let scene, camera, renderer, mixer;

init();
animate();

function init() {

Expand Down Expand Up @@ -96,7 +97,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

//
Expand Down Expand Up @@ -125,6 +125,14 @@

function animate() {

requestAnimationFrame( animate );

render();

}

function render() {

const delta = clock.getDelta();

if ( mixer ) {
Expand Down
11 changes: 9 additions & 2 deletions examples/misc_boxselection.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
let camera, scene, renderer;

init();
animate();

function init() {

Expand Down Expand Up @@ -105,7 +106,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap;

Expand All @@ -131,12 +131,19 @@

function animate() {

renderer.render( scene, camera );
requestAnimationFrame( animate );

render();
stats.update();

}

function render() {

renderer.render( scene, camera );

}

const selectionBox = new SelectionBox( camera, scene );
const helper = new SelectionHelper( renderer, 'selectBox' );

Expand Down
4 changes: 3 additions & 1 deletion examples/misc_controls_fly.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
const clock = new THREE.Clock();

init();
animate();

function init() {

Expand Down Expand Up @@ -200,7 +201,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

//
Expand Down Expand Up @@ -249,6 +249,8 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
6 changes: 4 additions & 2 deletions examples/misc_controls_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
let camera, controls, scene, renderer;

init();
//render(); // remove when using animation loop
//render(); // remove when using next line for animation loop (requestAnimationFrame)
animate();

function init() {

Expand All @@ -53,7 +54,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
Expand Down Expand Up @@ -131,6 +131,8 @@

function animate() {

requestAnimationFrame( animate );

controls.update(); // only required if controls.enableDamping = true, or if controls.autoRotate = true

render();
Expand Down
6 changes: 4 additions & 2 deletions examples/misc_controls_orbit.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
let camera, controls, scene, renderer;

init();
//render(); // remove when using animation loop
//render(); // remove when using next line for animation loop (requestAnimationFrame)
animate();

function init() {

Expand All @@ -51,7 +52,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
Expand Down Expand Up @@ -121,6 +121,8 @@

function animate() {

requestAnimationFrame( animate );

controls.update(); // only required if controls.enableDamping = true, or if controls.autoRotate = true

render();
Expand Down
4 changes: 3 additions & 1 deletion examples/misc_controls_pointerlock.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
const color = new THREE.Color();

init();
animate();

function init() {

Expand Down Expand Up @@ -259,7 +260,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

//
Expand All @@ -279,6 +279,8 @@

function animate() {

requestAnimationFrame( animate );

const time = performance.now();

if ( controls.isLocked === true ) {
Expand Down
8 changes: 5 additions & 3 deletions examples/misc_controls_trackball.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
const frustumSize = 400;

init();
animate();

function init() {

Expand Down Expand Up @@ -99,7 +100,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

stats = new Stats();
Expand Down Expand Up @@ -157,12 +157,14 @@

function animate() {

controls.update();
requestAnimationFrame( animate );

render();
controls.update();

stats.update();

render();

}

function render() {
Expand Down
3 changes: 2 additions & 1 deletion examples/misc_exporter_draco.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
};

init();
animate();

function init() {

Expand Down Expand Up @@ -90,7 +91,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
document.body.appendChild( renderer.domElement );

Expand Down Expand Up @@ -123,6 +123,7 @@

function animate() {

requestAnimationFrame( animate );
renderer.render( scene, camera );

}
Expand Down
3 changes: 2 additions & 1 deletion examples/misc_exporter_exr.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
};

init();
animate();

function init() {

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

//
Expand Down Expand Up @@ -109,6 +109,7 @@

function animate() {

requestAnimationFrame( animate );
controls.update();
renderer.render( scene, camera );

Expand Down
12 changes: 9 additions & 3 deletions examples/misc_exporter_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
};

init();
animate();

function init() {

Expand Down Expand Up @@ -463,7 +464,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1;

Expand Down Expand Up @@ -572,6 +572,14 @@

function animate() {

requestAnimationFrame( animate );

render();

}

function render() {

const timer = Date.now() * 0.0001;

camera.position.x = Math.cos( timer ) * 800;
Expand All @@ -582,8 +590,6 @@

}



</script>

</body>
Expand Down
6 changes: 4 additions & 2 deletions examples/misc_exporter_obj.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
};

init();
animate();

function init() {

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
Expand Down Expand Up @@ -240,6 +240,8 @@

function animate() {

requestAnimationFrame( animate );

renderer.render( scene, camera );

}
Expand Down
3 changes: 2 additions & 1 deletion examples/misc_exporter_ply.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
};

init();
animate();

function init() {

Expand Down Expand Up @@ -102,7 +103,6 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
document.body.appendChild( renderer.domElement );

Expand Down Expand Up @@ -136,6 +136,7 @@

function animate() {

requestAnimationFrame( animate );
renderer.render( scene, camera );

}
Expand Down
Loading

0 comments on commit 7e32b8f

Please sign in to comment.