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

Remove .is checks in UniformUtils #24202

Closed
wants to merge 2 commits into from
Closed

Conversation

LeviPesin
Copy link
Contributor

@LeviPesin LeviPesin commented Jun 7, 2022

Related issue: #24199 (comment)

Description

Remove .is checks in the UniformUtils, instead use "check by method" (duck typing).

@LeviPesin
Copy link
Contributor Author

LeviPesin commented Jun 7, 2022

Also, Array.isArray( property ) can be also changed to property.slice !== undefined for more readability... Should I do that?

So it is something like this:

if ( property && property.clone !== undefined ) {

    clonedProperty = property.clone();

} else if ( property && property.slice !== undefined ) {

    clonedProperty = property.slice();

} else {

    clonedProperty = property;

}

And if I remember correctly, similar code is actually used in other places of the Three.js codebase... (I have found only https://github.com/mrdoob/three.js/blob/dev/src/core/Uniform.js#L18).

@donmccurdy
Copy link
Collaborator

donmccurdy commented Jun 7, 2022

It's nice that this change is shorter than the original, so I'm OK with this PR, but let's not remove .is properties generally please. See #24199 (comment)

Array.isArray( property ) can be also changed to property.slice !== undefined for more readability... Should I do that?

Personally I find Array.isArray( property ) easier to read.

@mrdoob
Copy link
Owner

mrdoob commented Jun 8, 2022

This seems better: #24199 (comment)

@Mugen87 Mugen87 closed this Jun 8, 2022
@LeviPesin LeviPesin deleted the patch-1 branch June 9, 2022 10:23
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.

4 participants