Vector2Editor.js 633 B

12345678910111213141516171819202122232425262728
  1. import { ObjectNode, NumberInput, LabelElement } from '../../libs/flow.module.js';
  2. import { Vector2Node } from '../../renderers/nodes/Nodes.js';
  3. export class Vector2Editor extends ObjectNode {
  4. constructor() {
  5. const node = new Vector2Node();
  6. super( 'Vector 2', 2, node );
  7. this.title.setIcon( 'ti ti-box-multiple-2' );
  8. const onUpdate = () => {
  9. node.value.x = fieldX.getValue();
  10. node.value.y = fieldY.getValue();
  11. };
  12. const fieldX = new NumberInput().onChange( onUpdate );
  13. const fieldY = new NumberInput().onChange( onUpdate );
  14. this.add( new LabelElement( 'Values' ).add( fieldX ).add( fieldY ) );
  15. }
  16. }