+1
-24
src/viewer.js
+1
-24
src/viewer.js
···
8
8
DirectionalLight,
9
9
GridHelper,
10
10
HemisphereLight,
11
-
LinearEncoding,
12
11
LoaderUtils,
13
12
LoadingManager,
14
13
PMREMGenerator,
···
80
79
punctualLights: true,
81
80
exposure: 0.0,
82
81
toneMapping: LinearToneMapping,
83
-
textureEncoding: 'sRGB',
84
82
ambientIntensity: 0.3,
85
83
ambientColor: 0xFFFFFF,
86
84
directIntensity: 0.8 * Math.PI, // TODO(#116)
···
107
105
this.scene.add( this.defaultCamera );
108
106
109
107
this.renderer = window.renderer = new WebGLRenderer({antialias: true});
110
-
this.renderer.physicallyCorrectLights = true;
108
+
this.renderer.useLegacyLights = false;
111
109
this.renderer.outputEncoding = sRGBEncoding;
112
110
this.renderer.setClearColor( 0xcccccc );
113
111
this.renderer.setPixelRatio( window.devicePixelRatio );
···
315
313
this.updateLights();
316
314
this.updateGUI();
317
315
this.updateEnvironment();
318
-
this.updateTextureEncoding();
319
316
this.updateDisplay();
320
317
321
318
window.VIEWER.scene = this.content;
···
372
369
}
373
370
}
374
371
375
-
updateTextureEncoding () {
376
-
const encoding = this.state.textureEncoding === 'sRGB'
377
-
? sRGBEncoding
378
-
: LinearEncoding;
379
-
traverseMaterials(this.content, (material) => {
380
-
if (material.map) material.map.encoding = encoding;
381
-
if (material.emissiveMap) material.emissiveMap.encoding = encoding;
382
-
if (material.map || material.emissiveMap) material.needsUpdate = true;
383
-
});
384
-
}
385
-
386
372
updateLights () {
387
373
const state = this.state;
388
374
const lights = this.lights;
···
570
556
571
557
// Lighting controls.
572
558
const lightFolder = gui.addFolder('Lighting');
573
-
const encodingCtrl = lightFolder.add(this.state, 'textureEncoding', ['sRGB', 'Linear']);
574
-
encodingCtrl.onChange(() => this.updateTextureEncoding());
575
-
lightFolder.add(this.renderer, 'outputEncoding', {sRGB: sRGBEncoding, Linear: LinearEncoding})
576
-
.onChange(() => {
577
-
this.renderer.outputEncoding = Number(this.renderer.outputEncoding);
578
-
traverseMaterials(this.content, (material) => {
579
-
material.needsUpdate = true;
580
-
});
581
-
});
582
559
const envMapCtrl = lightFolder.add(this.state, 'environment', environments.map((env) => env.name));
583
560
envMapCtrl.onChange(() => this.updateEnvironment());
584
561
[