InputNode.js 847 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import Node from './Node.js';
  2. class InputNode extends Node {
  3. constructor( type ) {
  4. super( type );
  5. this.constant = false;
  6. }
  7. setConst( value ) {
  8. this.constant = value;
  9. return this;
  10. }
  11. getConst() {
  12. return this.constant;
  13. }
  14. generateConst( builder ) {
  15. return builder.getConst( this.getType( builder ), this.value );
  16. }
  17. generate( builder, output ) {
  18. const type = this.getType( builder );
  19. if ( this.constant === true ) {
  20. return builder.format( this.generateConst( builder ), type, output );
  21. } else {
  22. const nodeUniform = builder.getUniformFromNode( this, builder.shaderStage, this.getType( builder ) );
  23. const propertyName = builder.getPropertyName( nodeUniform );
  24. return builder.format( propertyName, type, output );
  25. }
  26. }
  27. }
  28. InputNode.prototype.isInputNode = true;
  29. export default InputNode;