Sidebar.Geometry.PlaneGeometry.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import * as THREE from '../../build/three.module.js';
  2. import { UIRow, UIText, UIInteger, 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. // width
  10. var widthRow = new UIRow();
  11. var width = new UINumber( parameters.width ).onChange( update );
  12. widthRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/width' ) ).setWidth( '90px' ) );
  13. widthRow.add( width );
  14. container.add( widthRow );
  15. // height
  16. var heightRow = new UIRow();
  17. var height = new UINumber( parameters.height ).onChange( update );
  18. heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/height' ) ).setWidth( '90px' ) );
  19. heightRow.add( height );
  20. container.add( heightRow );
  21. // widthSegments
  22. var widthSegmentsRow = new UIRow();
  23. var widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
  24. widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/widthsegments' ) ).setWidth( '90px' ) );
  25. widthSegmentsRow.add( widthSegments );
  26. container.add( widthSegmentsRow );
  27. // heightSegments
  28. var heightSegmentsRow = new UIRow();
  29. var heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  30. heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/heightsegments' ) ).setWidth( '90px' ) );
  31. heightSegmentsRow.add( heightSegments );
  32. container.add( heightSegmentsRow );
  33. //
  34. function update() {
  35. editor.execute( new SetGeometryCommand( editor, object, new THREE.PlaneGeometry(
  36. width.getValue(),
  37. height.getValue(),
  38. widthSegments.getValue(),
  39. heightSegments.getValue()
  40. ) ) );
  41. }
  42. return container;
  43. }
  44. export { GeometryParametersPanel };