InputNode.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. this.readonly = false;
  9. };
  10. THREE.InputNode.prototype = Object.create( THREE.TempNode.prototype );
  11. THREE.InputNode.prototype.constructor = THREE.InputNode;
  12. THREE.InputNode.prototype.isReadonly = function ( builder ) {
  13. return this.readonly;
  14. };
  15. THREE.InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needsUpdate ) {
  16. var material = builder.material;
  17. uuid = builder.getUuid( uuid || this.getUuid() );
  18. type = type || this.getType( builder );
  19. var data = material.getDataNode( uuid ),
  20. readonly = this.isReadonly( builder ) && this.generateReadonly !== undefined;
  21. if ( readonly ) {
  22. return this.generateReadonly( builder, output, uuid, type, ns, needsUpdate );
  23. } else {
  24. if ( builder.isShader( 'vertex' ) ) {
  25. if ( ! data.vertex ) {
  26. data.vertex = material.createVertexUniform( type, this, ns, needsUpdate );
  27. }
  28. return builder.format( data.vertex.name, type, output );
  29. } else {
  30. if ( ! data.fragment ) {
  31. data.fragment = material.createFragmentUniform( type, this, ns, needsUpdate );
  32. }
  33. return builder.format( data.fragment.name, type, output );
  34. }
  35. }
  36. };