File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 88 MeshPhongMaterial ,
99 RepeatWrapping ,
1010 TextureLoader ,
11- Vector2
11+ Vector2 ,
12+ sRGBEncoding
1213} from 'three' ;
1314
1415/**
@@ -358,6 +359,12 @@ class MaterialCreator {
358359 map . wrapS = scope . wrap ;
359360 map . wrapT = scope . wrap ;
360361
362+ if ( mapType === 'map' || mapType === 'emissiveMap' ) {
363+
364+ map . encoding = sRGBEncoding ;
365+
366+ }
367+
361368 params [ mapType ] = map ;
362369
363370 }
@@ -377,21 +384,21 @@ class MaterialCreator {
377384
378385 // Diffuse color (color under white light) using RGB values
379386
380- params . color = new Color ( ) . fromArray ( value ) ;
387+ params . color = new Color ( ) . fromArray ( value ) . convertSRGBToLinear ( ) ;
381388
382389 break ;
383390
384391 case 'ks' :
385392
386393 // Specular color (color when light is reflected from shiny surface) using RGB values
387- params . specular = new Color ( ) . fromArray ( value ) ;
394+ params . specular = new Color ( ) . fromArray ( value ) . convertSRGBToLinear ( ) ;
388395
389396 break ;
390397
391398 case 'ke' :
392399
393400 // Emissive using RGB values
394- params . emissive = new Color ( ) . fromArray ( value ) ;
401+ params . emissive = new Color ( ) . fromArray ( value ) . convertSRGBToLinear ( ) ;
395402
396403 break ;
397404
Original file line number Diff line number Diff line change 105105 //
106106
107107 renderer = new THREE . WebGLRenderer ( ) ;
108+ renderer . outputEncoding = THREE . sRGBEncoding ;
108109 renderer . setPixelRatio ( window . devicePixelRatio ) ;
109110 renderer . setSize ( window . innerWidth , window . innerHeight ) ;
110111 container . appendChild ( renderer . domElement ) ;
You can’t perform that action at this time.
0 commit comments