TrigonometryEditor.js 868 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { ObjectNode, SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
  2. import { MathNode, Vector3Node } from '../../renderers/nodes/Nodes.js';
  3. const DEFAULT_VALUE = new Vector3Node();
  4. export class TrigonometryEditor extends ObjectNode {
  5. constructor() {
  6. const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );
  7. super( 'Trigonometry', 1, node, 200 );
  8. const optionsField = new SelectInput( [
  9. { name: 'Sin', value: MathNode.SIN },
  10. { name: 'Cos', value: MathNode.COS },
  11. { name: 'Tan', value: MathNode.TAN }
  12. ] ).onChange( () => {
  13. node.method = optionsField.getValue();
  14. this.invalidate();
  15. } );
  16. const input = new LabelElement( 'Source' ).setInput( 1 );
  17. input.onConnect( () => {
  18. node.aNode = input.linkedExtra || DEFAULT_VALUE;
  19. } );
  20. this.add( new Element().add( optionsField ) )
  21. .add( input );
  22. }
  23. }