diff --git a/examples/js/nodes/ConstNode.js b/examples/js/nodes/ConstNode.js index e664f2293c3c0a48c92a0523e3fd0ee5b81ae102..2237b03828b53a4f122fbd9725650b8b3db78dae 100644 --- a/examples/js/nodes/ConstNode.js +++ b/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.PI2 = 'PI2'; THREE.ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI'; @@ -20,6 +17,9 @@ THREE.ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2'; THREE.ConstNode.LOG2 = 'LOG2'; 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 ) { var name, type; diff --git a/examples/js/nodes/NodeMaterial.js b/examples/js/nodes/NodeMaterial.js index 1c4d57d114d373f2953509129ca1cbac2e8149fe..1ffb056fbec74996c54722c666c0447351dc9f1c 100644 --- a/examples/js/nodes/NodeMaterial.js +++ b/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', tc : 'samplerCube', bv1 : 'bool', @@ -26,39 +23,46 @@ THREE.NodeMaterial.Type = { 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 ) { 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'; - var type = THREE.NodeMaterial.Type[ parsType ]; + var type = THREE.NodeMaterial.types[ parsType ]; if ( type == undefined ) throw new Error( "Node pars " + parsType + " not found." ); diff --git a/examples/js/nodes/accessors/CameraNode.js b/examples/js/nodes/accessors/CameraNode.js index e02e3fc24ad1babe49cfc99313b469ae6661f6c3..59905e289387e79967737bdedab876640876923f 100644 --- a/examples/js/nodes/accessors/CameraNode.js +++ b/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.DEPTH = 'depth'; +THREE.CameraNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.CameraNode.prototype.constructor = THREE.CameraNode; + THREE.CameraNode.prototype.setCamera = function( camera ) { this.camera = camera; diff --git a/examples/js/nodes/accessors/ColorsNode.js b/examples/js/nodes/accessors/ColorsNode.js index 1371270c76d13feae7f7c51b3459087471a3135d..af8ffcc68729a72c475339acb6c8d7398f19fd76 100644 --- a/examples/js/nodes/accessors/ColorsNode.js +++ b/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.fragmentDict = [ 'vColor', 'vColor2' ]; +THREE.ColorsNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.ColorsNode.prototype.constructor = THREE.ColorsNode; + THREE.ColorsNode.prototype.generate = function( builder, output ) { var material = builder.material; diff --git a/examples/js/nodes/accessors/NormalNode.js b/examples/js/nodes/accessors/NormalNode.js index ced8842e5d33d320c97667005217f1bc3b44d838..6c263e4357fee945f1341591295a26f13643c7fc 100644 --- a/examples/js/nodes/accessors/NormalNode.js +++ b/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.WORLD = 'world'; THREE.NormalNode.VIEW = 'view'; +THREE.NormalNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.NormalNode.prototype.constructor = THREE.NormalNode; + THREE.NormalNode.prototype.isShared = function( builder ) { switch ( this.scope ) { diff --git a/examples/js/nodes/accessors/PositionNode.js b/examples/js/nodes/accessors/PositionNode.js index 45139bbbd5e0e74f684871b779b9f0ca4149e1d2..57acd4141c8b3e2554cfc985c6b719593e8f45b8 100644 --- a/examples/js/nodes/accessors/PositionNode.js +++ b/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.WORLD = 'world'; THREE.PositionNode.VIEW = 'view'; THREE.PositionNode.PROJECTION = 'projection'; +THREE.PositionNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.PositionNode.prototype.constructor = THREE.PositionNode; + THREE.PositionNode.prototype.getType = function( builder ) { switch ( this.scope ) { diff --git a/examples/js/nodes/accessors/UVNode.js b/examples/js/nodes/accessors/UVNode.js index eedee4e607cd16e16f22fc21d93b2d4deff596a9..5121d76e75de065643bb2888e11d13b9c3fbd7a9 100644 --- a/examples/js/nodes/accessors/UVNode.js +++ b/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.fragmentDict = [ 'vUv', 'vUv2' ]; +THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.UVNode.prototype.constructor = THREE.UVNode; + THREE.UVNode.prototype.generate = function( builder, output ) { var material = builder.material; diff --git a/examples/js/nodes/inputs/ColorNode.js b/examples/js/nodes/inputs/ColorNode.js index 0174002507782698d83caec60b31a56eda1a6e66..80c03701f633194372d6d59354be64a4460486a9 100644 --- a/examples/js/nodes/inputs/ColorNode.js +++ b/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.constructor = THREE.ColorNode; -THREE.NodeMaterial.Shortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] ); +THREE.NodeMaterial.addShortcuts( THREE.ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] ); diff --git a/examples/js/nodes/inputs/Vector2Node.js b/examples/js/nodes/inputs/Vector2Node.js index 2e6458b3ec5f039d0f5beb6b799604a30ef74260..afbc5b2d28242b804d6fbbf6a4c15ca15c2a3ff1 100644 --- a/examples/js/nodes/inputs/Vector2Node.js +++ b/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.constructor = THREE.Vector2Node; -THREE.NodeMaterial.Shortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] ); +THREE.NodeMaterial.addShortcuts( THREE.Vector2Node.prototype, 'value', [ 'x', 'y' ] ); diff --git a/examples/js/nodes/inputs/Vector3Node.js b/examples/js/nodes/inputs/Vector3Node.js index c252b7c49c30f7a28d8e08c125648011028ff066..d60278f13c683fc741e4d08517a19fd069423d50 100644 --- a/examples/js/nodes/inputs/Vector3Node.js +++ b/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.constructor = THREE.Vector3Node; -THREE.NodeMaterial.Shortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] ); +THREE.NodeMaterial.addShortcuts( THREE.Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] ); diff --git a/examples/js/nodes/inputs/Vector4Node.js b/examples/js/nodes/inputs/Vector4Node.js index 7d1da9c4fa5e8915ac8f4370a4fc5358c8981c6a..07f6ff5f46defc2daefe00ad75495ffe4df60095 100644 --- a/examples/js/nodes/inputs/Vector4Node.js +++ b/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.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' ] ); diff --git a/examples/js/nodes/materials/PhongNode.js b/examples/js/nodes/materials/PhongNode.js index cd7f1f935533b8a55c5a8e5e6398d63b6d51aa40..5f6df3c7356d82d286eeec3d9e4400fd03c0934d 100644 --- a/examples/js/nodes/materials/PhongNode.js +++ b/examples/js/nodes/materials/PhongNode.js @@ -27,7 +27,7 @@ THREE.PhongNode.prototype.build = function( builder ) { 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( [ @@ -114,7 +114,7 @@ THREE.PhongNode.prototype.build = function( builder ) { if ( this.normalScale && this.normal ) this.normalScale.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 @@ -133,7 +133,7 @@ THREE.PhongNode.prototype.build = function( builder ) { var normalScale = this.normalScale && this.normal ? this.normalScale.buildCode( builder, 'v2' ) : 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; @@ -236,11 +236,11 @@ THREE.PhongNode.prototype.build = function( builder ) { 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 { diff --git a/examples/js/nodes/materials/PhongNodeMaterial.js b/examples/js/nodes/materials/PhongNodeMaterial.js index da1fa4693cb3d5c1865128187bfbd8e838beeadb..3020239321bb49dfb17f6cb30a707f196779fad1 100644 --- a/examples/js/nodes/materials/PhongNodeMaterial.js +++ b/examples/js/nodes/materials/PhongNodeMaterial.js @@ -13,5 +13,5 @@ THREE.PhongNodeMaterial = function() { THREE.PhongNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 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' ] ); diff --git a/examples/js/nodes/materials/StandardNode.js b/examples/js/nodes/materials/StandardNode.js index a8fdc1735c865450ac73063336a981c1ec1e739b..9d6038f11b18d77f9a5526050c7013c254121e4b 100644 --- a/examples/js/nodes/materials/StandardNode.js +++ b/examples/js/nodes/materials/StandardNode.js @@ -27,7 +27,7 @@ THREE.StandardNode.prototype.build = function( builder ) { 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( [ @@ -120,7 +120,6 @@ THREE.StandardNode.prototype.build = function( 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.environmentIntensity && this.environment ) this.environmentIntensity.verify( builder ); // 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 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; @@ -254,13 +252,6 @@ THREE.StandardNode.prototype.build = function( builder ) { output.push( environment.code ); 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;" ); diff --git a/examples/js/nodes/materials/StandardNodeMaterial.js b/examples/js/nodes/materials/StandardNodeMaterial.js index 8d6019aa9a5a9b0cdc5596ed236f9de7bc3dbcae..20896cd545bfa0a3244ed8adf8a50cfcb74e0b24 100644 --- a/examples/js/nodes/materials/StandardNodeMaterial.js +++ b/examples/js/nodes/materials/StandardNodeMaterial.js @@ -13,5 +13,5 @@ THREE.StandardNodeMaterial = function() { THREE.StandardNodeMaterial.prototype = Object.create( THREE.NodeMaterial.prototype ); 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' ] ); diff --git a/examples/js/nodes/math/Math1Node.js b/examples/js/nodes/math/Math1Node.js index 55ae7f8bb2d93c01a5f69052918ba4275b19daf9..a314255828bedb33959be462a1884cdf61ccfe73 100644 --- a/examples/js/nodes/math/Math1Node.js +++ b/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.DEG = 'degrees'; THREE.Math1Node.EXP = 'exp'; @@ -39,6 +36,9 @@ THREE.Math1Node.LENGTH = 'length'; THREE.Math1Node.NEGATE = 'negate'; THREE.Math1Node.INVERT = 'invert'; +THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype ); +THREE.Math1Node.prototype.constructor = THREE.Math1Node; + THREE.Math1Node.prototype.getType = function( builder ) { switch ( this.method ) { diff --git a/examples/js/nodes/math/Math2Node.js b/examples/js/nodes/math/Math2Node.js index cd675d3d118689d161aba0fab25e462d963fdb12..cf22c1db4550900e3c665177eff80173c552f870 100644 --- a/examples/js/nodes/math/Math2Node.js +++ b/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.MAX = 'max'; THREE.Math2Node.MOD = 'mod'; @@ -26,6 +23,9 @@ THREE.Math2Node.DOT = 'dot'; THREE.Math2Node.CROSS = 'cross'; THREE.Math2Node.POW = 'pow'; +THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype ); +THREE.Math2Node.prototype.constructor = THREE.Math2Node; + THREE.Math2Node.prototype.getInputType = function( builder ) { // use the greater length vector diff --git a/examples/js/nodes/math/Math3Node.js b/examples/js/nodes/math/Math3Node.js index f300748fd004fb1534640fad5889abf5a879cd03..b366524440b20c851549476df8e31f75bb56dde3 100644 --- a/examples/js/nodes/math/Math3Node.js +++ b/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.REFRACT = 'refract'; THREE.Math3Node.SMOOTHSTEP = 'smoothstep'; THREE.Math3Node.FACEFORWARD = 'faceforward'; +THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype ); +THREE.Math3Node.prototype.constructor = THREE.Math3Node; + THREE.Math3Node.prototype.getType = function( builder ) { var a = builder.getFormatLength( this.a.getType( builder ) ); diff --git a/examples/js/nodes/math/OperatorNode.js b/examples/js/nodes/math/OperatorNode.js index 623073c72239fc9f8b7c51c8f0d4c9be88a6153a..436408769807d6ea66b5ffa261e14484f1ffb391 100644 --- a/examples/js/nodes/math/OperatorNode.js +++ b/examples/js/nodes/math/OperatorNode.js @@ -6,21 +6,20 @@ THREE.OperatorNode = function( a, b, op ) { THREE.TempNode.call( this ); - this.op = op || THREE.OperatorNode.ADD; - this.a = a; 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.SUB = '-'; THREE.OperatorNode.MUL = '*'; THREE.OperatorNode.DIV = '/'; +THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.OperatorNode.prototype.constructor = THREE.OperatorNode; + THREE.OperatorNode.prototype.getType = function( builder ) { // use the greater length vector diff --git a/examples/js/nodes/postprocessing/NodePass.js b/examples/js/nodes/postprocessing/NodePass.js index 45cb464b08a7e01657783b5eaf8b9bfb10a6316b..9dc80b04840593cb162b6673a408b5c154df2eaa 100644 --- a/examples/js/nodes/postprocessing/NodePass.js +++ b/examples/js/nodes/postprocessing/NodePass.js @@ -20,6 +20,8 @@ THREE.NodePass = function() { THREE.NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); THREE.NodePass.prototype.constructor = THREE.NodePass; +THREE.NodeMaterial.addShortcuts( THREE.NodePass.prototype, 'fragment', [ 'value' ] ); + THREE.NodePass.prototype.build = function() { this.node.build(); @@ -28,6 +30,3 @@ THREE.NodePass.prototype.build = function() { this.material = this.node; }; - -THREE.NodeMaterial.Shortcuts( THREE.NodePass.prototype, 'fragment', -[ 'value' ] ); diff --git a/examples/js/nodes/utils/JoinNode.js b/examples/js/nodes/utils/JoinNode.js index 4a1b12d0b6098c9d40f0b0b9357a526f6b05d6cd..7601e14be121b93b44d961c733950262de29d5e1 100644 --- a/examples/js/nodes/utils/JoinNode.js +++ b/examples/js/nodes/utils/JoinNode.js @@ -4,7 +4,7 @@ THREE.JoinNode = function( x, y, z, w ) { - THREE.GLNode.call( this, 'fv1' ); + THREE.TempNode.call( this, 'fv1' ); this.x = x; 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.prototype = Object.create( THREE.TempNode.prototype ); +THREE.JoinNode.prototype.constructor = THREE.JoinNode; + THREE.JoinNode.prototype.getNumElements = function() { var inputs = THREE.JoinNode.inputs; diff --git a/examples/js/nodes/utils/NormalMapNode.js b/examples/js/nodes/utils/NormalMapNode.js index 28af8af4b7e1f4335456380a9bcb7007170d74a9..0fabc4d8fea4a134e49ae62dfbc86ab0e428f1fa 100644 --- a/examples/js/nodes/utils/NormalMapNode.js +++ b/examples/js/nodes/utils/NormalMapNode.js @@ -34,7 +34,7 @@ THREE.NormalMapNode.prototype.generate = function( builder, output ) { } 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 ); diff --git a/examples/js/nodes/utils/SwitchNode.js b/examples/js/nodes/utils/SwitchNode.js index 3c883c15d6aef23c354ecdfbc2f29616ad6cefbf..b37f50e6ca88d48cadb5427f207177a4696bfb2f 100644 --- a/examples/js/nodes/utils/SwitchNode.js +++ b/examples/js/nodes/utils/SwitchNode.js @@ -2,13 +2,12 @@ * @author sunag / http://www.sunag.com.br/ */ -THREE.SwitchNode = function( a, component ) { +THREE.SwitchNode = function( node, components ) { 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 ) { - return builder.getFormatByLength( this.component.length ); + return builder.getFormatByLength( this.components.length ); }; 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 a = this.a.build( builder, type ); + var node = this.node.build( builder, type ); var outputLength = 0; - var i, len = this.component.length; + var i, len = this.components.length; // get max length 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 - a += '.'; + node += '.'; 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; @@ -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 ); }; diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index a367145928a56b17d071365afe5726fea0eeb211..56516928316e24962110af3427270e45b3a045d3 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -273,7 +273,7 @@ //mtl.shadow = // shadowmap //mtl.ao = // ambient occlusion //mtl.environment = // reflection map (CubeMap recommended) - //mtl.environmentIntensity = // environment intensity + //mtl.environmentAlpha = // environment alpha //mtl.transform = // vertex transformation var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' ); @@ -282,7 +282,7 @@ mtl.specular = new THREE.FloatNode( .5 ); mtl.shininess = new THREE.FloatNode( 15 ); mtl.environment = new THREE.CubeTextureNode( cubemap ); - mtl.environmentIntensity = mask; + mtl.environmentAlpha = mask; mtl.normal = new THREE.TextureNode( grassNormal ); mtl.normalScale = new THREE.Math1Node( mask, THREE.Math1Node.INVERT ); @@ -305,7 +305,7 @@ //mtl.shadow = // shadowmap //mtl.ao = // ambient occlusion //mtl.environment = // reflection map (CubeMap recommended) - //mtl.environmentIntensity = // environment intensity + //mtl.environmentAlpha = // environment alpha //mtl.transform = // vertex transformation var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' ); @@ -619,7 +619,7 @@ mtl.color = new THREE.ColorNode( 0x3399FF ); mtl.environment = color; - mtl.environmentIntensity = new THREE.Math1Node( fresnel, THREE.Math1Node.SAT ); + mtl.environmentAlpha = new THREE.Math1Node( fresnel, THREE.Math1Node.SAT ); // GUI