Skip to content

Commit

Permalink
Explicitly set r, g, b in setRGB calls (#26691)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlinna authored Sep 4, 2023
1 parent 55783cc commit d930553
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class GLTFLightsExtension {

const color = new Color( 0xffffff );

if ( lightDef.color !== undefined ) color.setRGB( ...lightDef.color, LinearSRGBColorSpace );
if ( lightDef.color !== undefined ) color.setRGB( lightDef.color[ 0 ], lightDef.color[ 1 ], lightDef.color[ 2 ], LinearSRGBColorSpace );

const range = lightDef.range !== undefined ? lightDef.range : 0;

Expand Down Expand Up @@ -665,7 +665,7 @@ class GLTFMaterialsUnlitExtension {

const array = metallicRoughness.baseColorFactor;

materialParams.color.setRGB( ...array, LinearSRGBColorSpace );
materialParams.color.setRGB( array[ 0 ], array[ 1 ], array[ 2 ], LinearSRGBColorSpace );
materialParams.opacity = array[ 3 ];

}
Expand Down Expand Up @@ -941,7 +941,8 @@ class GLTFMaterialsSheenExtension {

if ( extension.sheenColorFactor !== undefined ) {

materialParams.sheenColor.setRGB( ...extension.sheenColorFactor, LinearSRGBColorSpace );
const colorFactor = extension.sheenColorFactor;
materialParams.sheenColor.setRGB( colorFactor[ 0 ], colorFactor[ 1 ], colorFactor [ 2 ], LinearSRGBColorSpace );

}

Expand Down Expand Up @@ -1079,7 +1080,7 @@ class GLTFMaterialsVolumeExtension {
materialParams.attenuationDistance = extension.attenuationDistance || Infinity;

const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
materialParams.attenuationColor = new Color().setRGB( ...colorArray, LinearSRGBColorSpace );
materialParams.attenuationColor = new Color().setRGB( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ], LinearSRGBColorSpace );

return Promise.all( pending );

Expand Down Expand Up @@ -1182,7 +1183,7 @@ class GLTFMaterialsSpecularExtension {
}

const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
materialParams.specularColor = new Color().setRGB( ...colorArray, LinearSRGBColorSpace );
materialParams.specularColor = new Color().setRGB( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ], LinearSRGBColorSpace );

if ( extension.specularColorTexture !== undefined ) {

Expand Down Expand Up @@ -3480,7 +3481,8 @@ class GLTFParser {

if ( materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial ) {

materialParams.emissive = new Color().setRGB( ...materialDef.emissiveFactor, LinearSRGBColorSpace );
const emissiveFactor = materialDef.emissiveFactor;
materialParams.emissive = new Color().setRGB( emissiveFactor[ 0 ], emissiveFactor[ 1 ], emissiveFactor[ 2 ], LinearSRGBColorSpace );

}

Expand Down

0 comments on commit d930553

Please sign in to comment.