@@ -867,12 +867,11 @@ const extractTextureTransform = (source, material, maps) => {
867867} ;
868868
869869const extensionPbrSpecGlossiness = ( data , material , textures ) => {
870- let color , texture ;
870+ let texture ;
871871 if ( data . hasOwnProperty ( 'diffuseFactor' ) ) {
872- color = data . diffuseFactor ;
873- // Convert from linear space to sRGB space
874- material . diffuse . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
875- material . opacity = color [ 3 ] ;
872+ const [ r , g , b , a ] = data . diffuseFactor ;
873+ material . diffuse . set ( r , g , b ) . gamma ( ) ;
874+ material . opacity = a ;
876875 } else {
877876 material . diffuse . set ( 1 , 1 , 1 ) ;
878877 material . opacity = 1 ;
@@ -890,9 +889,8 @@ const extensionPbrSpecGlossiness = (data, material, textures) => {
890889 }
891890 material . useMetalness = false ;
892891 if ( data . hasOwnProperty ( 'specularFactor' ) ) {
893- color = data . specularFactor ;
894- // Convert from linear space to sRGB space
895- material . specular . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
892+ const [ r , g , b ] = data . specularFactor ;
893+ material . specular . set ( r , g , b ) . gamma ( ) ;
896894 } else {
897895 material . specular . set ( 1 , 1 , 1 ) ;
898896 }
@@ -986,8 +984,8 @@ const extensionSpecular = (data, material, textures) => {
986984 }
987985
988986 if ( data . hasOwnProperty ( 'specularColorFactor' ) ) {
989- const color = data . specularColorFactor ;
990- material . specular . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
987+ const [ r , g , b ] = data . specularColorFactor ;
988+ material . specular . set ( r , g , b ) . gamma ( ) ;
991989 } else {
992990 material . specular . set ( 1 , 1 , 1 ) ;
993991 }
@@ -1034,8 +1032,8 @@ const extensionTransmission = (data, material, textures) => {
10341032const extensionSheen = ( data , material , textures ) => {
10351033 material . useSheen = true ;
10361034 if ( data . hasOwnProperty ( 'sheenColorFactor' ) ) {
1037- const color = data . sheenColorFactor ;
1038- material . sheen . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
1035+ const [ r , g , b ] = data . sheenColorFactor ;
1036+ material . sheen . set ( r , g , b ) . gamma ( ) ;
10391037 } else {
10401038 material . sheen . set ( 1 , 1 , 1 ) ;
10411039 }
@@ -1070,8 +1068,8 @@ const extensionVolume = (data, material, textures) => {
10701068 material . attenuationDistance = data . attenuationDistance ;
10711069 }
10721070 if ( data . hasOwnProperty ( 'attenuationColor' ) ) {
1073- const color = data . attenuationColor ;
1074- material . attenuation . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
1071+ const [ r , g , b ] = data . attenuationColor ;
1072+ material . attenuation . set ( r , g , b ) . gamma ( ) ;
10751073 }
10761074} ;
10771075
@@ -1150,15 +1148,14 @@ const createMaterial = (gltfMaterial, textures) => {
11501148 material . glossInvert = true ;
11511149 material . useMetalness = true ;
11521150
1153- let color , texture ;
1151+ let texture ;
11541152 if ( gltfMaterial . hasOwnProperty ( 'pbrMetallicRoughness' ) ) {
11551153 const pbrData = gltfMaterial . pbrMetallicRoughness ;
11561154
11571155 if ( pbrData . hasOwnProperty ( 'baseColorFactor' ) ) {
1158- color = pbrData . baseColorFactor ;
1159- // Convert from linear space to sRGB space
1160- material . diffuse . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
1161- material . opacity = color [ 3 ] ;
1156+ const [ r , g , b , a ] = pbrData . baseColorFactor ;
1157+ material . diffuse . set ( r , g , b ) . gamma ( ) ;
1158+ material . opacity = a ;
11621159 }
11631160 if ( pbrData . hasOwnProperty ( 'baseColorTexture' ) ) {
11641161 const baseColorTexture = pbrData . baseColorTexture ;
@@ -1208,9 +1205,8 @@ const createMaterial = (gltfMaterial, textures) => {
12081205 }
12091206
12101207 if ( gltfMaterial . hasOwnProperty ( 'emissiveFactor' ) ) {
1211- color = gltfMaterial . emissiveFactor ;
1212- // Convert from linear space to sRGB space
1213- material . emissive . set ( Math . pow ( color [ 0 ] , 1 / 2.2 ) , Math . pow ( color [ 1 ] , 1 / 2.2 ) , Math . pow ( color [ 2 ] , 1 / 2.2 ) ) ;
1208+ const [ r , g , b ] = gltfMaterial . emissiveFactor ;
1209+ material . emissive . set ( r , g , b ) . gamma ( ) ;
12141210 }
12151211
12161212 if ( gltfMaterial . hasOwnProperty ( 'emissiveTexture' ) ) {
0 commit comments