Browse Source

Merge pull request #16796 from sunag/dev-fix-TextureCubeNode

NodeMaterial revision
Mr.doob 6 năm trước cách đây
mục cha
commit
95c6dcc926
34 tập tin đã thay đổi với 1017 bổ sung696 xóa
  1. 1 0
      examples/files.js
  2. 1 3
      examples/js/nodes/Nodes.js
  3. 2 6
      examples/js/nodes/THREE.Nodes.js
  4. 3 3
      examples/js/nodes/core/ConstNode.js
  5. 4 4
      examples/js/nodes/core/FunctionNode.js
  6. 14 11
      examples/js/nodes/core/Node.js
  7. 5 2
      examples/js/nodes/core/NodeBuilder.js
  8. 2 2
      examples/js/nodes/core/StructNode.js
  9. 2 2
      examples/js/nodes/core/TempNode.js
  10. 17 5
      examples/js/nodes/inputs/CubeTextureNode.js
  11. 18 6
      examples/js/nodes/inputs/TextureNode.js
  12. 16 14
      examples/js/nodes/materials/NodeMaterial.js
  13. 29 29
      examples/js/nodes/materials/nodes/PhongNode.js
  14. 1 1
      examples/js/nodes/materials/nodes/RawNode.js
  15. 8 8
      examples/js/nodes/materials/nodes/SpriteNode.js
  16. 48 33
      examples/js/nodes/materials/nodes/StandardNode.js
  17. 7 7
      examples/js/nodes/math/CondNode.js
  18. 0 117
      examples/js/nodes/math/Math1Node.js
  19. 0 140
      examples/js/nodes/math/Math2Node.js
  20. 0 121
      examples/js/nodes/math/Math3Node.js
  21. 268 0
      examples/js/nodes/math/MathNode.js
  22. 64 13
      examples/js/nodes/misc/TextureCubeNode.js
  23. 3 4
      examples/js/nodes/misc/TextureCubeUVNode.js
  24. 48 38
      examples/js/nodes/utils/ColorSpaceNode.js
  25. 0 0
      examples/nodes/caustic.json
  26. 0 0
      examples/nodes/displace.json
  27. 0 0
      examples/nodes/wave.json
  28. 0 0
      examples/nodes/xray.json
  29. 302 0
      examples/webgl_materials_envmaps_hdr_nodes.html
  30. 120 93
      examples/webgl_materials_nodes.html
  31. 2 2
      examples/webgl_mirror_nodes.html
  32. 15 15
      examples/webgl_postprocessing_nodes.html
  33. 13 13
      examples/webgl_postprocessing_nodes_pass.html
  34. 4 4
      examples/webgl_sprites_nodes.html

+ 1 - 0
examples/files.js

