Skip to content

Commit

Permalink
Node: Add increaseUsage() (#27672)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Feb 4, 2024
1 parent ff4f0ad commit bfe2874
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions examples/jsm/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,20 @@ class Node extends EventDispatcher {

}

analyze( builder ) {
increaseUsage( builder ) {

const nodeData = builder.getDataFromNode( this );
nodeData.dependenciesCount = nodeData.dependenciesCount === undefined ? 1 : nodeData.dependenciesCount + 1;
nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;

return nodeData.usageCount;

}

analyze( builder ) {

const usageCount = this.increaseUsage( builder );

if ( nodeData.dependenciesCount === 1 ) {
if ( usageCount === 1 ) {

// node flow children

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/TempNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TempNode extends Node {

hasDependencies( builder ) {

return builder.getDataFromNode( this ).dependenciesCount > 1;
return builder.getDataFromNode( this ).usageCount > 1;

}

Expand Down

0 comments on commit bfe2874

Please sign in to comment.