DotEditor.js 738 B

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