SUNAG 9 年之前
父节点
当前提交
524e028a18
共有 1 个文件被更改,包括 9 次插入9 次删除
  1. 9 9
      examples/js/nodes/utils/SwitchNode.js

+ 9 - 9
examples/js/nodes/utils/SwitchNode.js

@@ -24,25 +24,25 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
 
 	var type = this.node.getType( builder );
 	var inputLength = builder.getFormatLength( type ) - 1;
-	var components = builder.colorToVector( this.components );
 
 	var node = this.node.build( builder, type );
 
-	var outputLength = 0;
+	if ( inputLength > 0 ) {
 
-	var i, len = components.length;
+		// get max length
 
-	// get max length
+		var outputLength = 0;
+		var components = builder.colorToVector( this.components );
 
-	for ( i = 0; i < len; i ++ ) {
+		var i, len = components.length;
 
-		outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) );
+		for ( i = 0; i < len; i ++ ) {
 
-	}
+			outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) );
 
-	if ( outputLength > inputLength ) outputLength = inputLength;
+		}
 
-	if ( inputLength > 0 ) {
+		if ( outputLength > inputLength ) outputLength = inputLength;
 
 		// split