TrigonometryEditor.js 1.1 KB

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