Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader: Explicitly set r, g, b in setRGB() calls. #26691

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

wlinna
Copy link
Contributor

@wlinna wlinna commented Sep 4, 2023

Related issue: #26534 (comment)

Description

Since r156, GLTFLoader has used array spread syntax (...) to call setRGB. This can lead to the fourth argument (typically opacity) of an array to be passed as an argument to the colorSpace parameter. The actual color space argument LinearSRGBColorSpace is ignored.

This PR passes arguments for r, g, b parameters explicitly, i.e. instead of

setRGB( ...array, LinearSRGBColorSpace)

we call

setRGB( array[ 0 ], array [ 1 ], array[ 2 ], LinearSRGBColorSpace)

@Mugen87 Mugen87 changed the title Explicitly set r, g, b in setRGB calls GLTFLoader: Explicitly set r, g, b in setRGB() calls. Sep 4, 2023
Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, my mistake here – thank you!

@@ -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 );
Copy link
Collaborator

@donmccurdy donmccurdy Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all of the spread operations are technically safe, except this one – the other factors do not allow >3 components. For consistency and safety perhaps it's better that we write them all this way though, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants