Node.js 890 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. Object.defineProperty( this, 'isNode', { value: true } );
  7. }
  8. getUpdateType( /*builder*/ ) {
  9. return this.updateType;
  10. }
  11. getType( /*builder*/ ) {
  12. return this.type;
  13. }
  14. update( /*frame*/ ) {
  15. console.warn( 'Abstract function.' );
  16. }
  17. generate( /*builder, output*/ ) {
  18. console.warn( 'Abstract function.' );
  19. }
  20. buildStage( builder, shaderStage, output = null ) {
  21. const oldShaderStage = builder.shaderStage;
  22. builder.shaderStage = shaderStage;
  23. const snippet = this.build( builder, output );
  24. builder.shaderStage = oldShaderStage;
  25. return snippet;
  26. }
  27. build( builder, output = null ) {
  28. builder.addNode( this );
  29. return this.generate( builder, output );
  30. }
  31. }
  32. export default Node;