InputNode.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. }
  22. else {
  23. if ( ! data.fragment ) {
  24. data.fragment = material.createFragmentUniform( type, this.value, ns, needsUpdate );
  25. }
  26. return builder.format( data.fragment.name, type, output );
  27. }
  28. };