Browse Source

mrdoob approves

SUNAG 9 years ago
parent
commit
1599e1ac2e
38 changed files with 1557 additions and 1459 deletions
  1. 72 72
      examples/js/materials/nodes/BuilderNode.js
  2. 23 23
      examples/js/materials/nodes/ConstNode.js
  3. 24 24
      examples/js/materials/nodes/FunctionCallNode.js
  4. 80 78
      examples/js/materials/nodes/FunctionNode.js
  5. 41 37
      examples/js/materials/nodes/GLNode.js
  6. 19 17
      examples/js/materials/nodes/InputNode.js
  7. 29 21
      examples/js/materials/nodes/LibNode.js
  8. 203 189
      examples/js/materials/nodes/NodeMaterial.js
  9. 14 14
      examples/js/materials/nodes/RawNode.js
  10. 57 55
      examples/js/materials/nodes/TempNode.js
  11. 45 45
      examples/js/materials/nodes/accessors/CameraNode.js
  12. 13 13
      examples/js/materials/nodes/accessors/ColorsNode.js
  13. 25 25
      examples/js/materials/nodes/accessors/NormalNode.js
  14. 35 35
      examples/js/materials/nodes/accessors/PositionNode.js
  15. 16 16
      examples/js/materials/nodes/accessors/ReflectNode.js
  16. 13 13
      examples/js/materials/nodes/accessors/UVNode.js
  17. 19 19
      examples/js/materials/nodes/extras/VelocityNode.js
  18. 5 5
      examples/js/materials/nodes/inputs/ColorNode.js
  19. 11 11
      examples/js/materials/nodes/inputs/CubeTextureNode.js
  20. 15 7
      examples/js/materials/nodes/inputs/FloatNode.js
  21. 16 8
      examples/js/materials/nodes/inputs/IntNode.js
  22. 7 7
      examples/js/materials/nodes/inputs/TextureNode.js
  23. 5 5
      examples/js/materials/nodes/inputs/Vector2Node.js
  24. 5 5
      examples/js/materials/nodes/inputs/Vector3Node.js
  25. 5 5
      examples/js/materials/nodes/inputs/Vector4Node.js
  26. 104 87
      examples/js/materials/nodes/interfaces/PhongNode.js
  27. 5 5
      examples/js/materials/nodes/interfaces/PhongNodeMaterial.js
  28. 107 89
      examples/js/materials/nodes/interfaces/StandardNode.js
  29. 5 5
      examples/js/materials/nodes/interfaces/StandardNodeMaterial.js
  30. 18 18
      examples/js/materials/nodes/math/Math1Node.js
  31. 28 25
      examples/js/materials/nodes/math/Math2Node.js
  32. 27 23
      examples/js/materials/nodes/math/Math3Node.js
  33. 14 12
      examples/js/materials/nodes/math/OperatorNode.js
  34. 31 27
      examples/js/materials/nodes/utils/JoinNode.js
  35. 23 23
      examples/js/materials/nodes/utils/RoughnessToBlinnExponentNode.js
  36. 35 33
      examples/js/materials/nodes/utils/SwitchNode.js
  37. 6 6
      examples/js/materials/nodes/utils/TimeNode.js
  38. 357 357
      examples/webgl_materials_nodes.html

+ 72 - 72
examples/js/materials/nodes/BuilderNode.js

@@ -3,122 +3,122 @@
  */
  */
 
 
 THREE.BuilderNode = function( material ) {
 THREE.BuilderNode = function( material ) {
-	
+
 	this.material = material;
 	this.material = material;
-	
+
 	this.require = {};
 	this.require = {};
 	this.isVerify = false;
 	this.isVerify = false;
 	this.cache = '';
 	this.cache = '';
-	
+
 };
 };
 
 
 THREE.BuilderNode.prototype = {
 THREE.BuilderNode.prototype = {
 	constructor: THREE.BuilderNode,
 	constructor: THREE.BuilderNode,
 
 
-	include : function ( func ) {
-		
+	include : function( func ) {
+
 		this.material.include( this.shader, func );
 		this.material.include( this.shader, func );
 
 
 	},
 	},
-	
-	getFormatConstructor : function ( len ) {
-		
-		return THREE.BuilderNode.constructors[len-1];
-	
+
+	getFormatConstructor : function( len ) {
+
+		return THREE.BuilderNode.constructors[ len - 1 ];
+
 	},
 	},
-	
-	getFormat : function ( format ) {
-		
-		return format.replace('c','v3').replace(/fv1|iv1/, 'v1');
-	
+
+	getFormat : function( format ) {
+
+		return format.replace( 'c', 'v3' ).replace( /fv1|iv1/, 'v1' );
+
 	},
 	},
-	
-	getFormatLength : function ( format ) {
-		
-		return parseInt( this.getFormat(format).substr(1) );
-	
+
+	getFormatLength : function( format ) {
+
+		return parseInt( this.getFormat( format ).substr( 1 ) );
+
 	},
 	},
-	
-	getFormatByLength : function ( len ) {
-		
-		if (len == 1) return 'fv1';
-		
+
+	getFormatByLength : function( len ) {
+
+		if ( len == 1 ) return 'fv1';
+
 		return 'v' + len;
 		return 'v' + len;
-	
+
 	},
 	},
-	
-	format : function ( code, from, to ) {
-		
-		var format = this.getFormat(from + '=' + to);
-	
+
+	format : function( code, from, to ) {
+
+		var format = this.getFormat( from + '=' + to );
+
 		switch ( format ) {
 		switch ( format ) {
 			case 'v1=v2': return 'vec2(' + code + ')';
 			case 'v1=v2': return 'vec2(' + code + ')';
 			case 'v1=v3': return 'vec3(' + code + ')';
 			case 'v1=v3': return 'vec3(' + code + ')';
 			case 'v1=v4': return 'vec4(' + code + ')';
 			case 'v1=v4': return 'vec4(' + code + ')';
-			
+
 			case 'v2=v1': return code + '.x';
 			case 'v2=v1': return code + '.x';
 			case 'v2=v3': return 'vec3(' + code + ',0.0)';
 			case 'v2=v3': return 'vec3(' + code + ',0.0)';
 			case 'v2=v4': return 'vec4(' + code + ',0.0,0.0)';
 			case 'v2=v4': return 'vec4(' + code + ',0.0,0.0)';
-			
+
 			case 'v3=v1': return code + '.x';
 			case 'v3=v1': return code + '.x';
 			case 'v3=v2': return code + '.xy';
 			case 'v3=v2': return code + '.xy';
 			case 'v3=v4': return 'vec4(' + code + ',0.0)';
 			case 'v3=v4': return 'vec4(' + code + ',0.0)';
-			
+
 			case 'v4=v1': return code + '.x';
 			case 'v4=v1': return code + '.x';
 			case 'v4=v2': return code + '.xy';
 			case 'v4=v2': return code + '.xy';
 			case 'v4=v3': return code + '.xyz';
 			case 'v4=v3': return code + '.xyz';
 		}
 		}
-		
+
 		return code;
 		return code;
-	
+
 	},
 	},
-	
-	getType : function ( format ) {
-		
+
+	getType : function( format ) {
+
 		return THREE.BuilderNode.type[ format ];
 		return THREE.BuilderNode.type[ format ];
-	
+
 	},
 	},
-	
-	getUuid : function ( uuid, useCache ) {
-		
+
+	getUuid : function( uuid, useCache ) {
+
 		useCache = useCache !== undefined ? useCache : true;
 		useCache = useCache !== undefined ? useCache : true;
-		
-		if (useCache && this.cache) uuid = this.cache + '-' + uuid;
-		
+
+		if ( useCache && this.cache ) uuid = this.cache + '-' + uuid;
+
 		return uuid;
 		return uuid;
 
 
 	},
 	},
-	
-	setCache : function ( name ) {
-		
+
+	setCache : function( name ) {
+
 		this.cache = name || '';
 		this.cache = name || '';
-		
+
 		return this;
 		return this;
 
 
 	},
 	},
-	
-	getElementByIndex : function ( index ) {
-		
+
+	getElementByIndex : function( index ) {
+
 		return THREE.BuilderNode.elements[ index ];
 		return THREE.BuilderNode.elements[ index ];
-	
+
 	},
 	},
-	
-	getElementIndex : function ( elm ) {
-		
+
+	getElementIndex : function( elm ) {
+
 		return THREE.BuilderNode.elements.indexOf( elm );
 		return THREE.BuilderNode.elements.indexOf( elm );
-	
+
 	},
 	},
-	
-	isShader : function ( shader ) {
-		
+
+	isShader : function( shader ) {
+
 		return this.shader == shader || this.isVerify;
 		return this.shader == shader || this.isVerify;
 
 
 	},
 	},
-	
-	setShader : function ( shader ) {
-		
+
+	setShader : function( shader ) {
+
 		this.shader = shader;
 		this.shader = shader;
-		
+
 		return this;
 		return this;
 
 
 	}
 	}
@@ -132,15 +132,15 @@ THREE.BuilderNode.type = {
 };
 };
 
 
 THREE.BuilderNode.constructors = [
 THREE.BuilderNode.constructors = [
-	'', 
-	'vec2', 
-	'vec3', 
+	'',
+	'vec2',
+	'vec3',
 	'vec4'
 	'vec4'
 ];
 ];
 
 
 THREE.BuilderNode.elements = [
 THREE.BuilderNode.elements = [
-	'x', 
-	'y', 
-	'z', 
+	'x',
+	'y',
+	'z',
 	'w'
 	'w'
-];
+];

+ 23 - 23
examples/js/materials/nodes/ConstNode.js

@@ -2,37 +2,37 @@
  * @author sunag / http://www.sunag.com.br/
  * @author sunag / http://www.sunag.com.br/
  */
  */
 
 
-THREE.ConstNode = function(name, useDefine) {
-	
+THREE.ConstNode = function( name, useDefine ) {
+
 	name = name || THREE.ConstNode.PI;
 	name = name || THREE.ConstNode.PI;
-	
+
 	var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=(.*?)\;/i;
 	var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=(.*?)\;/i;
 	var type = 'fv1';
 	var type = 'fv1';
-	
+
 	var match = name.match( rDeclaration );
 	var match = name.match( rDeclaration );
-	
-	if (match && match.length > 1) {
-	
-		type = match[1];
-		name = match[2];
-		
-		if (useDefine) {
-			
-			this.src = '#define ' + name + ' ' + match[3];
-		
+
+	if ( match && match.length > 1 ) {
+
+		type = match[ 1 ];
+		name = match[ 2 ];
+
+		if ( useDefine ) {
+
+			this.src = '#define ' + name + ' ' + match[ 3 ];
+
 		}
 		}
 		else {
 		else {
-			
-			this.src = 'const ' + type + ' ' + name + ' = ' + match[3] + ';';
-		
+
+			this.src = 'const ' + type + ' ' + name + ' = ' + match[ 3 ] + ';';
+
 		}
 		}
-	
+
 	}
 	}
-	
+
 	this.name = name;
 	this.name = name;
-	
+
 	THREE.TempNode.call( this, type );
 	THREE.TempNode.call( this, type );
-	
+
 };
 };
 
 
 THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -46,7 +46,7 @@ THREE.ConstNode.LOG2 = 'LOG2';
 THREE.ConstNode.EPSILON = 'EPSILON';
 THREE.ConstNode.EPSILON = 'EPSILON';
 
 
 THREE.ConstNode.prototype.generate = function( builder, output ) {
 THREE.ConstNode.prototype.generate = function( builder, output ) {
-	
+
 	return builder.format( this.name, this.getType( builder ), output );
 	return builder.format( this.name, this.getType( builder ), output );
 
 
-};
+};

+ 24 - 24
examples/js/materials/nodes/FunctionCallNode.js

@@ -3,58 +3,58 @@
  */
  */
 
 
 THREE.FunctionCallNode = function( value ) {
 THREE.FunctionCallNode = function( value ) {
-	
+
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
-	
+
 	this.setFunction( value );
 	this.setFunction( value );
-	
+
 };
 };
 
 
 THREE.FunctionCallNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.FunctionCallNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.FunctionCallNode.prototype.constructor = THREE.FunctionCallNode;
 THREE.FunctionCallNode.prototype.constructor = THREE.FunctionCallNode;
 
 
-THREE.FunctionCallNode.prototype.setFunction = function(val) {
-	
+THREE.FunctionCallNode.prototype.setFunction = function( val ) {
+
 	this.input = [];
 	this.input = [];
 	this.value = val;
 	this.value = val;
-	
+
 };
 };
 
 
 THREE.FunctionCallNode.prototype.getFunction = function() {
 THREE.FunctionCallNode.prototype.getFunction = function() {
-	
+
 	return this.value;
 	return this.value;
-	
+
 };
 };
 
 
 THREE.FunctionCallNode.prototype.getType = function( builder ) {
 THREE.FunctionCallNode.prototype.getType = function( builder ) {
-	
+
 	return this.value.getType( builder );
 	return this.value.getType( builder );
-	
+
 };
 };
 
 
 THREE.FunctionCallNode.prototype.generate = function( builder, output ) {
 THREE.FunctionCallNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var type = this.getType( builder );
 	var type = this.getType( builder );
 	var func = this.value;
 	var func = this.value;
-	
+
 	builder.include( func );
 	builder.include( func );
-	
+
 	var code = func.name + '(';
 	var code = func.name + '(';
 	var params = [];
 	var params = [];
-	
-	for(var i = 0; i < func.input.length; i++) {
-		
-		var inpt = func.input[i];
-		var param = this.input[i] || this.input[inpt.name];
-		
+
+	for ( var i = 0; i < func.input.length; i ++ ) {
+
+		var inpt = func.input[ i ];
+		var param = this.input[ i ] || this.input[ inpt.name ];
+
 		params.push( param.build( builder, builder.getType( inpt.type ) ) );
 		params.push( param.build( builder, builder.getType( inpt.type ) ) );
-	
+
 	}
 	}
-	
-	code += params.join(',') + ')';
-	
+
+	code += params.join( ',' ) + ')';
+
 	return builder.format( code, type, output );
 	return builder.format( code, type, output );
 
 
 };
 };

+ 80 - 78
examples/js/materials/nodes/FunctionNode.js

