Browse Source

TSL: Fix duplicate assignments (#27798)

* AssignNode: Fix duplicate assignments

* add void
sunag 1 year ago
parent
commit
499d3139ef
1 changed files with 13 additions and 1 deletions
  1. 13 1
      examples/jsm/nodes/core/AssignNode.js

+ 13 - 1
examples/jsm/nodes/core/AssignNode.js

@@ -56,11 +56,21 @@ class AssignNode extends TempNode {
 
 
 		const sourceType = sourceNode.getNodeType( builder );
 		const sourceType = sourceNode.getNodeType( builder );
 
 
+		const nodeData = builder.getDataFromNode( this );
+
 		//
 		//
 
 
 		let snippet;
 		let snippet;
 
 
-		if ( needsSplitAssign ) {
+		if ( nodeData.initialized === true ) {
+
+			if ( output !== 'void' ) {
+
+				snippet = target;
+
+			}
+
+		} else if ( needsSplitAssign ) {
 
 
 			const sourceVar = builder.getVarFromNode( this, null, targetType );
 			const sourceVar = builder.getVarFromNode( this, null, targetType );
 			const sourceProperty = builder.getPropertyName( sourceVar );
 			const sourceProperty = builder.getPropertyName( sourceVar );
@@ -101,6 +111,8 @@ class AssignNode extends TempNode {
 
 
 		}
 		}
 
 
+		nodeData.initialized = true;
+
 		return builder.format( snippet, targetType, output );
 		return builder.format( snippet, targetType, output );
 
 
 	}
 	}