Vector4Editor.js 937 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { NumberInput, LabelElement } from '../../libs/flow.module.js';
  2. import { BaseNode } from '../core/BaseNode.js';
  3. import { Vector4Node } from 'three-nodes/Nodes.js';
  4. export class Vector4Editor extends BaseNode {
  5. constructor() {
  6. const node = new Vector4Node();
  7. super( 'Vector 4', 4, node, 350 );
  8. const onUpdate = () => {
  9. node.value.x = fieldX.getValue();
  10. node.value.y = fieldY.getValue();
  11. node.value.z = fieldZ.getValue();
  12. node.value.w = fieldW.getValue();
  13. };
  14. const fieldX = new NumberInput().setTagColor( 'red' ).onChange( onUpdate );
  15. const fieldY = new NumberInput().setTagColor( 'green' ).onChange( onUpdate );
  16. const fieldZ = new NumberInput().setTagColor( 'blue' ).onChange( onUpdate );
  17. const fieldW = new NumberInput( 1 ).setTagColor( 'white' ).onChange( onUpdate );
  18. this.add( new LabelElement( 'XYZW' )
  19. .add( fieldX )
  20. .add( fieldY )
  21. .add( fieldZ )
  22. .add( fieldW )
  23. );
  24. }
  25. }