Node.js 848 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { NodeUpdateType } from './constants.js';
  2. class Node {
  3. constructor( type = null ) {
  4. this.type = type;
  5. this.updateType = NodeUpdateType.None;
  6. }
  7. getUpdateType( /*builder*/ ) {
  8. return this.updateType;
  9. }
  10. getType( /*builder*/ ) {
  11. return this.type;
  12. }
  13. update( /*frame*/ ) {
  14. console.warn( 'Abstract function.' );
  15. }
  16. generate( /*builder, output*/ ) {
  17. console.warn( 'Abstract function.' );
  18. }
  19. buildStage( builder, shaderStage, output = null ) {
  20. const oldShaderStage = builder.shaderStage;
  21. builder.shaderStage = shaderStage;
  22. const snippet = this.build( builder, output );
  23. builder.shaderStage = oldShaderStage;
  24. return snippet;
  25. }
  26. build( builder, output = null ) {
  27. builder.addNode( this );
  28. return this.generate( builder, output );
  29. }
  30. }
  31. Node.prototype.isNode = true;
  32. export default Node;