Browse Source

Merge pull request #7849 from sunag/dev

NodeMaterial auto cache JoinNode and cleanup
Mr.doob 9 years ago
parent
commit
805d92d7e8

+ 3 - 3
examples/js/nodes/ConstNode.js

@@ -10,9 +10,6 @@ THREE.ConstNode = function( name, useDefine ) {
 
 
 };
 };
 
 
-THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.ConstNode.prototype.constructor = THREE.ConstNode;
-
 THREE.ConstNode.PI = 'PI';
 THREE.ConstNode.PI = 'PI';
 THREE.ConstNode.PI2 = 'PI2';
 THREE.ConstNode.PI2 = 'PI2';
 THREE.ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI';
 THREE.ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI';
@@ -20,6 +17,9 @@ THREE.ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2';
 THREE.ConstNode.LOG2 = 'LOG2';
 THREE.ConstNode.LOG2 = 'LOG2';
 THREE.ConstNode.EPSILON = 'EPSILON';
 THREE.ConstNode.EPSILON = 'EPSILON';
 
 
+THREE.ConstNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.ConstNode.prototype.constructor = THREE.ConstNode;
+
 THREE.ConstNode.prototype.parse = function( src, useDefine ) {
 THREE.ConstNode.prototype.parse = function( src, useDefine ) {
 
 
 	var name, type;
 	var name, type;

+ 25 - 21
examples/js/nodes/NodeMaterial.js

@@ -11,10 +11,7 @@ THREE.NodeMaterial = function( vertex, fragment ) {
 
 
 };
 };
 
 
-THREE.NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
-THREE.NodeMaterial.prototype.constructor = THREE.NodeMaterial;
-
-THREE.NodeMaterial.Type = {
+THREE.NodeMaterial.types = {
 	t : 'sampler2D',
 	t : 'sampler2D',
 	tc : 'samplerCube',
 	tc : 'samplerCube',
 	bv1 : 'bool',
 	bv1 : 'bool',
@@ -26,39 +23,46 @@ THREE.NodeMaterial.Type = {
 	v4 : 'vec4'
 	v4 : 'vec4'
 };
 };
 
 
-THREE.NodeMaterial.GetShortcuts = function( prop, name ) {
+THREE.NodeMaterial.addShortcuts = function( proto, prop, list ) {
 
 
-	return {
-		get: function() {
+	function applyShortcut( prop, name ) {
 
 
-			return this[ prop ][ name ];
+		return {
+			get: function() {
 
 
-		},
-		set: function( val ) {
+				return this[ prop ][ name ];
 
 
-			this[ prop ][ name ] = val;
+			},
+			set: function( val ) {
+
+				this[ prop ][ name ] = val;
+
+			}
+		};
 
 
-		}
 	};
 	};
 
 
-};
+	return (function() {
 
 
-THREE.NodeMaterial.Shortcuts = function( proto, prop, list ) {
+		var shortcuts = {};
 
 
-	var shortcuts = {};
+		for ( var i = 0; i < list.length; ++ i ) {
 
 
-	for ( var i = 0; i < list.length; ++ i ) {
+			var name = list[ i ];
 
 
-		var name = list[ i ];
+			shortcuts[ name ] = applyShortcut( prop, name );
 
 
-		shortcuts[ name ] = this.GetShortcuts( prop, name );
+		}
 
 
-	}
+		Object.defineProperties( proto, shortcuts );
 
 
-	Object.defineProperties( proto, shortcuts );
+	})();
 
 
 };
 };
 
 
+THREE.NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
+THREE.NodeMaterial.prototype.constructor = THREE.NodeMaterial;
+
 THREE.NodeMaterial.prototype.updateAnimation = function( delta ) {
 THREE.NodeMaterial.prototype.updateAnimation = function( delta ) {
 
 
 	for ( var i = 0; i < this.requestUpdate.length; ++ i ) {
 	for ( var i = 0; i < this.requestUpdate.length; ++ i ) {
@@ -388,7 +392,7 @@ THREE.NodeMaterial.prototype.getCodePars = function( pars, prefix ) {
 
 
 		if ( parsType == 't' && parsValue instanceof THREE.CubeTexture ) parsType = 'tc';
 		if ( parsType == 't' && parsValue instanceof THREE.CubeTexture ) parsType = 'tc';
 
 
-		var type = THREE.NodeMaterial.Type[ parsType ];
+		var type = THREE.NodeMaterial.types[ parsType ];
 
 
 		if ( type == undefined ) throw new Error( "Node pars " + parsType + " not found." );
 		if ( type == undefined ) throw new Error( "Node pars " + parsType + " not found." );
 
 

+ 3 - 3
examples/js/nodes/accessors/CameraNode.js

@@ -11,12 +11,12 @@ THREE.CameraNode = function( scope, camera ) {
 
 
 };
 };
 
 
-THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.CameraNode.prototype.constructor = THREE.CameraNode;
-
 THREE.CameraNode.POSITION = 'position';
 THREE.CameraNode.POSITION = 'position';
 THREE.CameraNode.DEPTH = 'depth';
 THREE.CameraNode.DEPTH = 'depth';
 
 
+THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.CameraNode.prototype.constructor = THREE.CameraNode;
+
 THREE.CameraNode.prototype.setCamera = function( camera ) {
 THREE.CameraNode.prototype.setCamera = function( camera ) {
 
 
 	this.camera = camera;
 	this.camera = camera;

+ 3 - 3
examples/js/nodes/accessors/ColorsNode.js

@@ -10,12 +10,12 @@ THREE.ColorsNode = function( index ) {
 
 
 };
 };
 
 
-THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.ColorsNode.prototype.constructor = THREE.ColorsNode;
-
 THREE.ColorsNode.vertexDict = [ 'color', 'color2' ];
 THREE.ColorsNode.vertexDict = [ 'color', 'color2' ];
 THREE.ColorsNode.fragmentDict = [ 'vColor', 'vColor2' ];
 THREE.ColorsNode.fragmentDict = [ 'vColor', 'vColor2' ];
 
 
+THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.ColorsNode.prototype.constructor = THREE.ColorsNode;
+
 THREE.ColorsNode.prototype.generate = function( builder, output ) {
 THREE.ColorsNode.prototype.generate = function( builder, output ) {
 
 
 	var material = builder.material;
 	var material = builder.material;

+ 3 - 3
examples/js/nodes/accessors/NormalNode.js

@@ -10,13 +10,13 @@ THREE.NormalNode = function( scope ) {
 
 
 };
 };
 
 
-THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.NormalNode.prototype.constructor = THREE.NormalNode;
-
 THREE.NormalNode.LOCAL = 'local';
 THREE.NormalNode.LOCAL = 'local';
 THREE.NormalNode.WORLD = 'world';
 THREE.NormalNode.WORLD = 'world';
 THREE.NormalNode.VIEW = 'view';
 THREE.NormalNode.VIEW = 'view';
 
 
+THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.NormalNode.prototype.constructor = THREE.NormalNode;
+
 THREE.NormalNode.prototype.isShared = function( builder ) {
 THREE.NormalNode.prototype.isShared = function( builder ) {
 
 
 	switch ( this.scope ) {
 	switch ( this.scope ) {

+ 3 - 3
examples/js/nodes/accessors/PositionNode.js

@@ -10,14 +10,14 @@ THREE.PositionNode = function( scope ) {
 
 
 };
 };
 
 
-THREE.PositionNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.PositionNode.prototype.constructor = THREE.PositionNode;
-
 THREE.PositionNode.LOCAL = 'local';
 THREE.PositionNode.LOCAL = 'local';
 THREE.PositionNode.WORLD = 'world';
 THREE.PositionNode.WORLD = 'world';
 THREE.PositionNode.VIEW = 'view';
 THREE.PositionNode.VIEW = 'view';
 THREE.PositionNode.PROJECTION = 'projection';
 THREE.PositionNode.PROJECTION = 'projection';
 
 
+THREE.PositionNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.PositionNode.prototype.constructor = THREE.PositionNode;
+
 THREE.PositionNode.prototype.getType = function( builder ) {
 THREE.PositionNode.prototype.getType = function( builder ) {
 
 
 	switch ( this.scope ) {
 	switch ( this.scope ) {

+ 3 - 3
examples/js/nodes/accessors/UVNode.js

@@ -10,12 +10,12 @@ THREE.UVNode = function( index ) {
 
 
 };
 };
 
 
-THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.UVNode.prototype.constructor = THREE.UVNode;
-
 THREE.UVNode.vertexDict = [ 'uv', 'uv2' ];
 THREE.UVNode.vertexDict = [ 'uv', 'uv2' ];
 THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ];
 THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ];
 
 
+THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.UVNode.prototype.constructor = THREE.UVNode;
+
 THREE.UVNode.prototype.generate = function( builder, output ) {
 THREE.UVNode.prototype.generate = function( builder, output ) {
 
 
 	var material = builder.material;
 	var material = builder.material;

+ 1 - 1
examples/js/nodes/inputs/ColorNode.js

@@ -13,4 +13,4 @@ THREE.ColorNode = function( color ) {
 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.addShortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] );

+ 1 - 1
examples/js/nodes/inputs/Vector2Node.js

@@ -13,4 +13,4 @@ THREE.Vector2Node = function( 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.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] );

+ 1 - 1
examples/js/nodes/inputs/Vector3Node.js

@@ -14,4 +14,4 @@ THREE.Vector3Node = function( 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.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] );

+ 1 - 1
examples/js/nodes/inputs/Vector4Node.js

@@ -13,4 +13,4 @@ THREE.Vector4Node = function( 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.addShortcuts( THREE.Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] );

+ 6 - 6
examples/js/nodes/materials/PhongNode.js

@@ -27,7 +27,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
 
 
 	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', 'transform' ) : undefined;
 
 
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 
 
@@ -114,7 +114,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
 		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
 		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
 
 
 		if ( this.environment ) this.environment.verify( builder );
 		if ( this.environment ) this.environment.verify( builder );
-		if ( this.environmentIntensity && this.environment ) this.environmentIntensity.verify( builder );
+		if ( this.environmentAlpha && this.environment ) this.environmentAlpha.verify( builder );
 
 
 		// build code
 		// build code
 
 
@@ -133,7 +133,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'v2' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'v2' ) : undefined;
 
 
 		var environment = this.environment ? this.environment.buildCode( builder, 'c' ) : undefined;
 		var environment = this.environment ? this.environment.buildCode( builder, 'c' ) : undefined;
-		var environmentIntensity = this.environmentIntensity && this.environment ? this.environmentIntensity.buildCode( builder, 'fv1' ) : undefined;
+		var environmentAlpha = this.environmentAlpha && this.environment ? this.environmentAlpha.buildCode( builder, 'fv1' ) : undefined;
 
 
 		material.requestAttrib.transparent = alpha != undefined;
 		material.requestAttrib.transparent = alpha != undefined;
 
 
@@ -236,11 +236,11 @@ THREE.PhongNode.prototype.build = function( builder ) {
 
 
 			output.push( environment.code );
 			output.push( environment.code );
 
 
-			if ( environmentIntensity ) {
+			if ( environmentAlpha ) {
 
 
-				output.push( environmentIntensity.code );
+				output.push( environmentAlpha.code );
 
 
-				output.push( "outgoingLight = mix(" + 'outgoingLight' + "," + environment.result + "," + environmentIntensity.result + ");" );
+				output.push( "outgoingLight = mix(" + 'outgoingLight' + "," + environment.result + "," + environmentAlpha.result + ");" );
 
 
 			}
 			}
 			else {
 			else {

+ 2 - 2
examples/js/nodes/materials/PhongNodeMaterial.js

@@ -13,5 +13,5 @@ THREE.PhongNodeMaterial = function() {
 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', 'environmentIntensity', 'transform' ] );
+THREE.NodeMaterial.addShortcuts( THREE.PhongNodeMaterial.prototype, 'node',
+[ 'color', 'alpha', 'specular', 'shininess', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'environmentAlpha', 'transform' ] );

+ 1 - 10
examples/js/nodes/materials/StandardNode.js

@@ -27,7 +27,7 @@ THREE.StandardNode.prototype.build = function( builder ) {
 
 
 	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', 'transform' ) : undefined;
 
 
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 		material.mergeUniform( THREE.UniformsUtils.merge( [
 
 
@@ -120,7 +120,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
 		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
 		if ( this.normalScale && this.normal ) this.normalScale.verify( builder );
 
 
 		if ( this.environment ) this.environment.verify( builder, 'env', requires ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
 		if ( this.environment ) this.environment.verify( builder, 'env', requires ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
-		if ( this.environmentIntensity && this.environment ) this.environmentIntensity.verify( builder );
 
 
 		// build code
 		// build code
 
 
@@ -139,7 +138,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'v2' ) : undefined;
 		var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'v2' ) : undefined;
 
 
 		var environment = this.environment ? this.environment.buildCode( builder, 'c', 'env', requires ) : undefined;
 		var environment = this.environment ? this.environment.buildCode( builder, 'c', 'env', requires ) : undefined;
-		var environmentIntensity = this.environmentIntensity && this.environment ? this.environmentIntensity.buildCode( builder, 'fv1' ) : undefined;
 
 
 		material.requestAttrib.transparent = alpha != undefined;
 		material.requestAttrib.transparent = alpha != undefined;
 
 
@@ -254,13 +252,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
 			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 ( environmentIntensity ) {
-
-				output.push( environmentIntensity.code );
-				output.push( "reflectedLight.indirectSpecular *= " + environmentIntensity.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;" );

+ 2 - 2
examples/js/nodes/materials/StandardNodeMaterial.js

@@ -13,5 +13,5 @@ THREE.StandardNodeMaterial = function() {
 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', 'environmentIntensity', 'transform' ] );
+THREE.NodeMaterial.addShortcuts( THREE.StandardNodeMaterial.prototype, 'node',
+[ 'color', 'alpha', 'roughness', 'metalness', 'normal', 'normalScale', 'emissive', 'ambient', 'shadow', 'ao', 'environment', 'transform' ] );

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

@@ -12,9 +12,6 @@ THREE.Math1Node = function( a, method ) {
 
 
 };
 };
 
 
-THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype );
-THREE.Math1Node.prototype.constructor = THREE.Math1Node;
-
 THREE.Math1Node.RAD = 'radians';
 THREE.Math1Node.RAD = 'radians';
 THREE.Math1Node.DEG = 'degrees';
 THREE.Math1Node.DEG = 'degrees';
 THREE.Math1Node.EXP = 'exp';
 THREE.Math1Node.EXP = 'exp';
@@ -39,6 +36,9 @@ THREE.Math1Node.LENGTH = 'length';
 THREE.Math1Node.NEGATE = 'negate';
 THREE.Math1Node.NEGATE = 'negate';
 THREE.Math1Node.INVERT = 'invert';
 THREE.Math1Node.INVERT = 'invert';
 
 
+THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype );
+THREE.Math1Node.prototype.constructor = THREE.Math1Node;
+
 THREE.Math1Node.prototype.getType = function( builder ) {
 THREE.Math1Node.prototype.getType = function( builder ) {
 
 
 	switch ( this.method ) {
 	switch ( this.method ) {

+ 3 - 3
examples/js/nodes/math/Math2Node.js

@@ -13,9 +13,6 @@ THREE.Math2Node = function( a, b, method ) {
 
 
 };
 };
 
 
-THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype );
-THREE.Math2Node.prototype.constructor = THREE.Math2Node;
-
 THREE.Math2Node.MIN = 'min';
 THREE.Math2Node.MIN = 'min';
 THREE.Math2Node.MAX = 'max';
 THREE.Math2Node.MAX = 'max';
 THREE.Math2Node.MOD = 'mod';
 THREE.Math2Node.MOD = 'mod';
@@ -26,6 +23,9 @@ THREE.Math2Node.DOT = 'dot';
 THREE.Math2Node.CROSS = 'cross';
 THREE.Math2Node.CROSS = 'cross';
 THREE.Math2Node.POW = 'pow';
 THREE.Math2Node.POW = 'pow';
 
 
+THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype );
+THREE.Math2Node.prototype.constructor = THREE.Math2Node;
+
 THREE.Math2Node.prototype.getInputType = function( builder ) {
 THREE.Math2Node.prototype.getInputType = function( builder ) {
 
 
 	// use the greater length vector
 	// use the greater length vector

+ 3 - 3
examples/js/nodes/math/Math3Node.js

@@ -14,14 +14,14 @@ THREE.Math3Node = function( a, b, c, method ) {
 
 
 };
 };
 
 
-THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype );
-THREE.Math3Node.prototype.constructor = THREE.Math3Node;
-
 THREE.Math3Node.MIX = 'mix';
 THREE.Math3Node.MIX = 'mix';
 THREE.Math3Node.REFRACT = 'refract';
 THREE.Math3Node.REFRACT = 'refract';
 THREE.Math3Node.SMOOTHSTEP = 'smoothstep';
 THREE.Math3Node.SMOOTHSTEP = 'smoothstep';
 THREE.Math3Node.FACEFORWARD = 'faceforward';
 THREE.Math3Node.FACEFORWARD = 'faceforward';
 
 
+THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype );
+THREE.Math3Node.prototype.constructor = THREE.Math3Node;
+
 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 ) );

+ 4 - 5
examples/js/nodes/math/OperatorNode.js

@@ -6,21 +6,20 @@ THREE.OperatorNode = function( a, b, op ) {
 
 
 	THREE.TempNode.call( this );
 	THREE.TempNode.call( this );
 
 
-	this.op = op || THREE.OperatorNode.ADD;
-
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
+	this.op = op || THREE.OperatorNode.ADD;
 
 
 };
 };
 
 
-THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype );
-THREE.OperatorNode.prototype.constructor = THREE.OperatorNode;
-
 THREE.OperatorNode.ADD = '+';
 THREE.OperatorNode.ADD = '+';
 THREE.OperatorNode.SUB = '-';
 THREE.OperatorNode.SUB = '-';
 THREE.OperatorNode.MUL = '*';
 THREE.OperatorNode.MUL = '*';
 THREE.OperatorNode.DIV = '/';
 THREE.OperatorNode.DIV = '/';
 
 
+THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.OperatorNode.prototype.constructor = THREE.OperatorNode;
+
 THREE.OperatorNode.prototype.getType = function( builder ) {
 THREE.OperatorNode.prototype.getType = function( builder ) {
 
 
 	// use the greater length vector
 	// use the greater length vector

+ 2 - 3
examples/js/nodes/postprocessing/NodePass.js

@@ -20,6 +20,8 @@ THREE.NodePass = function() {
 THREE.NodePass.prototype = Object.create( THREE.ShaderPass.prototype );
 THREE.NodePass.prototype = Object.create( THREE.ShaderPass.prototype );
 THREE.NodePass.prototype.constructor = THREE.NodePass;
 THREE.NodePass.prototype.constructor = THREE.NodePass;
 
 
+THREE.NodeMaterial.addShortcuts( THREE.NodePass.prototype, 'fragment', [ 'value' ] );
+
 THREE.NodePass.prototype.build = function() {
 THREE.NodePass.prototype.build = function() {
 
 
 	this.node.build();
 	this.node.build();
@@ -28,6 +30,3 @@ THREE.NodePass.prototype.build = function() {
 	this.material = this.node;
 	this.material = this.node;
 
 
 };
 };
-
-THREE.NodeMaterial.Shortcuts( THREE.NodePass.prototype, 'fragment',
-[ 'value' ] );

+ 4 - 4
examples/js/nodes/utils/JoinNode.js

@@ -4,7 +4,7 @@
 
 
 THREE.JoinNode = function( x, y, z, w ) {
 THREE.JoinNode = function( x, y, z, w ) {
 
 
-	THREE.GLNode.call( this, 'fv1' );
+	THREE.TempNode.call( this, 'fv1' );
 
 
 	this.x = x;
 	this.x = x;
 	this.y = y;
 	this.y = y;
@@ -13,11 +13,11 @@ THREE.JoinNode = function( x, y, z, w ) {
 
 
 };
 };
 
 
-THREE.JoinNode.prototype = Object.create( THREE.GLNode.prototype );
-THREE.JoinNode.prototype.constructor = THREE.JoinNode;
-
 THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ];
 THREE.JoinNode.inputs = [ 'x', 'y', 'z', 'w' ];
 
 
+THREE.JoinNode.prototype = Object.create( THREE.TempNode.prototype );
+THREE.JoinNode.prototype.constructor = THREE.JoinNode;
+
 THREE.JoinNode.prototype.getNumElements = function() {
 THREE.JoinNode.prototype.getNumElements = function() {
 
 
 	var inputs = THREE.JoinNode.inputs;
 	var inputs = THREE.JoinNode.inputs;

+ 1 - 1
examples/js/nodes/utils/NormalMapNode.js

@@ -34,7 +34,7 @@ THREE.NormalMapNode.prototype.generate = function( builder, output ) {
 	}
 	}
 	else {
 	else {
 
 
-		console.warn( "THREE.NormalMap is not compatible with " + builder.shader + " shader." );
+		console.warn( "THREE.NormalMapNode 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 - 14
examples/js/nodes/utils/SwitchNode.js

@@ -2,13 +2,12 @@
  * @author sunag / http://www.sunag.com.br/
  * @author sunag / http://www.sunag.com.br/
  */
  */
 
 
-THREE.SwitchNode = function( a, component ) {
+THREE.SwitchNode = function( node, components ) {
 
 
 	THREE.GLNode.call( this, 'fv1' );
 	THREE.GLNode.call( this, 'fv1' );
 
 
-	this.component = component || 'x';
-
-	this.a = a;
+	this.node = node;
+	this.components = components || 'x';
 
 
 };
 };
 
 
@@ -17,26 +16,26 @@ 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.components.length );
 
 
 };
 };
 
 
 THREE.SwitchNode.prototype.generate = function( builder, output ) {
 THREE.SwitchNode.prototype.generate = function( builder, output ) {
 
 
-	var type = this.a.getType( builder );
+	var type = this.node.getType( builder );
 	var inputLength = builder.getFormatLength( type ) - 1;
 	var inputLength = builder.getFormatLength( type ) - 1;
 
 
-	var a = this.a.build( builder, type );
+	var node = this.node.build( builder, type );
 
 
 	var outputLength = 0;
 	var outputLength = 0;
 
 
-	var i, len = this.component.length;
+	var i, len = this.components.length;
 
 
 	// get max length
 	// get max length
 
 
 	for ( i = 0; i < len; i ++ ) {
 	for ( i = 0; i < len; i ++ ) {
 
 
-		outputLength = Math.max( outputLength, builder.getIndexByElement( this.component.charAt( i ) ) );
+		outputLength = Math.max( outputLength, builder.getIndexByElement( this.components.charAt( i ) ) );
 
 
 	}
 	}
 
 
@@ -44,12 +43,12 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
 
 
 	// build switch
 	// build switch
 
 
-	a += '.';
+	node += '.';
 
 
 	for ( i = 0; i < len; i ++ ) {
 	for ( i = 0; i < len; i ++ ) {
 
 
-		var elm = this.component.charAt( i );
-		var idx = builder.getIndexByElement( this.component.charAt( i ) );
+		var elm = this.components.charAt( i );
+		var idx = builder.getIndexByElement( this.components.charAt( i ) );
 
 
 		if ( idx > outputLength ) idx = outputLength;
 		if ( idx > outputLength ) idx = outputLength;
 
 
@@ -59,10 +58,10 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
 
 
 		}
 		}
 
 
-		a += builder.getElementByIndex( idx );
+		node += builder.getElementByIndex( idx );
 
 
 	}
 	}
 
 
-	return builder.format( a, this.getType( builder ), output );
+	return builder.format( node, this.getType( builder ), output );
 
 
 };
 };

+ 4 - 4
examples/webgl_materials_nodes.html

@@ -273,7 +273,7 @@
 					//mtl.shadow = // shadowmap
 					//mtl.shadow = // shadowmap
 					//mtl.ao = // ambient occlusion
 					//mtl.ao = // ambient occlusion
 					//mtl.environment = // reflection map (CubeMap recommended)
 					//mtl.environment = // reflection map (CubeMap recommended)
-					//mtl.environmentIntensity = // environment intensity
+					//mtl.environmentAlpha = // environment alpha
 					//mtl.transform = // vertex transformation
 					//mtl.transform = // vertex transformation
 
 
 					var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' );
 					var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' );
@@ -282,7 +282,7 @@
 					mtl.specular = new THREE.FloatNode( .5 );
 					mtl.specular = new THREE.FloatNode( .5 );
 					mtl.shininess = new THREE.FloatNode( 15 );
 					mtl.shininess = new THREE.FloatNode( 15 );
 					mtl.environment = new THREE.CubeTextureNode( cubemap );
 					mtl.environment = new THREE.CubeTextureNode( cubemap );
-					mtl.environmentIntensity = mask;
+					mtl.environmentAlpha = mask;
 					mtl.normal = new THREE.TextureNode( grassNormal );
 					mtl.normal = new THREE.TextureNode( grassNormal );
 					mtl.normalScale = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
 					mtl.normalScale = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
 
 
@@ -305,7 +305,7 @@
 					//mtl.shadow = // shadowmap
 					//mtl.shadow = // shadowmap
 					//mtl.ao = // ambient occlusion
 					//mtl.ao = // ambient occlusion
 					//mtl.environment = // reflection map (CubeMap recommended)
 					//mtl.environment = // reflection map (CubeMap recommended)
-					//mtl.environmentIntensity = // environment intensity
+					//mtl.environmentAlpha = // environment alpha
 					//mtl.transform = // vertex transformation
 					//mtl.transform = // vertex transformation
 
 
 					var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' );
 					var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' );
@@ -619,7 +619,7 @@
 
 
 					mtl.color = new THREE.ColorNode( 0x3399FF );
 					mtl.color = new THREE.ColorNode( 0x3399FF );
 					mtl.environment = color;
 					mtl.environment = color;
-					mtl.environmentIntensity = new THREE.Math1Node( fresnel, THREE.Math1Node.SAT );
+					mtl.environmentAlpha = new THREE.Math1Node( fresnel, THREE.Math1Node.SAT );
 
 
 					// GUI
 					// GUI