InputNode.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.InputNode = function( type, params ) {
  5. params = params || {};
  6. params.shared = params.shared !== undefined ? params.shared : false;
  7. THREE.TempNode.call( this, type, params );
  8. };
  9. THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
  10. THREE.InputNode.prototype.constructor = THREE.InputNode;
  11. THREE.InputNode.prototype.generate = function( builder, output, uuid, type, ns, needsUpdate ) {
  12. var material = builder.material;
  13. uuid = builder.getUuid( uuid || this.getUuid() );
  14. type = type || this.getType( builder );
  15. var data = material.getDataNode( uuid );
  16. if ( builder.isShader( 'vertex' ) ) {
  17. if ( ! data.vertex ) {
  18. data.vertex = material.createVertexUniform( type, this.value, ns, needsUpdate );
  19. }
  20. return builder.format( data.vertex.name, type, output );
  21. } else {
  22. if ( ! data.fragment ) {
  23. data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate );
  24. }
  25. return builder.format( data.fragment.name, type, output );
  26. }
  27. };