Skip to content

Commit

Permalink
ShaderNode: Share nodeObjects (#23226)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Jan 13, 2022
1 parent c9daf11 commit 09eca6d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/jsm/renderers/nodes/ShaderNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const NodeHandler = {

};

const nodeObjects = new WeakMap();

const ShaderNodeObject = ( obj ) => {

const type = typeof obj;
Expand All @@ -81,16 +83,17 @@ const ShaderNodeObject = ( obj ) => {

if ( obj.isNode === true ) {

const node = obj;

if ( node.isProxyNode !== true ) {
let nodeObject = nodeObjects.get( obj );

node.isProxyNode = true;
if ( nodeObject === undefined ) {

return new Proxy( node, NodeHandler );
nodeObject = new Proxy( obj, NodeHandler );
nodeObjects.set( obj, nodeObject );

}

return nodeObject;

}

}
Expand Down

0 comments on commit 09eca6d

Please sign in to comment.