Skip to content

Commit a152f08

Browse files
committed
Update example for Three.js and glTF Loader
1 parent 869b346 commit a152f08

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

examples/threejs/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ var gltf = null;
2323
var mixer = null;
2424
var clock = new THREE.Clock();
2525
var axis;
26+
var hemispheric;
2627
var gui;
28+
2729
var ROTATE = true;
2830
var AXIS = true;
31+
var LIGHTS = true;
32+
var SKYBOX = true;
33+
2934
var scene;
3035
var camera;
3136
var renderer;
3237
var controls;
38+
var envMap;
3339

3440
init();
3541
animate();
@@ -48,7 +54,7 @@ function resize() {
4854
function init() {
4955
scene = new THREE.Scene();
5056

51-
var hemispheric = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.2 );
57+
hemispheric = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.2 );
5258
scene.add(hemispheric);
5359
/*
5460
var ambient = new THREE.AmbientLight( 0xffffff, 0.3 );
@@ -104,7 +110,7 @@ function init() {
104110
}
105111
}
106112

107-
var envMap = getEnvMap();
113+
envMap = getEnvMap();
108114
object.traverse( function( node ) {
109115
if ( node.isMesh ) {
110116
var materials = Array.isArray( node.material ) ? node.material : [ node.material ];
@@ -143,13 +149,21 @@ function init() {
143149
gui = new dat.GUI();
144150
var guiRotate = gui.add(window, 'ROTATE').name('Rotate');
145151
var guiAxis = gui.add(window, 'AXIS').name('Axis');
152+
var guiLights = gui.add(window, 'LIGHTS').name('Lights');
153+
var guiSkybox = gui.add(window, 'SKYBOX').name('IBL');
146154

147155
guiRotate.onChange(function (value) {
148156
controls.autoRotate = value;
149157
});
150158
guiAxis.onChange(function (value) {
151159
axis.visible = value;
152160
});
161+
guiLights.onChange(function (value) {
162+
hemispheric.visible = value;
163+
});
164+
guiSkybox.onChange(function (value) {
165+
scene.background = value ? envMap : null;
166+
});
153167

154168
document.body.appendChild( renderer.domElement );
155169

0 commit comments

Comments
 (0)