Vector4Editor.js 976 B

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