@@ -4,21 +4,21 @@
  */
  */
 
 
 THREE.FunctionNode = function( src, includes, extensions ) {
 THREE.FunctionNode = function( src, includes, extensions ) {
-	
+
 	THREE.GLNode.call( this );
 	THREE.GLNode.call( this );
-	
+
 	this.parse( src || '', includes, extensions );
 	this.parse( src || '', includes, extensions );
-	
+
 };
 };
 
 
 THREE.FunctionNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.FunctionNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.FunctionNode.prototype.constructor = THREE.FunctionNode;
 THREE.FunctionNode.prototype.constructor = THREE.FunctionNode;
 
 
 THREE.FunctionNode.prototype.parseReference = function( name ) {
 THREE.FunctionNode.prototype.parseReference = function( name ) {
-	
-	switch(name) {
+
+	switch ( name ) {
 		case 'uv': return new THREE.UVNode().name;
 		case 'uv': return new THREE.UVNode().name;
-		case 'uv2': return new THREE.UVNode(1).name;
+		case 'uv2': return new THREE.UVNode( 1 ).name;
 		case 'position': return new THREE.PositionNode().name;
 		case 'position': return new THREE.PositionNode().name;
 		case 'worldPosition': return new THREE.PositionNode( THREE.PositionNode.WORLD ).name;
 		case 'worldPosition': return new THREE.PositionNode( THREE.PositionNode.WORLD ).name;
 		case 'normal': return new THREE.NormalNode().name;
 		case 'normal': return new THREE.NormalNode().name;
@@ -26,9 +26,9 @@ THREE.FunctionNode.prototype.parseReference = function( name ) {
 		case 'viewPosition': return new THREE.PositionNode( THREE.NormalNode.VIEW ).name;
 		case 'viewPosition': return new THREE.PositionNode( THREE.NormalNode.VIEW ).name;
 		case 'viewNormal': return new THREE.NormalNode( THREE.NormalNode.VIEW ).name;
 		case 'viewNormal': return new THREE.NormalNode( THREE.NormalNode.VIEW ).name;
 	}
 	}
-	
+
 	return name;
 	return name;
-	
+
 };
 };
 
 
 THREE.FunctionNode.prototype.getTypeNode = function( builder, type ) {
 THREE.FunctionNode.prototype.getTypeNode = function( builder, type ) {
@@ -38,120 +38,122 @@ THREE.FunctionNode.prototype.getTypeNode = function( builder, type ) {
 };
 };
 
 
 THREE.FunctionNode.prototype.getInputByName = function( name ) {
 THREE.FunctionNode.prototype.getInputByName = function( name ) {
-	
+
 	var i = this.input.length;
 	var i = this.input.length;
-	
-	while(i--) {
-	
-		if (this.input[i].name === name)
-			return this.input[i];
-		
+
+	while ( i -- ) {
+
+		if ( this.input[ i ].name === name )
+			return this.input[ i ];
+
 	}
 	}
-	
+
 };
 };
 
 
 THREE.FunctionNode.prototype.getType = function( builder ) {
 THREE.FunctionNode.prototype.getType = function( builder ) {
-	
+
 	return this.getTypeNode( builder, this.type );
 	return this.getTypeNode( builder, this.type );
-	
+
 };
 };
 
 
 THREE.FunctionNode.prototype.getInclude = function( name ) {
 THREE.FunctionNode.prototype.getInclude = function( name ) {
-	
+
 	var i = this.includes.length;
 	var i = this.includes.length;
-	
-	while(i--) {
-		
-		if (this.includes[i].name === name)
-			return this.includes[i];
-	
+
+	while ( i -- ) {
+
+		if ( this.includes[ i ].name === name )
+			return this.includes[ i ];
+
 	}
 	}
-	
+
 	return undefined;
 	return undefined;
-	
+
 };
 };
 
 
 THREE.FunctionNode.prototype.parse = function( src, includes, extensions ) {
 THREE.FunctionNode.prototype.parse = function( src, includes, extensions ) {
-	
+
 	var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\((.*?)\)/i;
 	var rDeclaration = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\((.*?)\)/i;
 	var rProperties = /[a-z_0-9]+/ig;
 	var rProperties = /[a-z_0-9]+/ig;
-	
+
 	this.includes = includes || [];
 	this.includes = includes || [];
 	this.extensions = extensions || {};
 	this.extensions = extensions || {};
-	
+
 	var match = src.match( rDeclaration );
 	var match = src.match( rDeclaration );
-	
+
 	this.input = [];
 	this.input = [];
-	
-	if (match && match.length == 4) {
-	
-		this.type = match[1];
-		this.name = match[2];
-		
-		var inputs = match[3].match( rProperties );
-		
-		if (inputs) {
-		
+
+	if ( match && match.length == 4 ) {
+
+		this.type = match[ 1 ];
+		this.name = match[ 2 ];
+
+		var inputs = match[ 3 ].match( rProperties );
+
+		if ( inputs ) {
+
 			var i = 0;
 			var i = 0;
-			
-			while(i < inputs.length) {
-			
-				var qualifier = inputs[i++];
+
+			while ( i < inputs.length ) {
+
+				var qualifier = inputs[ i ++ ];
 				var type, name;
 				var type, name;
-				
-				if (qualifier == 'in' || qualifier == 'out' || qualifier == 'inout') {
-				
-					type = inputs[i++];
-					
+
+				if ( qualifier == 'in' || qualifier == 'out' || qualifier == 'inout' ) {
+
+					type = inputs[ i ++ ];
+
 				}
 				}
 				else {
 				else {
-					
+
 					type = qualifier;
 					type = qualifier;
 					qualifier = '';
 					qualifier = '';
-				
+
 				}
 				}
-				
-				name = inputs[i++];
-				
-				this.input.push({
+
+				name = inputs[ i ++ ];
+
+				this.input.push( {
 					name : name,
 					name : name,
 					type : type,
 					type : type,
 					qualifier : qualifier
 					qualifier : qualifier
-				});
+				} );
+
 			}
 			}
-			
+
 		}
 		}
 
 
 		var match, offset = 0;
 		var match, offset = 0;
-		
-		while (match = rProperties.exec(src)) {
-			
-			var prop = match[0];
+
+		while ( match = rProperties.exec( src ) ) {
+
+			var prop = match[ 0 ];
 			var reference = this.parseReference( prop );
 			var reference = this.parseReference( prop );
-			
-			if (prop != reference) {
-				
-				src = src.substring( 0, match.index + offset ) + reference + src.substring( match.index + prop.length + offset  );
-				
+
+			if ( prop != reference ) {
+
+				src = src.substring( 0, match.index + offset ) + reference + src.substring( match.index + prop.length + offset );
+
 				offset += reference.length - prop.length;
 				offset += reference.length - prop.length;
-				
+
 			}
 			}
-			
-			if (this.getInclude(reference) === undefined && THREE.LibNode.contains(reference)) {
-					
-				this.includes.push( THREE.LibNode.get(reference) );
-				
+
+			if ( this.getInclude( reference ) === undefined && THREE.LibNode.contains( reference ) ) {
+
+				this.includes.push( THREE.LibNode.get( reference ) );
+
 			}
 			}
-			
+
 		}
 		}
-		
+
 		this.src = src;
 		this.src = src;
 
 
 	}
 	}
 	else {
 	else {
-		
+
 		this.type = '';
 		this.type = '';
 		this.name = '';
 		this.name = '';
-	
+
 	}
 	}
-};
+
+};

+ 41 - 37
examples/js/materials/nodes/GLNode.js

@@ -3,66 +3,66 @@
  */
  */
 
 
 THREE.GLNode = function( type ) {
 THREE.GLNode = function( type ) {
-	
+
 	this.uuid = THREE.Math.generateUUID();
 	this.uuid = THREE.Math.generateUUID();
-	
+
 	this.allow = {};
 	this.allow = {};
 	this.requestUpdate = false;
 	this.requestUpdate = false;
-	
+
 	this.type = type;
 	this.type = type;
-	
+
 };
 };
 
 
 THREE.GLNode.prototype.verify = function( builder ) {
 THREE.GLNode.prototype.verify = function( builder ) {
-	
+
 	builder.isVerify = true;
 	builder.isVerify = true;
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	this.build( builder, 'v4' );
 	this.build( builder, 'v4' );
-	
+
 	material.clearVertexNode();
 	material.clearVertexNode();
 	material.clearFragmentNode();
 	material.clearFragmentNode();
-	
+
 	builder.setCache(); // reset cache
 	builder.setCache(); // reset cache
-	
+
 	builder.isVerify = false;
 	builder.isVerify = false;
 
 
 };
 };
 
 
 THREE.GLNode.prototype.verifyAndBuildCode = function( builder, output, cache ) {
 THREE.GLNode.prototype.verifyAndBuildCode = function( builder, output, cache ) {
-	
-	this.verify( builder.setCache(cache) );
-	
-	return this.buildCode( builder.setCache(cache), output );
-	
+
+	this.verify( builder.setCache( cache ) );
+
+	return this.buildCode( builder.setCache( cache ), output );
+
 };
 };
 
 
 THREE.GLNode.prototype.buildCode = function( builder, output, uuid ) {
 THREE.GLNode.prototype.buildCode = function( builder, output, uuid ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var data = { result : this.build( builder, output, uuid ) };
 	var data = { result : this.build( builder, output, uuid ) };
-	
-	if (builder.isShader('vertex')) data.code = material.clearVertexNode();
+
+	if ( builder.isShader( 'vertex' ) ) data.code = material.clearVertexNode();
 	else data.code = material.clearFragmentNode();
 	else data.code = material.clearFragmentNode();
-	
+
 	builder.setCache(); // reset cache
 	builder.setCache(); // reset cache
-	
+
 	return data;
 	return data;
 
 
 };
 };
 
 
 THREE.GLNode.prototype.verifyDepsNode = function( builder, data, output ) {
 THREE.GLNode.prototype.verifyDepsNode = function( builder, data, output ) {
-	
-	data.deps = (data.deps || 0) + 1;
-	
+
+	data.deps = ( data.deps || 0 ) + 1;
+
 	var outputLen = builder.getFormatLength( output );
 	var outputLen = builder.getFormatLength( output );
-	
-	if (outputLen > data.outputMax || this.getType( builder )) {
-		
+
+	if ( outputLen > data.outputMax || this.getType( builder ) ) {
+
 		data.outputMax = outputLen;
 		data.outputMax = outputLen;
 		data.output = output;
 		data.output = output;
-		
+
 	}
 	}
 
 
 };
 };
@@ -71,24 +71,28 @@ THREE.GLNode.prototype.build = function( builder, output, uuid ) {
 
 
 	var material = builder.material;
 	var material = builder.material;
 	var data = material.getDataNode( uuid || this.uuid );
 	var data = material.getDataNode( uuid || this.uuid );
-	
-	if (builder.isShader('verify')) this.verifyDepsNode( builder, data, output );
-	
-	if (this.allow[builder.shader] === false) {
+
+	if ( builder.isShader( 'verify' ) ) this.verifyDepsNode( builder, data, output );
+
+	if ( this.allow[ builder.shader ] === false ) {
+
 		throw new Error( 'Shader ' + shader + ' is not compatible with this node.' );
 		throw new Error( 'Shader ' + shader + ' is not compatible with this node.' );
+
 	}
 	}
-	
-	if (this.requestUpdate && !data.requestUpdate) {
+
+	if ( this.requestUpdate && ! data.requestUpdate ) {
+
 		material.requestUpdate.push( this );
 		material.requestUpdate.push( this );
 		data.requestUpdate = true;
 		data.requestUpdate = true;
+
 	}
 	}
-	
+
 	return this.generate( builder, output, uuid );
 	return this.generate( builder, output, uuid );
-	
+
 };
 };
 
 
 THREE.GLNode.prototype.getType = function( builder ) {
 THREE.GLNode.prototype.getType = function( builder ) {
 
 
 	return this.type;
 	return this.type;
-	
-};
+
+};

+ 19 - 17
examples/js/materials/nodes/InputNode.js

@@ -2,10 +2,10 @@
  * @author sunag / http://www.sunag.com.br/
  * @author sunag / http://www.sunag.com.br/
  */
  */
 
 
-THREE.InputNode = function(type, params) {
-	
+THREE.InputNode = function( type, params ) {
+
 	THREE.TempNode.call( this, type, params );
 	THREE.TempNode.call( this, type, params );
-	
+
 };
 };
 
 
 THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -17,28 +17,30 @@ THREE.InputNode.prototype.generate = function( builder, output, uuid, type ) {
 
 
 	uuid = builder.getUuid( uuid || this.uuid );
 	uuid = builder.getUuid( uuid || this.uuid );
 	type = type || this.type;
 	type = type || this.type;
-	
+
 	var data = material.getDataNode( uuid );
 	var data = material.getDataNode( uuid );
-	
-	if (builder.isShader('vertex')) {
-	
-		if (!data.vertex) {
-		
+
+	if ( builder.isShader( 'vertex' ) ) {
+
+		if ( ! data.vertex ) {
+
 			data.vertex = material.getVertexUniform( this.value, type );
 			data.vertex = material.getVertexUniform( this.value, type );
-			
+
 		}
 		}
-		
+
 		return builder.format( data.vertex.name, type, output );
 		return builder.format( data.vertex.name, type, output );
+
 	}
 	}
 	else {
 	else {
-		
-		if (!data.fragment) { 
-			
+
+		if ( ! data.fragment ) {
+
 			data.fragment = material.getFragmentUniform( this.value, type );
 			data.fragment = material.getFragmentUniform( this.value, type );
-			
+
 		}
 		}
-		
+
 		return builder.format( data.fragment.name, type, output );
 		return builder.format( data.fragment.name, type, output );
+
 	}
 	}
 
 
-};
+};

+ 29 - 21
examples/js/materials/nodes/LibNode.js

@@ -3,18 +3,26 @@
  */
  */
 
 
 THREE.LibNode = {
 THREE.LibNode = {
-	nodes:{},
-	add:function(node) {
-		this.nodes[node.name] = node;
+	nodes: {},
+	add: function( node ) {
+
+		this.nodes[ node.name ] = node;
+
 	},
 	},
-	remove:function(node) {
-		delete this.nodes[node.name];
+	remove: function( node ) {
+
+		delete this.nodes[ node.name ];
+
 	},
 	},
-	get:function(name) {
-		return this.nodes[name];
+	get: function( name ) {
+
+		return this.nodes[ name ];
+
 	},
 	},
-	contains:function(name) {
-		return this.nodes[name] != undefined;
+	contains: function( name ) {
+
+		return this.nodes[ name ] != undefined;
+
 	}
 	}
 };
 };
 
 
@@ -22,13 +30,13 @@ THREE.LibNode = {
 //	Luma
 //	Luma
 //
 //
 
 
-THREE.LibNode.add(new THREE.ConstNode("vec3 LUMA = vec3(0.2125, 0.7154, 0.0721);") );
+THREE.LibNode.add( new THREE.ConstNode( "vec3 LUMA = vec3(0.2125, 0.7154, 0.0721);" ) );
 
 
 //
 //
 //	DepthColor
 //	DepthColor
 //
 //
-			
-THREE.LibNode.add(new THREE.FunctionNode([
+
+THREE.LibNode.add( new THREE.FunctionNode( [
 "float depthcolor( float mNear, float mFar ) {",
 "float depthcolor( float mNear, float mFar ) {",
 
 
 	"#ifdef USE_LOGDEPTHBUF_EXT",
 	"#ifdef USE_LOGDEPTHBUF_EXT",
@@ -36,16 +44,16 @@ THREE.LibNode.add(new THREE.FunctionNode([
 	"#else",
 	"#else",
 		"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 		"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 	"#endif",
 	"#endif",
-	
+
 	"return 1.0 - smoothstep( mNear, mFar, depth );",
 	"return 1.0 - smoothstep( mNear, mFar, depth );",
 "}"
 "}"
-].join( "\n" )));
+].join( "\n" ) ) );
 
 
 //
 //
 //	NormalMap
 //	NormalMap
 //
 //
-			
-THREE.LibNode.add(new THREE.FunctionNode([
+
+THREE.LibNode.add( new THREE.FunctionNode( [
 // Per-Pixel Tangent Space Normal Mapping
 // Per-Pixel Tangent Space Normal Mapping
 // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
 // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
 "vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, float scale ) {",
 "vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, float scale ) {",
@@ -61,27 +69,27 @@ THREE.LibNode.add(new THREE.FunctionNode([
 	"mat3 tsn = mat3( S, T, N );",
 	"mat3 tsn = mat3( S, T, N );",
 	"return normalize( tsn * mapN );",
 	"return normalize( tsn * mapN );",
 "}"
 "}"
-].join( "\n" ), null, {derivatives:true}));
+].join( "\n" ), null, { derivatives: true } ) );
 
 
 //
 //
 //	Saturation
 //	Saturation
 //
 //
 
 
-THREE.LibNode.add(new THREE.FunctionNode([
+THREE.LibNode.add( new THREE.FunctionNode( [
 // Algorithm from Chapter 16 of OpenGL Shading Language
 // Algorithm from Chapter 16 of OpenGL Shading Language
 "vec3 saturation_rgb(vec3 rgb, float adjustment) {",
 "vec3 saturation_rgb(vec3 rgb, float adjustment) {",
 	"vec3 intensity = vec3(dot(rgb, LUMA));",
 	"vec3 intensity = vec3(dot(rgb, LUMA));",
 	"return mix(intensity, rgb, adjustment);",
 	"return mix(intensity, rgb, adjustment);",
 "}"
 "}"
-].join( "\n" )));
+].join( "\n" ) ) );
 
 
 //
 //
 //	Luminance
 //	Luminance
 //
 //
 
 
-THREE.LibNode.add(new THREE.FunctionNode([
+THREE.LibNode.add( new THREE.FunctionNode( [
 // Algorithm from Chapter 10 of Graphics Shaders.
 // Algorithm from Chapter 10 of Graphics Shaders.
 "float luminance_rgb(vec3 rgb) {",
 "float luminance_rgb(vec3 rgb) {",
 	"return dot(rgb, LUMA);",
 	"return dot(rgb, LUMA);",
 "}"
 "}"
-].join( "\n" )));
+].join( "\n" ) ) );

+ 203 - 189
examples/js/materials/nodes/NodeMaterial.js

@@ -3,12 +3,12 @@
  */
  */
 
 
 THREE.NodeMaterial = function( vertex, fragment ) {
 THREE.NodeMaterial = function( vertex, fragment ) {
-	
+
 	THREE.ShaderMaterial.call( this );
 	THREE.ShaderMaterial.call( this );
-	
+
 	this.vertex = vertex || new THREE.RawNode( new THREE.PositionNode( THREE.PositionNode.PROJECTION ) );
 	this.vertex = vertex || new THREE.RawNode( new THREE.PositionNode( THREE.PositionNode.PROJECTION ) );
 	this.fragment = fragment || new THREE.RawNode( new THREE.ColorNode( 0xFF0000 ) );
 	this.fragment = fragment || new THREE.RawNode( new THREE.ColorNode( 0xFF0000 ) );
-	
+
 };
 };
 
 
 THREE.NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
 THREE.NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
@@ -27,168 +27,176 @@ THREE.NodeMaterial.Type = {
 };
 };
 
 
 THREE.NodeMaterial.GetShortcuts = function( prop, name ) {
 THREE.NodeMaterial.GetShortcuts = function( prop, name ) {
-	
+
 	return {
 	return {
-		get: function () { return this[prop][name]; },
-		set: function ( val ) { this[prop][name] = val; }
+		get: function() {
+
+			return this[ prop ][ name ];
+
+		},
+		set: function( val ) {
+
+			this[ prop ][ name ] = val;
+
+		}
 	};
 	};
 
 
 };
 };
 
 
 THREE.NodeMaterial.Shortcuts = function( proto, prop, list ) {
 THREE.NodeMaterial.Shortcuts = function( proto, prop, list ) {
-	
+
 	var shortcuts = {};
 	var shortcuts = {};
-	
-	for(var i = 0; i < list.length; ++i) {
-		
-		var name = list[i];
-		
-		shortcuts[name] =  this.GetShortcuts( prop, name );
-	
+
+	for ( var i = 0; i < list.length; ++ i ) {
+
+		var name = list[ i ];
+
+		shortcuts[ name ] = this.GetShortcuts( prop, name );
+
 	}
 	}
-	
+
 	Object.defineProperties( proto, shortcuts );
 	Object.defineProperties( proto, shortcuts );
 
 
 };
 };
 
 
 THREE.NodeMaterial.prototype.updateAnimation = function( delta ) {
 THREE.NodeMaterial.prototype.updateAnimation = function( delta ) {
-	
-	for(var i = 0; i < this.requestUpdate.length; ++i) {
 
 
-		this.requestUpdate[i].updateAnimation( delta );
-	
+	for ( var i = 0; i < this.requestUpdate.length; ++ i ) {
+
+		this.requestUpdate[ i ].updateAnimation( delta );
+
 	}
 	}
-	
+
 };
 };
 
 
 THREE.NodeMaterial.prototype.build = function() {
 THREE.NodeMaterial.prototype.build = function() {
-	
+
 	var vertex, fragment;
 	var vertex, fragment;
-	
+
 	this.defines = {};
 	this.defines = {};
-	this.uniforms = {}; 
-	
-	this.nodeData = {};	
-	
+	this.uniforms = {};
+
+	this.nodeData = {};
+
 	this.vertexUniform = [];
 	this.vertexUniform = [];
 	this.fragmentUniform = [];
 	this.fragmentUniform = [];
-	
+
 	this.vertexTemps = [];
 	this.vertexTemps = [];
 	this.fragmentTemps = [];
 	this.fragmentTemps = [];
-	
+
 	this.uniformList = [];
 	this.uniformList = [];
-	
+
 	this.consts = [];
 	this.consts = [];
 	this.functions = [];
 	this.functions = [];
-	
+
 	this.requestUpdate = [];
 	this.requestUpdate = [];
-	
+
 	this.requestAttrib = {
 	this.requestAttrib = {
-		uv:[],
-		color:[]
+		uv: [],
+		color: []
 	};
 	};
-	
+
 	this.needsColor = false;
 	this.needsColor = false;
 	this.needsLight = false;
 	this.needsLight = false;
 	this.needsPosition = false;
 	this.needsPosition = false;
 	this.needsTransparent = false;
 	this.needsTransparent = false;
-	
+
 	this.vertexPars = '';
 	this.vertexPars = '';
 	this.fragmentPars = '';
 	this.fragmentPars = '';
-	
+
 	this.vertexCode = '';
 	this.vertexCode = '';
 	this.fragmentCode = '';
 	this.fragmentCode = '';
-	
+
 	this.vertexNode = '';
 	this.vertexNode = '';
 	this.fragmentNode = '';
 	this.fragmentNode = '';
-	
-	var builder = new THREE.BuilderNode(this);
-	
-	vertex = this.vertex.build( builder.setShader('vertex'), 'v4' );
-	fragment = this.fragment.build( builder.setShader('fragment'), 'v4' );
-	
-	if (this.requestAttrib.uv[0]) {
-		
+
+	var builder = new THREE.BuilderNode( this );
+
+	vertex = this.vertex.build( builder.setShader( 'vertex' ), 'v4' );
+	fragment = this.fragment.build( builder.setShader( 'fragment' ), 'v4' );
+
+	if ( this.requestAttrib.uv[ 0 ] ) {
+
 		this.addVertexPars( 'varying vec2 vUv;' );
 		this.addVertexPars( 'varying vec2 vUv;' );
 		this.addFragmentPars( 'varying vec2 vUv;' );
 		this.addFragmentPars( 'varying vec2 vUv;' );
-		
+
 		this.addVertexCode( 'vUv = uv;' );
 		this.addVertexCode( 'vUv = uv;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.uv[1]) {
-		
+
+	if ( this.requestAttrib.uv[ 1 ] ) {
+
 		this.addVertexPars( 'varying vec2 vUv2; attribute vec2 uv2;' );
 		this.addVertexPars( 'varying vec2 vUv2; attribute vec2 uv2;' );
 		this.addFragmentPars( 'varying vec2 vUv2;' );
 		this.addFragmentPars( 'varying vec2 vUv2;' );
-		
+
 		this.addVertexCode( 'vUv2 = uv2;' );
 		this.addVertexCode( 'vUv2 = uv2;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.color[0]) {
+
+	if ( this.requestAttrib.color[ 0 ] ) {
 
 
 		this.addVertexPars( 'varying vec4 vColor; attribute vec4 color;' );
 		this.addVertexPars( 'varying vec4 vColor; attribute vec4 color;' );
 		this.addFragmentPars( 'varying vec4 vColor;' );
 		this.addFragmentPars( 'varying vec4 vColor;' );
-		
+
 		this.addVertexCode( 'vColor = color;' );
 		this.addVertexCode( 'vColor = color;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.color[1]) {
+
+	if ( this.requestAttrib.color[ 1 ] ) {
 
 
 		this.addVertexPars( 'varying vec4 vColor2; attribute vec4 color2;' );
 		this.addVertexPars( 'varying vec4 vColor2; attribute vec4 color2;' );
 		this.addFragmentPars( 'varying vec4 vColor2;' );
 		this.addFragmentPars( 'varying vec4 vColor2;' );
-		
+
 		this.addVertexCode( 'vColor2 = color2;' );
 		this.addVertexCode( 'vColor2 = color2;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.position) {
+
+	if ( this.requestAttrib.position ) {
 
 
 		this.addVertexPars( 'varying vec3 vPosition;' );
 		this.addVertexPars( 'varying vec3 vPosition;' );
 		this.addFragmentPars( 'varying vec3 vPosition;' );
 		this.addFragmentPars( 'varying vec3 vPosition;' );
-		
+
 		this.addVertexCode( 'vPosition = transformed;' );
 		this.addVertexCode( 'vPosition = transformed;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.worldPosition) {
-		
+
+	if ( this.requestAttrib.worldPosition ) {
+
 		// for future update replace from the native "varying vec3 vWorldPosition" for optimization
 		// for future update replace from the native "varying vec3 vWorldPosition" for optimization
-		
+
 		this.addVertexPars( 'varying vec3 vWPosition;' );
 		this.addVertexPars( 'varying vec3 vWPosition;' );
 		this.addFragmentPars( 'varying vec3 vWPosition;' );
 		this.addFragmentPars( 'varying vec3 vWPosition;' );
-		
+
 		this.addVertexCode( 'vWPosition = worldPosition.xyz;' );
 		this.addVertexCode( 'vWPosition = worldPosition.xyz;' );
 
 
 	}
 	}
-	
-	if (this.requestAttrib.normal) {
+
+	if ( this.requestAttrib.normal ) {
 
 
 		this.addVertexPars( 'varying vec3 vObjectNormal;' );
 		this.addVertexPars( 'varying vec3 vObjectNormal;' );
 		this.addFragmentPars( 'varying vec3 vObjectNormal;' );
 		this.addFragmentPars( 'varying vec3 vObjectNormal;' );
-		
+
 		this.addVertexCode( 'vObjectNormal = normal;' );
 		this.addVertexCode( 'vObjectNormal = normal;' );
-		
+
 	}
 	}
-	
-	if (this.requestAttrib.worldNormal) {
+
+	if ( this.requestAttrib.worldNormal ) {
 
 
 		this.addVertexPars( 'varying vec3 vWNormal;' );
 		this.addVertexPars( 'varying vec3 vWNormal;' );
 		this.addFragmentPars( 'varying vec3 vWNormal;' );
 		this.addFragmentPars( 'varying vec3 vWNormal;' );
-		
+
 		this.addVertexCode( 'vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;' );
 		this.addVertexCode( 'vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;' );
-		
+
 	}
 	}
-	
+
 	this.lights = this.needsLight;
 	this.lights = this.needsLight;
 	this.transparent = this.needsTransparent;
 	this.transparent = this.needsTransparent;
-	
+
 	this.vertexShader = [
 	this.vertexShader = [
 		this.vertexPars,
 		this.vertexPars,
 		this.getCodePars( this.vertexUniform, 'uniform' ),
 		this.getCodePars( this.vertexUniform, 'uniform' ),
-		this.getIncludes(this.consts['vertex']),
-		this.getIncludes(this.functions['vertex']),
+		this.getIncludes( this.consts[ 'vertex' ] ),
+		this.getIncludes( this.functions[ 'vertex' ] ),
 		'void main(){',
 		'void main(){',
 		this.getCodePars( this.vertexTemps ),
 		this.getCodePars( this.vertexTemps ),
 		vertex,
 		vertex,
@@ -199,115 +207,120 @@ THREE.NodeMaterial.prototype.build = function() {
 	this.fragmentShader = [
 	this.fragmentShader = [
 		this.fragmentPars,
 		this.fragmentPars,
 		this.getCodePars( this.fragmentUniform, 'uniform' ),
 		this.getCodePars( this.fragmentUniform, 'uniform' ),
-		this.getIncludes(this.consts['fragment']),
-		this.getIncludes(this.functions['fragment']),
+		this.getIncludes( this.consts[ 'fragment' ] ),
+		this.getIncludes( this.functions[ 'fragment' ] ),
 		'void main(){',
 		'void main(){',
 		this.getCodePars( this.fragmentTemps ),
 		this.getCodePars( this.fragmentTemps ),
 		this.fragmentCode,
 		this.fragmentCode,
 		fragment,
 		fragment,
 		'}'
 		'}'
 	].join( "\n" );
 	].join( "\n" );
-	
+
 	this.needsUpdate = true;
 	this.needsUpdate = true;
 	this.dispose(); // force update
 	this.dispose(); // force update
-	
+
 	return this;
 	return this;
+
 };
 };
 
 
-THREE.NodeMaterial.prototype.define = function(name, value) {
+THREE.NodeMaterial.prototype.define = function( name, value ) {
 
 
-	this.defines[name] = value == undefined ? 1 : value;
+	this.defines[ name ] = value == undefined ? 1 : value;
 
 
 };
 };
 
 
-THREE.NodeMaterial.prototype.isDefined = function(name) {
+THREE.NodeMaterial.prototype.isDefined = function( name ) {
 
 
-	return this.defines[name] != undefined;
+	return this.defines[ name ] != undefined;
 
 
 };
 };
 
 
 THREE.NodeMaterial.prototype.mergeUniform = function( uniforms ) {
 THREE.NodeMaterial.prototype.mergeUniform = function( uniforms ) {
-	
-	for (var name in uniforms) {
-		
+
+	for ( var name in uniforms ) {
+
 		this.uniforms[ name ] = uniforms[ name ];
 		this.uniforms[ name ] = uniforms[ name ];
-	
+
 	}
 	}
-	
+
 };
 };
 
 
 THREE.NodeMaterial.prototype.createUniform = function( value, type, needsUpdate ) {
 THREE.NodeMaterial.prototype.createUniform = function( value, type, needsUpdate ) {
-	
+
 	var index = this.uniformList.length;
 	var index = this.uniformList.length;
-	
+
 	var uniform = {
 	var uniform = {
 		type : type,
 		type : type,
 		value : value,
 		value : value,
 		needsUpdate : needsUpdate,
 		needsUpdate : needsUpdate,
 		name : 'nVu' + index
 		name : 'nVu' + index
 	};
 	};
-	
-	this.uniformList.push(uniform);
-	
+
+	this.uniformList.push( uniform );
+
 	return uniform;
 	return uniform;
-	
+
 };
 };
 
 
 THREE.NodeMaterial.prototype.getVertexTemp = function( uuid, type ) {
 THREE.NodeMaterial.prototype.getVertexTemp = function( uuid, type ) {
-	
-	if (!this.vertexTemps[ uuid ]) {
-		
+
+	if ( ! this.vertexTemps[ uuid ] ) {
+
 		var index = this.vertexTemps.length,
 		var index = this.vertexTemps.length,
 			name = 'nVt' + index,
 			name = 'nVt' + index,
 			data = { name : name, type : type };
 			data = { name : name, type : type };
-		
+
 		this.vertexTemps.push( data );
 		this.vertexTemps.push( data );
-		this.vertexTemps[uuid] = data;
-		
+		this.vertexTemps[ uuid ] = data;
+
 	}
 	}
-	
-	return this.vertexTemps[uuid];
-	
+
+	return this.vertexTemps[ uuid ];
+
 };
 };
 
 
 THREE.NodeMaterial.prototype.getIncludes = function( incs ) {
 THREE.NodeMaterial.prototype.getIncludes = function( incs ) {
-	
-	function sortByPosition(a, b){
+
+	function sortByPosition( a, b ) {
+
 		return b.deps - a.deps;
 		return b.deps - a.deps;
+
 	}
 	}
-	
+
 	return function( incs ) {
 	return function( incs ) {
-		
-		if (!incs) return '';
-		
+
+		if ( ! incs ) return '';
+
 		var code = '';
 		var code = '';
-		var incs = incs.sort(sortByPosition);
-		
-		for(var i = 0; i < incs.length; i++) {
-			
-			code += incs[i].node.src + '\n';
-		
+		var incs = incs.sort( sortByPosition );
+
+		for ( var i = 0; i < incs.length; i ++ ) {
+
+			code += incs[ i ].node.src + '\n';
+
 		}
 		}
-		
+
 		return code;
 		return code;
+
 	}
 	}
+
 }();
 }();
 
 
 THREE.NodeMaterial.prototype.getFragmentTemp = function( uuid, type ) {
 THREE.NodeMaterial.prototype.getFragmentTemp = function( uuid, type ) {
-	
-	if (!this.fragmentTemps[ uuid ]) {
-		
+
+	if ( ! this.fragmentTemps[ uuid ] ) {
+
 		var index = this.fragmentTemps.length,
 		var index = this.fragmentTemps.length,
 			name = 'nVt' + index,
 			name = 'nVt' + index,
 			data = { name : name, type : type };
 			data = { name : name, type : type };
-		
+
 		this.fragmentTemps.push( data );
 		this.fragmentTemps.push( data );
-		this.fragmentTemps[uuid] = data;
-		
+		this.fragmentTemps[ uuid ] = data;
+
 	}
 	}
-	
-	return this.fragmentTemps[uuid];
-	
+
+	return this.fragmentTemps[ uuid ];
+
 };
 };
 
 
 THREE.NodeMaterial.prototype.addVertexPars = function( code ) {
 THREE.NodeMaterial.prototype.addVertexPars = function( code ) {
@@ -343,9 +356,9 @@ THREE.NodeMaterial.prototype.addVertexNode = function( code ) {
 THREE.NodeMaterial.prototype.clearVertexNode = function() {
 THREE.NodeMaterial.prototype.clearVertexNode = function() {
 
 
 	var code = this.fragmentNode;
 	var code = this.fragmentNode;
-	
+
 	this.fragmentNode = '';
 	this.fragmentNode = '';
-	
+
 	return code;
 	return code;
 
 
 };
 };
@@ -359,9 +372,9 @@ THREE.NodeMaterial.prototype.addFragmentNode = function( code ) {
 THREE.NodeMaterial.prototype.clearFragmentNode = function() {
 THREE.NodeMaterial.prototype.clearFragmentNode = function() {
 
 
 	var code = this.fragmentNode;
 	var code = this.fragmentNode;
-	
+
 	this.fragmentNode = '';
 	this.fragmentNode = '';
-	
+
 	return code;
 	return code;
 
 
 };
 };
@@ -371,20 +384,21 @@ THREE.NodeMaterial.prototype.getCodePars = function( pars, prefix ) {
 	prefix = prefix || '';
 	prefix = prefix || '';
 
 
 	var code = '';
 	var code = '';
-	
-	for (var i = 0, l = pars.length; i < l; ++i) {
-		
-		var parsType = pars[i].type;
-		var parsName = pars[i].name;
-		var parsValue = pars[i].value;
-		
-		if (parsType == 't' && parsValue instanceof THREE.CubeTexture) parsType = 'tc';
-		
+
+	for ( var i = 0, l = pars.length; i < l; ++ i ) {
+
+		var parsType = pars[ i ].type;
+		var parsName = pars[ i ].name;
+		var parsValue = pars[ i ].value;
+
+		if ( parsType == 't' && parsValue instanceof THREE.CubeTexture ) parsType = 'tc';
+
 		var type = THREE.NodeMaterial.Type[ parsType ];
 		var type = THREE.NodeMaterial.Type[ parsType ];
-		
-		if (type == undefined) throw new Error( "Node pars " + parsType + " not found." );
-		
+
+		if ( type == undefined ) throw new Error( "Node pars " + parsType + " not found." );
+
 		code += prefix + ' ' + type + ' ' + parsName + ';\n';
 		code += prefix + ' ' + type + ' ' + parsName + ';\n';
+
 	}
 	}
 
 
 	return code;
 	return code;
@@ -394,12 +408,12 @@ THREE.NodeMaterial.prototype.getCodePars = function( pars, prefix ) {
 THREE.NodeMaterial.prototype.getVertexUniform = function( value, type, needsUpdate ) {
 THREE.NodeMaterial.prototype.getVertexUniform = function( value, type, needsUpdate ) {
 
 
 	var uniform = this.createUniform( value, type, needsUpdate );
 	var uniform = this.createUniform( value, type, needsUpdate );
-	
-	this.vertexUniform.push(uniform);
-	this.vertexUniform[uniform.name] = uniform;
-	
+
+	this.vertexUniform.push( uniform );
+	this.vertexUniform[ uniform.name ] = uniform;
+
 	this.uniforms[ uniform.name ] = uniform;
 	this.uniforms[ uniform.name ] = uniform;
-	
+
 	return uniform;
 	return uniform;
 
 
 };
 };
@@ -407,61 +421,61 @@ THREE.NodeMaterial.prototype.getVertexUniform = function( value, type, needsUpda
 THREE.NodeMaterial.prototype.getFragmentUniform = function( value, type, needsUpdate ) {
 THREE.NodeMaterial.prototype.getFragmentUniform = function( value, type, needsUpdate ) {
 
 
 	var uniform = this.createUniform( value, type, needsUpdate );
 	var uniform = this.createUniform( value, type, needsUpdate );
-	
-	this.fragmentUniform.push(uniform);
-	this.fragmentUniform[uniform.name] = uniform;
-	
+
+	this.fragmentUniform.push( uniform );
+	this.fragmentUniform[ uniform.name ] = uniform;
+
 	this.uniforms[ uniform.name ] = uniform;
 	this.uniforms[ uniform.name ] = uniform;
-	
+
 	return uniform;
 	return uniform;
 
 
 };
 };
 
 
 THREE.NodeMaterial.prototype.getDataNode = function( uuid ) {
 THREE.NodeMaterial.prototype.getDataNode = function( uuid ) {
 
 
-	return this.nodeData[uuid] = this.nodeData[uuid] || {};
+	return this.nodeData[ uuid ] = this.nodeData[ uuid ] || {};
 
 
 };
 };
 
 
 THREE.NodeMaterial.prototype.include = function( shader, node ) {
 THREE.NodeMaterial.prototype.include = function( shader, node ) {
-	
+
 	var includes;
 	var includes;
-	
-	node = typeof node === 'string' ? THREE.LibNode.get(node) : node;
-	
-	if (node instanceof THREE.FunctionNode) {
-	
-		for (var i = 0; i < node.includes.length; i++) {
-			
-			this.include( shader, node.includes[i] );
-		
+
+	node = typeof node === 'string' ? THREE.LibNode.get( node ) : node;
+
+	if ( node instanceof THREE.FunctionNode ) {
+
+		for ( var i = 0; i < node.includes.length; i ++ ) {
+
+			this.include( shader, node.includes[ i ] );
+
 		}
 		}
-		
-		includes = this.functions[shader] = this.functions[shader] || [];
-		
+
+		includes = this.functions[ shader ] = this.functions[ shader ] || [];
+
 	}
 	}
-	else if (node instanceof THREE.ConstNode) {
-		
-		includes = this.consts[shader] = this.consts[shader] || [];
-	
+	else if ( node instanceof THREE.ConstNode ) {
+
+		includes = this.consts[ shader ] = this.consts[ shader ] || [];
+
 	}
 	}
-	
-	if (includes[node.name] === undefined) {
-			
-		for (var ext in node.extensions) {
-			
-			this.extensions[ext] = true;
-			
+
+	if ( includes[ node.name ] === undefined ) {
+
+		for ( var ext in node.extensions ) {
+
+			this.extensions[ ext ] = true;
+
 		}
 		}
-		
-		includes[node.name] = { 
+
+		includes[ node.name ] = {
 			node : node,
 			node : node,
 			deps : 1
 			deps : 1
 		};
 		};
-		
-		includes.push(includes[node.name]);
-		
+
+		includes.push( includes[ node.name ] );
+
 	}
 	}
-	else ++includes[node.name].deps;
+	else ++ includes[ node.name ].deps;
 
 
-};
+};

+ 14 - 14
examples/js/materials/nodes/RawNode.js

@@ -3,35 +3,35 @@
  */
  */
 
 
 THREE.RawNode = function( value ) {
 THREE.RawNode = function( value ) {
-	
+
 	THREE.GLNode.call( this, 'v4' );
 	THREE.GLNode.call( this, 'v4' );
-	
+
 	this.value = value;
 	this.value = value;
-	
+
 };
 };
 
 
 THREE.RawNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.RawNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.RawNode.prototype.constructor = THREE.RawNode;
 THREE.RawNode.prototype.constructor = THREE.RawNode;
 
 
 THREE.GLNode.prototype.generate = function( builder ) {
 THREE.GLNode.prototype.generate = function( builder ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var data = this.value.verifyAndBuildCode( builder, this.type );
 	var data = this.value.verifyAndBuildCode( builder, this.type );
-	
+
 	var code = data.code + '\n';
 	var code = data.code + '\n';
-	
-	if (builder.shader == 'vertex') {
-		
+
+	if ( builder.shader == 'vertex' ) {
+
 		code += 'gl_Position = ' + data.result + ';';
 		code += 'gl_Position = ' + data.result + ';';
-		
+
 	}
 	}
 	else {
 	else {
-		
+
 		code += 'gl_FragColor = ' + data.result + ';';
 		code += 'gl_FragColor = ' + data.result + ';';
-	
+
 	}
 	}
-	
+
 	return code;
 	return code;
 
 
-};
+};

+ 57 - 55
examples/js/materials/nodes/TempNode.js

@@ -4,113 +4,115 @@
  */
  */
 
 
 THREE.TempNode = function( type, params ) {
 THREE.TempNode = function( type, params ) {
-	
+
 	THREE.GLNode.call( this, type );
 	THREE.GLNode.call( this, type );
-	
+
 	params = params || {};
 	params = params || {};
-	
+
 	this.shared = params.shared !== undefined ? params.shared : true;
 	this.shared = params.shared !== undefined ? params.shared : true;
 	this.unique = params.unique !== undefined ? params.unique : false;
 	this.unique = params.unique !== undefined ? params.unique : false;
-	
+
 };
 };
 
 
 THREE.TempNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.TempNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.TempNode.prototype.constructor = THREE.TempNode;
 THREE.TempNode.prototype.constructor = THREE.TempNode;
 
 
 THREE.TempNode.prototype.build = function( builder, output, uuid ) {
 THREE.TempNode.prototype.build = function( builder, output, uuid ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
-	if (this.isShared()) {
-		
+
+	if ( this.isShared() ) {
+
 		var isUnique = this.isUnique();
 		var isUnique = this.isUnique();
-		
-		if (isUnique && this.constructor.uuid === undefined) {
-			
+
+		if ( isUnique && this.constructor.uuid === undefined ) {
+
 			this.constructor.uuid = THREE.Math.generateUUID();
 			this.constructor.uuid = THREE.Math.generateUUID();
-		
+
 		}
 		}
-		
-		uuid = builder.getUuid( uuid || this.constructor.uuid || this.uuid, !isUnique );
-		
+
+		uuid = builder.getUuid( uuid || this.constructor.uuid || this.uuid, ! isUnique );
+
 		var data = material.getDataNode( uuid );
 		var data = material.getDataNode( uuid );
-		
-		if (builder.isShader('verify')) {
-		
-			if (data.deps || 0 > 0) {
+
+		if ( builder.isShader( 'verify' ) ) {
+
+			if ( data.deps || 0 > 0 ) {
+
 				this.verifyDepsNode( builder, data, output );
 				this.verifyDepsNode( builder, data, output );
 				return '';
 				return '';
+
 			}
 			}
-			
+
 			return THREE.GLNode.prototype.build.call( this, builder, output, uuid );
 			return THREE.GLNode.prototype.build.call( this, builder, output, uuid );
-			
+
 		}
 		}
-		else if (data.deps == 1) {
-		
+		else if ( data.deps == 1 ) {
+
 			return THREE.GLNode.prototype.build.call( this, builder, output, uuid );
 			return THREE.GLNode.prototype.build.call( this, builder, output, uuid );
-			
+
 		}
 		}
-		
+
 		var name = this.getTemp( builder, uuid );
 		var name = this.getTemp( builder, uuid );
 		var type = data.output || this.getType( builder );
 		var type = data.output || this.getType( builder );
-		
-		if (name) {
-		
+
+		if ( name ) {
+
 			return builder.format( name, type, output );
 			return builder.format( name, type, output );
-			
+
 		}
 		}
 		else {
 		else {
-			
+
 			name = THREE.TempNode.prototype.generate.call( this, builder, output, uuid, data.output );
 			name = THREE.TempNode.prototype.generate.call( this, builder, output, uuid, data.output );
-			
+
 			var code = this.generate( builder, type, uuid );
 			var code = this.generate( builder, type, uuid );
-			
-			if (builder.isShader('vertex')) material.addVertexNode(name + '=' + code + ';');
-			else material.addFragmentNode(name + '=' + code + ';');
-			
+
+			if ( builder.isShader( 'vertex' ) ) material.addVertexNode( name + '=' + code + ';' );
+			else material.addFragmentNode( name + '=' + code + ';' );
+
 			return builder.format( name, type, output );
 			return builder.format( name, type, output );
-		
+
 		}
 		}
-		
+
 	}
 	}
 	else {
 	else {
-		
+
 		return builder.format( this.generate( builder, this.getType( builder ), uuid ), type, output );
 		return builder.format( this.generate( builder, this.getType( builder ), uuid ), type, output );
-	
+
 	}
 	}
-	
+
 };
 };
 
 
 THREE.TempNode.prototype.isShared = function() {
 THREE.TempNode.prototype.isShared = function() {
-	
+
 	return this.shared;
 	return this.shared;
-	
+
 };
 };
 
 
 THREE.TempNode.prototype.isUnique = function() {
 THREE.TempNode.prototype.isUnique = function() {
-	
+
 	return this.unique;
 	return this.unique;
-	
+
 };
 };
 
 
 THREE.TempNode.prototype.getTemp = function( builder, uuid ) {
 THREE.TempNode.prototype.getTemp = function( builder, uuid ) {
-	
+
 	uuid = uuid || this.uuid;
 	uuid = uuid || this.uuid;
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
-	if (builder.isShader('vertex') && material.vertexTemps[ uuid ]) return material.vertexTemps[ uuid ].name;
-	else if (material.fragmentTemps[ uuid ]) return material.fragmentTemps[ uuid ].name;
+
+	if ( builder.isShader( 'vertex' ) && material.vertexTemps[ uuid ] ) return material.vertexTemps[ uuid ].name;
+	else if ( material.fragmentTemps[ uuid ] ) return material.fragmentTemps[ uuid ].name;
 
 
 };
 };
 
 
 THREE.TempNode.prototype.generate = function( builder, output, uuid, type ) {
 THREE.TempNode.prototype.generate = function( builder, output, uuid, type ) {
-	
-	if (!this.isShared()) console.error("THREE.TempNode is not shared!");
-	
+
+	if ( ! this.isShared() ) console.error( "THREE.TempNode is not shared!" );
+
 	uuid = uuid || this.uuid;
 	uuid = uuid || this.uuid;
-	
-	if (builder.isShader('vertex')) return builder.material.getVertexTemp( uuid, type || this.getType( builder ) ).name;
+
+	if ( builder.isShader( 'vertex' ) ) return builder.material.getVertexTemp( uuid, type || this.getType( builder ) ).name;
 	else return builder.material.getFragmentTemp( uuid, type || this.getType( builder ) ).name;
 	else return builder.material.getFragmentTemp( uuid, type || this.getType( builder ) ).name;
 
 
-};
+};

+ 45 - 45
examples/js/materials/nodes/accessors/CameraNode.js

@@ -3,25 +3,25 @@
  */
  */
 
 
 THREE.CameraNode = function( scope, camera ) {
 THREE.CameraNode = function( scope, camera ) {
-	
+
 	THREE.TempNode.call( this, 'v3' );
 	THREE.TempNode.call( this, 'v3' );
-	
+
 	this.scope = scope || THREE.CameraNode.POSITION;
 	this.scope = scope || THREE.CameraNode.POSITION;
 	this.camera = camera;
 	this.camera = camera;
-	
-	switch(scope) {
-		
+
+	switch ( scope ) {
+
 		case THREE.CameraNode.DEPTH:
 		case THREE.CameraNode.DEPTH:
-			
-			this.near = new THREE.FloatNode( camera ? camera.near : 1);
-			this.far = new THREE.FloatNode(camera ? camera.far : 1200);
-			
+
+			this.near = new THREE.FloatNode( camera ? camera.near : 1 );
+			this.far = new THREE.FloatNode( camera ? camera.far : 1200 );
+
 			break;
 			break;
-	
+
 	}
 	}
-	
+
 	this.requestUpdate = this.camera !== undefined;
 	this.requestUpdate = this.camera !== undefined;
-	
+
 };
 };
 
 
 THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -31,76 +31,76 @@ THREE.CameraNode.POSITION = 'position';
 THREE.CameraNode.DEPTH = 'depth';
 THREE.CameraNode.DEPTH = 'depth';
 
 
 THREE.CameraNode.prototype.getType = function( builder ) {
 THREE.CameraNode.prototype.getType = function( builder ) {
-	
-	switch(this.scope) {
+
+	switch ( this.scope ) {
 		case THREE.CameraNode.DEPTH:
 		case THREE.CameraNode.DEPTH:
 			return 'fv1';
 			return 'fv1';
 	}
 	}
-	
+
 	return this.type;
 	return this.type;
-	
+
 };
 };
 
 
 THREE.CameraNode.prototype.isUnique = function( builder ) {
 THREE.CameraNode.prototype.isUnique = function( builder ) {
-	
-	switch(this.scope) {
+
+	switch ( this.scope ) {
 		case THREE.CameraNode.DEPTH:
 		case THREE.CameraNode.DEPTH:
 			return true;
 			return true;
 	}
 	}
-	
+
 	return false;
 	return false;
-	
+
 };
 };
 
 
 THREE.CameraNode.prototype.isShared = function( builder ) {
 THREE.CameraNode.prototype.isShared = function( builder ) {
-	
-	switch(this.scope) {
+
+	switch ( this.scope ) {
 		case THREE.CameraNode.POSITION:
 		case THREE.CameraNode.POSITION:
 			return false;
 			return false;
 	}
 	}
-	
+
 	return true;
 	return true;
-	
+
 };
 };
 
 
 THREE.CameraNode.prototype.generate = function( builder, output ) {
 THREE.CameraNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var result;
 	var result;
-	
-	switch (this.scope) {
-	
+
+	switch ( this.scope ) {
+
 		case THREE.CameraNode.POSITION:
 		case THREE.CameraNode.POSITION:
-	
+
 			result = 'cameraPosition';
 			result = 'cameraPosition';
-			
+
 			break;
 			break;
-			
+
 		case THREE.CameraNode.DEPTH:
 		case THREE.CameraNode.DEPTH:
-			
-			builder.include('depthcolor');
-			
+
+			builder.include( 'depthcolor' );
+
 			result = 'depthcolor(' + this.near.build( builder, 'fv1' ) + ',' + this.far.build( builder, 'fv1' ) + ')';
 			result = 'depthcolor(' + this.near.build( builder, 'fv1' ) + ',' + this.far.build( builder, 'fv1' ) + ')';
-		
+
 			break;
 			break;
-			
+
 	}
 	}
-	
+
 	return builder.format( result, this.getType( builder ), output );
 	return builder.format( result, this.getType( builder ), output );
 
 
 };
 };
 
 
 THREE.CameraNode.prototype.updateAnimation = function( delta ) {
 THREE.CameraNode.prototype.updateAnimation = function( delta ) {
-	
-	switch(this.scope) {
-		
+
+	switch ( this.scope ) {
+
 		case THREE.CameraNode.DEPTH:
 		case THREE.CameraNode.DEPTH:
-		
+
 			this.near.number = camera.near;
 			this.near.number = camera.near;
 			this.far.number = camera.far;
 			this.far.number = camera.far;
-		
+
 			break;
 			break;
-	
+
 	}
 	}
-	
-};
+
+};

+ 13 - 13
examples/js/materials/nodes/accessors/ColorsNode.js

@@ -3,29 +3,29 @@
  */
  */
 
 
 THREE.ColorsNode = function( index ) {
 THREE.ColorsNode = function( index ) {
-	
-	THREE.TempNode.call( this, 'v4', {share:false} );
-	
+
+	THREE.TempNode.call( this, 'v4', { share: false } );
+
 	this.index = index || 0;
 	this.index = index || 0;
-	
+
 };
 };
 
 
 THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.ColorsNode.prototype.constructor = THREE.ColorsNode;
 THREE.ColorsNode.prototype.constructor = THREE.ColorsNode;
 
 
-THREE.ColorsNode.vertexDict = ['color', 'color2'];
-THREE.ColorsNode.fragmentDict = ['vColor', 'vColor2'];
+THREE.ColorsNode.vertexDict = [ 'color', 'color2' ];
+THREE.ColorsNode.fragmentDict = [ 'vColor', 'vColor2' ];
 
 
 THREE.ColorsNode.prototype.generate = function( builder, output ) {
 THREE.ColorsNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var result;
 	var result;
-	
-	material.requestAttrib.color[this.index] = true; 
-	
-	if (builder.isShader('vertex')) result = THREE.ColorsNode.vertexDict[this.index];
-	else result = THREE.ColorsNode.fragmentDict[this.index];
-	
+
+	material.requestAttrib.color[ this.index ] = true;
+
+	if ( builder.isShader( 'vertex' ) ) result = THREE.ColorsNode.vertexDict[ this.index ];
+	else result = THREE.ColorsNode.fragmentDict[ this.index ];
+
 	return builder.format( result, this.getType( builder ), output );
 	return builder.format( result, this.getType( builder ), output );
 
 
 };
 };

+ 25 - 25
examples/js/materials/nodes/accessors/NormalNode.js

@@ -3,11 +3,11 @@
  */
  */
 
 
 THREE.NormalNode = function( scope ) {
 THREE.NormalNode = function( scope ) {
-	
+
 	THREE.TempNode.call( this, 'v3' );
 	THREE.TempNode.call( this, 'v3' );
-	
+
 	this.scope = scope || THREE.NormalNode.LOCAL;
 	this.scope = scope || THREE.NormalNode.LOCAL;
-	
+
 };
 };
 
 
 THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -18,49 +18,49 @@ THREE.NormalNode.WORLD = 'world';
 THREE.NormalNode.VIEW = 'view';
 THREE.NormalNode.VIEW = 'view';
 
 
 THREE.NormalNode.prototype.isShared = function( builder ) {
 THREE.NormalNode.prototype.isShared = function( builder ) {
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.NormalNode.WORLD:
 		case THREE.NormalNode.WORLD:
 			return true;
 			return true;
 	}
 	}
-	
+
 	return false;
 	return false;
-	
+
 };
 };
 
 
 THREE.NormalNode.prototype.generate = function( builder, output ) {
 THREE.NormalNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var result;
 	var result;
-	
-	switch (this.scope) {
-	
+
+	switch ( this.scope ) {
+
 		case THREE.NormalNode.LOCAL:
 		case THREE.NormalNode.LOCAL:
-	
+
 			material.requestAttrib.normal = true;
 			material.requestAttrib.normal = true;
-	
-			if (builder.isShader('vertex')) result = 'normal';
+
+			if ( builder.isShader( 'vertex' ) ) result = 'normal';
 			else result = 'vObjectNormal';
 			else result = 'vObjectNormal';
-			
+
 			break;
 			break;
-			
+
 		case THREE.NormalNode.WORLD:
 		case THREE.NormalNode.WORLD:
-	
+
 			material.requestAttrib.worldNormal = true;
 			material.requestAttrib.worldNormal = true;
-			
-			if (builder.isShader('vertex')) result = '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz';
+
+			if ( builder.isShader( 'vertex' ) ) result = '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz';
 			else result = 'vWNormal';
 			else result = 'vWNormal';
-			
+
 			break;
 			break;
-			
+
 		case THREE.NormalNode.VIEW:
 		case THREE.NormalNode.VIEW:
-	
+
 			result = 'vNormal';
 			result = 'vNormal';
-			
+
 			break;
 			break;
-			
+
 	}
 	}
-	
+
 	return builder.format( result, this.getType( builder ), output );
 	return builder.format( result, this.getType( builder ), output );
 
 
 };
 };

+ 35 - 35
examples/js/materials/nodes/accessors/PositionNode.js

@@ -3,11 +3,11 @@
  */
  */
 
 
 THREE.PositionNode = function( scope ) {
 THREE.PositionNode = function( scope ) {
-	
+
 	THREE.TempNode.call( this, 'v3' );
 	THREE.TempNode.call( this, 'v3' );
-	
+
 	this.scope = scope || THREE.PositionNode.LOCAL;
 	this.scope = scope || THREE.PositionNode.LOCAL;
-	
+
 };
 };
 
 
 THREE.PositionNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.PositionNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -19,69 +19,69 @@ THREE.PositionNode.VIEW = 'view';
 THREE.PositionNode.PROJECTION = 'projection';
 THREE.PositionNode.PROJECTION = 'projection';
 
 
 THREE.PositionNode.prototype.getType = function( builder ) {
 THREE.PositionNode.prototype.getType = function( builder ) {
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.PositionNode.PROJECTION:
 		case THREE.PositionNode.PROJECTION:
 			return 'v4';
 			return 'v4';
 	}
 	}
-	
+
 	return this.type;
 	return this.type;
-	
+
 };
 };
 
 
 THREE.PositionNode.prototype.isShared = function( builder ) {
 THREE.PositionNode.prototype.isShared = function( builder ) {
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.PositionNode.LOCAL:
 		case THREE.PositionNode.LOCAL:
 		case THREE.PositionNode.WORLD:
 		case THREE.PositionNode.WORLD:
 			return false;
 			return false;
 	}
 	}
-	
+
 	return true;
 	return true;
-	
+
 };
 };
 
 
 THREE.PositionNode.prototype.generate = function( builder, output ) {
 THREE.PositionNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var result;
 	var result;
-	
-	switch (this.scope) {
-	
+
+	switch ( this.scope ) {
+
 		case THREE.PositionNode.LOCAL:
 		case THREE.PositionNode.LOCAL:
-	
+
 			material.requestAttrib.position = true;
 			material.requestAttrib.position = true;
-			
-			if (builder.isShader('vertex')) result = 'transformed';
+
+			if ( builder.isShader( 'vertex' ) ) result = 'transformed';
 			else result = 'vPosition';
 			else result = 'vPosition';
-			
+
 			break;
 			break;
-			
+
 		case THREE.PositionNode.WORLD:
 		case THREE.PositionNode.WORLD:
-	
+
 			material.requestAttrib.worldPosition = true;
 			material.requestAttrib.worldPosition = true;
-			
-			if (builder.isShader('vertex')) result = 'vWPosition';
+
+			if ( builder.isShader( 'vertex' ) ) result = 'vWPosition';
 			else result = 'vWPosition';
 			else result = 'vWPosition';
-			
+
 			break;
 			break;
-			
+
 		case THREE.PositionNode.VIEW:
 		case THREE.PositionNode.VIEW:
-	
-			if (builder.isShader('vertex')) result = '-mvPosition.xyz';
+
+			if ( builder.isShader( 'vertex' ) ) result = '-mvPosition.xyz';
 			else result = 'vViewPosition';
 			else result = 'vViewPosition';
-			
+
 			break;
 			break;
-			
+
 		case THREE.PositionNode.PROJECTION:
 		case THREE.PositionNode.PROJECTION:
-	
-			if (builder.isShader('vertex')) result = '(projectionMatrix * modelViewMatrix * vec4( position, 1.0 ))';
+
+			if ( builder.isShader( 'vertex' ) ) result = '(projectionMatrix * modelViewMatrix * vec4( position, 1.0 ))';
 			else result = 'vec4( 0.0 )';
 			else result = 'vec4( 0.0 )';
-			
+
 			break;
 			break;
-			
+
 	}
 	}
-	
+
 	return builder.format( result, this.getType( builder ), output );
 	return builder.format( result, this.getType( builder ), output );
 
 
-};
+};

+ 16 - 16
examples/js/materials/nodes/accessors/ReflectNode.js

@@ -3,37 +3,37 @@
  */
  */
 
 
 THREE.ReflectNode = function() {
 THREE.ReflectNode = function() {
-	
-	THREE.TempNode.call( this, 'v3', {unique:true} );
-	
+
+	THREE.TempNode.call( this, 'v3', { unique: true } );
+
 	this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD );
 	this.worldPosition = new THREE.PositionNode( THREE.PositionNode.WORLD );
-	
+
 };
 };
 
 
 THREE.ReflectNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.ReflectNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.ReflectNode.prototype.constructor = THREE.ReflectNode;
 THREE.ReflectNode.prototype.constructor = THREE.ReflectNode;
 
 
 THREE.ReflectNode.prototype.generate = function( builder, output ) {
 THREE.ReflectNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
-	if (builder.isShader('fragment')) {
-		
+
+	if ( builder.isShader( 'fragment' ) ) {
+
 		material.addFragmentNode( [
 		material.addFragmentNode( [
-			'vec3 cameraToVertex = normalize( ' + this.worldPosition.build( builder, 'v3' )  + ' - cameraPosition );',
+			'vec3 cameraToVertex = normalize( ' + this.worldPosition.build( builder, 'v3' ) + ' - cameraPosition );',
 			'vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );',
 			'vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );',
 			'vec3 vReflect = reflect( cameraToVertex, worldNormal );'
 			'vec3 vReflect = reflect( cameraToVertex, worldNormal );'
 		].join( "\n" ) );
 		].join( "\n" ) );
-		
+
 		return builder.format( 'vReflect', this.type, output );
 		return builder.format( 'vReflect', this.type, output );
-		
+
 	}
 	}
 	else {
 	else {
-		
-		console.warn("THREE.ReflectNode is not compatible with " + builder.shader + " shader");
-		
+
+		console.warn( "THREE.ReflectNode is not compatible with " + builder.shader + " shader" );
+
 		return builder.format( 'vec3( 0.0 )', this.type, output );
 		return builder.format( 'vec3( 0.0 )', this.type, output );
-	
+
 	}
 	}
 
 
-};
+};

+ 13 - 13
examples/js/materials/nodes/accessors/UVNode.js

@@ -3,29 +3,29 @@
  */
  */
 
 
 THREE.UVNode = function( index ) {
 THREE.UVNode = function( index ) {
-	
-	THREE.TempNode.call( this, 'v2', {shared:false} );
-	
+
+	THREE.TempNode.call( this, 'v2', { shared: false } );
+
 	this.index = index || 0;
 	this.index = index || 0;
-	
+
 };
 };
 
 
 THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.UVNode.prototype.constructor = THREE.UVNode;
 THREE.UVNode.prototype.constructor = THREE.UVNode;
 
 
-THREE.UVNode.vertexDict = ['uv', 'uv2'];
-THREE.UVNode.fragmentDict = ['vUv', 'vUv2'];
+THREE.UVNode.vertexDict = [ 'uv', 'uv2' ];
+THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ];
 
 
 THREE.UVNode.prototype.generate = function( builder, output ) {
 THREE.UVNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var result;
 	var result;
-	
-	material.requestAttrib.uv[this.index] = true; 
-	
-	if (builder.isShader('vertex')) result = THREE.UVNode.vertexDict[this.index];
-	else result = THREE.UVNode.fragmentDict[this.index];
-	
+
+	material.requestAttrib.uv[ this.index ] = true;
+
+	if ( builder.isShader( 'vertex' ) ) result = THREE.UVNode.vertexDict[ this.index ];
+	else result = THREE.UVNode.fragmentDict[ this.index ];
+
 	return builder.format( result, this.getType( builder ), output );
 	return builder.format( result, this.getType( builder ), output );
 
 
 };
 };

+ 19 - 19
examples/js/materials/nodes/extras/VelocityNode.js

@@ -3,38 +3,38 @@
  */
  */
 
 
 THREE.VelocityNode = function( target, params ) {
 THREE.VelocityNode = function( target, params ) {
-	
+
 	THREE.Vector3Node.call( this );
 	THREE.Vector3Node.call( this );
-	
+
 	this.requestUpdate = true;
 	this.requestUpdate = true;
-	
+
 	this.target = target;
 	this.target = target;
-	
+
 	this.position = this.target.position.clone();
 	this.position = this.target.position.clone();
 	this.velocity = new THREE.Vector3();
 	this.velocity = new THREE.Vector3();
 	this.moment = new THREE.Vector3();
 	this.moment = new THREE.Vector3();
-	
+
 	this.params = params || {};
 	this.params = params || {};
-	
+
 };
 };
 
 
 THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype );
 THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype );
 THREE.VelocityNode.prototype.constructor = THREE.VelocityNode;
 THREE.VelocityNode.prototype.constructor = THREE.VelocityNode;
 
 
 THREE.VelocityNode.prototype.updateAnimation = function( delta ) {
 THREE.VelocityNode.prototype.updateAnimation = function( delta ) {
-	
+
 	this.velocity.subVectors( this.target.position, this.position );
 	this.velocity.subVectors( this.target.position, this.position );
 	this.position.copy( this.target.position );
 	this.position.copy( this.target.position );
-	
-	switch(this.params.type) {
-			
+
+	switch ( this.params.type ) {
+
 		case "elastic":
 		case "elastic":
-			
+
 			delta *= this.params.fps || 60;
 			delta *= this.params.fps || 60;
-			
+
 			var spring = Math.pow( this.params.spring, delta );
 			var spring = Math.pow( this.params.spring, delta );
 			var friction = Math.pow( this.params.friction, delta );
 			var friction = Math.pow( this.params.friction, delta );
-			
+
 			// spring
 			// spring
 			this.moment.x += this.velocity.x * spring;
 			this.moment.x += this.velocity.x * spring;
 			this.moment.y += this.velocity.y * spring;
 			this.moment.y += this.velocity.y * spring;
@@ -46,14 +46,14 @@ THREE.VelocityNode.prototype.updateAnimation = function( delta ) {
 			this.moment.z *= friction;
 			this.moment.z *= friction;
 
 
 			this.value.copy( this.moment );
 			this.value.copy( this.moment );
-		
+
 			break;
 			break;
-	
+
 		default:
 		default:
-			
+
 			this.value.copy( this.velocity );
 			this.value.copy( this.velocity );
-		
+
 			break;
 			break;
 	}
 	}
-	
-};
+
+};

+ 5 - 5
examples/js/materials/nodes/inputs/ColorNode.js

@@ -3,14 +3,14 @@
  */
  */
 
 
 THREE.ColorNode = function( color ) {
 THREE.ColorNode = function( color ) {
-	
-	THREE.InputNode.call( this, 'c', {share:false} );
-	
+
+	THREE.InputNode.call( this, 'c', { share: false } );
+
 	this.value = new THREE.Color( color || 0 );
 	this.value = new THREE.Color( color || 0 );
-	
+
 };
 };
 
 
 THREE.ColorNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.ColorNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.ColorNode.prototype.constructor = THREE.ColorNode;
 THREE.ColorNode.prototype.constructor = THREE.ColorNode;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] );
+THREE.NodeMaterial.Shortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] );

+ 11 - 11
examples/js/materials/nodes/inputs/CubeTextureNode.js

@@ -3,13 +3,13 @@
  */
  */
 
 
 THREE.CubeTextureNode = function( value, coord, bias ) {
 THREE.CubeTextureNode = function( value, coord, bias ) {
-	
+
 	THREE.InputNode.call( this, 'v4' );
 	THREE.InputNode.call( this, 'v4' );
 
 
 	this.value = value;
 	this.value = value;
 	this.coord = coord || new THREE.ReflectNode();
 	this.coord = coord || new THREE.ReflectNode();
 	this.bias = bias;
 	this.bias = bias;
-	
+
 };
 };
 
 
 THREE.CubeTextureNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.CubeTextureNode.prototype = Object.create( THREE.InputNode.prototype );
@@ -20,18 +20,18 @@ THREE.CubeTextureNode.prototype.generate = function( builder, output ) {
 	var cubetex = THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
 	var cubetex = THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
 	var coord = this.coord.build( builder, 'v3' );
 	var coord = this.coord.build( builder, 'v3' );
 	var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;;
 	var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;;
-	
-	if (bias == undefined && builder.require.cubeTextureBias) {
-		
+
+	if ( bias == undefined && builder.require.cubeTextureBias ) {
+
 		bias = builder.require.cubeTextureBias.build( builder, 'fv1' );
 		bias = builder.require.cubeTextureBias.build( builder, 'fv1' );
-		
+
 	}
 	}
-	
+
 	var code;
 	var code;
 
 
-	if (bias) code = 'textureCube(' + cubetex + ',' + coord + ',' + bias + ')';
+	if ( bias ) code = 'textureCube(' + cubetex + ',' + coord + ',' + bias + ')';
 	else code = 'textureCube(' + cubetex + ',' + coord + ')';
 	else code = 'textureCube(' + cubetex + ',' + coord + ')';
-	
-	return builder.format(code, this.type, output );
 
 
-};
+	return builder.format( code, this.type, output );
+
+};

+ 15 - 7
examples/js/materials/nodes/inputs/FloatNode.js

@@ -3,11 +3,11 @@
  */
  */
 
 
 THREE.FloatNode = function( value ) {
 THREE.FloatNode = function( value ) {
-	
-	THREE.InputNode.call( this, 'fv1', {share:false} );
-	
+
+	THREE.InputNode.call( this, 'fv1', { share: false } );
+
 	this.value = [ value || 0 ];
 	this.value = [ value || 0 ];
-	
+
 };
 };
 
 
 THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.FloatNode.prototype = Object.create( THREE.InputNode.prototype );
@@ -15,7 +15,15 @@ THREE.FloatNode.prototype.constructor = THREE.FloatNode;
 
 
 Object.defineProperties( THREE.FloatNode.prototype, {
 Object.defineProperties( THREE.FloatNode.prototype, {
 	number: {
 	number: {
-		get: function () { return this.value[0]; },
-		set: function ( val ) { this.value[0] = val; }
+		get: function() {
+
+			return this.value[ 0 ];
+
+		},
+		set: function( val ) {
+
+			this.value[ 0 ] = val;
+
+		}
 	}
 	}
-});
+} );

+ 16 - 8
examples/js/materials/nodes/inputs/IntNode.js

@@ -3,11 +3,11 @@
  */
  */
 
 
 THREE.IntNode = function( value ) {
 THREE.IntNode = function( value ) {
-	
-	THREE.InputNode.call( this, 'fv1', {share:false} );
-	
-	this.value = [ Math.floor(value || 0) ];
-	
+
+	THREE.InputNode.call( this, 'fv1', { share: false } );
+
+	this.value = [ Math.floor( value || 0 ) ];
+
 };
 };
 
 
 THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype );
@@ -15,7 +15,15 @@ THREE.IntNode.prototype.constructor = THREE.IntNode;
 
 
 Object.defineProperties( THREE.IntNode.prototype, {
 Object.defineProperties( THREE.IntNode.prototype, {
 	number: {
 	number: {
-		get: function () { return this.value[0]; },
-		set: function ( val ) { this.value[0] = Math.floor(val); }
+		get: function() {
+
+			return this.value[ 0 ];
+
+		},
+		set: function( val ) {
+
+			this.value[ 0 ] = Math.floor( val );
+
+		}
 	}
 	}
-});
+} );

+ 7 - 7
examples/js/materials/nodes/inputs/TextureNode.js

@@ -3,13 +3,13 @@
  */
  */
 
 
 THREE.TextureNode = function( value, coord, bias ) {
 THREE.TextureNode = function( value, coord, bias ) {
-	
+
 	THREE.InputNode.call( this, 'v4' );
 	THREE.InputNode.call( this, 'v4' );
-	
+
 	this.value = value;
 	this.value = value;
 	this.coord = coord || new THREE.UVNode();
 	this.coord = coord || new THREE.UVNode();
 	this.bias = bias;
 	this.bias = bias;
-	
+
 };
 };
 
 
 THREE.TextureNode.prototype = Object.create( THREE.InputNode.prototype );
 THREE.TextureNode.prototype = Object.create( THREE.InputNode.prototype );
@@ -20,12 +20,12 @@ THREE.TextureNode.prototype.generate = function( builder, output ) {
 	var tex = THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
 	var tex = THREE.InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
 	var coord = this.coord.build( builder, 'v2' );
 	var coord = this.coord.build( builder, 'v2' );
 	var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;
 	var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;
-	
+
 	var code;
 	var code;
 
 
-	if (bias) code = 'texture2D(' + tex + ',' + coord + ',' + bias + ')';
+	if ( bias ) code = 'texture2D(' + tex + ',' + coord + ',' + bias + ')';
 	else code = 'texture2D(' + tex + ',' + coord + ')';
 	else code = 'texture2D(' + tex + ',' + coord + ')';
-	
-	return builder.format(code, this.type, output );
+
+	return builder.format( code, this.type, output );
 
 
 };
 };

+ 5 - 5
examples/js/materials/nodes/inputs/Vector2Node.js

@@ -3,14 +3,14 @@
  */
  */
 
 
 THREE.Vector2Node = function( x, y ) {
 THREE.Vector2Node = function( x, y ) {
-	
-	THREE.InputNode.call( this, 'v2', {share:false} );
-	
+
+	THREE.InputNode.call( this, 'v2', { share: false } );
+
 	this.value = new THREE.Vector2( x, y );
 	this.value = new THREE.Vector2( x, y );
-	
+
 };
 };
 
 
 THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector2Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector2Node.prototype.constructor = THREE.Vector2Node;
 THREE.Vector2Node.prototype.constructor = THREE.Vector2Node;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] );
+THREE.NodeMaterial.Shortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] );

