diff --git a/src/nodes/code/CodeNode.js b/src/nodes/code/CodeNode.js index b878972e67c85a..1d731e7f55e9c1 100644 --- a/src/nodes/code/CodeNode.js +++ b/src/nodes/code/CodeNode.js @@ -120,6 +120,8 @@ class CodeNode extends Node { data.code = this.code; data.language = this.language; + return data; + } deserialize( data ) { @@ -128,6 +130,9 @@ class CodeNode extends Node { this.code = data.code; this.language = data.language; + this.includes = data.includes || []; + + return this; } diff --git a/src/nodes/code/FunctionNode.js b/src/nodes/code/FunctionNode.js index d54602064aae0c..87dbe34ee93024 100644 --- a/src/nodes/code/FunctionNode.js +++ b/src/nodes/code/FunctionNode.js @@ -105,6 +105,14 @@ class FunctionNode extends CodeNode { nodeFunction = builder.parser.parseFunction( this.code ); + if ( ! nodeFunction ) { + + throw new Error( + 'TSL: Failed to parse function in FunctionNode. Check the shader syntax:\n' + this.code + ); + + } + nodeData.nodeFunction = nodeFunction; } @@ -113,6 +121,7 @@ class FunctionNode extends CodeNode { } + generate( builder, output ) { super.generate( builder );