Sidebar.Geometry.CylinderGeometry.js 2.8 KB

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