+ 5 - 5
examples/js/materials/nodes/inputs/Vector3Node.js

@@ -3,15 +3,15 @@
  */
  */
 
 
 THREE.Vector3Node = function( x, y, z ) {
 THREE.Vector3Node = function( x, y, z ) {
-	
-	THREE.InputNode.call( this, 'v3', {share:false} );
-	
+
+	THREE.InputNode.call( this, 'v3', { share: false } );
+
 	this.type = 'v3';
 	this.type = 'v3';
 	this.value = new THREE.Vector3( x, y, z );
 	this.value = new THREE.Vector3( x, y, z );
-	
+
 };
 };
 
 
 THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector3Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector3Node.prototype.constructor = THREE.Vector3Node;
 THREE.Vector3Node.prototype.constructor = THREE.Vector3Node;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] );
+THREE.NodeMaterial.Shortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] );

+ 5 - 5
examples/js/materials/nodes/inputs/Vector4Node.js

@@ -3,14 +3,14 @@
  */
  */
 
 
 THREE.Vector4Node = function( x, y, z, w ) {
 THREE.Vector4Node = function( x, y, z, w ) {
-	
-	THREE.InputNode.call( this, 'v4', {share:false} );
-	
+
+	THREE.InputNode.call( this, 'v4', { share: false } );
+
 	this.value = new THREE.Vector4( x, y, z, w );
 	this.value = new THREE.Vector4( x, y, z, w );
-	
+
 };
 };
 
 
 THREE.Vector4Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector4Node.prototype = Object.create( THREE.InputNode.prototype );
 THREE.Vector4Node.prototype.constructor = THREE.Vector4Node;
 THREE.Vector4Node.prototype.constructor = THREE.Vector4Node;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] );
