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

fix: 🐛 Fix issue with setting 0 or false values #1766

Conversation

Seungup
Copy link
Collaborator

@Seungup Seungup commented Jul 15, 2023

The change involves replacing the logical OR operator (||) with the nullish coalescing operator (??) in the _applyUniforms() method. This modification addresses a specific issue where 0 or false values were not being correctly assigned. By using the nullish coalescing operator, the code ensures that if the value of this.uniforms[name] is either 0 or false, it will be properly assigned as the value for value. This change enhances the accuracy and reliability of the code by handling these specific cases effectively.

Closes: #1741

For #1741

Background

The issue with the original code was that it did not handle 0 and false values correctly when assigning them to uniforms. This resulted in unexpected behavior when attempting to set these values. The change to use the nullish coalescing operator ensures that 0 and false values are properly assigned.

Change List

  • Replaced logical OR operator (||) with nullish coalescing operator (??) in the _applyUniforms() method to handle 0 and false values correctly when assigning them to uniforms.

The change involves replacing the logical OR operator (`||`) with the
nullish coalescing operator (`??`) in the `_applyUniforms()` method.
This modification addresses a specific issue where 0 or false values
were not being correctly assigned. By using the nullish coalescing
operator, the code ensures that if the value of `this.uniforms[name]` is
either 0 or false, it will be properly assigned as the value for
`value`. This change enhances the accuracy and reliability of the code
by handling these specific cases effectively.

✅ Closes: #1741
@Seungup Seungup added the bug label Jul 15, 2023
@Seungup Seungup self-assigned this Jul 15, 2023
@Seungup Seungup linked an issue Jul 15, 2023 that may be closed by this pull request
8 tasks
@Seungup
Copy link
Collaborator Author

Seungup commented Jul 15, 2023

PS: Uniform object type is Record<string, any>

Personally, I think there is a need for the type to be defined as follows.

export type UniformValue = number | boolean | number[] | boolean[];

@Seungup Seungup assigned ibgreen and unassigned Seungup Jul 16, 2023
@Seungup Seungup requested a review from ibgreen July 16, 2023 22:45
@Seungup Seungup assigned Seungup and unassigned ibgreen Jul 16, 2023
@ibgreen ibgreen merged commit f0b8361 into master Jul 17, 2023
1 check passed
@ibgreen ibgreen deleted the 1741-cannot-set-a-value-of-false-or-0-for-uniform-on-version-900-alpha15 branch July 17, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot set a value of false, or 0 for uniform on version 9.0.0-alpha.15
2 participants