LimiterEditor.js 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { ObjectNode, SelectInput, LabelElement } from '../../libs/flow.module.js';
  2. import { MathNode, FloatNode } from '../../renderers/nodes/Nodes.js';
  3. const NULL_VALUE = new FloatNode();
  4. export class LimiterEditor extends ObjectNode {
  5. constructor() {
  6. const node = new MathNode( MathNode.MAX, NULL_VALUE, NULL_VALUE );
  7. super( 'Limiter', 1, node, 250 );
  8. const methodInput = new SelectInput( [
  9. { name: 'Max', value: MathNode.MAX },
  10. { name: 'Min', value: MathNode.MIN }
  11. ] );
  12. methodInput.onChange( ( data ) => {
  13. node.method = data.getValue();
  14. this.invalidate();
  15. } );
  16. const aElement = new LabelElement( 'A' ).setInput( 1 );
  17. const bElement = new LabelElement( 'B' ).setInput( 1 );
  18. aElement.onConnect( () => {
  19. node.aNode = aElement.linkedExtra || NULL_VALUE;
  20. } );
  21. bElement.onConnect( () => {
  22. node.bNode = bElement.linkedExtra || NULL_VALUE;
  23. } );
  24. this.add( new LabelElement( 'Method' ).add( methodInput ) )
  25. .add( aElement )
  26. .add( bElement );
  27. }
  28. }