diff --git a/examples/js/nodes/InputNode.js b/examples/js/nodes/InputNode.js index 1675464e71467686e4e90f9b44ab92c037ce6212..523646d4ef5d4e924290ebc5ce458b1cf5b4d547 100644 --- a/examples/js/nodes/InputNode.js +++ b/examples/js/nodes/InputNode.js @@ -42,7 +42,7 @@ THREE.InputNode.prototype.generate = function ( builder, output, uuid, type, ns, if ( ! data.vertex ) { - data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate ); + data.vertex = material.createVertexUniform( type, this, ns, needsUpdate ); } @@ -52,7 +52,7 @@ THREE.InputNode.prototype.generate = function ( builder, output, uuid, type, ns, if ( ! data.fragment ) { - data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate ); + data.fragment = material.createFragmentUniform( type, this, ns, needsUpdate ); } diff --git a/examples/js/nodes/NodeMaterial.js b/examples/js/nodes/NodeMaterial.js index 670f7ffbb00ac0cbc64167e6ca84e8cc31efc7f7..64a99ce3a7d52bcbb478e60c29cc194f79ff3f3f 100644 --- a/examples/js/nodes/NodeMaterial.js +++ b/examples/js/nodes/NodeMaterial.js @@ -282,16 +282,16 @@ THREE.NodeMaterial.prototype.mergeUniform = function ( uniforms ) { }; -THREE.NodeMaterial.prototype.createUniform = function ( type, value, ns, needsUpdate ) { +THREE.NodeMaterial.prototype.createUniform = function ( type, node, ns, needsUpdate ) { var index = this.uniformList.length; - var uniform = { + var uniform = new THREE.NodeUniform( { type: type, - value: value, name: ns ? ns : 'nVu' + index, + node: node, needsUpdate: needsUpdate - }; + } ); this.uniformList.push( uniform ); @@ -487,9 +487,9 @@ THREE.NodeMaterial.prototype.getCodePars = function ( pars, prefix ) { }; -THREE.NodeMaterial.prototype.createVertexUniform = function ( type, value, ns, needsUpdate ) { +THREE.NodeMaterial.prototype.createVertexUniform = function ( type, node, ns, needsUpdate ) { - var uniform = this.createUniform( type, value, ns, needsUpdate ); + var uniform = this.createUniform( type, node, ns, needsUpdate ); this.vertexUniform.push( uniform ); this.vertexUniform[ uniform.name ] = uniform; @@ -500,9 +500,9 @@ THREE.NodeMaterial.prototype.createVertexUniform = function ( type, value, ns, n }; -THREE.NodeMaterial.prototype.createFragmentUniform = function ( type, value, ns, needsUpdate ) { +THREE.NodeMaterial.prototype.createFragmentUniform = function ( type, node, ns, needsUpdate ) { - var uniform = this.createUniform( type, value, ns, needsUpdate ); + var uniform = this.createUniform( type, node, ns, needsUpdate ); this.fragmentUniform.push( uniform ); this.fragmentUniform[ uniform.name ] = uniform; diff --git a/examples/js/nodes/NodeUniform.js b/examples/js/nodes/NodeUniform.js new file mode 100644 index 0000000000000000000000000000000000000000..cc4add6d3c40d2665c73ecd9aca2aa7af71af882 --- /dev/null +++ b/examples/js/nodes/NodeUniform.js @@ -0,0 +1,29 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +THREE.NodeUniform = function ( params ) { + + params = params || {}; + + this.name = params.name; + this.type = params.type; + this.node = params.node; + this.needsUpdate = params.needsUpdate; + +}; + +Object.defineProperties( THREE.NodeUniform.prototype, { + value: { + get: function () { + + return this.node.value; + + }, + set: function ( val ) { + + this.node.value = val; + + } + } +} ); diff --git a/examples/webgl_loader_nodes.html b/examples/webgl_loader_nodes.html index 0377ea125cc19785e21a163ede28de0bf18d649a..0297e8a5a486e94b2cccd9fa1339f981aea11809 100644 --- a/examples/webgl_loader_nodes.html +++ b/examples/webgl_loader_nodes.html @@ -50,6 +50,7 @@ + diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index 650139dc927a05f1dfa4a26dbab255104a736a52..70ab610365824a34c7dd09790486e254c9355f7c 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -50,6 +50,7 @@ + diff --git a/examples/webgl_mirror_nodes.html b/examples/webgl_mirror_nodes.html index 5ec375eed3e95d3972edc79bbdca96fd6cdc8f15..b6cc3599c1d5c69f24a0b12e00062c405adb65ce 100644 --- a/examples/webgl_mirror_nodes.html +++ b/examples/webgl_mirror_nodes.html @@ -48,6 +48,7 @@ + diff --git a/examples/webgl_postprocessing_nodes.html b/examples/webgl_postprocessing_nodes.html index 0f4937ded25c5b249bd37db9345cbb2c4d32fe17..784456038e83e120f17b9193cbe77d4243ec9e47 100644 --- a/examples/webgl_postprocessing_nodes.html +++ b/examples/webgl_postprocessing_nodes.html @@ -49,6 +49,7 @@ + diff --git a/examples/webgl_sprites_nodes.html b/examples/webgl_sprites_nodes.html index 367c2207ec12fb3bb7a8de5db7da181c2e75d803..399ef5ac324c64fc063dac130f1d0cb57b7f236d 100644 --- a/examples/webgl_sprites_nodes.html +++ b/examples/webgl_sprites_nodes.html @@ -49,6 +49,7 @@ +