浏览代码

fix float input, auto joint or split node

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

+ 14 - 10
examples/js/nodes/utils/SwitchNode.js

@@ -4,7 +4,7 @@
 
 THREE.SwitchNode = function( node, components ) {
 
-	THREE.GLNode.call( this, 'fv1' );
+	THREE.GLNode.call( this );
 
 	this.node = node;
 	this.components = components || 'x';
@@ -42,24 +42,28 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
 
 	if ( outputLength > inputLength ) outputLength = inputLength;
 
-	// build switch
+	if ( inputLength > 0 ) {
 
-	node += '.';
+		// split
 
-	for ( i = 0; i < len; i ++ ) {
+		node += '.';
 
-		var elm = components.charAt( i );
-		var idx = builder.getIndexByElement( components.charAt( i ) );
+		for ( i = 0; i < len; i ++ ) {
 
-		if ( idx > outputLength ) idx = outputLength;
+			var elm = components.charAt( i );
+			var idx = builder.getIndexByElement( components.charAt( i ) );
 
-		if ( builder.getElementByIndex( idx ) == undefined ) {
+			if ( idx > outputLength ) idx = outputLength;
 
-			console.log( builder.getElementByIndex( idx ) );
+			node += builder.getElementByIndex( idx );
 
 		}
 
-		node += builder.getElementByIndex( idx );
+	} else {
+
+		// join
+
+		node = builder.format( node, type, this.getType( builder ) )
 
 	}