JoinNode.js 641 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Node from '../core/Node.js';
  2. class JoinNode extends Node {
  3. constructor( nodes = [] ) {
  4. super();
  5. this.nodes = nodes;
  6. }
  7. getNodeType( builder ) {
  8. return builder.getTypeFromLength( this.nodes.length );
  9. }
  10. generate( builder ) {
  11. const type = this.getNodeType( builder );
  12. const nodes = this.nodes;
  13. const snippetValues = [];
  14. for ( let i = 0; i < nodes.length; i ++ ) {
  15. const input = nodes[ i ];
  16. const inputSnippet = input.build( builder, 'float' );
  17. snippetValues.push( inputSnippet );
  18. }
  19. return `${ builder.getType( type ) }( ${ snippetValues.join( ', ' ) } )`;
  20. }
  21. }
  22. export default JoinNode;