Sidebar.Geometry.PlaneGeometry.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import * as THREE from '../../build/three.module.js';
  5. import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  6. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  7. var SidebarGeometryPlaneGeometry = 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/plane_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/plane_geometry/height' ) ).setWidth( '90px' ) );
  22. heightRow.add( height );
  23. container.add( heightRow );
  24. // widthSegments
  25. var widthSegmentsRow = new UIRow();
  26. var widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
  27. widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/widthsegments' ) ).setWidth( '90px' ) );
  28. widthSegmentsRow.add( widthSegments );
  29. container.add( widthSegmentsRow );
  30. // heightSegments
  31. var heightSegmentsRow = new UIRow();
  32. var heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  33. heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/heightsegments' ) ).setWidth( '90px' ) );
  34. heightSegmentsRow.add( heightSegments );
  35. container.add( heightSegmentsRow );
  36. //
  37. function update() {
  38. editor.execute( new SetGeometryCommand( editor, object, new THREE.PlaneBufferGeometry(
  39. width.getValue(),
  40. height.getValue(),
  41. widthSegments.getValue(),
  42. heightSegments.getValue()
  43. ) ) );
  44. }
  45. return container;
  46. };
  47. export { SidebarGeometryPlaneGeometry };