소스 검색

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob 9 년 전
부모
커밋
231b1a3ea3
2개의 변경된 파일27개의 추가작업 그리고 22개의 파일을 삭제
  1. 3 2
      examples/js/nodes/math/Math1Node.js
  2. 24 20
      examples/js/nodes/utils/SwitchNode.js

+ 3 - 2
examples/js/nodes/math/Math1Node.js

@@ -18,7 +18,8 @@ THREE.Math1Node.EXP = 'exp';
 THREE.Math1Node.EXP2 = 'exp2';
 THREE.Math1Node.LOG = 'log';
 THREE.Math1Node.LOG2 = 'log2';
-THREE.Math1Node.INVERSE_SQRT = 'inversesqrt';
+THREE.Math1Node.SQRT = 'sqrt';
+THREE.Math1Node.INV_SQRT = 'inversesqrt';
 THREE.Math1Node.FLOOR = 'floor';
 THREE.Math1Node.CEIL = 'ceil';
 THREE.Math1Node.NORMALIZE = 'normalize';
@@ -42,7 +43,7 @@ THREE.Math1Node.prototype.constructor = THREE.Math1Node;
 THREE.Math1Node.prototype.getType = function( builder ) {
 
 	switch ( this.method ) {
-		case THREE.Math1Node.DISTANCE:
+		case THREE.Math1Node.LENGTH:
 			return 'fv1';
 	}
 

+ 24 - 20
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';
@@ -24,45 +24,49 @@ 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;
+		}
 
-	// build switch
+		if ( outputLength > inputLength ) outputLength = inputLength;
 
-	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 );
+		return builder.format( node, this.getType( builder ), output );
 
-	}
+	} else {
 
-	return builder.format( node, this.getType( builder ), output );
+		// join
+
+		return builder.format( node, type, output )
+
+	}
 
 };