AngleEditor.js 882 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 AngleEditor extends BaseNode {
  6. constructor() {
  7. const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );
  8. super( 'Angle', 1, node, 175 );
  9. const optionsField = new SelectInput( [
  10. { name: 'Degrees to Radians', value: MathNode.RAD },
  11. { name: 'Radians to Degrees', value: MathNode.DEG }
  12. ], MathNode.RAD ).onChange( () => {
  13. node.method = optionsField.getValue();
  14. this.invalidate();
  15. } );
  16. const input = new LabelElement( 'A' ).setInput( 1 );
  17. input.onConnect( () => {
  18. node.aNode = input.getLinkedObject() || DEFAULT_VALUE;
  19. } );
  20. this.add( new Element().add( optionsField ) )
  21. .add( input );
  22. }
  23. }