+THREE.NodeMaterial.Shortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] );

+ 104 - 87
examples/js/materials/nodes/interfaces/PhongNode.js

@@ -3,32 +3,32 @@
  */
  */
 
 
 THREE.PhongNode = function() {
 THREE.PhongNode = function() {
-	
+
 	THREE.GLNode.call( this );
 	THREE.GLNode.call( this );
-	
+
 	this.color = new THREE.ColorNode( 0xEEEEEE );
 	this.color = new THREE.ColorNode( 0xEEEEEE );
 	this.specular = new THREE.ColorNode( 0x111111 );
 	this.specular = new THREE.ColorNode( 0x111111 );
 	this.shininess = new THREE.FloatNode( 30 );
 	this.shininess = new THREE.FloatNode( 30 );
-	
+
 };
 };
 
 
 THREE.PhongNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.PhongNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.PhongNode.prototype.constructor = THREE.PhongNode;
 THREE.PhongNode.prototype.constructor = THREE.PhongNode;
 
 
 THREE.PhongNode.prototype.build = function( builder ) {
 THREE.PhongNode.prototype.build = function( builder ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var code;
 	var code;
-	
+
 	material.define( 'PHONG' );
 	material.define( 'PHONG' );
 	material.define( 'ALPHATEST', '0.0' );
 	material.define( 'ALPHATEST', '0.0' );
-	
+
 	material.needsLight = true;
 	material.needsLight = true;
-	
-	if (builder.isShader('vertex')) {
-		
+
+	if ( builder.isShader( 'vertex' ) ) {
+
 		var transform = this.transform ? this.transform.verifyAndBuildCode( builder, 'v3' ) : undefined;
 		var transform = this.transform ? this.transform.verifyAndBuildCode( builder, 'v3' ) : undefined;
-		
+
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 
 
 			THREE.UniformsLib[ "fog" ],
 			THREE.UniformsLib[ "fog" ],
@@ -36,7 +36,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
 			THREE.UniformsLib[ "shadowmap" ]
 			THREE.UniformsLib[ "shadowmap" ]
 
 
 		] ) );
 		] ) );
