Skip to content
Merged
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
35 changes: 14 additions & 21 deletions examples/webgl_materials_physical_transmission.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import * as THREE from '../build/three.module.js';

import Stats from './jsm/libs/stats.module.js';

import { GUI } from './jsm/libs/dat.gui.module.js';
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { RGBELoader } from './jsm/loaders/RGBELoader.js';
Expand All @@ -33,7 +31,6 @@
exposure: 1
};

let container, stats;
let camera, scene, renderer;

let hdrCubeRenderTarget;
Expand All @@ -45,20 +42,17 @@
.load( 'royal_esplanade_1k.hdr', function () {

init();
animate();
render();

} );

function init() {

container = document.createElement( 'div' );
document.body.appendChild( container );

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

renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = params.exposure;
Expand Down Expand Up @@ -108,10 +102,8 @@

//

stats = new Stats();
container.appendChild( stats.dom );

const controls = new OrbitControls( camera, renderer.domElement );
controls.addEventListener( 'change', render ); // use if there is no animation loop
controls.minDistance = 10;
controls.maxDistance = 150;

Expand All @@ -125,41 +117,47 @@
.onChange( function () {

material.color.set( params.color );
render();

} );

gui.add( params, 'transmission', 0, 1, 0.01 )
.onChange( function () {

material.transmission = params.transmission;
render();

} );

gui.add( params, 'opacity', 0, 1, 0.01 )
.onChange( function () {

material.opacity = params.opacity;
render();

} );

gui.add( params, 'metalness', 0, 1, 0.01 )
.onChange( function () {

material.metalness = params.metalness;
render();

} );

gui.add( params, 'roughness', 0, 1, 0.01 )
.onChange( function () {

material.roughness = params.roughness;
render();

} );

gui.add( params, 'reflectivity', 0, 1, 0.01 )
.onChange( function () {

material.reflectivity = params.reflectivity;
render();

} );

Expand All @@ -168,13 +166,15 @@
.onChange( function () {

material.envMapIntensity = params.envMapIntensity;
render();

} );

gui.add( params, 'exposure', 0, 1, 0.01 )
.onChange( function () {

renderer.toneMappingExposure = params.exposure;
render();

} );

Expand All @@ -192,6 +192,8 @@

renderer.setSize( width, height );

render();

}

//
Expand All @@ -210,18 +212,9 @@

}

function animate() {

requestAnimationFrame( animate );

//const t = performance.now();

//mesh.rotation.x = t * 0.0002;
//mesh.rotation.z = - t * 0.0002;
function render() {

stats.begin();
renderer.render( scene, camera );
stats.end();

}

Expand Down