Sidebar.Geometry.BoxGeometry.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { BoxBufferGeometry } from '../../build/three.module.js';
  5. import { UIRow, UIText, UINumber, UIInteger } from './libs/ui.js';
  6. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  7. var SidebarGeometryBoxGeometry = function ( editor, object ) {
  8. var strings = editor.strings;
  9. var container = new UIRow();
  10. var geometry = object.geometry;
  11. var parameters = geometry.parameters;
  12. // width
  13. var widthRow = new UIRow();
  14. var width = new UINumber( parameters.width ).onChange( update );
  15. widthRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/width' ) ).setWidth( '90px' ) );
  16. widthRow.add( width );
  17. container.add( widthRow );
  18. // height
  19. var heightRow = new UIRow();
  20. var height = new UINumber( parameters.height ).onChange( update );
  21. heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/height' ) ).setWidth( '90px' ) );
  22. heightRow.add( height );
  23. container.add( heightRow );
  24. // depth
  25. var depthRow = new UIRow();
  26. var depth = new UINumber( parameters.depth ).onChange( update );
  27. depthRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/depth' ) ).setWidth( '90px' ) );
  28. depthRow.add( depth );
  29. container.add( depthRow );
  30. // widthSegments
  31. var widthSegmentsRow = new UIRow();
  32. var widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
  33. widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/widthseg' ) ).setWidth( '90px' ) );
  34. widthSegmentsRow.add( widthSegments );
  35. container.add( widthSegmentsRow );
  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/box_geometry/heightseg' ) ).setWidth( '90px' ) );
  40. heightSegmentsRow.add( heightSegments );
  41. container.add( heightSegmentsRow );
  42. // depthSegments
  43. var depthSegmentsRow = new UIRow();
  44. var depthSegments = new UIInteger( parameters.depthSegments ).setRange( 1, Infinity ).onChange( update );
  45. depthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/depthseg' ) ).setWidth( '90px' ) );
  46. depthSegmentsRow.add( depthSegments );
  47. container.add( depthSegmentsRow );
  48. //
  49. function update() {
  50. editor.execute( new SetGeometryCommand( editor, object, new BoxBufferGeometry(
  51. width.getValue(),
  52. height.getValue(),
  53. depth.getValue(),
  54. widthSegments.getValue(),
  55. heightSegments.getValue(),
  56. depthSegments.getValue()
  57. ) ) );
  58. }
  59. return container;
  60. };
  61. export { SidebarGeometryBoxGeometry };