瀏覽代碼

CondNode: Fix duplicate conditional (#27828)

sunag 1 年之前
父節點
當前提交
3d07bacfe8
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      examples/jsm/nodes/math/CondNode.js

+ 10 - 0
examples/jsm/nodes/math/CondNode.js

@@ -41,11 +41,21 @@ class CondNode extends Node {
 		const type = this.getNodeType( builder );
 		const type = this.getNodeType( builder );
 		const context = { tempWrite: false };
 		const context = { tempWrite: false };
 
 
+		const nodeData = builder.getDataFromNode( this );
+
+		if ( nodeData.nodeProperty !== undefined ) {
+
+			return nodeData.nodeProperty;
+
+		}
+
 		const { ifNode, elseNode } = this;
 		const { ifNode, elseNode } = this;
 
 
 		const needsOutput = output !== 'void';
 		const needsOutput = output !== 'void';
 		const nodeProperty = needsOutput ? property( type ).build( builder ) : '';
 		const nodeProperty = needsOutput ? property( type ).build( builder ) : '';
 
 
+		nodeData.nodeProperty = nodeProperty;
+
 		const nodeSnippet = contextNode( this.condNode/*, context*/ ).build( builder, 'bool' );
 		const nodeSnippet = contextNode( this.condNode/*, context*/ ).build( builder, 'bool' );
 
 
 		builder.addFlowCode( `\n${ builder.tab }if ( ${ nodeSnippet } ) {\n\n` ).addFlowTab();
 		builder.addFlowCode( `\n${ builder.tab }if ( ${ nodeSnippet } ) {\n\n` ).addFlowTab();