-		
+
 		material.addVertexPars( [
 		material.addVertexPars( [
 			"varying vec3 vViewPosition;",
 			"varying vec3 vViewPosition;",
 
 
@@ -54,7 +54,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
 			THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ]
 			THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ]
 
 
 		].join( "\n" ) );
 		].join( "\n" ) );
-		
+
 		var output = [
 		var output = [
 				THREE.ShaderChunk[ "beginnormal_vertex" ],
 				THREE.ShaderChunk[ "beginnormal_vertex" ],
 				THREE.ShaderChunk[ "morphnormal_vertex" ],
 				THREE.ShaderChunk[ "morphnormal_vertex" ],
@@ -70,12 +70,14 @@ THREE.PhongNode.prototype.build = function( builder ) {
 
 
 				THREE.ShaderChunk[ "begin_vertex" ]
 				THREE.ShaderChunk[ "begin_vertex" ]
 		];
 		];
-		
+
 		if ( transform ) {
 		if ( transform ) {
+
 			output.push( transform.code );
 			output.push( transform.code );
 			output.push( "transformed = " + transform.result + ";" );
 			output.push( "transformed = " + transform.result + ";" );
+
 		}
 		}
-		
+
 		output.push(
 		output.push(
 				THREE.ShaderChunk[ "morphtarget_vertex" ],
 				THREE.ShaderChunk[ "morphtarget_vertex" ],
 				THREE.ShaderChunk[ "skinning_vertex" ],
 				THREE.ShaderChunk[ "skinning_vertex" ],
@@ -88,52 +90,52 @@ THREE.PhongNode.prototype.build = function( builder ) {
 				THREE.ShaderChunk[ "lights_phong_vertex" ],
 				THREE.ShaderChunk[ "lights_phong_vertex" ],
 				THREE.ShaderChunk[ "shadowmap_vertex" ]
 				THREE.ShaderChunk[ "shadowmap_vertex" ]
 		);
 		);
-		
+
 		code = output.join( "\n" );
 		code = output.join( "\n" );
-		
+
 	}
 	}
 	else {
 	else {
-		
+
 		// verify all nodes to reuse generate codes
 		// verify all nodes to reuse generate codes
-		
+
 		this.color.verify( builder );
 		this.color.verify( builder );
 		this.specular.verify( builder );
 		this.specular.verify( builder );
 		this.shininess.verify( builder );
 		this.shininess.verify( builder );
-		
-		if (this.alpha) this.alpha.verify( builder );
-		
-		if (this.ao) this.ao.verify( builder );
-		if (this.ambient) this.ambient.verify( builder );
-		if (this.shadow) this.shadow.verify( builder );
-		if (this.emissive) this.emissive.verify( builder );
-		
-		if (this.normal) this.normal.verify( builder );
-		if (this.normalScale && this.normal) this.normalScale.verify( builder );
-		
-		if (this.environment) this.environment.verify( builder );
-		if (this.reflectivity && this.environment) this.reflectivity.verify( builder );
-		
+
+		if ( this.alpha ) this.alpha.verify( builder );
+
+		if ( this.ao ) this.ao.verify( builder );
+		if ( this.ambient ) this.ambient.verify( builder );
+		if ( this.shadow ) this.shadow.verify( builder );
+		if ( this.emissive ) this.emissive.verify( builder );
+
+		if ( this.normal ) this.normal.verify( builder );
+		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
+
+		if ( this.environment ) this.environment.verify( builder );
+		if ( this.reflectivity && this.environment ) this.reflectivity.verify( builder );
+
 		// build code
 		// build code
-		
+
 		var color = this.color.buildCode( builder, 'v4' );
 		var color = this.color.buildCode( builder, 'v4' );
 		var specular = this.specular.buildCode( builder, 'c' );
 		var specular = this.specular.buildCode( builder, 'c' );
 		var shininess = this.shininess.buildCode( builder, 'fv1' );
 		var shininess = this.shininess.buildCode( builder, 'fv1' );
-		
+
 		var alpha = this.alpha ? this.alpha.buildCode( builder, 'fv1' ) : undefined;
 		var alpha = this.alpha ? this.alpha.buildCode( builder, 'fv1' ) : undefined;
-		
+
 		var ao = this.ao ? this.ao.buildCode( builder, 'c' ) : undefined;
 		var ao = this.ao ? this.ao.buildCode( builder, 'c' ) : undefined;
 		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
 		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
 		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
 		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
 		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c' ) : undefined;
 		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c' ) : undefined;
-		
+
 		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
 		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'fv1' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'fv1' ) : undefined;
-		
-		var environment = this.environment ? this.environment.buildCode( builder.setCache('env'), 'c' ) : undefined; 
+
+		var environment = this.environment ? this.environment.buildCode( builder.setCache( 'env' ), 'c' ) : undefined;
 		var reflectivity = this.reflectivity && this.environment ? this.reflectivity.buildCode( builder, 'fv1' ) : undefined;
 		var reflectivity = this.reflectivity && this.environment ? this.reflectivity.buildCode( builder, 'fv1' ) : undefined;
-		
+
 		material.needsTransparent = alpha != undefined;
 		material.needsTransparent = alpha != undefined;
-		
+
 		material.addFragmentPars( [
 		material.addFragmentPars( [
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
@@ -143,115 +145,130 @@ THREE.PhongNode.prototype.build = function( builder ) {
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ]
 			THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ]
 		].join( "\n" ) );
 		].join( "\n" ) );
-	
+
 		var output = [
 		var output = [
 				// prevent undeclared normal
 				// prevent undeclared normal
 				THREE.ShaderChunk[ "normal_fragment" ],
 				THREE.ShaderChunk[ "normal_fragment" ],
-			
+
 				color.code,
 				color.code,
 			"	vec4 diffuseColor = " + color.result + ";",
 			"	vec4 diffuseColor = " + color.result + ";",
 			"	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
 			"	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
-			
+
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
-				
+
 			specular.code,
 			specular.code,
 			"	vec3 specular = " + specular.result + ";",
 			"	vec3 specular = " + specular.result + ";",
-			
+
 			shininess.code,
 			shininess.code,
 			"	float shininess = max(0.0001," + shininess.result + ");",
 			"	float shininess = max(0.0001," + shininess.result + ");",
-			
+
 			"	float specularStrength = 1.0;" // Ignored in MaterialNode ( replace to specular )
 			"	float specularStrength = 1.0;" // Ignored in MaterialNode ( replace to specular )
-		];	
-		
-		if (alpha) {
-			
-			output.push( 
+		];
+
+		if ( alpha ) {
+
+			output.push(
 				alpha.code,
 				alpha.code,
 				'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
 				'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
 			);
 			);
-		
+
 		}
 		}
-		
-		if (normal) {
-			
+
+		if ( normal ) {
+
 			builder.include( 'perturbNormal2Arb' );
 			builder.include( 'perturbNormal2Arb' );
-			
-			output.push(normal.code);
-			
-			if (normalScale) output.push(normalScale.code);
-			
+
+			output.push( normal.code );
+
+			if ( normalScale ) output.push( normalScale.code );
+
 			output.push(
 			output.push(
 				'normal = perturbNormal2Arb(-vViewPosition,normal,' +
 				'normal = perturbNormal2Arb(-vViewPosition,normal,' +
 				normal.result + ',' +
 				normal.result + ',' +
 				new THREE.UVNode().build( builder, 'v2' ) + ',' +
 				new THREE.UVNode().build( builder, 'v2' ) + ',' +
-				(normalScale ? normalScale.result : '1.0') + ');'
+				( normalScale ? normalScale.result : '1.0' ) + ');'
 			);
 			);
 
 
 		}
 		}
 
 
 		output.push(
 		output.push(
 			THREE.ShaderChunk[ "shadowmap_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_fragment" ],
-			
+
 			// accumulation
 			// accumulation
 			THREE.ShaderChunk[ "lights_phong_fragment" ],
 			THREE.ShaderChunk[ "lights_phong_fragment" ],
 			THREE.ShaderChunk[ "lights_template" ]
 			THREE.ShaderChunk[ "lights_template" ]
 		);
 		);
-		
-		if (ao) { 
+
+		if ( ao ) {
+
 			output.push( ao.code );
 			output.push( ao.code );
 			output.push( "reflectedLight.indirectDiffuse *= " + ao.result + ";" );
 			output.push( "reflectedLight.indirectDiffuse *= " + ao.result + ";" );
+
 		}
 		}
-		
-		if (ambient) { 
+
+		if ( ambient ) {
+
 			output.push( ambient.code );
 			output.push( ambient.code );
 			output.push( "reflectedLight.indirectDiffuse += " + ambient.result + ";" );
 			output.push( "reflectedLight.indirectDiffuse += " + ambient.result + ";" );
+
 		}
 		}
-		
-		if (shadow) {
+
+		if ( shadow ) {
+
 			output.push( shadow.code );
 			output.push( shadow.code );
 			output.push( "reflectedLight.directDiffuse *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directDiffuse *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directSpecular *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directSpecular *= " + shadow.result + ";" );
+
 		}
 		}
-		
-		if (emissive) { 
+
+		if ( emissive ) {
+
 			output.push( emissive.code );
 			output.push( emissive.code );
 			output.push( "reflectedLight.directDiffuse += " + emissive.result + ";" );
 			output.push( "reflectedLight.directDiffuse += " + emissive.result + ";" );
+
 		}
 		}
-		
-		output.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");
-		
-		if (environment) {
+
+		output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" );
+
+		if ( environment ) {
+
 			output.push( environment.code );
 			output.push( environment.code );
-			
-			if (reflectivity) {
-				
+
+			if ( reflectivity ) {
+
 				output.push( reflectivity.code );
 				output.push( reflectivity.code );
-				
+
 				output.push( "outgoingLight = mix(" + 'outgoingLight' + "," + environment.result + "," + reflectivity.result + ");" );
 				output.push( "outgoingLight = mix(" + 'outgoingLight' + "," + environment.result + "," + reflectivity.result + ");" );
-				
+
 			}
 			}
 			else {
 			else {
-			
+
 				output.push( "outgoingLight = " + environment.result + ";" );
 				output.push( "outgoingLight = " + environment.result + ";" );
+
 			}
 			}
+
 		}
 		}
-		
+
 		output.push(
 		output.push(
 			THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
 			THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
 			THREE.ShaderChunk[ "fog_fragment" ]
 			THREE.ShaderChunk[ "fog_fragment" ]
 		);
 		);
-		
-		if (alpha) {
+
+		if ( alpha ) {
+
 			output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" );
 			output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" );
+
 		}
 		}
 		else {
 		else {
+
 			output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" );
 			output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" );
+
 		}
 		}
-		
+
 		code = output.join( "\n" );
 		code = output.join( "\n" );
-	
+
 	}
 	}
-	
+
 	return code;
 	return code;
 
 
-};
+};

+ 5 - 5
examples/js/materials/nodes/interfaces/PhongNodeMaterial.js

@@ -3,15 +3,15 @@
  */
  */
 
 
 THREE.PhongNodeMaterial = function() {
 THREE.PhongNodeMaterial = function() {
-	
+
 	this.node = new THREE.PhongNode();
 	this.node = new THREE.PhongNode();
-	
+
 	THREE.NodeMaterial.call( this, this.node, this.node );
 	THREE.NodeMaterial.call( this, this.node, this.node );
-	
+
 };
 };
 
 
 THREE.PhongNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype );
 THREE.PhongNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype );
 THREE.PhongNodeMaterial.prototype.constructor = THREE.PhongNodeMaterial;
 THREE.PhongNodeMaterial.prototype.constructor = THREE.PhongNodeMaterial;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.PhongNodeMaterial.prototype, 'node', 
-[ 'color',  'alpha', 'specular', 'shininess', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'reflectivity', 'transform' ] );
+THREE.NodeMaterial.Shortcuts( THREE.PhongNodeMaterial.prototype, 'node',
+[ 'color', 'alpha', 'specular', 'shininess', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'reflectivity', 'transform' ] );

+ 107 - 89
examples/js/materials/nodes/interfaces/StandardNode.js

@@ -3,32 +3,32 @@
  */
  */
 
 
 THREE.StandardNode = function() {
 THREE.StandardNode = function() {
-	
+
 	THREE.GLNode.call( this );
 	THREE.GLNode.call( this );
-	
+
 	this.color = new THREE.ColorNode( 0xEEEEEE );
 	this.color = new THREE.ColorNode( 0xEEEEEE );
 	this.roughness = new THREE.FloatNode( 0.5 );
 	this.roughness = new THREE.FloatNode( 0.5 );
 	this.metalness = new THREE.FloatNode( 0.5 );
 	this.metalness = new THREE.FloatNode( 0.5 );
-	
+
 };
 };
 
 
 THREE.StandardNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.StandardNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.StandardNode.prototype.constructor = THREE.StandardNode;
 THREE.StandardNode.prototype.constructor = THREE.StandardNode;
 
 
 THREE.StandardNode.prototype.build = function( builder ) {
 THREE.StandardNode.prototype.build = function( builder ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var code;
 	var code;
-	
+
 	material.define( 'STANDARD' );
 	material.define( 'STANDARD' );
 	material.define( 'ALPHATEST', '0.0' );
 	material.define( 'ALPHATEST', '0.0' );
-	
+
 	material.needsLight = true;
 	material.needsLight = true;
-	
-	if (builder.isShader('vertex')) {
-		
+
+	if ( builder.isShader( 'vertex' ) ) {
+
 		var transform = this.transform ? this.transform.verifyAndBuildCode( builder, 'v3' ) : undefined;
 		var transform = this.transform ? this.transform.verifyAndBuildCode( builder, 'v3' ) : undefined;
-		
+
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 
 
 			THREE.UniformsLib[ "fog" ],
 			THREE.UniformsLib[ "fog" ],
@@ -36,7 +36,7 @@ THREE.StandardNode.prototype.build = function( builder ) {
 			THREE.UniformsLib[ "shadowmap" ]
 			THREE.UniformsLib[ "shadowmap" ]
 
 
 		] ) );
 		] ) );
-		
+
 		material.addVertexPars( [
 		material.addVertexPars( [
 			"varying vec3 vViewPosition;",
 			"varying vec3 vViewPosition;",
 
 
@@ -54,7 +54,7 @@ THREE.StandardNode.prototype.build = function( builder ) {
 			THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ]
 			THREE.ShaderChunk[ "logdepthbuf_pars_vertex" ]
 
 
 		].join( "\n" ) );
 		].join( "\n" ) );
