TrigonometryEditor.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
  2. import { BaseNode } from '../core/BaseNode.js';
  3. import { MathNode, Vector3Node } from 'three-nodes/Nodes.js';
  4. const DEFAULT_VALUE = new Vector3Node();
  5. export class TrigonometryEditor extends BaseNode {
  6. constructor() {
  7. const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );
  8. super( 'Trigonometry', 1, node, 175 );
  9. const optionsField = new SelectInput( [
  10. { name: 'Sin', value: MathNode.SIN },
  11. { name: 'Cos', value: MathNode.COS },
  12. { name: 'Tan', value: MathNode.TAN },
  13. { name: 'asin', value: MathNode.ASIN },
  14. { name: 'acos', value: MathNode.ACOS },
  15. { name: 'atan', value: MathNode.ATAN }
  16. ], MathNode.SIN ).onChange( () => {
  17. node.method = optionsField.getValue();
  18. this.invalidate();
  19. } );
  20. const input = new LabelElement( 'A' ).setInput( 1 );
  21. input.onConnect( () => {
  22. node.aNode = input.getLinkedObject() || DEFAULT_VALUE;
  23. } );
  24. this.add( new Element().add( optionsField ) )
  25. .add( input );
  26. }
  27. }