浏览代码

fix bypassnode without .value

sunag 7 年之前
父节点
当前提交
836e363c07
共有 1 个文件被更改,包括 21 次插入9 次删除
  1. 21 9
      examples/js/nodes/core/BypassNode.js

+ 21 - 9
examples/js/nodes/core/BypassNode.js

@@ -17,7 +17,17 @@ THREE.BypassNode.prototype.nodeType = "Bypass";
 
 THREE.BypassNode.prototype.getType = function ( builder ) {
 
-	return this.value ? this.value.getType( builder ) : 'void';
+	if ( this.value ) {
+		
+		return this.value.getType( builder );
+		
+	} else if (builder.isShader( 'fragment' )) {
+		
+		return 'fv1';
+		
+	}
+	
+	return 'void';
 
 };
 
@@ -25,19 +35,21 @@ THREE.BypassNode.prototype.generate = function ( builder, output ) {
 
 	var code = this.code.build( builder, output ) + ';';
 
-	if ( builder.isShader( 'fragment' ) ) {
+	if ( builder.isShader( 'vertex' ) ) {
 		
-		builder.material.addFragmentNode( code );
+		builder.material.addVertexNode( code );
+		
+		if (this.value) {
+		
+			return this.value.build( builder, output );
+			
+		}
 		
 	} else {
 		
-		builder.material.addVertexNode( code );
-
-	}
-
-	if (this.value) {
+		builder.material.addFragmentNode( code );
 		
-		return this.value.build( builder, output );
+		return this.value ? this.value.build( builder, output ) : builder.format( '0.0', 'fv1', output );
 		
 	}