@@ -159,6 +159,7 @@ var files = {
 		"webgl_materials_envmaps",
 		"webgl_materials_envmaps_exr",
 		"webgl_materials_envmaps_hdr",
+		"webgl_materials_envmaps_hdr_nodes",
 		"webgl_materials_envmaps_parallax",
 		"webgl_materials_grass",
 		"webgl_materials_lightmap",

+ 1 - 3
examples/js/nodes/Nodes.js

@@ -50,9 +50,7 @@ export { ResolutionNode } from './accessors/ResolutionNode.js';
 
 // math
 
-export { Math1Node } from './math/Math1Node.js';
-export { Math2Node } from './math/Math2Node.js';
-export { Math3Node } from './math/Math3Node.js';
+export { MathNode } from './math/MathNode.js';
 export { OperatorNode } from './math/OperatorNode.js';
 export { CondNode } from './math/CondNode.js';
 

+ 2 - 6
examples/js/nodes/THREE.Nodes.js

@@ -50,9 +50,7 @@ import {
 
 	// math
 
-	Math1Node,
-	Math2Node,
-	Math3Node,
+	MathNode,
 	OperatorNode,
 	CondNode,
 
@@ -163,9 +161,7 @@ THREE.ResolutionNode = ResolutionNode;
 
 // math
 
-THREE.Math1Node = Math1Node;
-THREE.Math2Node = Math2Node;
-THREE.Math3Node = Math3Node;
+THREE.MathNode = MathNode;
 THREE.OperatorNode = OperatorNode;
 THREE.CondNode = CondNode;
 

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

@@ -10,7 +10,7 @@ function ConstNode( src, useDefine ) {
 
 	TempNode.call( this );
 
-	this.eval( src || ConstNode.PI, useDefine );
+	this.parse( src || ConstNode.PI, useDefine );
 
 }
 
@@ -31,7 +31,7 @@ ConstNode.prototype.getType = function ( builder ) {
 
 };
 
-ConstNode.prototype.eval = function ( src, useDefine ) {
+ConstNode.prototype.parse = function ( src, useDefine ) {
 
 	this.src = src || '';
 
@@ -100,7 +100,7 @@ ConstNode.prototype.copy = function ( source ) {
 
 	TempNode.prototype.copy.call( this, source );
 
-	this.eval( source.src, source.useDefine );
+	this.parse( source.src, source.useDefine );
 
 };
 

+ 4 - 4
examples/js/nodes/core/FunctionNode.js

@@ -15,7 +15,7 @@ function FunctionNode( src, includes, extensions, keywords, type ) {
 
 	TempNode.call( this, type );
 
-	this.eval( src, includes, extensions, keywords );
+	this.parse( src, includes, extensions, keywords );
 
 }
 
@@ -117,7 +117,7 @@ FunctionNode.prototype.generate = function ( builder, output ) {
 
 		}
 
-		if ( prop != reference ) {
+		if ( prop !== reference ) {
 
 			src = src.substring( 0, match.index + offset ) + reference + src.substring( match.index + prop.length + offset );
 
@@ -151,7 +151,7 @@ FunctionNode.prototype.generate = function ( builder, output ) {
 
 };
 
-FunctionNode.prototype.eval = function ( src, includes, extensions, keywords ) {
+FunctionNode.prototype.parse = function ( src, includes, extensions, keywords ) {
 
 	this.src = src || '';
 
@@ -222,7 +222,7 @@ FunctionNode.prototype.copy = function ( source ) {
 	this.isMethod = source.isMethod;
 	this.useKeywords = source.useKeywords;
 
-	this.eval( source.src, source.includes, source.extensions, source.keywords );
+	this.parse( source.src, source.includes, source.extensions, source.keywords );
 
 	if ( source.type !== undefined ) this.type = source.type;
 

+ 14 - 11
examples/js/nodes/core/Node.js

@@ -20,11 +20,11 @@ Node.prototype = {
 
 	isNode: true,
 
-	parse: function ( builder, settings ) {
+	analyze: function ( builder, settings ) {
 
 		settings = settings || {};
 
-		builder.parsing = true;
+		builder.analyzing = true;
 
 		this.build( builder.addFlow( settings.slot, settings.cache, settings.context ), 'v4' );
 
@@ -33,31 +33,34 @@ Node.prototype = {
 
 		builder.removeFlow();
 
-		builder.parsing = false;
+		builder.analyzing = false;
 
 	},
 
-	parseAndBuildCode: function ( builder, output, settings ) {
+	analyzeAndFlow: function ( builder, output, settings ) {
 
 		settings = settings || {};
 
-		this.parse( builder, settings );
+		this.analyze( builder, settings );
 
-		return this.buildCode( builder, output, settings );
+		return this.flow( builder, output, settings );
 
 	},
 
-	buildCode: function ( builder, output, settings ) {
+	flow: function ( builder, output, settings ) {
 
 		settings = settings || {};
 
-		var data = { result: this.build( builder.addFlow( settings.slot, settings.cache, settings.context ), output ) };
+		builder.addFlow( settings.slot, settings.cache, settings.context )
 
-		data.code = builder.clearNodeCode();
+		var flow = {};
+		flow.result = this.build( builder, output );
+		flow.code = builder.clearNodeCode();
+		flow.extra = builder.context.extra;
 
 		builder.removeFlow();
 
-		return data;
+		return flow;
 
 	},
 
@@ -67,7 +70,7 @@ Node.prototype = {
 
 		var data = builder.getNodeData( uuid || this );
 
-		if ( builder.parsing ) {
+		if ( builder.analyzing ) {
 
 			this.appendDepsNode( builder, data, output );
 

+ 5 - 2
examples/js/nodes/core/NodeBuilder.js

@@ -13,6 +13,8 @@ import { Vector3Node } from '../inputs/Vector3Node.js';
 import { Vector4Node } from '../inputs/Vector4Node.js';
 import { TextureNode } from '../inputs/TextureNode.js';
 import { CubeTextureNode } from '../inputs/CubeTextureNode.js';
+import { TextureCubeNode } from '../misc/TextureCubeNode.js';
+
 
 var elements = NodeUtils.elements,
 	constructors = [ 'float', 'vec2', 'vec3', 'vec4' ],
@@ -140,8 +142,7 @@ function NodeBuilder() {
 
 	// --
 
-	this.parsing = false;
-	this.optimize = true;
+	this.analyzing = false;
 
 }
 
@@ -278,6 +279,8 @@ NodeBuilder.prototype = {
 	addContext: function ( context ) {
 
 		this.context = Object.assign( {}, this.context, context );
+		this.context.extra = this.context.extra || {};
+
 		this.contexts.push( this.context );
 
 		return this;

+ 2 - 2
examples/js/nodes/core/StructNode.js

@@ -11,7 +11,7 @@ function StructNode( src ) {
 
 	TempNode.call( this );
 
-	this.eval( src );
+	this.parse( src );
 
 }
 
@@ -55,7 +55,7 @@ StructNode.prototype.generate = function ( builder, output ) {
 
 };
 
-StructNode.prototype.eval = function ( src ) {
+StructNode.prototype.parse = function ( src ) {
 
 	this.src = src || '';
 

+ 2 - 2
examples/js/nodes/core/TempNode.js

@@ -38,7 +38,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
 		var data = builder.getNodeData( uuid ),
 			type = data.output || this.getType( builder );
 
-		if ( builder.parsing ) {
+		if ( builder.analyzing ) {
 
 			if ( ( data.deps || 0 ) > 0 || this.getLabel() ) {
 
@@ -56,7 +56,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
 
 			return data.name;
 
-		} else if ( ! this.getLabel() && ( ! this.getShared( builder, type ) || ( ! builder.optimize || data.deps === 1 ) ) ) {
+		} else if ( ! this.getLabel() && ( ! this.getShared( builder, type ) || ( builder.context.ignoreCache || data.deps === 1 ) ) ) {
 
 			return Node.prototype.build.call( this, builder, output, uuid );
 

+ 17 - 5
examples/js/nodes/inputs/CubeTextureNode.js

@@ -5,6 +5,7 @@
 import { InputNode } from '../core/InputNode.js';
 import { ReflectNode } from '../accessors/ReflectNode.js';
 import { ColorSpaceNode } from '../utils/ColorSpaceNode.js';
+import { ExpressionNode } from '../core/ExpressionNode.js';
 
 function CubeTextureNode( value, uv, bias ) {
 
@@ -49,16 +50,27 @@ CubeTextureNode.prototype.generate = function ( builder, output ) {
 	if ( bias ) code = 'texCubeBias( ' + cubetex + ', ' + uv + ', ' + bias + ' )';
 	else code = 'texCube( ' + cubetex + ', ' + uv + ' )';
 
-	// add this context to replace ColorSpaceNode.input to code
+	// add a custom context for fix incompatibility with the core
+	// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
+	// this should be removed in the future
+	// context.include =: is used to include or not functions if used FunctionNode
+	// context.ignoreCache =: not create variables temp nodeT0..9 to optimize the code
+	var context = { include: builder.isShader( 'vertex' ), ignoreCache: true };
+	var outputType = this.getType( builder );
 
-	builder.addContext( { input: code, encoding: builder.getTextureEncodingFromMap( this.value ), include: builder.isShader( 'vertex' ) } );
+	builder.addContext( context );
 
-	this.colorSpace = this.colorSpace || new ColorSpaceNode( this );
-	code = this.colorSpace.build( builder, this.type );
+	this.colorSpace = this.colorSpace || new ColorSpaceNode( new ExpressionNode('', outputType ) );
+	this.colorSpace.fromEncoding( builder.getTextureEncodingFromMap( this.value ) );
+	this.colorSpace.input.parse( code );
+
+	code = this.colorSpace.build( builder, outputType );
+
+	// end custom context
 
 	builder.removeContext();
 
-	return builder.format( code, this.type, output );
+	return builder.format( code, outputType, output );
 
 };
 

+ 18 - 6
examples/js/nodes/inputs/TextureNode.js

@@ -5,6 +5,7 @@
 import { InputNode } from '../core/InputNode.js';
 import { UVNode } from '../accessors/UVNode.js';
 import { ColorSpaceNode } from '../utils/ColorSpaceNode.js';
+import { ExpressionNode } from '../core/ExpressionNode.js';
 
 function TextureNode( value, uv, bias, project ) {
 
@@ -39,7 +40,7 @@ TextureNode.prototype.generate = function ( builder, output ) {
 		uv = this.uv.build( builder, this.project ? 'v4' : 'v2' ),
 		bias = this.bias ? this.bias.build( builder, 'f' ) : undefined;
 
-	if ( bias == undefined && builder.context.bias ) {
+	if ( bias === undefined && builder.context.bias ) {
 
 		bias = new builder.context.bias( this ).build( builder, 'f' );
 
@@ -53,16 +54,27 @@ TextureNode.prototype.generate = function ( builder, output ) {
 	if ( bias ) code = method + '( ' + tex + ', ' + uv + ', ' + bias + ' )';
 	else code = method + '( ' + tex + ', ' + uv + ' )';
 
-	// add this context to replace ColorSpaceNode.input to code
+	// add a custom context for fix incompatibility with the core
+	// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
+	// this should be removed in the future
+	// context.include is used to include or not functions if used FunctionNode
+	// context.ignoreCache =: not create temp variables nodeT0..9 to optimize the code
+	var context = { include: builder.isShader( 'vertex' ), ignoreCache: true };
+	var outputType = this.getType( builder );
 
-	builder.addContext( { input: code, encoding: builder.getTextureEncodingFromMap( this.value ), include: builder.isShader( 'vertex' ) } );
+	builder.addContext( context );
 
-	this.colorSpace = this.colorSpace || new ColorSpaceNode( this );
-	code = this.colorSpace.build( builder, this.type );
+	this.colorSpace = this.colorSpace || new ColorSpaceNode( new ExpressionNode('', outputType ) );
+	this.colorSpace.fromEncoding( builder.getTextureEncodingFromMap( this.value ) );
+	this.colorSpace.input.parse( code );
+
+	code = this.colorSpace.build( builder, outputType );
+
+	// end custom context
 
 	builder.removeContext();
 
-	return builder.format( code, this.type, output );
+	return builder.format( code, outputType, output );
 
 };
 

+ 16 - 14
examples/js/nodes/materials/NodeMaterial.js

@@ -18,6 +18,22 @@ function NodeMaterial( vertex, fragment ) {
 
 	this.updaters = [];
 
+	// onBeforeCompile can't be in the prototype because onBeforeCompile.toString varies per material
+
+	this.onBeforeCompile = function ( shader, renderer ) {
+
+		if ( this.needsUpdate ) {
+
+			this.build( { renderer: renderer } );
+
+			shader.uniforms = this.uniforms;
+			shader.vertexShader = this.vertexShader;
+			shader.fragmentShader = this.fragmentShader;
+
+		}
+
+	};
+
 	// it fix the programCache and share the code with others materials
 
 	this.onBeforeCompile.toString = function() {
@@ -74,20 +90,6 @@ NodeMaterial.prototype.updateFrame = function ( frame ) {
 
 };
 
-NodeMaterial.prototype.onBeforeCompile = function ( shader, renderer ) {
-
-	if ( this.needsUpdate ) {
-
-		this.build( { renderer: renderer } );
-
-		shader.uniforms = this.uniforms;
-		shader.vertexShader = this.vertexShader;
-		shader.fragmentShader = this.fragmentShader;
-
-	}
-
-};
-
 NodeMaterial.prototype.build = function ( params ) {
 
 	params = params || {};

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

@@ -30,7 +30,7 @@ PhongNode.prototype.build = function ( builder ) {
 
 	if ( builder.isShader( 'vertex' ) ) {
 
-		var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined;
+		var position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
 
 		builder.mergeUniform( THREE.UniformsUtils.merge( [
 
@@ -101,51 +101,51 @@ PhongNode.prototype.build = function ( builder ) {
 
 	} else {
 
-		// parse all nodes to reuse generate codes
+		// analyze all nodes to reuse generate codes
 
-		if ( this.mask ) this.mask.parse( builder );
+		if ( this.mask ) this.mask.analyze( builder );
 
-		this.color.parse( builder, { slot: 'color' } );
-		this.specular.parse( builder );
-		this.shininess.parse( builder );
+		this.color.analyze( builder, { slot: 'color' } );
+		this.specular.analyze( builder );
+		this.shininess.analyze( builder );
 
-		if ( this.alpha ) this.alpha.parse( builder );
+		if ( this.alpha ) this.alpha.analyze( builder );
 
-		if ( this.normal ) this.normal.parse( builder );
+		if ( this.normal ) this.normal.analyze( builder );
 
-		if ( this.light ) this.light.parse( builder, { cache: 'light' } );
+		if ( this.light ) this.light.analyze( builder, { cache: 'light' } );
 
-		if ( this.ao ) this.ao.parse( builder );
-		if ( this.ambient ) this.ambient.parse( builder );
-		if ( this.shadow ) this.shadow.parse( builder );
-		if ( this.emissive ) this.emissive.parse( builder, { slot: 'emissive' } );
+		if ( this.ao ) this.ao.analyze( builder );
+		if ( this.ambient ) this.ambient.analyze( builder );
+		if ( this.shadow ) this.shadow.analyze( builder );
+		if ( this.emissive ) this.emissive.analyze( builder, { slot: 'emissive' } );
 
-		if ( this.environment ) this.environment.parse( builder, { slot: 'environment' } );
-		if ( this.environmentAlpha && this.environment ) this.environmentAlpha.parse( builder );
+		if ( this.environment ) this.environment.analyze( builder, { slot: 'environment' } );
+		if ( this.environmentAlpha && this.environment ) this.environmentAlpha.analyze( builder );
 
 		// build code
 
-		var mask = this.mask ? this.mask.buildCode( builder, 'b' ) : undefined;
+		var mask = this.mask ? this.mask.flow( builder, 'b' ) : undefined;
 
-		var color = this.color.buildCode( builder, 'c', { slot: 'color' } );
-		var specular = this.specular.buildCode( builder, 'c' );
-		var shininess = this.shininess.buildCode( builder, 'f' );
+		var color = this.color.flow( builder, 'c', { slot: 'color' } );
+		var specular = this.specular.flow( builder, 'c' );
+		var shininess = this.shininess.flow( builder, 'f' );
 
-		var alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined;
+		var alpha = this.alpha ? this.alpha.flow( builder, 'f' ) : undefined;
 
-		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
+		var normal = this.normal ? this.normal.flow( builder, 'v3' ) : undefined;
 
-		var light = this.light ? this.light.buildCode( builder, 'v3', { cache: 'light' } ) : undefined;
+		var light = this.light ? this.light.flow( builder, 'v3', { cache: 'light' } ) : undefined;
 
-		var ao = this.ao ? this.ao.buildCode( builder, 'f' ) : undefined;
-		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
-		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
-		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c', { slot: 'emissive' } ) : undefined;
+		var ao = this.ao ? this.ao.flow( builder, 'f' ) : undefined;
+		var ambient = this.ambient ? this.ambient.flow( builder, 'c' ) : undefined;
+		var shadow = this.shadow ? this.shadow.flow( builder, 'c' ) : undefined;
+		var emissive = this.emissive ? this.emissive.flow( builder, 'c', { slot: 'emissive' } ) : undefined;
 
-		var environment = this.environment ? this.environment.buildCode( builder, 'c', { slot: 'environment' } ) : undefined;
-		var environmentAlpha = this.environmentAlpha && this.environment ? this.environmentAlpha.buildCode( builder, 'f' ) : undefined;
+		var environment = this.environment ? this.environment.flow( builder, 'c', { slot: 'environment' } ) : undefined;
+		var environmentAlpha = this.environmentAlpha && this.environment ? this.environmentAlpha.flow( builder, 'f' ) : undefined;
 
-		builder.requires.transparent = alpha != undefined;
+		builder.requires.transparent = alpha !== undefined;
 
 		builder.addParsCode( [
 			"#include <fog_pars_fragment>",

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

@@ -18,7 +18,7 @@ RawNode.prototype.nodeType = "Raw";
 
 RawNode.prototype.generate = function ( builder ) {
 
-	var data = this.value.parseAndBuildCode( builder, this.type ),
+	var data = this.value.analyzeAndFlow( builder, this.type ),
 		code = data.code + '\n';
 
 	if ( builder.isShader( 'vertex' ) ) {

+ 8 - 8
examples/js/nodes/materials/nodes/SpriteNode.js

@@ -29,7 +29,7 @@ SpriteNode.prototype.build = function ( builder ) {
 
 	if ( builder.isShader( 'vertex' ) ) {
 
-		var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined;
+		var position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
 
 		builder.mergeUniform( THREE.UniformsUtils.merge( [
 			THREE.UniformsLib.fog
@@ -121,19 +121,19 @@ SpriteNode.prototype.build = function ( builder ) {
 			"#include <logdepthbuf_fragment>"
 		].join( "\n" ) );
 
-		// parse all nodes to reuse generate codes
+		// analyze all nodes to reuse generate codes
 
-		if ( this.mask ) this.mask.parse( builder );
+		if ( this.mask ) this.mask.analyze( builder );
 
-		if ( this.alpha ) this.alpha.parse( builder );
+		if ( this.alpha ) this.alpha.analyze( builder );
 
-		this.color.parse( builder, { slot: 'color' } );
+		this.color.analyze( builder, { slot: 'color' } );
 
 		// build code
 
-		var mask = this.mask ? this.mask.buildCode( builder, 'b' ) : undefined,
-			alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined,
-			color = this.color.buildCode( builder, 'c', { slot: 'color' } ),
+		var mask = this.mask ? this.mask.flow( builder, 'b' ) : undefined,
+			alpha = this.alpha ? this.alpha.flow( builder, 'f' ) : undefined,
+			color = this.color.flow( builder, 'c', { slot: 'color' } ),
 			output = [];
 
 		if ( mask ) {

+ 48 - 33
examples/js/nodes/materials/nodes/StandardNode.js

@@ -33,7 +33,7 @@ StandardNode.prototype.build = function ( builder ) {
 
 	if ( builder.isShader( 'vertex' ) ) {
 
-		var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined;
+		var position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
 
 		builder.mergeUniform( THREE.UniformsUtils.merge( [
 
@@ -42,6 +42,15 @@ StandardNode.prototype.build = function ( builder ) {
 
 		] ) );
 
+		if ( THREE.UniformsLib.LTC_1 ) {
+
+			// add ltc data textures to material uniforms
+
+			builder.uniforms.ltc_1 = { value: undefined };
+			builder.uniforms.ltc_2 = { value: undefined };
+
+		}
+
 		builder.addParsCode( [
 			"varying vec3 vViewPosition;",
 
@@ -115,59 +124,59 @@ StandardNode.prototype.build = function ( builder ) {
 
 		var useClearCoat = ! builder.isDefined( 'STANDARD' );
 
-		// parse all nodes to reuse generate codes
+		// analyze all nodes to reuse generate codes
 
-		if ( this.mask ) this.mask.parse( builder );
+		if ( this.mask ) this.mask.analyze( builder );
 
-		this.color.parse( builder, { slot: 'color', context: contextGammaOnly } );
-		this.roughness.parse( builder );
-		this.metalness.parse( builder );
+		this.color.analyze( builder, { slot: 'color', context: contextGammaOnly } );
+		this.roughness.analyze( builder );
+		this.metalness.analyze( builder );
 
-		if ( this.alpha ) this.alpha.parse( builder );
+		if ( this.alpha ) this.alpha.analyze( builder );
 
-		if ( this.normal ) this.normal.parse( builder );
+		if ( this.normal ) this.normal.analyze( builder );
 
-		if ( this.clearCoat ) this.clearCoat.parse( builder );
-		if ( this.clearCoatRoughness ) this.clearCoatRoughness.parse( builder );
+		if ( this.clearCoat ) this.clearCoat.analyze( builder );
+		if ( this.clearCoatRoughness ) this.clearCoatRoughness.analyze( builder );
 
-		if ( this.reflectivity ) this.reflectivity.parse( builder );
+		if ( this.reflectivity ) this.reflectivity.analyze( builder );
 
-		if ( this.light ) this.light.parse( builder, { cache: 'light' } );
+		if ( this.light ) this.light.analyze( builder, { cache: 'light' } );
 
-		if ( this.ao ) this.ao.parse( builder );
-		if ( this.ambient ) this.ambient.parse( builder );
-		if ( this.shadow ) this.shadow.parse( builder );
-		if ( this.emissive ) this.emissive.parse( builder, { slot: 'emissive' } );
+		if ( this.ao ) this.ao.analyze( builder );
+		if ( this.ambient ) this.ambient.analyze( builder );
+		if ( this.shadow ) this.shadow.analyze( builder );
+		if ( this.emissive ) this.emissive.analyze( builder, { slot: 'emissive' } );
 
-		if ( this.environment ) this.environment.parse( builder, { cache: 'env', context: contextEnvironment, slot: 'environment' } ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
+		if ( this.environment ) this.environment.analyze( builder, { cache: 'env', context: contextEnvironment, slot: 'environment' } ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode )
 
 		// build code
 
-		var mask = this.mask ? this.mask.buildCode( builder, 'b' ) : undefined;
+		var mask = this.mask ? this.mask.flow( builder, 'b' ) : undefined;
 
-		var color = this.color.buildCode( builder, 'c', { slot: 'color', context: contextGammaOnly } );
-		var roughness = this.roughness.buildCode( builder, 'f' );
-		var metalness = this.metalness.buildCode( builder, 'f' );
+		var color = this.color.flow( builder, 'c', { slot: 'color', context: contextGammaOnly } );
+		var roughness = this.roughness.flow( builder, 'f' );
+		var metalness = this.metalness.flow( builder, 'f' );
 
-		var alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined;
+		var alpha = this.alpha ? this.alpha.flow( builder, 'f' ) : undefined;
 
-		var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined;
+		var normal = this.normal ? this.normal.flow( builder, 'v3' ) : undefined;
 
-		var clearCoat = this.clearCoat ? this.clearCoat.buildCode( builder, 'f' ) : undefined;
-		var clearCoatRoughness = this.clearCoatRoughness ? this.clearCoatRoughness.buildCode( builder, 'f' ) : undefined;
+		var clearCoat = this.clearCoat ? this.clearCoat.flow( builder, 'f' ) : undefined;
+		var clearCoatRoughness = this.clearCoatRoughness ? this.clearCoatRoughness.flow( builder, 'f' ) : undefined;
 
-		var reflectivity = this.reflectivity ? this.reflectivity.buildCode( builder, 'f' ) : undefined;
+		var reflectivity = this.reflectivity ? this.reflectivity.flow( builder, 'f' ) : undefined;
 
-		var light = this.light ? this.light.buildCode( builder, 'v3', { cache: 'light' } ) : undefined;
+		var light = this.light ? this.light.flow( builder, 'v3', { cache: 'light' } ) : undefined;
 
-		var ao = this.ao ? this.ao.buildCode( builder, 'f' ) : undefined;
-		var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined;
-		var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined;
-		var emissive = this.emissive ? this.emissive.buildCode( builder, 'c', { slot: 'emissive' } ) : undefined;
+		var ao = this.ao ? this.ao.flow( builder, 'f' ) : undefined;
+		var ambient = this.ambient ? this.ambient.flow( builder, 'c' ) : undefined;
+		var shadow = this.shadow ? this.shadow.flow( builder, 'c' ) : undefined;
+		var emissive = this.emissive ? this.emissive.flow( builder, 'c', { slot: 'emissive' } ) : undefined;
 
-		var environment = this.environment ? this.environment.buildCode( builder, 'c', { cache: 'env', context: contextEnvironment, slot: 'environment' } ) : undefined;
+		var environment = this.environment ? this.environment.flow( builder, 'c', { cache: 'env', context: contextEnvironment, slot: 'environment' } ) : undefined;
 
-		var clearCoatEnv = useClearCoat && environment ? this.environment.buildCode( builder, 'c', { cache: 'clearCoat', context: contextEnvironment, slot: 'environment' } ) : undefined;
+		var clearCoatEnv = useClearCoat && environment ? this.environment.flow( builder, 'c', { cache: 'clearCoat', context: contextEnvironment, slot: 'environment' } ) : undefined;
 
 		builder.requires.transparent = alpha !== undefined;
 
@@ -370,6 +379,12 @@ StandardNode.prototype.build = function ( builder ) {
 
 			output.push( "radiance += " + environment.result + ";" );
 
+			if ( environment.extra.irradiance ) {
+
+				output.push( "irradiance += PI * " + environment.extra.irradiance + ";" );
+
+			}
+
 		}
 
 		output.push(

+ 7 - 7
examples/js/nodes/math/CondNode.js

@@ -32,10 +32,10 @@ CondNode.prototype.nodeType = "Cond";
 CondNode.prototype.getType = function ( builder ) {
 
 	if (this.ifNode) {
-		
+
 		var ifType = this.ifNode.getType( builder );
 		var elseType = this.elseNode.getType( builder );
-		
+
 		if ( builder.getTypeLength( elseType ) > builder.getTypeLength( ifType ) ) {
 
 			return elseType;
@@ -43,7 +43,7 @@ CondNode.prototype.getType = function ( builder ) {
 		}
 
 		return ifType;
-		
+
 	}
 	
 	return 'b';
@@ -69,18 +69,18 @@ CondNode.prototype.generate = function ( builder, output ) {
 		a = this.a.build( builder, condType ),
 		b = this.b.build( builder, condType ),
 		code;
-		
+
 	if (this.ifNode) {
-		
+
 		var ifCode = this.ifNode.build( builder, type ),
 			elseCode = this.elseNode.build( builder, type );
 		
 		code = '( ' + [ a, this.op, b, '?', ifCode, ':', elseCode ].join( ' ' ) + ' )';
-		
+
 	} else {
 
 		code = '( ' + a + ' ' + this.op + ' ' +  b  + ' )';
-		
+
 	}
 
 	return builder.format( code, this.getType( builder ), output );

+ 0 - 117
examples/js/nodes/math/Math1Node.js

@@ -1,117 +0,0 @@
-/**
- * @author sunag / http://www.sunag.com.br/
- */
-
-import { TempNode } from '../core/TempNode.js';
-
-function Math1Node( a, method ) {
-
-	TempNode.call( this );
-
-	this.a = a;
-
-	this.method = method;
-
-}
-
-Math1Node.RAD = 'radians';
-Math1Node.DEG = 'degrees';
-Math1Node.EXP = 'exp';
-Math1Node.EXP2 = 'exp2';
-Math1Node.LOG = 'log';
-Math1Node.LOG2 = 'log2';
-Math1Node.SQRT = 'sqrt';
-Math1Node.INV_SQRT = 'inversesqrt';
-Math1Node.FLOOR = 'floor';
-Math1Node.CEIL = 'ceil';
-Math1Node.NORMALIZE = 'normalize';
-Math1Node.FRACT = 'fract';
-Math1Node.SATURATE = 'saturate';
-Math1Node.SIN = 'sin';
-Math1Node.COS = 'cos';
-Math1Node.TAN = 'tan';
-Math1Node.ASIN = 'asin';
-Math1Node.ACOS = 'acos';
-Math1Node.ARCTAN = 'atan';
-Math1Node.ABS = 'abs';
-Math1Node.SIGN = 'sign';
-Math1Node.LENGTH = 'length';
-Math1Node.NEGATE = 'negate';
-Math1Node.INVERT = 'invert';
-
-Math1Node.prototype = Object.create( TempNode.prototype );
-Math1Node.prototype.constructor = Math1Node;
-Math1Node.prototype.nodeType = "Math1";
-
-Math1Node.prototype.getType = function ( builder ) {
-
-	switch ( this.method ) {
-
-		case Math1Node.LENGTH:
-
-			return 'f';
-
-	}
-
-	return this.a.getType( builder );
-
-};
-
-Math1Node.prototype.generate = function ( builder, output ) {
-
-	var type = this.getType( builder ),
-		result = this.a.build( builder, type );
-
-	switch ( this.method ) {
-
-		case Math1Node.NEGATE:
-
-			result = '( -' + result + ' )';
-
-			break;
-
-		case Math1Node.INVERT:
-
-			result = '( 1.0 - ' + result + ' )';
-
-			break;
-
-		default:
-
-			result = this.method + '( ' + result + ' )';
-
-			break;
-
-	}
-
-	return builder.format( result, type, output );
-
-};
-
-Math1Node.prototype.copy = function ( source ) {
-
-	TempNode.prototype.copy.call( this, source );
-
-	this.a = source.a;
-	this.method = source.method;
-
-};
-
-Math1Node.prototype.toJSON = function ( meta ) {
-
-	var data = this.getJSONNode( meta );
-
-	if ( ! data ) {
-
-		data = this.createJSONNode( meta );
-
-		data.a = this.a.toJSON( meta ).uuid;
-		data.method = this.method;
-
-	}
-
-	return data;
-
-};
-
-export { Math1Node };

+ 0 - 140
examples/js/nodes/math/Math2Node.js

@@ -1,140 +0,0 @@
-/**
- * @author sunag / http://www.sunag.com.br/
- */
-
-import { TempNode } from '../core/TempNode.js';
-
-function Math2Node( a, b, method ) {
-
-	TempNode.call( this );
-
-	this.a = a;
-	this.b = b;
-
-	this.method = method;
-
-}
-
-Math2Node.MIN = 'min';
-Math2Node.MAX = 'max';
-Math2Node.MOD = 'mod';
-Math2Node.STEP = 'step';
-Math2Node.REFLECT = 'reflect';
-Math2Node.DISTANCE = 'distance';
-Math2Node.DOT = 'dot';
-Math2Node.CROSS = 'cross';
-Math2Node.POW = 'pow';
-
-Math2Node.prototype = Object.create( TempNode.prototype );
-Math2Node.prototype.constructor = Math2Node;
-Math2Node.prototype.nodeType = "Math2";
-
-Math2Node.prototype.getInputType = function ( builder ) {
-
-	// use the greater length vector
-
-	if ( builder.getTypeLength( this.b.getType( builder ) ) > builder.getTypeLength( this.a.getType( builder ) ) ) {
-
-		return this.b.getType( builder );
-
-	}
-
-	return this.a.getType( builder );
-
-};
-
-Math2Node.prototype.getType = function ( builder ) {
-
-	switch ( this.method ) {
-
-		case Math2Node.DISTANCE:
-		case Math2Node.DOT:
-
-			return 'f';
-
-		case Math2Node.CROSS:
-
-			return 'v3';
-
-	}
-
-	return this.getInputType( builder );
-
-};
-
-Math2Node.prototype.generate = function ( builder, output ) {
-
-	var a, b,
-		type = this.getInputType( builder ),
-		al = builder.getTypeLength( this.a.getType( builder ) ),
-		bl = builder.getTypeLength( this.b.getType( builder ) );
-
-	// optimzer
-
-	switch ( this.method ) {
-
-		case Math2Node.CROSS:
-
-			a = this.a.build( builder, 'v3' );
-			b = this.b.build( builder, 'v3' );
-
-			break;
-
-		case Math2Node.STEP:
-
-			a = this.a.build( builder, al === 1 ? 'f' : type );
-			b = this.b.build( builder, type );
-
-			break;
-
-		case Math2Node.MIN:
-		case Math2Node.MAX:
-		case Math2Node.MOD:
-
-			a = this.a.build( builder, type );
-			b = this.b.build( builder, bl === 1 ? 'f' : type );
-
-			break;
-
-		default:
-
-			a = this.a.build( builder, type );
-			b = this.b.build( builder, type );
-
-			break;
-
-	}
-
-	return builder.format( this.method + '( ' + a + ', ' + b + ' )', this.getType( builder ), output );
-
-};
-
-Math2Node.prototype.copy = function ( source ) {
-
-	TempNode.prototype.copy.call( this, source );
-
-	this.a = source.a;
-	this.b = source.b;
-	this.method = source.method;
-
-};
-
-Math2Node.prototype.toJSON = function ( meta ) {
-
-	var data = this.getJSONNode( meta );
-
-	if ( ! data ) {
-
-		data = this.createJSONNode( meta );
-
-		data.a = this.a.toJSON( meta ).uuid;
-		data.b = this.b.toJSON( meta ).uuid;
-		data.method = this.method;
-
-	}
-
-	return data;
-
-};
-
-export { Math2Node };

+ 0 - 121
examples/js/nodes/math/Math3Node.js

@@ -1,121 +0,0 @@
-/**
- * @author sunag / http://www.sunag.com.br/
- */
-
-import { TempNode } from '../core/TempNode.js';
-
-function Math3Node( a, b, c, method ) {
-
-	TempNode.call( this );
-
-	this.a = a;
-	this.b = b;
-	this.c = c;
-
-	this.method = method;
-
-}
-
-Math3Node.MIX = 'mix';
-Math3Node.CLAMP = 'clamp';
-Math3Node.REFRACT = 'refract';
-Math3Node.SMOOTHSTEP = 'smoothstep';
-Math3Node.FACEFORWARD = 'faceforward';
-
-Math3Node.prototype = Object.create( TempNode.prototype );
-Math3Node.prototype.constructor = Math3Node;
-Math3Node.prototype.nodeType = "Math3";
-
-Math3Node.prototype.getType = function ( builder ) {
-
-	var a = builder.getTypeLength( this.a.getType( builder ) );
-	var b = builder.getTypeLength( this.b.getType( builder ) );
-	var c = builder.getTypeLength( this.c.getType( builder ) );
-
-	if ( a > b && a > c ) {
-
-		return this.a.getType( builder );
-
-	} else if ( b > c ) {
-
-		return this.b.getType( builder );
-
-	}
-
-	return this.c.getType( builder );
-
-};
-
-Math3Node.prototype.generate = function ( builder, output ) {
-
-	var a, b, c,
-		al = builder.getTypeLength( this.a.getType( builder ) ),
-		bl = builder.getTypeLength( this.b.getType( builder ) ),
-		cl = builder.getTypeLength( this.c.getType( builder ) ),
-		type = this.getType( builder );
-
-	// optimzer
-
-	switch ( this.method ) {
-
-		case Math3Node.REFRACT:
-
-			a = this.a.build( builder, type );
-			b = this.b.build( builder, type );
-			c = this.c.build( builder, 'f' );
-
-			break;
-
-		case Math3Node.MIX:
-
-			a = this.a.build( builder, type );
-			b = this.b.build( builder, type );
-			c = this.c.build( builder, cl === 1 ? 'f' : type );
-
-			break;
-
-		default:
-
-			a = this.a.build( builder, type );
-			b = this.b.build( builder, type );
-			c = this.c.build( builder, type );
-
-			break;
-
-	}
-
-	return builder.format( this.method + '( ' + a + ', ' + b + ', ' + c + ' )', type, output );
-
-};
-
-Math3Node.prototype.copy = function ( source ) {
-
-	TempNode.prototype.copy.call( this, source );
-
-	this.a = source.a;
-	this.b = source.b;
-	this.c = source.c;
-	this.method = source.method;
-
-};
-
-Math3Node.prototype.toJSON = function ( meta ) {
-
-	var data = this.getJSONNode( meta );
-
-	if ( ! data ) {
-
-		data = this.createJSONNode( meta );
-
-		data.a = this.a.toJSON( meta ).uuid;
-		data.b = this.b.toJSON( meta ).uuid;
-		data.c = this.c.toJSON( meta ).uuid;
-		data.method = this.method;
-
-	}
-
-	return data;
-
-};
-
-export { Math3Node };

+ 268 - 0
examples/js/nodes/math/MathNode.js

@@ -0,0 +1,268 @@
+/**
+ * @author sunag / http://www.sunag.com.br/
+ */
+
+import { TempNode } from '../core/TempNode.js';
+
+function MathNode( a, bOrMethod, cOrMethod, method ) {
+
+	TempNode.call( this );
+
+	this.a = a;
+	typeof bOrMethod !== 'string' ? this.b = bOrMethod : method = bOrMethod;
+	typeof cOrMethod !== 'string' ? this.c = cOrMethod : method = cOrMethod;
+
+	this.method = method;
+
+}
+
+// 1 input
+
+MathNode.RAD = 'radians';
+MathNode.DEG = 'degrees';
+MathNode.EXP = 'exp';
+MathNode.EXP2 = 'exp2';
+MathNode.LOG = 'log';
+MathNode.LOG2 = 'log2';
+MathNode.SQRT = 'sqrt';
+MathNode.INV_SQRT = 'inversesqrt';
+MathNode.FLOOR = 'floor';
+MathNode.CEIL = 'ceil';
+MathNode.NORMALIZE = 'normalize';
+MathNode.FRACT = 'fract';
+MathNode.SATURATE = 'saturate';
+MathNode.SIN = 'sin';
+MathNode.COS = 'cos';
+MathNode.TAN = 'tan';
+MathNode.ASIN = 'asin';
+MathNode.ACOS = 'acos';
+MathNode.ARCTAN = 'atan';
+MathNode.ABS = 'abs';
+MathNode.SIGN = 'sign';
+MathNode.LENGTH = 'length';
+MathNode.NEGATE = 'negate';
+MathNode.INVERT = 'invert';
+
+// 2 inputs
+
+MathNode.MIN = 'min';
+MathNode.MAX = 'max';
+MathNode.MOD = 'mod';
+MathNode.STEP = 'step';
+MathNode.REFLECT = 'reflect';
+MathNode.DISTANCE = 'distance';
+MathNode.DOT = 'dot';
+MathNode.CROSS = 'cross';
+MathNode.POW = 'pow';
+
+// 3 inputs
+
+MathNode.MIX = 'mix';
+MathNode.CLAMP = 'clamp';
+MathNode.REFRACT = 'refract';
+MathNode.SMOOTHSTEP = 'smoothstep';
+MathNode.FACEFORWARD = 'faceforward';
+
+MathNode.prototype = Object.create( TempNode.prototype );
+MathNode.prototype.constructor = MathNode;
+MathNode.prototype.nodeType = "Math";
+
+MathNode.prototype.getNumInputs = function ( builder ) {
+
+	switch ( this.method ) {
+
+		case MathNode.MIX:
+		case MathNode.CLAMP:
+		case MathNode.REFRACT:
+		case MathNode.SMOOTHSTEP:
+		case MathNode.FACEFORWARD:
+			
+			return 3;
+
+		case MathNode.MIN:
+		case MathNode.MAX:
+		case MathNode.MOD:
+		case MathNode.STEP:
+		case MathNode.REFLECT:
+		case MathNode.DISTANCE:
+		case MathNode.DOT:
+		case MathNode.CROSS:
+		case MathNode.POW:
+
+			return 2;
+
+		default:
+
+			return 1;
+
+	}
+
+};
+
+MathNode.prototype.getInputType = function ( builder ) {
+
+	var a = builder.getTypeLength( this.a.getType( builder ) );
+	var b = this.b ? builder.getTypeLength( this.b.getType( builder ) ) : 0;
+	var c = this.c ? builder.getTypeLength( this.c.getType( builder ) ) : 0;
+
+	if ( a > b && a > c ) {
+
+		return this.a.getType( builder );
+
+	} else if ( b > c ) {
+
+		return this.b.getType( builder );
+
+	}
+
+	return this.c.getType( builder );
+
+};
+
+MathNode.prototype.getType = function ( builder ) {
+
+	switch ( this.method ) {
+
+		case MathNode.LENGTH:
+		case MathNode.DISTANCE:
+		case MathNode.DOT:
+
+			return 'f';
+
+		case MathNode.CROSS:
+
+			return 'v3';
+
+	}
+
+	return this.getInputType( builder );
+
+};
+
+MathNode.prototype.generate = function ( builder, output ) {
+
+	var a, b, c,
+		al = this.a ? builder.getTypeLength( this.a.getType( builder ) ) : 0,
+		bl = this.b ? builder.getTypeLength( this.b.getType( builder ) ) : 0,
+		cl = this.c ? builder.getTypeLength( this.c.getType( builder ) ) : 0,
+		inputType = this.getInputType( builder ),
+		nodeType = this.getType( builder );
+
+	switch ( this.method ) {
+
+		// 1 input
+
+		case MathNode.NEGATE:
+
+			return builder.format( '( -' + this.a.build( builder, inputType ) + ' )', inputType, output );
+
+		case MathNode.INVERT:
+
+			return builder.format( '( 1.0 - ' + this.a.build( builder, inputType ) + ' )', inputType, output );
+
+		// 2 inputs
+
+		case MathNode.CROSS:
+
+			a = this.a.build( builder, 'v3' );
+			b = this.b.build( builder, 'v3' );
+
+			break;
+
+		case MathNode.STEP:
+
+			a = this.a.build( builder, al === 1 ? 'f' : inputType );
+			b = this.b.build( builder, inputType );
+
+			break;
+
+		case MathNode.MIN:
+		case MathNode.MAX:
+		case MathNode.MOD:
+
+			a = this.a.build( builder, inputType );
+			b = this.b.build( builder, bl === 1 ? 'f' : inputType );
+
+			break;
+
+		// 3 inputs
+
+		case MathNode.REFRACT:
+
+			a = this.a.build( builder, inputType );
+			b = this.b.build( builder, inputType );
+			c = this.c.build( builder, 'f' );
+
+			break;
+
+		case MathNode.MIX:
+
+			a = this.a.build( builder, inputType );
+			b = this.b.build( builder, inputType );
+			c = this.c.build( builder, cl === 1 ? 'f' : inputType );
+
+			break;
+
+		// default
+
+		default:
+
+			a = this.a.build( builder, inputType );
+			if ( this.b ) b = this.b.build( builder, inputType );
+			if ( this.c ) c = this.c.build( builder, inputType );
+
+			break;
+
+	}
+
+	// build function call
+
+	var params = [];
+	params.push( a );
+	if (b) params.push( b );
+	if (c) params.push( c );
+
+	var numInputs = this.getNumInputs( builder );
+
+	if (params.length !== numInputs) {
+
+		throw Error(`Arguments not match used in "${this.method}". Require ${numInputs}, currently ${params.length}.`);
+
+	}
+
+	return builder.format( this.method + '( ' + params.join(', ') + ' )', nodeType, output );
+
+};
+
+MathNode.prototype.copy = function ( source ) {
+
+	TempNode.prototype.copy.call( this, source );
+
+	this.a = source.a;
+	this.b = source.b;
+	this.c = source.c;
+	this.method = source.method;
+
+};
+
+MathNode.prototype.toJSON = function ( meta ) {
+
+	var data = this.getJSONNode( meta );
+
+	if ( ! data ) {
+
+		data = this.createJSONNode( meta );
+
+		data.a = this.a.toJSON( meta ).uuid;
+		if ( this.b ) data.b = this.b.toJSON( meta ).uuid;
+		if ( this.c ) data.c = this.c.toJSON( meta ).uuid;
+
+		data.method = this.method;
+
+	}
+
+	return data;
+
+};
+
+export { MathNode };

+ 64 - 13
examples/js/nodes/misc/TextureCubeNode.js

@@ -3,14 +3,32 @@
  */
 
 import { TempNode } from '../core/TempNode.js';
+import { FloatNode } from '../inputs/FloatNode.js';
+import { ExpressionNode } from '../core/ExpressionNode.js';
 import { TextureCubeUVNode } from './TextureCubeUVNode.js';
+import { ReflectNode } from '../accessors/ReflectNode.js';
+import { NormalNode } from '../accessors/NormalNode.js';
+import { ColorSpaceNode } from '../utils/ColorSpaceNode.js';
+import { BlinnExponentToRoughnessNode } from '../bsdfs/BlinnExponentToRoughnessNode.js';
 
-function TextureCubeNode( value, uv ) {
+function TextureCubeNode( value, textureSize ) {
 
 	TempNode.call( this, 'v4' );
 
 	this.value = value;
-	this.uv = uv || new TextureCubeUVNode();
+	this.textureSize = textureSize || new FloatNode( 1024 );
+
+	this.radianceCache = { uv: new TextureCubeUVNode( 
+		new ReflectNode( ReflectNode.VECTOR ), 
+		this.textureSize, 
+		new BlinnExponentToRoughnessNode() 
+	) };
+
+	this.irradianceCache = { uv: new TextureCubeUVNode( 
+		new NormalNode( NormalNode.WORLD ), 
+		this.textureSize, 
+		new FloatNode( 1 ).setReadonly( true ) 
+	) };
 
 }
 
@@ -18,18 +36,55 @@ TextureCubeNode.prototype = Object.create( TempNode.prototype );
 TextureCubeNode.prototype.constructor = TextureCubeNode;
 TextureCubeNode.prototype.nodeType = "TextureCube";
 
+TextureCubeNode.prototype.generateTextureCubeUV = function ( builder, cache ) {
+
+	var uv_10 = cache.uv.build( builder ) + '.uv_10',
+		uv_20 = cache.uv.build( builder ) + '.uv_20',
+		t = cache.uv.build( builder ) + '.t';
+
+	var color10 = 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_10 + ' )',
+		color20 = 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_20 + ' )';
+
+	// add a custom context for fix incompatibility with the core
+	// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
+	// this should be removed in the future
+	// context.include =: is used to include or not functions if used FunctionNode
+	// context.ignoreCache =: not create temp variables nodeT0..9 to optimize the code
+	var context = { include: builder.isShader( 'vertex' ), ignoreCache: true };
+	var outputType = this.getType( builder );
+
+	builder.addContext( context );
+
+	cache.colorSpace10 = cache.colorSpace10 || new ColorSpaceNode( new ExpressionNode('', outputType ) );
+	cache.colorSpace10.fromDecoding( builder.getTextureEncodingFromMap( this.value.value ) );
+	cache.colorSpace10.input.parse( color10 );
+
+	color10 = cache.colorSpace10.build( builder, outputType );
+
+	cache.colorSpace20 = cache.colorSpace20 || new ColorSpaceNode( new ExpressionNode('', outputType ) );
+	cache.colorSpace20.fromDecoding( builder.getTextureEncodingFromMap( this.value.value ) );
+	cache.colorSpace20.input.parse( color20 );
+
+	color20 = cache.colorSpace20.build( builder, outputType );
+
+	// end custom context
+
+	builder.removeContext();
+
+	return 'mix( ' + color10 + ', ' + color20 + ', ' + t + ' ).rgb';
+
+};
+
 TextureCubeNode.prototype.generate = function ( builder, output ) {
 
 	if ( builder.isShader( 'fragment' ) ) {
 
-		var uv_10 = this.uv.build( builder ) + '.uv_10',
-			uv_20 = this.uv.build( builder ) + '.uv_20',
-			t = this.uv.build( builder ) + '.t';
+		var radiance = this.generateTextureCubeUV( builder, this.radianceCache );
+		var irradiance = this.generateTextureCubeUV( builder, this.irradianceCache );
 
-		var color10 = builder.getTexelDecodingFunctionFromTexture( 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_10 + ' )', this.value.value ),
-			color20 = builder.getTexelDecodingFunctionFromTexture( 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_20 + ' )', this.value.value );
+		builder.context.extra.irradiance = irradiance;
 
-		return builder.format( 'vec4( mix( ' + color10 + ', ' + color20 + ', ' + t + ' ).rgb, 1.0 )', this.getType( builder ), output );
+		return builder.format( 'vec4( ' + radiance + ', 1.0 )', this.getType( builder ), output );
 
 	} else {
 
@@ -49,11 +104,7 @@ TextureCubeNode.prototype.toJSON = function ( meta ) {
 
 		data = this.createJSONNode( meta );
 
-		data.uv = this.uv.toJSON( meta ).uuid;
-		data.textureSize = this.textureSize.toJSON( meta ).uuid;
-		data.blinnExponentToRoughness = this.blinnExponentToRoughness.toJSON( meta ).uuid;
-
-		if ( this.roughness ) data.roughness = this.roughness.toJSON( meta ).uuid;
+		data.value = this.value.toJSON( meta ).uuid;
 
 	}
 

+ 3 - 4
examples/js/nodes/misc/TextureCubeUVNode.js

@@ -8,15 +8,14 @@ import { StructNode } from '../core/StructNode.js';
 import { FunctionNode } from '../core/FunctionNode.js';
 import { ReflectNode } from '../accessors/ReflectNode.js';
 import { FloatNode } from '../inputs/FloatNode.js';
-import { BlinnExponentToRoughnessNode } from '../bsdfs/BlinnExponentToRoughnessNode.js';
 
 function TextureCubeUVNode( uv, textureSize, blinnExponentToRoughness ) {
 
 	TempNode.call( this, 'TextureCubeUVData' ); // TextureCubeUVData is type as StructNode
 
-	this.uv = uv || new ReflectNode( ReflectNode.VECTOR );
-	this.textureSize = textureSize || new FloatNode( 1024 );
-	this.blinnExponentToRoughness = blinnExponentToRoughness || new BlinnExponentToRoughnessNode();
+	this.uv = uv;
+	this.textureSize = textureSize;
+	this.blinnExponentToRoughness = blinnExponentToRoughness;
 
 }
 

+ 48 - 38
examples/js/nodes/utils/ColorSpaceNode.js

@@ -4,7 +4,9 @@
 
 import { TempNode } from '../core/TempNode.js';
 import { ConstNode } from '../core/ConstNode.js';
+import { FloatNode } from '../inputs/FloatNode.js';
 import { FunctionNode } from '../core/FunctionNode.js';
+import { ExpressionNode } from '../core/ExpressionNode.js';
 
 function ColorSpaceNode( input, method ) {
 
@@ -12,7 +14,7 @@ function ColorSpaceNode( input, method ) {
 
 	this.input = input;
 
-	this.method = method || ColorSpaceNode.LINEAR;
+	this.method = method || ColorSpaceNode.LINEAR_TO_LINEAR;
 
 }
 
@@ -201,70 +203,78 @@ ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD';
 ColorSpaceNode.LINEAR_TO_LOG_LUV = 'LinearToLogLuv';
 ColorSpaceNode.LOG_LUV_TO_LINEAR = 'LogLuvToLinear';
 
+ColorSpaceNode.getEncodingComponents = function ( encoding ) {
+
+	switch ( encoding ) {
+
+		case THREE.LinearEncoding:
+			return [ 'Linear' ];
+		case THREE.sRGBEncoding:
+			return [ 'sRGB' ];
+		case THREE.RGBEEncoding:
+			return [ 'RGBE' ];
+		case THREE.RGBM7Encoding:
+			return [ 'RGBM', new FloatNode( 7.0 ).setReadonly( true ) ];
+		case THREE.RGBM16Encoding:
+			return [ 'RGBM', new FloatNode( 16.0 ).setReadonly( true ) ];
+		case THREE.RGBDEncoding:
+			return [ 'RGBD', new FloatNode( 256.0 ).setReadonly( true ) ];
+		case THREE.GammaEncoding:
+			return [ 'Gamma', new ExpressionNode( 'float( GAMMA_FACTOR )', 'f' ) ];
+
+	}
+
+};
+
 ColorSpaceNode.prototype = Object.create( TempNode.prototype );
 ColorSpaceNode.prototype.constructor = ColorSpaceNode;
-ColorSpaceNode.prototype.nodeType = "ColorAdjustment";
+ColorSpaceNode.prototype.nodeType = "ColorSpace";
 
 ColorSpaceNode.prototype.generate = function ( builder, output ) {
 
-	var input = builder.context.input || this.input.build( builder, 'v4' ),
-		encodingMethod = builder.context.encoding !== undefined ? this.getEncodingMethod( builder.context.encoding ) : [ this.method ],
-		factor = this.factor ? this.factor.build( builder, 'f' ) : encodingMethod[ 1 ];
+	var input = this.input.build( builder, 'v4' );
+	var outputType = this.getType( builder );
 
-	var method = builder.include( ColorSpaceNode.Nodes[ encodingMethod[ 0 ] ] );
+	var methodNode = ColorSpaceNode.Nodes[ this.method ];
+	var method = builder.include( methodNode );
 
-	if ( factor ) {
+	if ( method === ColorSpaceNode.LINEAR_TO_LINEAR ) {
 
-		return builder.format( method + '( ' + input + ', ' + factor + ' )', this.getType( builder ), output );
+		return builder.format( input, outputType, output );
 
 	} else {
 
-		return builder.format( method + '( ' + input + ' )', this.getType( builder ), output );
+		if ( methodNode.inputs.length === 2 ) {
 
-	}
+			var factor = this.factor.build( builder, 'f' );
 
-};
+			return builder.format( method + '( ' + input + ', ' + factor + ' )', outputType, output );
 
-ColorSpaceNode.prototype.getDecodingMethod = function ( encoding ) {
+		} else {
 
-	var components = this.getEncodingComponents( encoding );
+			return builder.format( method + '( ' + input + ' )', outputType, output );
 
-	components[ 0 ] += 'ToLinear';
+		}
 
-	return components;
+	}
 
 };
 
-ColorSpaceNode.prototype.getEncodingMethod = function ( encoding ) {
+ColorSpaceNode.prototype.fromEncoding = function ( encoding ) {
 
-	var components = this.getEncodingComponents( encoding );
+	var components = ColorSpaceNode.getEncodingComponents( encoding );
 
-	components[ 0 ] = 'LinearTo' + components[ 0 ];
-
-	return components;
+	this.method = 'LinearTo' + components[ 0 ];
+	this.factor = components[ 1 ];
 
 };
 
-ColorSpaceNode.prototype.getEncodingComponents = function ( encoding ) {
+ColorSpaceNode.prototype.fromDecoding = function ( encoding ) {
 
-	switch ( encoding ) {
+	var components = ColorSpaceNode.getEncodingComponents( encoding );
 
-		case THREE.LinearEncoding:
-			return [ 'Linear' ];
-		case THREE.sRGBEncoding:
-			return [ 'sRGB' ];
-		case THREE.RGBEEncoding:
-			return [ 'RGBE' ];
-		case THREE.RGBM7Encoding:
-			return [ 'RGBM', '7.0' ];
-		case THREE.RGBM16Encoding:
-			return [ 'RGBM', '16.0' ];
-		case THREE.RGBDEncoding:
-			return [ 'RGBD', '256.0' ];
-		case THREE.GammaEncoding:
-			return [ 'Gamma', 'float( GAMMA_FACTOR )' ];
-
-	}
+	this.method = components[ 0 ] + 'ToLinear';
+	this.factor = components[ 1 ];
 
 };
 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
examples/nodes/caustic.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
examples/nodes/displace.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
examples/nodes/wave.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
examples/nodes/xray.json


+ 302 - 0
examples/webgl_materials_envmaps_hdr_nodes.html

@@ -0,0 +1,302 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<title>threejs webgl - node material - hdr environment mapping</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+		<style>
+			body {
+				color: #fff;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+
+				background-color: #000;
+
+				margin: 0px;
+				overflow: hidden;
+			}
+			a { color: #00f }
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+			}
+		</style>
+	</head>
+	<body>
+
+		<div id="container"></div>
+		<div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">threejs</a> - High dynamic range (RGBE) Image-based Lighting (IBL)<br />using run-time generated pre-filtered roughness mipmaps (PMREM)<br/>
+			Created by Prashant Sharma and <a href="http://clara.io/" target="_blank" rel="noopener">Ben Houston</a>.</div>
+
+		<script src="../build/three.js"></script>
+		<script src="js/controls/OrbitControls.js"></script>
+
+		<script src="js/loaders/RGBELoader.js"></script>
+		<script src="js/loaders/HDRCubeTextureLoader.js"></script>
+
+		<script src="js/WebGL.js"></script>
+		<script src="js/libs/stats.min.js"></script>
+
+		<script src="js/pmrem/PMREMGenerator.js"></script>
+		<script src="js/pmrem/PMREMCubeUVPacker.js"></script>
+		<script src="js/libs/dat.gui.min.js"></script>
+
+		<script type="module">
+			/*
+			 * COPIED FROM webgl_materials_envmaps_hdr.html
+			 *
+			 *
+			 *
+			 */
+			import './js/nodes/THREE.Nodes.js';
+
+			if ( WEBGL.isWebGLAvailable() === false ) {
+
+				document.body.appendChild( WEBGL.getWebGLErrorMessage() );
+
+			}
+
+			var params = {
+				envMap: 'HDR',
+				roughness: 0.0,
+				metalness: 0.0,
+				exposure: 1.0,
+				nodes: true,
+				animate: true,
+				debug: false,
+			};
+
+			var container, stats;
+			var camera, scene, renderer, controls;
+			var torusMesh, torusMeshNode, planeMesh;
+			var ldrCubeRenderTarget, hdrCubeRenderTarget, rgbmCubeRenderTarget;
+			var ldrCubeMap, hdrCubeMap, rgbmCubeMap;
+
+			init();
+			animate();
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 1000 );
+				camera.position.set( 0, 0, 120 );
+
+				scene = new THREE.Scene();
+				scene.background = new THREE.Color( 0x000000 );
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.toneMapping = THREE.LinearToneMapping;
+
+				//
+
+				var geometry = new THREE.TorusKnotBufferGeometry( 18, 8, 150, 20 );
+				var material;
+
+				material = new THREE.MeshStandardMaterial();
+				material.color = new THREE.Color( 0xffffff );
+				material.roughness = params.metalness;
+				material.metalness = params.roguhness;
+
+				torusMesh = new THREE.Mesh( geometry, material );
+				scene.add( torusMesh );
+
+				material = new THREE.MeshStandardNodeMaterial();
+				material.color = new THREE.Color( 0xffffff );
+				material.roughness = params.metalness;
+				material.metalness = params.roguhness;
+
+				torusMeshNode = new THREE.Mesh( geometry, material );
+				scene.add( torusMeshNode );
+
+				planeMesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 200, 200 ), new THREE.MeshBasicMaterial() );
+				planeMesh.position.y = - 50;
+				planeMesh.rotation.x = - Math.PI * 0.5;
+				scene.add( planeMesh );
+
+				var hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ];
+				hdrCubeMap = new THREE.HDRCubeTextureLoader()
+					.setPath( './textures/cube/pisaHDR/' )
+					.load( THREE.UnsignedByteType, hdrUrls, function () {
+
+						var pmremGenerator = new THREE.PMREMGenerator( hdrCubeMap );
+						pmremGenerator.update( renderer );
+
+						var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
+						pmremCubeUVPacker.update( renderer );
+
+						hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
+
+						hdrCubeMap.magFilter = THREE.LinearFilter;
+						hdrCubeMap.needsUpdate = true;
+
+						pmremGenerator.dispose();
+						pmremCubeUVPacker.dispose();
+
+					} );
+
+				var ldrUrls = [ 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' ];
+				ldrCubeMap = new THREE.CubeTextureLoader()
+					.setPath( './textures/cube/pisa/' )
+					.load( ldrUrls, function () {
+
+						ldrCubeMap.encoding = THREE.GammaEncoding;
+
+						var pmremGenerator = new THREE.PMREMGenerator( ldrCubeMap );
+						pmremGenerator.update( renderer );
+
+						var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
+						pmremCubeUVPacker.update( renderer );
+
+						ldrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
+
+						pmremGenerator.dispose();
+						pmremCubeUVPacker.dispose();
+
+					} );
+
+
+				var rgbmUrls = [ 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' ];
+				rgbmCubeMap = new THREE.CubeTextureLoader()
+					.setPath( './textures/cube/pisaRGBM16/' )
+					.load( rgbmUrls, function () {
+
+						rgbmCubeMap.encoding = THREE.RGBM16Encoding;
+						rgbmCubeMap.format = THREE.RGBAFormat;
+
+						var pmremGenerator = new THREE.PMREMGenerator( rgbmCubeMap );
+						pmremGenerator.update( renderer );
+
+						var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
+						pmremCubeUVPacker.update( renderer );
+
+						rgbmCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
+
+						rgbmCubeMap.magFilter = THREE.LinearFilter;
+						rgbmCubeMap.needsUpdate = true;
+
+						pmremGenerator.dispose();
+						pmremCubeUVPacker.dispose();
+
+					} );
+
+				renderer.setPixelRatio( window.devicePixelRatio );
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				container.appendChild( renderer.domElement );
+
+				//renderer.toneMapping = THREE.ReinhardToneMapping;
+				renderer.gammaInput = true; // ???
+				renderer.gammaOutput = true;
+
+				stats = new Stats();
+				container.appendChild( stats.dom );
+
+				controls = new THREE.OrbitControls( camera, renderer.domElement );
+				controls.minDistance = 50;
+				controls.maxDistance = 300;
+
+				window.addEventListener( 'resize', onWindowResize, false );
+
+				var gui = new dat.GUI();
+
+				gui.add( params, 'envMap', [ 'LDR', 'HDR', 'RGBM16' ] );
+				gui.add( params, 'roughness', 0, 1, 0.01 );
+				gui.add( params, 'metalness', 0, 1, 0.01 );
+				gui.add( params, 'exposure', 0, 2, 0.01 );
+				gui.add( params, 'nodes', true );
+				gui.add( params, 'animate', true );
+				gui.add( params, 'debug', false );
+				gui.open();
+
+			}
+
+			function onWindowResize() {
+
+				var width = window.innerWidth;
+				var height = window.innerHeight;
+
+				camera.aspect = width / height;
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( width, height );
+
+			}
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				stats.begin();
+				render();
+				stats.end();
+
+			}
+
+			function render() {
+
+				torusMesh.material.roughness = params.roughness;
+				torusMesh.material.metalness = params.metalness;
+
+				torusMeshNode.material.roughness = params.roughness;
+				torusMeshNode.material.metalness = params.metalness;
+
+				torusMesh.visible = !params.nodes;
+				torusMeshNode.visible = params.nodes;
+
+				var renderTarget, cubeMap;
+
+				switch ( params.envMap ) {
+
+					case 'LDR':
+						renderTarget = ldrCubeRenderTarget;
+						cubeMap = ldrCubeMap;
+						break;
+					case 'HDR':
+						renderTarget = hdrCubeRenderTarget;
+						cubeMap = hdrCubeMap;
+						break;
+					case 'RGBM16':
+						renderTarget = rgbmCubeRenderTarget;
+						cubeMap = rgbmCubeMap;
+						break;
+				}
+
+				var newEnvMap = renderTarget ? renderTarget.texture : null;
+
+				if ( newEnvMap && newEnvMap !== torusMesh.material.envMap ) {
+
+					torusMesh.material.envMap = newEnvMap;
+					torusMesh.material.needsUpdate = true;
+
+					torusMeshNode.material.envMap = newEnvMap;
+					torusMeshNode.material.needsUpdate = true;
+
+					planeMesh.material.map = newEnvMap;
+					planeMesh.material.needsUpdate = true;
+
+				}
+
+				if ( params.animate ) {
+
+					torusMesh.rotation.y += 0.005;
+					torusMeshNode.rotation.y = torusMesh.rotation.y;
+
+				}
+
+				planeMesh.visible = params.debug;
+
+				scene.background = cubeMap;
+				renderer.toneMappingExposure = params.exposure;
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 120 - 93
examples/webgl_materials_nodes.html

@@ -177,6 +177,7 @@
 					'adv / translucent': 'translucent',
 					'node / position': 'node-position',
 					'node / normal': 'node-normal',
+					'node / reflect': 'node-reflect',
 					'misc / smoke': 'smoke',
 					'misc / firefly': 'firefly',
 					'misc / reserved-keywords': 'reserved-keywords',
@@ -209,7 +210,7 @@
 
 					} );
 
-				} else if ( typeof value == 'object' ) {
+				} else if ( typeof value === 'object' ) {
 
 					param[ name ] = value[ Object.keys( value )[ 0 ] ];
 
@@ -292,7 +293,7 @@
 						mtl.environment = new THREE.CubeTextureNode( cubemap );
 						mtl.environmentAlpha = mask;
 						mtl.normal = new THREE.NormalMapNode( new THREE.TextureNode( getTexture( "grassNormal" ) ) );
-						mtl.normal.scale = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
+						mtl.normal.scale = new THREE.MathNode( mask, THREE.MathNode.INVERT );
 
 						break;
 
@@ -325,22 +326,22 @@
 						var roughnessB = new THREE.FloatNode( 0 );
 						var metalnessB = new THREE.FloatNode( 1 );
 
-						var roughness = new THREE.Math3Node(
+						var roughness = new THREE.MathNode(
 							roughnessA,
 							roughnessB,
 							mask,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
-						var metalness = new THREE.Math3Node(
+						var metalness = new THREE.MathNode(
 							metalnessA,
 							metalnessB,
 							mask,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var normalMask = new THREE.OperatorNode(
-							new THREE.Math1Node( mask, THREE.Math1Node.INVERT ),
+							new THREE.MathNode( mask, THREE.MathNode.INVERT ),
 							normalScale,
 							THREE.OperatorNode.MUL
 						);
@@ -538,22 +539,22 @@
 						var clearCoat = new THREE.FloatNode( 1 );
 						var clearCoatRoughness = new THREE.FloatNode( 1 );
 
-						var roughness = new THREE.Math3Node(
+						var roughness = new THREE.MathNode(
 							roughnessA,
 							roughnessB,
 							mask,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
-						var metalness = new THREE.Math3Node(
+						var metalness = new THREE.MathNode(
 							metalnessA,
 							metalnessB,
 							mask,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var normalMask = new THREE.OperatorNode(
-							new THREE.Math1Node( mask, THREE.Math1Node.INVERT ),
+							new THREE.MathNode( mask, THREE.MathNode.INVERT ),
 							normalScale,
 							THREE.OperatorNode.MUL
 						);
@@ -661,7 +662,7 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var wave = new THREE.Math1Node( posContinuous, THREE.Math1Node.SIN );
+						var wave = new THREE.MathNode( posContinuous, THREE.MathNode.SIN );
 						wave = new THREE.SwitchNode( wave, 'x' );
 
 						var waveScale = new THREE.OperatorNode(
@@ -688,11 +689,11 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var color = new THREE.Math3Node(
+						var color = new THREE.MathNode(
 							colorB,
 							colorA,
 							wave,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl.color = color;
@@ -752,10 +753,10 @@
 						var power = new THREE.FloatNode( 3 );
 						var color = new THREE.ColorNode( 0xFFFFFF );
 
-						var viewZ = new THREE.Math2Node(
+						var viewZ = new THREE.MathNode(
 							new THREE.NormalNode(),
 							new THREE.Vector3Node( 0, 0, - intensity ),
-							THREE.Math2Node.DOT
+							THREE.MathNode.DOT
 						);
 
 						var rim = new THREE.OperatorNode(
@@ -764,10 +765,10 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var rimPower = new THREE.Math2Node(
+						var rimPower = new THREE.MathNode(
 							rim,
 							power,
-							THREE.Math2Node.POW
+							THREE.MathNode.POW
 						);
 
 						var rimColor = new THREE.OperatorNode(
@@ -812,7 +813,7 @@
 								mtl.blending = THREE.AdditiveBlending;
 								mtl.depthWrite = false;
 
-							}				else {
+							} else {
 
 								mtl.emissive = rimColor;
 								mtl.alpha = null;
@@ -1033,10 +1034,10 @@
 						var power = new THREE.FloatNode( 1 );
 						var color = new THREE.CubeTextureNode( cubemap );
 
-						var viewZ = new THREE.Math2Node(
+						var viewZ = new THREE.MathNode(
 							new THREE.NormalNode(),
 							new THREE.Vector3Node( 0, 0, - 1 ),
-							THREE.Math2Node.DOT
+							THREE.MathNode.DOT
 						);
 
 						var theta = new THREE.OperatorNode(
@@ -1045,10 +1046,10 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var thetaPower = new THREE.Math2Node(
+						var thetaPower = new THREE.MathNode(
 							theta,
 							power,
-							THREE.Math2Node.POW
+							THREE.MathNode.POW
 						);
 
 						var fresnel = new THREE.OperatorNode(
@@ -1059,7 +1060,7 @@
 
 						mtl.color = new THREE.ColorNode( 0x3399FF );
 						mtl.environment = color;
-						mtl.environmentAlpha = new THREE.Math1Node( fresnel, THREE.Math1Node.SATURATE );
+						mtl.environmentAlpha = new THREE.MathNode( fresnel, THREE.MathNode.SATURATE );
 
 						// GUI
 
@@ -1105,11 +1106,11 @@
 						var mask = new THREE.TextureNode( getTexture( "decalDiffuse" ), uvScale );
 						var maskAlphaChannel = new THREE.SwitchNode( mask, 'w' );
 
-						var blend = new THREE.Math3Node(
+						var blend = new THREE.MathNode(
 							tex1,
 							tex2,
 							maskAlphaChannel,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl.color = blend;
@@ -1195,9 +1196,9 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var clamp0at1 = new THREE.Math1Node( offsetClamp, THREE.Math1Node.SATURATE );
+						var clamp0at1 = new THREE.MathNode( offsetClamp, THREE.MathNode.SATURATE );
 
-						var blend = new THREE.Math3Node( top, bottom, clamp0at1, THREE.Math3Node.MIX );
+						var blend = new THREE.MathNode( top, bottom, clamp0at1, THREE.MathNode.MIX );
 
 						mtl.color = blend;
 
@@ -1268,11 +1269,11 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var color = new THREE.Math3Node(
+						var color = new THREE.MathNode(
 							colorB,
 							colorA,
 							texArea,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl.color = mtl.specular = new THREE.ColorNode( 0 );
@@ -1322,11 +1323,11 @@
 						var tex = new THREE.TextureNode( getTexture( "cloud" ) );
 						var texArea = new THREE.SwitchNode( tex, 'w' );
 
-						var thresholdBorder = new THREE.Math3Node(
+						var thresholdBorder = new THREE.MathNode(
 							new THREE.OperatorNode( threshold, borderSize, THREE.OperatorNode.ADD ),
 							threshold,
 							texArea,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
 						var thresholdEmissive = new THREE.OperatorNode(
@@ -1394,7 +1395,7 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var cycle = new THREE.Math1Node( sinCycleInSecs, THREE.Math1Node.SIN );
+						var cycle = new THREE.MathNode( sinCycleInSecs, THREE.MathNode.SIN );
 
 						// round sin to 0 at 1
 						cycle = new THREE.OperatorNode( cycle, new THREE.FloatNode( 1 ), THREE.OperatorNode.ADD );
@@ -1406,11 +1407,11 @@
 						var tex = new THREE.TextureNode( getTexture( "cloud" ) );
 						var texArea = new THREE.SwitchNode( tex, 'w' );
 
-						var thresholdBorder = new THREE.Math3Node(
+						var thresholdBorder = new THREE.MathNode(
 							new THREE.OperatorNode( threshold, fireSize, THREE.OperatorNode.ADD ),
 							threshold,
 							texArea,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
 						var fireStartAnimatedColor = new THREE.ColorAdjustmentNode(
@@ -1425,18 +1426,18 @@
 							THREE.ColorAdjustmentNode.SATURATION
 						);
 
-						var fireColor = new THREE.Math3Node(
+						var fireColor = new THREE.MathNode(
 							fireEndAnimatedColor,
 							fireStartAnimatedColor,
 							thresholdBorder,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
-						var thresholdBurnedBorder = new THREE.Math3Node(
+						var thresholdBurnedBorder = new THREE.MathNode(
 							new THREE.OperatorNode( threshold, burnedSize, THREE.OperatorNode.ADD ),
 							threshold,
 							texArea,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
 						var fireEmissive = new THREE.OperatorNode(
@@ -1445,11 +1446,11 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var burnedResultColor = new THREE.Math3Node(
+						var burnedResultColor = new THREE.MathNode(
 							color,
 							burnedColor,
 							thresholdBurnedBorder,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						// APPLY
@@ -1582,11 +1583,11 @@
 						depth.near.value = 1;
 						depth.far.value = 200;
 
-						var colors = new THREE.Math3Node(
+						var colors = new THREE.MathNode(
 							colorB,
 							colorA,
 							depth,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl = new THREE.PhongNodeMaterial();
@@ -1693,7 +1694,7 @@
 						var mask = new THREE.SwitchNode( worldNormal, 'y' );
 
 						// clamp0at1
-						mask = new THREE.Math1Node( mask, THREE.Math1Node.SATURATE );
+						mask = new THREE.MathNode( mask, THREE.MathNode.SATURATE );
 
 						var timeOffset = new THREE.OperatorNode(
 							time,
@@ -1723,18 +1724,18 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var voronoiColors = new THREE.Math3Node(
+						var voronoiColors = new THREE.MathNode(
 							colorB,
 							colorA,
-							new THREE.Math1Node( voronoiIntensity, THREE.Math1Node.SATURATE ), // mix needs clamp
-							THREE.Math3Node.MIX
+							new THREE.MathNode( voronoiIntensity, THREE.MathNode.SATURATE ), // mix needs clamp
+							THREE.MathNode.MIX
 						);
 
-						var caustic = new THREE.Math3Node(
+						var caustic = new THREE.MathNode(
 							color,
 							voronoiColors,
 							maskCaustic,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var causticLights = new THREE.OperatorNode(
@@ -1805,7 +1806,7 @@
 						var colorB = new THREE.ColorNode( 0x3366FF );
 
 						var pos = new THREE.PositionNode();
-						var posNorm = new THREE.Math1Node( pos, THREE.Math1Node.NORMALIZE );
+						var posNorm = new THREE.MathNode( pos, THREE.MathNode.NORMALIZE );
 
 						var mask = new THREE.SwitchNode( posNorm, 'y' );
 
@@ -1833,11 +1834,11 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var colors = new THREE.Math3Node(
+						var colors = new THREE.MathNode(
 							colorB,
 							colorA,
 							mask,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl.color = colors;
@@ -1887,13 +1888,13 @@
 						var mildness = new THREE.FloatNode( 1.6 );
 						var fur = new THREE.FloatNode( .5 );
 
-						var posDirection = new THREE.Math1Node( new THREE.PositionNode( THREE.PositionNode.VIEW ), THREE.Math1Node.NORMALIZE );
-						var norDirection = new THREE.Math1Node( new THREE.NormalNode(), THREE.Math1Node.NORMALIZE );
+						var posDirection = new THREE.MathNode( new THREE.PositionNode( THREE.PositionNode.VIEW ), THREE.MathNode.NORMALIZE );
+						var norDirection = new THREE.MathNode( new THREE.NormalNode(), THREE.MathNode.NORMALIZE );
 
-						var viewZ = new THREE.Math2Node(
+						var viewZ = new THREE.MathNode(
 							posDirection,
 							norDirection,
-							THREE.Math2Node.DOT
+							THREE.MathNode.DOT
 						);
 
 						// without luma correction for now
@@ -1913,7 +1914,7 @@
 						mtl.normal = new THREE.NormalMapNode( new THREE.TextureNode( getTexture( "grassNormal" ) ) );
 						mtl.normal.scale = furScale;
 						mtl.environment = mildnessColor;
-						mtl.environmentAlpha = new THREE.Math1Node( viewZ, THREE.Math1Node.INVERT );
+						mtl.environmentAlpha = new THREE.MathNode( viewZ, THREE.MathNode.INVERT );
 						mtl.shininess = new THREE.FloatNode( 0 );
 
 						// GUI
@@ -1954,11 +1955,11 @@
 
 						var lightLuminance = new THREE.LuminanceNode( directLight );
 
-						var lightWrap = new THREE.Math3Node(
+						var lightWrap = new THREE.MathNode(
 							wrapShadow,
 							wrapLight,
 							lightLuminance,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
 						var lightTransition = new THREE.OperatorNode(
@@ -1967,7 +1968,7 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var wrappedLight = new THREE.Math1Node( lightTransition, THREE.Math1Node.SIN );
+						var wrappedLight = new THREE.MathNode( lightTransition, THREE.MathNode.SIN );
 
 						var wrappedLightColor = new THREE.OperatorNode(
 							wrappedLight,
@@ -1975,7 +1976,7 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var bloodArea = new THREE.Math1Node( wrappedLightColor, THREE.Math1Node.SATURATE );
+						var bloodArea = new THREE.MathNode( wrappedLightColor, THREE.MathNode.SATURATE );
 
 						var totalLight = new THREE.OperatorNode(
 							directLight,
@@ -2058,9 +2059,9 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var celLight = new THREE.Math1Node(
+						var celLight = new THREE.MathNode(
 							preCelLight,
-							THREE.Math1Node.CEIL
+							THREE.MathNode.CEIL
 						);
 
 						var posCelLight = new THREE.OperatorNode(
@@ -2071,18 +2072,18 @@
 
 						// LINE
 
-						var posDirection = new THREE.Math1Node( new THREE.PositionNode( THREE.PositionNode.VIEW ), THREE.Math1Node.NORMALIZE );
-						var norDirection = new THREE.Math1Node( new THREE.NormalNode(), THREE.Math1Node.NORMALIZE );
+						var posDirection = new THREE.MathNode( new THREE.PositionNode( THREE.PositionNode.VIEW ), THREE.MathNode.NORMALIZE );
+						var norDirection = new THREE.MathNode( new THREE.NormalNode(), THREE.MathNode.NORMALIZE );
 
-						var viewZ = new THREE.Math2Node(
+						var viewZ = new THREE.MathNode(
 							posDirection,
 							norDirection,
-							THREE.Math2Node.DOT
+							THREE.MathNode.DOT
 						);
 
-						var lineOutside = new THREE.Math1Node(
+						var lineOutside = new THREE.MathNode(
 							viewZ,
-							THREE.Math1Node.ABS
+							THREE.MathNode.ABS
 						);
 
 						var line = new THREE.OperatorNode(
@@ -2091,14 +2092,14 @@
 							THREE.OperatorNode.DIV
 						);
 
-						var lineScaled = new THREE.Math3Node(
+						var lineScaled = new THREE.MathNode(
 							line,
 							lineSize,
 							lineInner,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
-						var innerContour = new THREE.Math1Node( new THREE.Math1Node( lineScaled, THREE.Math1Node.SATURATE ), THREE.Math1Node.INVERT );
+						var innerContour = new THREE.MathNode( new THREE.MathNode( lineScaled, THREE.MathNode.SATURATE ), THREE.MathNode.INVERT );
 
 						// APPLY
 
@@ -2291,6 +2292,32 @@
 
 						break;
 
+					case 'node-reflect':
+
+						// MATERIAL
+
+						var node = new THREE.ReflectNode();
+
+						mtl = new THREE.PhongNodeMaterial();
+						mtl.environment = new THREE.CubeTextureNode( cubemap, node );
+
+						// GUI
+
+						addGui( 'scope', {
+							vector: THREE.ReflectNode.VECTOR,
+							cube: THREE.ReflectNode.CUBE,
+							sphere: THREE.ReflectNode.SPHERE
+						}, function ( val ) {
+
+							node.scope = val;
+
+							mtl.needsUpdate = true;
+
+						} );
+
+						break;
+
+
 					case 'varying':
 
 						// MATERIAL
@@ -2474,11 +2501,11 @@
 
 						var timer = new THREE.TimerNode( .01, THREE.TimerNode.LOCAL );
 
-						var color = new THREE.Math3Node(
+						var color = new THREE.MathNode(
 							rttStore,
 							blur,
 							new THREE.FloatNode( .6 ),
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						blur.horizontal = blur.vertical = timer;
@@ -2594,11 +2621,11 @@
 							uv: new THREE.UVNode()
 						} );
 
-						var color = new THREE.Math3Node(
+						var color = new THREE.MathNode(
 							new THREE.TextureNode( getTexture( "brick" ) ),
 							blurredTexture,
 							alpha,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						mtl.color = color;
@@ -2698,7 +2725,7 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var cycle = new THREE.Math1Node( sinCycleInSecs, THREE.Math1Node.SIN );
+						var cycle = new THREE.MathNode( sinCycleInSecs, THREE.MathNode.SIN );
 
 						var cycleColor = new THREE.OperatorNode(
 							cycle,
@@ -2706,7 +2733,7 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var cos = new THREE.Math1Node( cycleColor, THREE.Math1Node.SIN );
+						var cos = new THREE.MathNode( cycleColor, THREE.MathNode.SIN );
 
 						mtl.color = new THREE.ColorNode( 0 );
 						mtl.emissive = cos;
@@ -2731,10 +2758,10 @@
 						var viewPos = new THREE.PositionNode( THREE.PositionNode.VIEW );
 						var cameraPosition = new THREE.CameraNode( THREE.CameraNode.POSITION );
 
-						var cameraDistance = new THREE.Math2Node(
+						var cameraDistance = new THREE.MathNode(
 							modelPos,
 							cameraPosition,
-							THREE.Math2Node.DISTANCE
+							THREE.MathNode.DISTANCE
 						);
 
 						var viewPosZ = new THREE.SwitchNode( viewPos, 'z' );
@@ -2751,11 +2778,11 @@
 							THREE.OperatorNode.ADD
 						);
 
-						var objectDepth = new THREE.Math3Node(
+						var objectDepth = new THREE.MathNode(
 							distanceRadius,
 							new THREE.FloatNode( 0 ),
 							new THREE.FloatNode( 50 ),
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
 						// RTT ( get back distance )
@@ -2782,33 +2809,33 @@
 							THREE.OperatorNode.SUB
 						);
 
-						var sss = new THREE.Math3Node(
+						var sss = new THREE.MathNode(
 							new THREE.FloatNode( - .1 ),
 							new THREE.FloatNode( .5 ),
 							difference,
-							THREE.Math3Node.SMOOTHSTEP
+							THREE.MathNode.SMOOTHSTEP
 						);
 
-						var sssAlpha = new THREE.Math1Node( sss, THREE.Math1Node.SATURATE );
+						var sssAlpha = new THREE.MathNode( sss, THREE.MathNode.SATURATE );
 
 						var frontColor, backColor;
 
 						if ( name == 'sss' ) {
 
-							var sssOut = new THREE.Math2Node(
+							var sssOut = new THREE.MathNode(
 								objectDepth,
 								sssAlpha,
-								THREE.Math2Node.MIN
+								THREE.MathNode.MIN
 							);
 
 							frontColor = new THREE.ColorNode( 0xd4cfbb );
 							backColor = new THREE.ColorNode( 0xd04327 );
 
-							var color = new THREE.Math3Node(
+							var color = new THREE.MathNode(
 								backColor,
 								frontColor,
 								sssOut,
-								THREE.Math3Node.MIX
+								THREE.MathNode.MIX
 							);
 
 							var light = new THREE.OperatorNode(
@@ -2829,11 +2856,11 @@
 							frontColor = new THREE.ColorNode( 0xd04327 );
 							backColor = new THREE.ColorNode( 0x1a0e14 );
 
-							var color = new THREE.Math3Node(
+							var color = new THREE.MathNode(
 								frontColor,
 								backColor,
 								sssAlpha,
-								THREE.Math3Node.MIX
+								THREE.MathNode.MIX
 							);
 
 							var light = new THREE.OperatorNode(
@@ -2973,7 +3000,7 @@
 
 				// update material animation and/or gpu calcs (pre-renderer)
 
-				frame.update( delta ).setRenderer( renderer );
+				frame.setRenderer( renderer ).update( delta );
 
 				if ( mesh.material instanceof THREE.NodeMaterial ) {
 

+ 2 - 2
examples/webgl_mirror_nodes.html

@@ -97,9 +97,9 @@
 
 				var normalMap = new THREE.TextureNode( decalNormal );
 				var normalXY = new THREE.SwitchNode( normalMap, 'xy' );
-				var normalXYFlip = new THREE.Math1Node(
+				var normalXYFlip = new THREE.MathNode(
 					normalXY,
-					THREE.Math1Node.INVERT
+					THREE.MathNode.INVERT
 				);
 
 				var offsetNormal = new THREE.OperatorNode(

+ 15 - 15
examples/webgl_postprocessing_nodes.html

@@ -172,11 +172,11 @@
 						var color = new THREE.ColorNode( 0xFFFFFF );
 						var percent = new THREE.FloatNode( .5 );
 
-						var fade = new THREE.Math3Node(
+						var fade = new THREE.MathNode(
 							new THREE.ScreenNode(),
 							color,
 							percent,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepost.output = fade;
@@ -204,13 +204,13 @@
 						var alpha = new THREE.FloatNode( 1 );
 
 						var screen = new THREE.ScreenNode();
-						var inverted = new THREE.Math1Node( screen, THREE.Math1Node.INVERT );
+						var inverted = new THREE.MathNode( screen, THREE.MathNode.INVERT );
 
-						var fade = new THREE.Math3Node(
+						var fade = new THREE.MathNode(
 							screen,
 							inverted,
 							alpha,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepost.output = fade;
@@ -293,9 +293,9 @@
 						var normalXY = new THREE.SwitchNode( normal, 'xy' );
 						var scale = new THREE.FloatNode( .5 );
 
-						var normalXYFlip = new THREE.Math1Node(
+						var normalXYFlip = new THREE.MathNode(
 							normalXY,
-							THREE.Math1Node.INVERT
+							THREE.MathNode.INVERT
 						);
 
 						var offsetNormal = new THREE.OperatorNode(
@@ -310,11 +310,11 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var scaleNormal = new THREE.Math3Node(
+						var scaleNormal = new THREE.MathNode(
 							new THREE.FloatNode( 1 ),
 							scaleTexture,
 							scale,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var offsetCoord = new THREE.OperatorNode(
@@ -355,11 +355,11 @@
 
 						var previousFrame = new THREE.RTTNode( size.width, size.height, screen );
 
-						var motionBlur = new THREE.Math3Node(
+						var motionBlur = new THREE.MathNode(
 							previousFrame,
 							screen,
 							new THREE.FloatNode( .5 ),
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var currentFrame = new THREE.RTTNode( size.width, size.height, motionBlur );
@@ -383,9 +383,9 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var blocksSize = new THREE.Math1Node(
+						var blocksSize = new THREE.MathNode(
 							blocks,
-							THREE.Math1Node.FLOOR
+							THREE.MathNode.FLOOR
 						);
 
 						var mosaicUV = new THREE.OperatorNode(
@@ -394,11 +394,11 @@
 							THREE.OperatorNode.DIV
 						);
 
-						var fadeScreen = new THREE.Math3Node(
+						var fadeScreen = new THREE.MathNode(
 							uv,
 							mosaicUV,
 							fade,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepost.output = new THREE.ScreenNode( fadeScreen );

+ 13 - 13
examples/webgl_postprocessing_nodes_pass.html

@@ -177,11 +177,11 @@
 						var color = new THREE.ColorNode( 0xFFFFFF );
 						var percent = new THREE.FloatNode( .5 );
 
-						var fade = new THREE.Math3Node(
+						var fade = new THREE.MathNode(
 							new THREE.ScreenNode(),
 							color,
 							percent,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepass.input = fade;
@@ -209,13 +209,13 @@
 						var alpha = new THREE.FloatNode( 1 );
 
 						var screen = new THREE.ScreenNode();
-						var inverted = new THREE.Math1Node( screen, THREE.Math1Node.INVERT );
+						var inverted = new THREE.MathNode( screen, THREE.MathNode.INVERT );
 
-						var fade = new THREE.Math3Node(
+						var fade = new THREE.MathNode(
 							screen,
 							inverted,
 							alpha,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepass.input = fade;
@@ -298,9 +298,9 @@
 						var normalXY = new THREE.SwitchNode( normal, 'xy' );
 						var scale = new THREE.FloatNode( .5 );
 
-						var normalXYFlip = new THREE.Math1Node(
+						var normalXYFlip = new THREE.MathNode(
 							normalXY,
-							THREE.Math1Node.INVERT
+							THREE.MathNode.INVERT
 						);
 
 						var offsetNormal = new THREE.OperatorNode(
@@ -315,11 +315,11 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var scaleNormal = new THREE.Math3Node(
+						var scaleNormal = new THREE.MathNode(
 							new THREE.FloatNode( 1 ),
 							scaleTexture,
 							scale,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						var offsetCoord = new THREE.OperatorNode(
@@ -364,9 +364,9 @@
 							THREE.OperatorNode.MUL
 						);
 
-						var blocksSize = new THREE.Math1Node(
+						var blocksSize = new THREE.MathNode(
 							blocks,
-							THREE.Math1Node.FLOOR
+							THREE.MathNode.FLOOR
 						);
 
 						var mosaicUV = new THREE.OperatorNode(
@@ -375,11 +375,11 @@
 							THREE.OperatorNode.DIV
 						);
 
-						var fadeScreen = new THREE.Math3Node(
+						var fadeScreen = new THREE.MathNode(
 							uv,
 							mosaicUV,
 							fade,
-							THREE.Math3Node.MIX
+							THREE.MathNode.MIX
 						);
 
 						nodepass.input = new THREE.ScreenNode( fadeScreen );

+ 4 - 4
examples/webgl_sprites_nodes.html

@@ -82,9 +82,9 @@
 						THREE.OperatorNode.MUL
 					);
 
-					var uvIntegerTimer = new THREE.Math1Node(
+					var uvIntegerTimer = new THREE.MathNode(
 						uvTimer,
-						THREE.Math1Node.FLOOR
+						THREE.MathNode.FLOOR
 					);
 
 					var uvFrameOffset = new THREE.OperatorNode(
@@ -126,12 +126,12 @@
 				sprite2.scale.y = spriteHeight;
 				sprite2.material.color = new THREE.TextureNode( walkingManTexture );
 				sprite2.material.color.uv = createHorizontalSpriteSheetNode( 8, 30 );
-				sprite2.material.color = new THREE.Math1Node( sprite2.material.color, THREE.Math1Node.INVERT );
+				sprite2.material.color = new THREE.MathNode( sprite2.material.color, THREE.MathNode.INVERT );
 				sprite2.material.spherical = false; // look at camera horizontally only, very used in vegetation
 				// horizontal zigzag sprite
 				sprite2.material.position = new THREE.OperatorNode(
 					new THREE.OperatorNode(
-						new THREE.Math1Node( new THREE.TimerNode( 3 ), THREE.Math1Node.SIN ), // 3 is speed (time scale)
+						new THREE.MathNode( new THREE.TimerNode( 3 ), THREE.MathNode.SIN ), // 3 is speed (time scale)
 						new THREE.Vector2Node( .3, 0 ), // horizontal scale (position)
 						THREE.OperatorNode.MUL
 					),

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác