Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: More usage of setAnimationLoop(). #28241

Merged
merged 1 commit into from
Apr 30, 2024
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
1 change: 1 addition & 0 deletions examples/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"misc_controls_trackball": [ "rotation" ],
"misc_controls_transform": [ "scale", "rotate", "translate" ],
"physics_ammo_cloth": [ "integration" ],
"physics_jolt_instancing": [ "external" ],
"physics_rapier_instancing": [ "external" ],
"webgl_clipping": [ "solid" ],
"webgl_clipping_advanced": [ "solid" ],
Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_camera.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
const frustumSize = 600;

init();
animate();

function init() {

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

renderer.setScissorTest( true );
Expand Down Expand Up @@ -199,8 +199,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_camera_array.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
const AMOUNT = 6;

init();
animate();

function init() {

Expand Down Expand Up @@ -86,6 +85,7 @@
renderer = new THREE.WebGLRenderer();
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 @@ -134,8 +134,6 @@

renderer.render( scene, camera );

requestAnimationFrame( animate );

}

</script>
Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_camera_cinematic.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
let theta = 0;

init();
animate();

function init() {

Expand Down Expand Up @@ -83,6 +82,7 @@
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 @@ -172,8 +172,6 @@

function animate() {

requestAnimationFrame( animate, renderer.domElement );

render();
stats.update();

Expand Down
19 changes: 9 additions & 10 deletions examples/webgl_clipping.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
let camera, scene, renderer, startTime, object, stats;

init();
animate();

function init() {

Expand Down Expand Up @@ -103,26 +102,28 @@
ground.receiveShadow = true;
scene.add( ground );

// Stats

stats = new Stats();
document.body.appendChild( stats.dom );

// Renderer

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

window.addEventListener( 'resize', onWindowResize );

// ***** Clipping setup (renderer): *****
const globalPlanes = [ globalPlane ],
Empty = Object.freeze( [] );
renderer.clippingPlanes = Empty; // GUI sets it to globalPlanes
renderer.localClippingEnabled = true;

// Stats

stats = new Stats();
document.body.appendChild( stats.dom );

// Controls

const controls = new OrbitControls( camera, renderer.domElement );
Expand Down Expand Up @@ -235,8 +236,6 @@
const currentTime = Date.now();
const time = ( currentTime - startTime ) / 1000;

requestAnimationFrame( animate );

object.position.y = 0.8;
object.rotation.x = time * 0.5;
object.rotation.y = time * 0.2;
Expand Down
9 changes: 4 additions & 5 deletions examples/webgl_clipping_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,18 @@
const container = document.body;

renderer = new THREE.WebGLRenderer();
renderer.shadowMap.enabled = true;
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
window.addEventListener( 'resize', onWindowResize );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
container.appendChild( renderer.domElement );
// Clipping setup:
globalClippingPlanes = createPlanes( GlobalClippingPlanes.length );
renderer.clippingPlanes = Empty;
renderer.localClippingEnabled = true;

window.addEventListener( 'resize', onWindowResize );

// Stats

stats = new Stats();
Expand Down Expand Up @@ -397,8 +399,6 @@
const currentTime = Date.now(),
time = ( currentTime - startTime ) / 1000;

requestAnimationFrame( animate );

object.position.y = 1;
object.rotation.x = time * 0.5;
object.rotation.y = time * 0.2;
Expand Down Expand Up @@ -433,7 +433,6 @@
}

init();
animate();

</script>

Expand Down
20 changes: 10 additions & 10 deletions examples/webgl_clipping_stencil.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
};

init();
animate();

function createPlaneStencilGroup( geometry, plane, renderOrder ) {

Expand Down Expand Up @@ -211,20 +210,23 @@
ground.receiveShadow = true;
scene.add( ground );

// Stats
stats = new Stats();
document.body.appendChild( stats.dom );

// Renderer
renderer = new THREE.WebGLRenderer( { antialias: true, stencil: true } );
renderer.shadowMap.enabled = true;
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0x263238 );
window.addEventListener( 'resize', onWindowResize );
renderer.setAnimationLoop( animate );
renderer.shadowMap.enabled = true;
renderer.localClippingEnabled = true;
document.body.appendChild( renderer.domElement );

renderer.localClippingEnabled = true;
// Stats
stats = new Stats();
document.body.appendChild( stats.dom );

//

window.addEventListener( 'resize', onWindowResize );

// Controls
const controls = new OrbitControls( camera, renderer.domElement );
Expand Down Expand Up @@ -284,8 +286,6 @@

const delta = clock.getDelta();

requestAnimationFrame( animate );

if ( params.animate ) {

object.rotation.x += delta * 0.5;
Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_custom_attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
let displacement, noise;

init();
animate();

function init() {

Expand Down Expand Up @@ -128,6 +127,7 @@
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );

const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );
Expand All @@ -152,8 +152,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_custom_attributes_lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
loader.load( 'fonts/helvetiker_bold.typeface.json', function ( font ) {

init( font );
animate();

} );

Expand Down Expand Up @@ -146,6 +145,7 @@
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );

const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );
Expand All @@ -170,8 +170,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_custom_attributes_points.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
const HEIGHT = window.innerHeight;

init();
animate();

function init() {

Expand Down Expand Up @@ -145,6 +144,7 @@
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( WIDTH, HEIGHT );
renderer.setAnimationLoop( animate );

const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );
Expand All @@ -169,8 +169,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_custom_attributes_points2.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
const HEIGHT = window.innerHeight;

init();
animate();

function init() {

Expand Down Expand Up @@ -162,6 +161,7 @@
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( WIDTH, HEIGHT );
renderer.setAnimationLoop( animate );

const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );
Expand Down Expand Up @@ -251,8 +251,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_custom_attributes_points3.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
const HEIGHT = window.innerHeight;

init();
animate();

function init() {

Expand Down Expand Up @@ -237,6 +236,7 @@
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( WIDTH, HEIGHT );
renderer.setAnimationLoop( animate );

const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );
Expand All @@ -261,8 +261,6 @@

function animate() {

requestAnimationFrame( animate );

render();
stats.update();

Expand Down
4 changes: 1 addition & 3 deletions examples/webgl_decals.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
};

init();
animate();

function init() {

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

stats = new Stats();
Expand Down Expand Up @@ -293,8 +293,6 @@

function animate() {

requestAnimationFrame( animate );

renderer.render( scene, camera );

stats.update();
Expand Down
Loading
Loading