AngleEditor.js 921 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 AngleEditor extends BaseNode {
  7. constructor() {
  8. const node = new MathNode( MathNode.SIN, DEFAULT_VALUE );
  9. super( 'Angle', 1, node, 175 );
  10. const optionsField = new SelectInput( [
  11. { name: 'Degrees to Radians', value: MathNode.RAD },
  12. { name: 'Radians to Degrees', value: MathNode.DEG }
  13. ], MathNode.RAD ).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. }