Skip to content

Commit

Permalink
Examples: Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 19, 2021
1 parent 7964d9d commit 1880f08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
13 changes: 3 additions & 10 deletions examples/webgl_mirror.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { Reflector } from './jsm/objects/Reflector.js';

// camera
const VIEW_ANGLE = 45;
let aspect = window.innerWidth / window.innerHeight;
const NEAR = 1;
const FAR = 500;

let camera, scene, renderer;

let cameraControls;
Expand All @@ -58,7 +52,7 @@
scene = new THREE.Scene();

// camera
camera = new THREE.PerspectiveCamera( VIEW_ANGLE, aspect, NEAR, FAR );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 );
camera.position.set( 0, 75, 160 );

cameraControls = new OrbitControls( camera, renderer.domElement );
Expand Down Expand Up @@ -166,14 +160,13 @@
blueLight.position.set( 0, 50, 550 );
scene.add( blueLight );

window.addEventListener( "resize", onWindowResize, false );
window.addEventListener( 'resize', onWindowResize, false );

}

function onWindowResize() {

aspect = window.innerWidth / window.innerHeight;
camera.aspect = aspect;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();

renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
25 changes: 9 additions & 16 deletions examples/webgl_mirror_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
NormalMapNode,
} from './jsm/nodes/Nodes.js';

// camera
const VIEW_ANGLE = 45;
let aspect = window.innerWidth / window.innerHeight;
const NEAR = 1;
const FAR = 500;

const decalNormal = new THREE.TextureLoader().load( 'textures/decal/decal-normal.jpg' );

const decalDiffuse = new THREE.TextureLoader().load( 'textures/decal/decal-diffuse.png' );
Expand Down Expand Up @@ -78,7 +72,7 @@
scene = new THREE.Scene();

// camera
camera = new THREE.PerspectiveCamera( VIEW_ANGLE, aspect, NEAR, FAR );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 );
camera.position.set( 0, 75, 160 );

cameraControls = new OrbitControls( camera, renderer.domElement );
Expand All @@ -90,14 +84,13 @@
const container = document.getElementById( 'container' );
container.appendChild( renderer.domElement );

window.addEventListener( "resize", onWindowResize, false );
window.addEventListener( 'resize', onWindowResize, false );

}

function onWindowResize() {

aspect = window.innerWidth / window.innerHeight;
camera.aspect = aspect;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();

renderer.setSize( window.innerWidth, window.innerHeight );
Expand All @@ -111,8 +104,8 @@
window.innerWidth * window.devicePixelRatio,
window.innerHeight * window.devicePixelRatio
);
blurMirror.updateFrame()
blurMirror.updateFrame();

}

function fillScene() {
Expand Down Expand Up @@ -157,11 +150,11 @@
window.innerWidth * window.devicePixelRatio,
window.innerHeight * window.devicePixelRatio
);
blurMirror.uv = new ExpressionNode( "projCoord.xyz / projCoord.q", "vec3" );
blurMirror.uv.keywords[ "projCoord" ] = new OperatorNode( mirror.offset, mirror.uv, OperatorNode.ADD );
blurMirror.uv = new ExpressionNode( 'projCoord.xyz / projCoord.q', 'vec3' );
blurMirror.uv.keywords[ 'projCoord' ] = new OperatorNode( mirror.offset, mirror.uv, OperatorNode.ADD );
blurMirror.radius.x = blurMirror.radius.y = 0;

gui.add( { blur: blurMirror.radius.x }, "blur", 0, 25 ).onChange( function ( v ) {
gui.add( { blur: blurMirror.radius.x }, 'blur', 0, 25 ).onChange( function ( v ) {

blurMirror.radius.x = blurMirror.radius.y = v;

Expand Down

0 comments on commit 1880f08

Please sign in to comment.