-		
+
 		var output = [
 		var output = [
 				THREE.ShaderChunk[ "beginnormal_vertex" ],
 				THREE.ShaderChunk[ "beginnormal_vertex" ],
 				THREE.ShaderChunk[ "morphnormal_vertex" ],
 				THREE.ShaderChunk[ "morphnormal_vertex" ],
@@ -70,12 +70,14 @@ THREE.StandardNode.prototype.build = function( builder ) {
 
 
 				THREE.ShaderChunk[ "begin_vertex" ]
 				THREE.ShaderChunk[ "begin_vertex" ]
 		];
 		];
-		
+
 		if ( transform ) {
 		if ( transform ) {
+
 			output.push( transform.code );
 			output.push( transform.code );
 			output.push( "transformed = " + transform.result + ";" );
 			output.push( "transformed = " + transform.result + ";" );
+
 		}
 		}
-		
+
 		output.push(
 		output.push(
 				THREE.ShaderChunk[ "morphtarget_vertex" ],
 				THREE.ShaderChunk[ "morphtarget_vertex" ],
 				THREE.ShaderChunk[ "skinning_vertex" ],
 				THREE.ShaderChunk[ "skinning_vertex" ],
@@ -88,66 +90,66 @@ THREE.StandardNode.prototype.build = function( builder ) {
 				THREE.ShaderChunk[ "lights_phong_vertex" ],
 				THREE.ShaderChunk[ "lights_phong_vertex" ],
 				THREE.ShaderChunk[ "shadowmap_vertex" ]
 				THREE.ShaderChunk[ "shadowmap_vertex" ]
 		);
 		);
-		
+
 		code = output.join( "\n" );
 		code = output.join( "\n" );
-		
+
 	}
 	}
 	else {
 	else {
-		
+
 		// CubeMap blur effect (PBR)
 		// CubeMap blur effect (PBR)
-		
+
 		builder.require.cubeTextureBias = builder.require.cubeTextureBias || new THREE.RoughnessToBlinnExponentNode();
 		builder.require.cubeTextureBias = builder.require.cubeTextureBias || new THREE.RoughnessToBlinnExponentNode();
-		
+
 		// verify all nodes to reuse generate codes
 		// verify all nodes to reuse generate codes
-		
+
 		this.color.verify( builder );
 		this.color.verify( builder );
 		this.roughness.verify( builder );
 		this.roughness.verify( builder );
 		this.metalness.verify( builder );
 		this.metalness.verify( builder );
-		
-		if (this.alpha) this.alpha.verify( builder );
-		
-		if (this.ao) this.ao.verify( builder );
-		if (this.ambient) this.ambient.verify( builder );
-		if (this.shadow) this.shadow.verify( builder );
-		if (this.emissive) this.emissive.verify( builder );
-		
-		if (this.normal) this.normal.verify( builder );
-		if (this.normalScale && this.normal) this.normalScale.verify( builder );
-		
-		if (this.environment) this.environment.verify( builder.setCache('env') ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
-		if (this.reflectivity && this.environment) this.reflectivity.verify( builder );
-		
+
+		if ( this.alpha ) this.alpha.verify( builder );
+
+		if ( this.ao ) this.ao.verify( builder );
+		if ( this.ambient ) this.ambient.verify( builder );
+		if ( this.shadow ) this.shadow.verify( builder );
+		if ( this.emissive ) this.emissive.verify( builder );
+
+		if ( this.normal ) this.normal.verify( builder );
+		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
+
+		if ( this.environment ) this.environment.verify( builder.setCache( 'env' ) ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
+		if ( this.reflectivity && this.environment ) this.reflectivity.verify( builder );
+
 		// build code
 		// build code
-		
+
 		var color = this.color.buildCode( builder, 'v4' );
 		var color = this.color.buildCode( builder, 'v4' );
 		var roughness = this.roughness.buildCode( builder, 'fv1' );
 		var roughness = this.roughness.buildCode( builder, 'fv1' );
 		var metalness = this.metalness.buildCode( builder, 'fv1' );
 		var metalness = this.metalness.buildCode( builder, 'fv1' );
-		
+
 		var alpha = this.alpha ? this.alpha.buildCode( builder, 'fv1' ) : undefined;
 		var alpha = this.alpha ? this.alpha.buildCode( builder, 'fv1' ) : undefined;
-		
+
 		var ao = this.ao ? this.ao.buildCode( builder, 'c' ) : undefined;
 		var ao = this.ao ? this.ao.buildCode( builder, 'c' ) : undefined;
 		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
 		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
 		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
 		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
 		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c' ) : undefined;
 		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c' ) : undefined;
-		
+
 		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
 		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'fv1' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'fv1' ) : undefined;
-		
-		var environment = this.environment ? this.environment.buildCode( builder.setCache('env'), 'c' ) : undefined;
+
+		var environment = this.environment ? this.environment.buildCode( builder.setCache( 'env' ), 'c' ) : undefined;
 		var reflectivity = this.reflectivity && this.environment ? this.reflectivity.buildCode( builder, 'fv1' ) : undefined;
 		var reflectivity = this.reflectivity && this.environment ? this.reflectivity.buildCode( builder, 'fv1' ) : undefined;
-		
+
 		material.needsTransparent = alpha != undefined;
 		material.needsTransparent = alpha != undefined;
-		
+
 		material.addFragmentPars( [
 		material.addFragmentPars( [
-			
+
 			"varying vec3 vViewPosition;",
 			"varying vec3 vViewPosition;",
-			
+
 			"#ifndef FLAT_SHADED",
 			"#ifndef FLAT_SHADED",
 
 
 			"	varying vec3 vNormal;",
 			"	varying vec3 vNormal;",
 
 
 			"#endif",
 			"#endif",
-			
+
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "common" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "fog_pars_fragment" ],
 			THREE.ShaderChunk[ "bsdfs" ],
 			THREE.ShaderChunk[ "bsdfs" ],
@@ -156,113 +158,129 @@ THREE.StandardNode.prototype.build = function( builder ) {
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
 			THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
 			THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ],
 		].join( "\n" ) );
 		].join( "\n" ) );
-	
+
 		var output = [
 		var output = [
 				// prevent undeclared normal
 				// prevent undeclared normal
 				THREE.ShaderChunk[ "normal_fragment" ],
 				THREE.ShaderChunk[ "normal_fragment" ],
-				
+
 				// prevent undeclared material
 				// prevent undeclared material
 			"	StandardMaterial material;",
 			"	StandardMaterial material;",
-			
+
 				color.code,
 				color.code,
 			"	vec4 diffuseColor = " + color.result + ";",
 			"	vec4 diffuseColor = " + color.result + ";",
 			"	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
 			"	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",
-			
+
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
-				
+
 			roughness.code,
 			roughness.code,
 			"	float roughnessFactor = " + roughness.result + ";",
 			"	float roughnessFactor = " + roughness.result + ";",
-			
+
 			metalness.code,
 			metalness.code,
 			"	float metalnessFactor = " + metalness.result + ";"
 			"	float metalnessFactor = " + metalness.result + ";"
-		];	
-		
-		if (alpha) {
-			
-			output.push( 
+		];
+
+		if ( alpha ) {
+
+			output.push(
 				alpha.code,
 				alpha.code,
 				'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
 				'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
 			);
 			);
-		
+
 		}
 		}
-		
-		if (normal) {
-			
+
+		if ( normal ) {
+
 			builder.include( 'perturbNormal2Arb' );
 			builder.include( 'perturbNormal2Arb' );
-			
-			output.push(normal.code);
-			
-			if (normalScale) output.push(normalScale.code);
-			
+
+			output.push( normal.code );
+
+			if ( normalScale ) output.push( normalScale.code );
+
 			output.push(
 			output.push(
 				'normal = perturbNormal2Arb(-vViewPosition,normal,' +
 				'normal = perturbNormal2Arb(-vViewPosition,normal,' +
 				normal.result + ',' +
 				normal.result + ',' +
 				new THREE.UVNode().build( builder, 'v2' ) + ',' +
 				new THREE.UVNode().build( builder, 'v2' ) + ',' +
-				(normalScale ? normalScale.result : '1.0') + ');'
+				( normalScale ? normalScale.result : '1.0' ) + ');'
 			);
 			);
 
 
 		}
 		}
 
 
 		output.push(
 		output.push(
 			THREE.ShaderChunk[ "shadowmap_fragment" ],
 			THREE.ShaderChunk[ "shadowmap_fragment" ],
-			
+
 			// accumulation
 			// accumulation
 			'material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );',
 			'material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );',
 			'material.specularRoughness = clamp( roughnessFactor, 0.001, 1.0 );', // disney's remapping of [ 0, 1 ] roughness to [ 0.001, 1 ]
 			'material.specularRoughness = clamp( roughnessFactor, 0.001, 1.0 );', // disney's remapping of [ 0, 1 ] roughness to [ 0.001, 1 ]
 			'material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );',
 			'material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );',
-			
+
 			THREE.ShaderChunk[ "lights_template" ]
 			THREE.ShaderChunk[ "lights_template" ]
 		);
 		);
-		
-		if (ao) { 
+
+		if ( ao ) {
+
 			output.push( ao.code );
 			output.push( ao.code );
 			output.push( "reflectedLight.indirectDiffuse *= " + ao.result + ";" );
 			output.push( "reflectedLight.indirectDiffuse *= " + ao.result + ";" );
+
 		}
 		}
-		
-		if (ambient) { 
+
+		if ( ambient ) {
+
 			output.push( ambient.code );
 			output.push( ambient.code );
 			output.push( "reflectedLight.indirectDiffuse += " + ambient.result + ";" );
 			output.push( "reflectedLight.indirectDiffuse += " + ambient.result + ";" );
+
 		}
 		}
-		
-		if (shadow) {
+
+		if ( shadow ) {
+
 			output.push( shadow.code );
 			output.push( shadow.code );
 			output.push( "reflectedLight.directDiffuse *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directDiffuse *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directSpecular *= " + shadow.result + ";" );
 			output.push( "reflectedLight.directSpecular *= " + shadow.result + ";" );
+
 		}
 		}
-		
-		if (emissive) { 
+
+		if ( emissive ) {
+
 			output.push( emissive.code );
 			output.push( emissive.code );
 			output.push( "reflectedLight.directDiffuse += " + emissive.result + ";" );
 			output.push( "reflectedLight.directDiffuse += " + emissive.result + ";" );
+
 		}
 		}
-		
-		if (environment) {
+
+		if ( environment ) {
+
 			output.push( environment.code );
 			output.push( environment.code );
 			output.push( "RE_IndirectSpecular(" + environment.result + ", geometry, material, reflectedLight );" );
 			output.push( "RE_IndirectSpecular(" + environment.result + ", geometry, material, reflectedLight );" );
+
 		}
 		}
-		
-		if (reflectivity) {	
+
+		if ( reflectivity ) {
+
 			output.push( reflectivity.code );
 			output.push( reflectivity.code );
 			output.push( "reflectedLight.indirectSpecular *= " + reflectivity.result + ";" );
 			output.push( "reflectedLight.indirectSpecular *= " + reflectivity.result + ";" );
+
 		}
 		}
-		
-		output.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");
-		
+
+		output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" );
+
 		output.push(
 		output.push(
 			THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
 			THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
 			THREE.ShaderChunk[ "fog_fragment" ]
 			THREE.ShaderChunk[ "fog_fragment" ]
 		);
 		);
-		
-		if (alpha) {
+
+		if ( alpha ) {
+
 			output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" );
 			output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" );
+
 		}
 		}
 		else {
 		else {
+
 			output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" );
 			output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" );
+
 		}
 		}
-		
+
 		code = output.join( "\n" );
 		code = output.join( "\n" );
-	
+
 	}
 	}
-	
+
 	return code;
 	return code;
 
 
-};
+};

+ 5 - 5
examples/js/materials/nodes/interfaces/StandardNodeMaterial.js

@@ -3,15 +3,15 @@
  */
  */
 
 
 THREE.StandardNodeMaterial = function() {
 THREE.StandardNodeMaterial = function() {
-	
+
 	this.node = new THREE.StandardNode();
 	this.node = new THREE.StandardNode();
-	
+
 	THREE.NodeMaterial.call( this, this.node, this.node );
 	THREE.NodeMaterial.call( this, this.node, this.node );
-	
+
 };
 };
 
 
 THREE.StandardNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype );
 THREE.StandardNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype );
 THREE.StandardNodeMaterial.prototype.constructor = THREE.StandardNodeMaterial;
 THREE.StandardNodeMaterial.prototype.constructor = THREE.StandardNodeMaterial;
 
 
-THREE.NodeMaterial.Shortcuts( THREE.StandardNodeMaterial.prototype, 'node', 
-[ 'color',  'alpha', 'roughness', 'metalness', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'reflectivity', 'transform' ] );
+THREE.NodeMaterial.Shortcuts( THREE.StandardNodeMaterial.prototype, 'node',
+[ 'color', 'alpha', 'roughness', 'metalness', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'reflectivity', 'transform' ] );

+ 18 - 18
examples/js/materials/nodes/math/Math1Node.js

@@ -3,13 +3,13 @@
  */
  */
 
 
 THREE.Math1Node = function( a, method ) {
 THREE.Math1Node = function( a, method ) {
-	
+
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
-	
+
 	this.a = a;
 	this.a = a;
-	
+
 	this.method = method || THREE.Math1Node.SIN;
 	this.method = method || THREE.Math1Node.SIN;
-	
+
 };
 };
 
 
 THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype );
 THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype );
@@ -40,39 +40,39 @@ THREE.Math1Node.NEGATE = 'negate';
 THREE.Math1Node.INVERT = 'invert';
 THREE.Math1Node.INVERT = 'invert';
 
 
 THREE.Math1Node.prototype.getType = function( builder ) {
 THREE.Math1Node.prototype.getType = function( builder ) {
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.Math1Node.DISTANCE:
 		case THREE.Math1Node.DISTANCE:
 			return 'fv1';
 			return 'fv1';
 	}
 	}
-	
+
 	return this.a.getType( builder );
 	return this.a.getType( builder );
-	
+
 };
 };
 
 
 THREE.Math1Node.prototype.generate = function( builder, output ) {
 THREE.Math1Node.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var type = this.getType( builder );
 	var type = this.getType( builder );
-	
+
 	var result = this.a.build( builder, type );
 	var result = this.a.build( builder, type );
-	
-	switch(this.method) {
-		
+
+	switch ( this.method ) {
+
 		case THREE.Math1Node.NEGATE:
 		case THREE.Math1Node.NEGATE:
 			result = '(-' + result + ')';
 			result = '(-' + result + ')';
 			break;
 			break;
-		
+
 		case THREE.Math1Node.INVERT:
 		case THREE.Math1Node.INVERT:
 			result = '(1.0-' + result + ')';
 			result = '(1.0-' + result + ')';
 			break;
 			break;
-		
+
 		default:
 		default:
 			result = this.method + '(' + result + ')';
 			result = this.method + '(' + result + ')';
 			break;
 			break;
 	}
 	}
-	
+
 	return builder.format( result, type, output );
 	return builder.format( result, type, output );
 
 
-};
+};

+ 28 - 25
examples/js/materials/nodes/math/Math2Node.js

@@ -3,14 +3,14 @@
  */
  */
 
 
 THREE.Math2Node = function( a, b, method ) {
 THREE.Math2Node = function( a, b, method ) {
-	
+
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
-	
+
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
-	
+
 	this.method = method || THREE.Math2Node.DISTANCE;
 	this.method = method || THREE.Math2Node.DISTANCE;
-	
+
 };
 };
 
 
 THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype );
 THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype );
@@ -27,67 +27,70 @@ THREE.Math2Node.CROSS = 'cross';
 THREE.Math2Node.POW = 'pow';
 THREE.Math2Node.POW = 'pow';
 
 
 THREE.Math2Node.prototype.getInputType = function( builder ) {
 THREE.Math2Node.prototype.getInputType = function( builder ) {
-	
+
 	// use the greater length vector
 	// use the greater length vector
-	if (builder.getFormatLength( this.b.getType( builder ) ) > builder.getFormatLength( this.a.getType( builder ) )) {
+	if ( builder.getFormatLength( this.b.getType( builder ) ) > builder.getFormatLength( this.a.getType( builder ) ) ) {
+
 		return this.b.getType( builder );
 		return this.b.getType( builder );
+
 	}
 	}
-	
+
 	return this.a.getType( builder );
 	return this.a.getType( builder );
-	
+
 };
 };
 
 
 THREE.Math2Node.prototype.getType = function( builder ) {
 THREE.Math2Node.prototype.getType = function( builder ) {
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.Math2Node.DISTANCE:
 		case THREE.Math2Node.DISTANCE:
 		case THREE.Math2Node.DOT:
 		case THREE.Math2Node.DOT:
 			return 'fv1';
 			return 'fv1';
-		
+
 		case THREE.Math2Node.CROSS:
 		case THREE.Math2Node.CROSS:
 			return 'v3';
 			return 'v3';
 	}
 	}
-	
+
 	return this.getInputType( builder );
 	return this.getInputType( builder );
