Browse Source

FunctionNode interface option for convert native functions for node

sunag 6 years ago
parent
commit
40e8f624f0
2 changed files with 10 additions and 11 deletions
  1. 8 1
      examples/jsm/nodes/core/FunctionNode.js
  2. 2 10
      examples/webgl_materials_nodes.html

+ 8 - 1
examples/jsm/nodes/core/FunctionNode.js

@@ -12,6 +12,7 @@ var declarationRegexp = /^([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,
 function FunctionNode( src, includes, extensions, keywords, type ) {
 
 	this.isMethod = type === undefined;
+	this.isInterface = false;
 
 	TempNode.call( this, type );
 
@@ -139,7 +140,11 @@ FunctionNode.prototype.generate = function ( builder, output ) {
 
 	} else if ( this.isMethod ) {
 
-		builder.include( this, false, src );
+		if ( ! this.isInterface ) {
+
+			builder.include( this, false, src );
+
+		}
 
 		return this.name;
 
@@ -204,6 +209,8 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords )
 
 			}
 
+			this.isInterface = this.src.indexOf('{') === -1;
+
 		} else {
 
 			this.type = '';

+ 2 - 10
examples/webgl_materials_nodes.html

@@ -2495,11 +2495,7 @@
 
 								case 'lod':
 
-									var textureCubeFunction = new Nodes.FunctionNode( [
-										"vec4 textureCubeFunction( samplerCube texture, vec3 uv, float bias ) {",
-										"	return textureCubeLodEXT( texture, uv, bias );",
-										"}"
-									].join( "\n" ), undefined, { shaderTextureLOD: true } );
+									var textureCubeFunction = new Nodes.FunctionNode( 'vec4 textureCubeLodEXT( samplerCube texture, vec3 uv, float bias );', undefined, { shaderTextureLOD: true } 								);
 
 									mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] );
 
@@ -2507,11 +2503,7 @@
 
 								case 'basic':
 
-									var textureCubeFunction = new Nodes.FunctionNode( [
-										"vec4 textureCubeFunction( samplerCube texture, vec3 uv, float bias ) {",
-										"	return textureCube( texture, uv, bias );",
-										"}"
-									].join( "\n" ) );
+									var textureCubeFunction = new Nodes.FunctionNode( 'vec4 textureCube( samplerCube texture, vec3 uv, float bias );' );
 
 									mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] );