Browse Source

Don't convert type of node if it is not needed (#23786)

LeviPesin 3 years ago
parent
commit
1e0cdd9c63
1 changed files with 7 additions and 1 deletions
  1. 7 1
      examples/jsm/nodes/ShaderNode.js

+ 7 - 1
examples/jsm/nodes/ShaderNode.js

@@ -236,7 +236,13 @@ const ConvertType = function ( type, cacheMap = null ) {
 
 
 			const nodes = params.map( getAutoTypedConstNode );
 			const nodes = params.map( getAutoTypedConstNode );
 
 
-			return nodeObject( new ConvertNode( nodes.length === 1 ? nodes[ 0 ] : new JoinNode( nodes ), type ) );
+			if ( nodes.length === 1 ) {
+
+				return nodeObject( nodes[ 0 ].nodeType === type ? nodes[ 0 ] : new ConvertNode( nodes[ 0 ], type ) );
+
+			}
+
+			return nodeObject( new ConvertNode( new JoinNode( nodes ), type ) );
 
 
 		}
 		}