TrigonometryEditor.js 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
  2. import { BaseNode } from '../core/BaseNode.js';
  3. import { MathNode, Vector3Node } from '../../renderers/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. ], MathNode.SIN ).onChange( () => {
  14. node.method = optionsField.getValue();
  15. this.invalidate();
  16. } );
  17. const input = new LabelElement( 'A' ).setInput( 1 );
  18. input.onConnect( () => {
  19. node.aNode = input.getLinkedObject() || DEFAULT_VALUE;
  20. } );
  21. this.add( new Element().add( optionsField ) )
  22. .add( input );
  23. }
  24. }