DotEditor.js 724 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { ObjectNode, LabelElement } from '../../libs/flow.module.js';
  2. import { MathNode, FloatNode } from '../../renderers/nodes/Nodes.js';
  3. const NULL_VALUE = new FloatNode();
  4. export class DotEditor extends ObjectNode {
  5. constructor() {
  6. const node = new MathNode( MathNode.DOT, NULL_VALUE, NULL_VALUE );
  7. super( 'Dot Product', 1, node );
  8. this.setWidth( 200 );
  9. const aElement = new LabelElement( 'A' ).setInput( 3 );
  10. const bElement = new LabelElement( 'B' ).setInput( 3 );
  11. aElement.onConnect( () => {
  12. node.aNode = aElement.linkedExtra || NULL_VALUE;
  13. } );
  14. bElement.onConnect( () => {
  15. node.bNode = bElement.linkedExtra || NULL_VALUE;
  16. } );
  17. this.add( aElement )
  18. .add( bElement );
  19. }
  20. }