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: Clean up. #26934

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 28 additions & 8 deletions examples/webgl_postprocessing_smaa.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
import * as THREE from 'three';

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

import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { SMAAPass } from 'three/addons/postprocessing/SMAAPass.js';
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';

let camera, scene, renderer, composer, stats, smaaPass;

let camera, scene, renderer, composer, stats;
const params = {
enabled: true,
autoRotate: true

};

init();
animate();
Expand Down Expand Up @@ -66,7 +72,7 @@
scene.add( mesh1 );

const texture = new THREE.TextureLoader().load( 'textures/brick_diffuse.jpg' );
texture.anisotropy = 4;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
texture.colorSpace = THREE.SRGBColorSpace;

const material2 = new THREE.MeshBasicMaterial( { map: texture } );
Expand All @@ -80,14 +86,22 @@
composer = new EffectComposer( renderer );
composer.addPass( new RenderPass( scene, camera ) );

const pass = new SMAAPass( window.innerWidth * renderer.getPixelRatio(), window.innerHeight * renderer.getPixelRatio() );
composer.addPass( pass );
smaaPass = new SMAAPass( window.innerWidth * renderer.getPixelRatio(), window.innerHeight * renderer.getPixelRatio() );
composer.addPass( smaaPass );

const outputPass = new OutputPass();
composer.addPass( outputPass );

window.addEventListener( 'resize', onWindowResize );

const gui = new GUI();

const smaaFolder = gui.addFolder( 'SMAA' );
smaaFolder.add( params, 'enabled' );

const sceneFolder = gui.addFolder( 'Scene' );
sceneFolder.add( params, 'autoRotate' );

}

function onWindowResize() {
Expand All @@ -109,15 +123,21 @@

stats.begin();

for ( let i = 0; i < scene.children.length; i ++ ) {
if ( params.autoRotate === true ) {

const child = scene.children[ i ];
for ( let i = 0; i < scene.children.length; i ++ ) {

child.rotation.x += 0.005;
child.rotation.y += 0.01;
const child = scene.children[ i ];

child.rotation.x += 0.005;
child.rotation.y += 0.01;

}

}

smaaPass.enabled = params.enabled;

composer.render();

stats.end();
Expand Down