diff --git a/src/nodes/core/NodeBuilder.js b/src/nodes/core/NodeBuilder.js index 0ec7cdc2054f21..84399cd53be449 100644 --- a/src/nodes/core/NodeBuilder.js +++ b/src/nodes/core/NodeBuilder.js @@ -1636,7 +1636,7 @@ class NodeBuilder { */ getStructTypeFromNode( node, membersLayout, name = null, shaderStage = this.shaderStage ) { - const nodeData = this.getDataFromNode( node, shaderStage ); + const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache ); let structType = nodeData.structType; @@ -2047,6 +2047,22 @@ class NodeBuilder { } + /** + * Includes a node in the current function node. + * + * @param {Node} node - The node to include. + * @returns {void} + */ + addInclude( node ) { + + if ( this.currentFunctionNode !== null ) { + + this.currentFunctionNode.includes.push( node ); + + } + + } + /** * Returns the native shader operator name for a given generic name. * It is a similar type of method like {@link NodeBuilder#getMethod}. diff --git a/src/nodes/core/StructTypeNode.js b/src/nodes/core/StructTypeNode.js index 5672690188e084..0e362c39405850 100644 --- a/src/nodes/core/StructTypeNode.js +++ b/src/nodes/core/StructTypeNode.js @@ -116,6 +116,12 @@ class StructTypeNode extends Node { } + setup( builder ) { + + builder.addInclude( this ); + + } + generate( builder ) { return this.getNodeType( builder ); diff --git a/src/nodes/tsl/TSLCore.js b/src/nodes/tsl/TSLCore.js index 94f02a851d1e01..f6712271f30775 100644 --- a/src/nodes/tsl/TSLCore.js +++ b/src/nodes/tsl/TSLCore.js @@ -307,11 +307,7 @@ class ShaderCallNodeInternal extends Node { } - if ( builder.currentFunctionNode !== null ) { - - builder.currentFunctionNode.includes.push( functionNode ); - - } + builder.addInclude( functionNode ); result = nodeObject( functionNode.call( inputNodes ) );