Skip to content

Commit

Permalink
Docs: Implemented scene.environment in material browser
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Mar 24, 2021
1 parent f9a3638 commit ec5926a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions docs/scenes/material-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import * as THREE from '../../build/three.module.js';
import * as DAT from '../../examples/jsm/libs/dat.gui.module.js';
import { RoomEnvironment } from '../../examples/jsm/environments/RoomEnvironment.js';

const constants = {

Expand Down Expand Up @@ -650,6 +651,12 @@
guiMaterial( gui, mesh, material, geometry );
guiMeshStandardMaterial( gui, mesh, material, geometry );

// only use scene environment

light1.visible = false;
light2.visible = false;
light3.visible = false;

return material;

break;
Expand All @@ -660,6 +667,12 @@
guiMaterial( gui, mesh, material, geometry );
guiMeshPhysicalMaterial( gui, mesh, material, geometry );

// only use scene environment

light1.visible = false;
light2.visible = false;
light3.visible = false;

return material;

break;
Expand Down Expand Up @@ -704,17 +717,22 @@

const gui = new DAT.GUI();

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

const environment = new RoomEnvironment();
const pmremGenerator = new THREE.PMREMGenerator( renderer );

const scene = new THREE.Scene();
scene.background = new THREE.Color( 0x444444 );
scene.environment = pmremGenerator.fromScene( environment ).texture;

const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 10, 50 );
camera.position.z = 30;

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

const ambientLight = new THREE.AmbientLight( 0x000000 );
scene.add( ambientLight );

Expand Down

0 comments on commit ec5926a

Please sign in to comment.