@@ -28,6 +28,7 @@ import {
2828 Scene ,
2929 ShapeUtils ,
3030 SphereGeometry ,
31+ SRGBColorSpace ,
3132 TextureLoader ,
3233 Vector2 ,
3334 Vector3
@@ -1370,6 +1371,7 @@ class VRMLLoader extends Loader {
13701371 }
13711372
13721373 texture = new DataTexture ( data , width , height ) ;
1374+ texture . colorSpace = SRGBColorSpace ;
13731375 texture . needsUpdate = true ;
13741376 texture . __type = textureType ; // needed for material modifications
13751377 break ;
@@ -1442,6 +1444,7 @@ class VRMLLoader extends Loader {
14421444
14431445 texture . wrapS = wrapS ;
14441446 texture . wrapT = wrapT ;
1447+ texture . colorSpace = SRGBColorSpace ;
14451448
14461449 }
14471450
@@ -1700,6 +1703,8 @@ class VRMLLoader extends Loader {
17001703
17011704 }
17021705
1706+ convertColorsToLinearSRGB ( colorAttribute ) ;
1707+
17031708 }
17041709
17051710 if ( normal ) {
@@ -1901,6 +1906,8 @@ class VRMLLoader extends Loader {
19011906
19021907 }
19031908
1909+ convertColorsToLinearSRGB ( colorAttribute ) ;
1910+
19041911 }
19051912
19061913 //
@@ -1966,7 +1973,15 @@ class VRMLLoader extends Loader {
19661973 const geometry = new BufferGeometry ( ) ;
19671974
19681975 geometry . setAttribute ( 'position' , new Float32BufferAttribute ( coord , 3 ) ) ;
1969- if ( color ) geometry . setAttribute ( 'color' , new Float32BufferAttribute ( color , 3 ) ) ;
1976+
1977+ if ( color ) {
1978+
1979+ const colorAttribute = new Float32BufferAttribute ( color , 3 ) ;
1980+ convertColorsToLinearSRGB ( colorAttribute ) ;
1981+
1982+ geometry . setAttribute ( 'color' , colorAttribute ) ;
1983+
1984+ }
19701985
19711986 geometry . _type = 'points' ;
19721987
@@ -2380,6 +2395,8 @@ class VRMLLoader extends Loader {
23802395
23812396 }
23822397
2398+ convertColorsToLinearSRGB ( colorAttribute ) ;
2399+
23832400 }
23842401
23852402 // normal attribute
@@ -3067,6 +3084,21 @@ class VRMLLoader extends Loader {
30673084
30683085 }
30693086
3087+ function convertColorsToLinearSRGB ( attribute ) {
3088+
3089+ const color = new Color ( ) ;
3090+
3091+ for ( let i = 0 ; i < attribute . count ; i ++ ) {
3092+
3093+ color . fromBufferAttribute ( attribute , i ) ;
3094+ color . convertSRGBToLinear ( ) ;
3095+
3096+ attribute . setXYZ ( i , color . r , color . g , color . b ) ;
3097+
3098+ }
3099+
3100+ }
3101+
30703102 /**
30713103 * Vertically paints the faces interpolating between the
30723104 * specified colors at the specified angels. This is used for the Background
@@ -3164,7 +3196,7 @@ class VRMLLoader extends Loader {
31643196 const colorA = colors [ thresholdIndexA ] ;
31653197 const colorB = colors [ thresholdIndexB ] ;
31663198
3167- color . copy ( colorA ) . lerp ( colorB , t ) ;
3199+ color . copy ( colorA ) . lerp ( colorB , t ) . convertSRGBToLinear ( ) ;
31683200
31693201 colorAttribute . setXYZ ( index , color . r , color . g , color . b ) ;
31703202
0 commit comments