Browse Source

TSL: Introduce `.toGlobal` (#28503)

sunag 1 year ago
parent
commit
0a03ca667a
2 changed files with 13 additions and 1 deletions
  1. 3 1
      examples/jsm/nodes/core/Node.js
  2. 10 0
      examples/jsm/nodes/shadernode/ShaderNode.js

+ 3 - 1
examples/jsm/nodes/core/Node.js

@@ -25,6 +25,8 @@ class Node extends EventDispatcher {
 		this._cacheKey = null;
 		this._cacheKeyVersion = 0;
 
+		this.global = false;
+
 		this.isNode = true;
 
 		Object.defineProperty( this, 'id', { value: _nodeId ++ } );
@@ -98,7 +100,7 @@ class Node extends EventDispatcher {
 
 	isGlobal( /*builder*/ ) {
 
-		return false;
+		return this.global;
 
 	}
 

+ 10 - 0
examples/jsm/nodes/shadernode/ShaderNode.js

@@ -531,6 +531,16 @@ addNodeClass( 'ShaderNode', ShaderNode );
 
 //
 
+addNodeElement( 'toGlobal', ( node ) => {
+
+	node.global = true;
+
+	return node;
+
+} );
+
+//
+
 export const setCurrentStack = ( stack ) => {
 
 	if ( currentStack === stack ) {