Sidebar.Geometry.CylinderGeometry.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import * as THREE from '../../build/three.module.js';
  2. import { UIRow, UIText, UIInteger, UICheckbox, UINumber } from './libs/ui.js';
  3. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  4. function GeometryParametersPanel( editor, object ) {
  5. var strings = editor.strings;
  6. var container = new UIRow();
  7. var geometry = object.geometry;
  8. var parameters = geometry.parameters;
  9. // radiusTop
  10. var radiusTopRow = new UIRow();
  11. var radiusTop = new UINumber( parameters.radiusTop ).onChange( update );
  12. radiusTopRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radiustop' ) ).setWidth( '90px' ) );
  13. radiusTopRow.add( radiusTop );
  14. container.add( radiusTopRow );
  15. // radiusBottom
  16. var radiusBottomRow = new UIRow();
  17. var radiusBottom = new UINumber( parameters.radiusBottom ).onChange( update );
  18. radiusBottomRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radiusbottom' ) ).setWidth( '90px' ) );
  19. radiusBottomRow.add( radiusBottom );
  20. container.add( radiusBottomRow );
  21. // height
  22. var heightRow = new UIRow();
  23. var height = new UINumber( parameters.height ).onChange( update );
  24. heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/height' ) ).setWidth( '90px' ) );
  25. heightRow.add( height );
  26. container.add( heightRow );
  27. // radialSegments
  28. var radialSegmentsRow = new UIRow();
  29. var radialSegments = new UIInteger( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
  30. radialSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radialsegments' ) ).setWidth( '90px' ) );
  31. radialSegmentsRow.add( radialSegments );
  32. container.add( radialSegmentsRow );
  33. // heightSegments
  34. var heightSegmentsRow = new UIRow();
  35. var heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  36. heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/heightsegments' ) ).setWidth( '90px' ) );
  37. heightSegmentsRow.add( heightSegments );
  38. container.add( heightSegmentsRow );
  39. // openEnded
  40. var openEndedRow = new UIRow();
  41. var openEnded = new UICheckbox( parameters.openEnded ).onChange( update );
  42. openEndedRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/openended' ) ).setWidth( '90px' ) );
  43. openEndedRow.add( openEnded );
  44. container.add( openEndedRow );
  45. //
  46. function update() {
  47. editor.execute( new SetGeometryCommand( editor, object, new THREE.CylinderGeometry(
  48. radiusTop.getValue(),
  49. radiusBottom.getValue(),
  50. height.getValue(),
  51. radialSegments.getValue(),
  52. heightSegments.getValue(),
  53. openEnded.getValue()
  54. ) ) );
  55. }
  56. return container;
  57. }
  58. export { GeometryParametersPanel };