InvertEditor.js 864 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ObjectNode, SelectInput, LabelElement } from '../../libs/flow.module.js';
  2. import { MathNode, FloatNode } from '../../renderers/nodes/Nodes.js';
  3. const DEFAULT_VALUE = new FloatNode();
  4. export class InvertEditor extends ObjectNode {
  5. constructor() {
  6. const node = new MathNode( MathNode.INVERT, DEFAULT_VALUE );
  7. super( 'Invert / Negate', 1, node );
  8. const optionsField = new SelectInput( [
  9. { name: 'Invert ( 1 - Source )', value: MathNode.INVERT },
  10. { name: 'Negate ( - Source )', value: MathNode.NEGATE }
  11. ] ).onChange( () => {
  12. node.method = optionsField.getValue();
  13. this.invalidate();
  14. } );
  15. const input = new LabelElement( 'Source' ).setInput( 1 );
  16. input.onConnect( () => {
  17. node.aNode = input.linkedExtra || DEFAULT_VALUE;
  18. } );
  19. this.add( new LabelElement( 'Method' ).add( optionsField ) )
  20. .add( input );
  21. }
  22. }