Sidebar.Geometry.PlaneGeometry.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import {
  5. PlaneBufferGeometry
  6. } from '../../build/three.module.js';
  7. import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  8. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  9. var SidebarGeometryPlaneGeometry = function ( editor, object ) {
  10. var strings = editor.strings;
  11. var container = new UIRow();
  12. var geometry = object.geometry;
  13. var parameters = geometry.parameters;
  14. // width
  15. var widthRow = new UIRow();
  16. var width = new UINumber( parameters.width ).onChange( update );
  17. widthRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/width' ) ).setWidth( '90px' ) );
  18. widthRow.add( width );
  19. container.add( widthRow );
  20. // height
  21. var heightRow = new UIRow();
  22. var height = new UINumber( parameters.height ).onChange( update );
  23. heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/height' ) ).setWidth( '90px' ) );
  24. heightRow.add( height );
  25. container.add( heightRow );
  26. // widthSegments
  27. var widthSegmentsRow = new UIRow();
  28. var widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
  29. widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/widthsegments' ) ).setWidth( '90px' ) );
  30. widthSegmentsRow.add( widthSegments );
  31. container.add( widthSegmentsRow );
  32. // heightSegments
  33. var heightSegmentsRow = new UIRow();
  34. var heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  35. heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/heightsegments' ) ).setWidth( '90px' ) );
  36. heightSegmentsRow.add( heightSegments );
  37. container.add( heightSegmentsRow );
  38. //
  39. function update() {
  40. editor.execute( new SetGeometryCommand( editor, object, new PlaneBufferGeometry(
  41. width.getValue(),
  42. height.getValue(),
  43. widthSegments.getValue(),
  44. heightSegments.getValue()
  45. ) ) );
  46. }
  47. return container;
  48. };
  49. export { SidebarGeometryPlaneGeometry };