2
0

Sidebar.Geometry.CapsuleGeometry.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import * as THREE from 'three';
  2. import { UIDiv, UIRow, UIText, UINumber, UIInteger } from './libs/ui.js';
  3. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  4. function GeometryParametersPanel( editor, object ) {
  5. const strings = editor.strings;
  6. const container = new UIDiv();
  7. const geometry = object.geometry;
  8. const parameters = geometry.parameters;
  9. // radius
  10. const radiusRow = new UIRow();
  11. const radius = new UINumber( parameters.radius ).onChange( update );
  12. radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/radius' ) ).setWidth( '90px' ) );
  13. radiusRow.add( radius );
  14. container.add( radiusRow );
  15. // length
  16. const lengthRow = new UIRow();
  17. const length = new UINumber( parameters.height ).onChange( update );
  18. lengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/length' ) ).setWidth( '90px' ) );
  19. lengthRow.add( length );
  20. container.add( lengthRow );
  21. // capSegments
  22. const capSegmentsRow = new UIRow();
  23. const capSegments = new UINumber( parameters.capSegments ).onChange( update );
  24. capSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/capseg' ) ).setWidth( '90px' ) );
  25. capSegmentsRow.add( capSegments );
  26. container.add( capSegmentsRow );
  27. // radialSegments
  28. const radialSegmentsRow = new UIRow();
  29. const radialSegments = new UIInteger( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
  30. radialSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/radialseg' ) ).setWidth( '90px' ) );
  31. radialSegmentsRow.add( radialSegments );
  32. container.add( radialSegmentsRow );
  33. //
  34. function update() {
  35. editor.execute( new SetGeometryCommand( editor, object, new THREE.CapsuleGeometry(
  36. radius.getValue(),
  37. length.getValue(),
  38. capSegments.getValue(),
  39. radialSegments.getValue()
  40. ) ) );
  41. }
  42. return container;
  43. }
  44. export { GeometryParametersPanel };