+
 };
 };
 
 
 THREE.Math2Node.prototype.generate = function( builder, output ) {
 THREE.Math2Node.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var type = this.getInputType( builder );
 	var type = this.getInputType( builder );
-	
-	var a, b, 
+
+	var a, b,
 		al = builder.getFormatLength( this.a.getType( builder ) ),
 		al = builder.getFormatLength( this.a.getType( builder ) ),
 		bl = builder.getFormatLength( this.b.getType( builder ) );
 		bl = builder.getFormatLength( this.b.getType( builder ) );
-	
+
 	// optimzer
 	// optimzer
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.Math2Node.CROSS:
 		case THREE.Math2Node.CROSS:
 			a = this.a.build( builder, 'v3' );
 			a = this.a.build( builder, 'v3' );
 			b = this.b.build( builder, 'v3' );
 			b = this.b.build( builder, 'v3' );
 			break;
 			break;
-		
+
 		case THREE.Math2Node.STEP:
 		case THREE.Math2Node.STEP:
 			a = this.a.build( builder, al == 1 ? 'fv1' : type );
 			a = this.a.build( builder, al == 1 ? 'fv1' : type );
 			b = this.b.build( builder, type );
 			b = this.b.build( builder, type );
 			break;
 			break;
-			
+
 		case THREE.Math2Node.MIN:
 		case THREE.Math2Node.MIN:
 		case THREE.Math2Node.MAX:
 		case THREE.Math2Node.MAX:
 		case THREE.Math2Node.MODULO:
 		case THREE.Math2Node.MODULO:
 			a = this.a.build( builder, type );
 			a = this.a.build( builder, type );
 			b = this.b.build( builder, bl == 1 ? 'fv1' : type );
 			b = this.b.build( builder, bl == 1 ? 'fv1' : type );
 			break;
 			break;
-			
+
 		default:
 		default:
 			a = this.a.build( builder, type );
 			a = this.a.build( builder, type );
 			b = this.b.build( builder, type );
 			b = this.b.build( builder, type );
 			break;
 			break;
-	
+
 	}
 	}
-	
+
 	return builder.format( this.method + '(' + a + ',' + b + ')', this.getType( builder ), output );
 	return builder.format( this.method + '(' + a + ',' + b + ')', this.getType( builder ), output );
 
 
-};
+};

+ 27 - 23
examples/js/materials/nodes/math/Math3Node.js

@@ -3,15 +3,15 @@
  */
  */
 
 
 THREE.Math3Node = function( a, b, c, method ) {
 THREE.Math3Node = function( a, b, c, method ) {
-	
+
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
-	
+
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
 	this.c = c;
 	this.c = c;
-	
+
 	this.method = method || THREE.Math3Node.MIX;
 	this.method = method || THREE.Math3Node.MIX;
-	
+
 };
 };
 
 
 THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype );
 THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype );
@@ -23,58 +23,62 @@ THREE.Math3Node.SMOOTHSTEP = 'smoothstep';
 THREE.Math3Node.FACEFORWARD = 'faceforward';
 THREE.Math3Node.FACEFORWARD = 'faceforward';
 
 
 THREE.Math3Node.prototype.getType = function( builder ) {
 THREE.Math3Node.prototype.getType = function( builder ) {
-	
+
 	var a = builder.getFormatLength( this.a.getType( builder ) );
 	var a = builder.getFormatLength( this.a.getType( builder ) );
 	var b = builder.getFormatLength( this.b.getType( builder ) );
 	var b = builder.getFormatLength( this.b.getType( builder ) );
 	var c = builder.getFormatLength( this.c.getType( builder ) );
 	var c = builder.getFormatLength( this.c.getType( builder ) );
-	
-	if (a > b) {
-		if (a > c) return this.a.getType( builder );
+
+	if ( a > b ) {
+
+		if ( a > c ) return this.a.getType( builder );
 		return this.c.getType( builder );
 		return this.c.getType( builder );
-	} 
+
+	}
 	else {
 	else {
-		if (b > c) return this.b.getType( builder );
-	
+
+		if ( b > c ) return this.b.getType( builder );
+
 		return this.c.getType( builder );
 		return this.c.getType( builder );
+
 	}
 	}
-	
+
 };
 };
 
 
 THREE.Math3Node.prototype.generate = function( builder, output ) {
 THREE.Math3Node.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var type = this.getType( builder );
 	var type = this.getType( builder );
-	
+
 	var a, b, c,
 	var a, b, c,
 		al = builder.getFormatLength( this.a.getType( builder ) ),
 		al = builder.getFormatLength( this.a.getType( builder ) ),
 		bl = builder.getFormatLength( this.b.getType( builder ) ),
 		bl = builder.getFormatLength( this.b.getType( builder ) ),
 		cl = builder.getFormatLength( this.c.getType( builder ) )
 		cl = builder.getFormatLength( this.c.getType( builder ) )
-	
+
 	// optimzer
 	// optimzer
-	
-	switch(this.method) {
+
+	switch ( this.method ) {
 		case THREE.Math3Node.REFRACT:
 		case THREE.Math3Node.REFRACT:
 			a = this.a.build( builder, type );
 			a = this.a.build( builder, type );
 			b = this.b.build( builder, type );
 			b = this.b.build( builder, type );
 			c = this.c.build( builder, 'fv1' );
 			c = this.c.build( builder, 'fv1' );
 			break;
 			break;
-		
+
 		case THREE.Math3Node.MIX:
 		case THREE.Math3Node.MIX:
 		case THREE.Math3Node.SMOOTHSTEP:
 		case THREE.Math3Node.SMOOTHSTEP:
 			a = this.a.build( builder, type );
 			a = this.a.build( builder, type );
 			b = this.b.build( builder, type );
 			b = this.b.build( builder, type );
 			c = this.c.build( builder, cl == 1 ? 'fv1' : type );
 			c = this.c.build( builder, cl == 1 ? 'fv1' : type );
 			break;
 			break;
-			
+
 		default:
 		default:
 			a = this.a.build( builder, type );
 			a = this.a.build( builder, type );
 			b = this.b.build( builder, type );
 			b = this.b.build( builder, type );
 			c = this.c.build( builder, type );
 			c = this.c.build( builder, type );
 			break;
 			break;
-	
+
 	}
 	}
-	
+
 	return builder.format( this.method + '(' + a + ',' + b + ',' + c + ')', type, output );
 	return builder.format( this.method + '(' + a + ',' + b + ',' + c + ')', type, output );
 
 
-};
+};

+ 14 - 12
examples/js/materials/nodes/math/OperatorNode.js

@@ -1,16 +1,16 @@
 /**
 /**
  * @author sunag / http://www.sunag.com.br/
  * @author sunag / http://www.sunag.com.br/
  */
  */
- 
+
 THREE.OperatorNode = function( a, b, op ) {
 THREE.OperatorNode = function( a, b, op ) {
-	
+
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
-	
+
 	this.op = op || THREE.OperatorNode.ADD;
 	this.op = op || THREE.OperatorNode.ADD;
-	
+
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
-	
+
 };
 };
 
 
 THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype );
@@ -22,24 +22,26 @@ THREE.OperatorNode.MUL = '*';
 THREE.OperatorNode.DIV = '/';
 THREE.OperatorNode.DIV = '/';
 
 
 THREE.OperatorNode.prototype.getType = function( builder ) {
 THREE.OperatorNode.prototype.getType = function( builder ) {
-	
+
 	// use the greater length vector
 	// use the greater length vector
-	if (builder.getFormatLength( this.b.getType( builder ) ) > builder.getFormatLength( this.a.getType( builder ) )) {
+	if ( builder.getFormatLength( this.b.getType( builder ) ) > builder.getFormatLength( this.a.getType( builder ) ) ) {
+
 		return this.b.getType( builder );
 		return this.b.getType( builder );
+
 	}
 	}
-	
+
 	return this.a.getType( builder );
 	return this.a.getType( builder );
 
 
 };
 };
 
 
 THREE.OperatorNode.prototype.generate = function( builder, output ) {
 THREE.OperatorNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
 	var data = material.getDataNode( this.uuid );
 	var data = material.getDataNode( this.uuid );
-	
+
 	var a = this.a.build( builder, output );
 	var a = this.a.build( builder, output );
 	var b = this.b.build( builder, output );
 	var b = this.b.build( builder, output );
-	
+
 	return '(' + a + this.op + b + ')';
 	return '(' + a + this.op + b + ')';
 
 
-};
+};

+ 31 - 27
examples/js/materials/nodes/utils/JoinNode.js

@@ -3,63 +3,67 @@
  */
  */
 
 
 THREE.JoinNode = function( x, y, z, w ) {
 THREE.JoinNode = function( x, y, z, w ) {
-	
+
 	THREE.GLNode.call( this, 'fv1' );
 	THREE.GLNode.call( this, 'fv1' );
-	
+
 	this.x = x;
 	this.x = x;
 	this.y = y;
 	this.y = y;
 	this.z = z;
 	this.z = z;
 	this.w = w;
 	this.w = w;
-	
+
 };
 };
 
 
 THREE.JoinNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.JoinNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.JoinNode.prototype.constructor = THREE.JoinNode;
 THREE.JoinNode.prototype.constructor = THREE.JoinNode;
 
 
-THREE.JoinNode.inputs = ['x','y','z','w'];
+THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ];
 
 
 THREE.JoinNode.prototype.getNumElements = function() {
 THREE.JoinNode.prototype.getNumElements = function() {
-	
+
 	var inputs = THREE.JoinNode.inputs;
 	var inputs = THREE.JoinNode.inputs;
 	var i = inputs.length;
 	var i = inputs.length;
-	
-	while (i--) {
-		if ( this[ inputs[i] ] !== undefined ) {
-			++i;
+
+	while ( i -- ) {
+
+		if ( this[ inputs[ i ] ] !== undefined ) {
+
+			++ i;
 			break;
 			break;
+
 		}
 		}
+
 	}
 	}
-	
-	return Math.max(i, 2);
-	
+
+	return Math.max( i, 2 );
+
 };
 };
 
 
 THREE.JoinNode.prototype.getType = function( builder ) {
 THREE.JoinNode.prototype.getType = function( builder ) {
-	
+
 	return builder.getFormatByLength( this.getNumElements() );
 	return builder.getFormatByLength( this.getNumElements() );
-	
+
 };
 };
 
 
 THREE.JoinNode.prototype.generate = function( builder, output ) {
 THREE.JoinNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
+
 	var type = this.getType( builder );
 	var type = this.getType( builder );
 	var length = this.getNumElements();
 	var length = this.getNumElements();
-	
+
 	var inputs = THREE.JoinNode.inputs;
 	var inputs = THREE.JoinNode.inputs;
 	var outputs = [];
 	var outputs = [];
-	
-	for(var i = 0; i < length; i++) {
-	
-		var elm = this[inputs[i]];
-		
+
+	for ( var i = 0; i < length; i ++ ) {
+
+		var elm = this[ inputs[ i ]];
+
 		outputs.push( elm ? elm.build( builder, 'fv1' ) : '0.' );
 		outputs.push( elm ? elm.build( builder, 'fv1' ) : '0.' );
-	
+
 	}
 	}
-	
-	var code = builder.getFormatConstructor(length) + '(' + outputs.join(',') + ')';
-	
+
+	var code = builder.getFormatConstructor( length ) + '(' + outputs.join( ',' ) + ')';
+
 	return builder.format( code, type, output );
 	return builder.format( code, type, output );
 
 
-};
+};

+ 23 - 23
examples/js/materials/nodes/utils/RoughnessToBlinnExponentNode.js

@@ -3,42 +3,42 @@
  */
  */
 
 
 THREE.RoughnessToBlinnExponentNode = function() {
 THREE.RoughnessToBlinnExponentNode = function() {
-	
-	THREE.TempNode.call( this, 'fv1', {unique:true} );
-	
+
+	THREE.TempNode.call( this, 'fv1', { unique: true } );
+
 };
 };
 
 
 THREE.RoughnessToBlinnExponentNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.RoughnessToBlinnExponentNode.prototype = Object.create( THREE.TempNode.prototype );
 THREE.RoughnessToBlinnExponentNode.prototype.constructor = THREE.RoughnessToBlinnExponentNode;
 THREE.RoughnessToBlinnExponentNode.prototype.constructor = THREE.RoughnessToBlinnExponentNode;
 
 
 THREE.RoughnessToBlinnExponentNode.prototype.generate = function( builder, output ) {
 THREE.RoughnessToBlinnExponentNode.prototype.generate = function( builder, output ) {
-	
+
 	var material = builder.material;
 	var material = builder.material;
-	
-	if (builder.isShader('fragment')) {
-		
-		if (material.isDefined('STANDARD')) {
-		
-			material.addFragmentNode('float specularMIPLevel = GGXRoughnessToBlinnExponent( 1.0 - material.specularRoughness );');
-			
+
+	if ( builder.isShader( 'fragment' ) ) {
+
+		if ( material.isDefined( 'STANDARD' ) ) {
+
+			material.addFragmentNode( 'float specularMIPLevel = GGXRoughnessToBlinnExponent( 1.0 - material.specularRoughness );' );
+
 		}
 		}
 		else {
 		else {
-			
-			console.warn("THREE.RoughnessToBlinnExponentNode is compatible with StandardMaterial only");
-			
-			material.addFragmentNode('float specularMIPLevel = 0.0;');
-		
+
+			console.warn( "THREE.RoughnessToBlinnExponentNode is compatible with StandardMaterial only" );
+
+			material.addFragmentNode( 'float specularMIPLevel = 0.0;' );
+
 		}
 		}
-		
+
 		return builder.format( 'specularMIPLevel', this.type, output );
 		return builder.format( 'specularMIPLevel', this.type, output );
-		
+
 	}
 	}
 	else {
 	else {
-		
-		console.warn("THREE.RoughnessToBlinnExponentNode is not compatible with " + builder.shader + " shader");
-		
+
+		console.warn( "THREE.RoughnessToBlinnExponentNode is not compatible with " + builder.shader + " shader" );
+
 		return builder.format( '0.0', this.type, output );
 		return builder.format( '0.0', this.type, output );
-	
+
 	}
 	}
 
 
-};
+};

+ 35 - 33
examples/js/materials/nodes/utils/SwitchNode.js

@@ -3,64 +3,66 @@
  */
  */
 
 
 THREE.SwitchNode = function( a, component ) {
 THREE.SwitchNode = function( a, component ) {
-	
+
 	THREE.GLNode.call( this, 'fv1' );
 	THREE.GLNode.call( this, 'fv1' );
-	
+
 	this.component = component || 'x';
 	this.component = component || 'x';
-	
+
 	this.a = a;
 	this.a = a;
-	
+
 };
 };
 
 
 THREE.SwitchNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.SwitchNode.prototype = Object.create( THREE.GLNode.prototype );
 THREE.SwitchNode.prototype.constructor = THREE.SwitchNode;
 THREE.SwitchNode.prototype.constructor = THREE.SwitchNode;
 
 
 THREE.SwitchNode.prototype.getType = function( builder ) {
 THREE.SwitchNode.prototype.getType = function( builder ) {
-	
+
 	return builder.getFormatByLength( this.component.length );
 	return builder.getFormatByLength( this.component.length );
-	
+
 };
 };
 
 
 THREE.SwitchNode.prototype.generate = function( builder, output ) {
 THREE.SwitchNode.prototype.generate = function( builder, output ) {
-	
+
 	var type = this.a.getType( builder );
 	var type = this.a.getType( builder );
 	var inputLength = builder.getFormatLength( type ) - 1;
 	var inputLength = builder.getFormatLength( type ) - 1;
-		
+
 	var a = this.a.build( builder, type );
 	var a = this.a.build( builder, type );
-	
+
 	var outputLength = 0;
 	var outputLength = 0;
-	
+
 	var i, len = this.component.length;
 	var i, len = this.component.length;
-	
+
 	// get max length
 	// get max length
-	
-	for (i = 0; i < len; i++) {
-		
-		outputLength = Math.max( outputLength, builder.getElementIndex( this.component.charAt(i) ) );
-		
+
+	for ( i = 0; i < len; i ++ ) {
+
+		outputLength = Math.max( outputLength, builder.getElementIndex( this.component.charAt( i ) ) );
+
 	}
 	}
-	
-	if (outputLength > inputLength) outputLength = inputLength;
-	
+
+	if ( outputLength > inputLength ) outputLength = inputLength;
+
 	// build switch
 	// build switch
-	
+
 	a += '.';
 	a += '.';
-	
-	for (i = 0; i < len; i++) {
-		
-		var elm = this.component.charAt(i);
-		var idx = builder.getElementIndex( this.component.charAt(i) );
-		
-		if (idx > outputLength) idx = outputLength;
-		
-		if (builder.getElementByIndex( idx ) == undefined) {
+
+	for ( i = 0; i < len; i ++ ) {
+
+		var elm = this.component.charAt( i );
+		var idx = builder.getElementIndex( this.component.charAt( i ) );
+
+		if ( idx > outputLength ) idx = outputLength;
+
+		if ( builder.getElementByIndex( idx ) == undefined ) {
+
 			console.log( builder.getElementByIndex( idx ) );
 			console.log( builder.getElementByIndex( idx ) );
+
 		}
 		}
-		
+
 		a += builder.getElementByIndex( idx );
 		a += builder.getElementByIndex( idx );
-		
+
 	}
 	}
-	
+
 	return builder.format( a, this.type, output );
 	return builder.format( a, this.type, output );
 
 
-};
+};

+ 6 - 6
examples/js/materials/nodes/utils/TimeNode.js

@@ -3,18 +3,18 @@
  */
  */
 
 
 THREE.TimeNode = function( value ) {
 THREE.TimeNode = function( value ) {
-	
+
 	THREE.FloatNode.call( this, value );
 	THREE.FloatNode.call( this, value );
-	
+
 	this.requestUpdate = true;
 	this.requestUpdate = true;
-	
+
 };
 };
 
 
 THREE.TimeNode.prototype = Object.create( THREE.FloatNode.prototype );
 THREE.TimeNode.prototype = Object.create( THREE.FloatNode.prototype );
 THREE.TimeNode.prototype.constructor = THREE.TimeNode;
 THREE.TimeNode.prototype.constructor = THREE.TimeNode;
 
 
 THREE.TimeNode.prototype.updateAnimation = function( delta ) {
 THREE.TimeNode.prototype.updateAnimation = function( delta ) {
-	
+
 	this.number += delta;
 	this.number += delta;
-	
-};
+
+};

File diff suppressed because it is too large
+ 357 - 357
examples/webgl_materials_nodes.html


Some files were not shown because too many files changed in this diff