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

AttributeNode: .nodeType is now optional #24050

Merged
merged 4 commits into from
May 12, 2022

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented May 12, 2022

Description

Usage:

// auto node type
material.colorNode = attribute( 'color' );

// declared node type
material.colorNode = attribute( 'color', 'vec3' );

This contribution is funded by Google via Igalia

@sunag sunag added this to the r141 milestone May 12, 2022
@@ -108,7 +108,7 @@ export const uniform = ( nodeOrType ) => {

};

export const attribute = ( name, nodeOrType ) => nodeObject( new AttributeNode( name, getConstNodeType( nodeOrType ) ) );
export const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better to just make getConstNodeType return undefined if input is undefined.

Copy link
Collaborator Author

@sunag sunag May 12, 2022

Choose a reason for hiding this comment

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

What kind of use did you imagine when you implemented this function? For this case, I see only 3 type of usage:

// name only
attribute( 'color' );

// typed
attribute( 'color', 'vec3' );

// typed from primitive class
attribute( 'color', vec3 );

Copy link
Contributor

Choose a reason for hiding this comment

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

It can handle attribute( 'color' ) (if make that change), attribute( 'color', 'vec3' ) and attribute( 'color', vec3() ). Did not thought about attribute( 'color', vec3 ), but it can also be easily added.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did not thought about attribute( 'color', vec3 ), but it can also be easily added.

Nice, is better use attribute( 'color', vec3 ) instead of attribute( 'color', vec3() ) because it's not allocate unnecessary object in memory. attribute( 'color', vec3() ) shouldn't have support.

@sunag sunag merged commit c17fd6c into mrdoob:dev May 12, 2022
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
* NodeBuilder: add .geometry property

* AttributeNode: .nodeType is now optional

* attribute: use optional node type parameter

* fix nodeType parameter
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.

None yet

2 participants