Sidebar.Geometry.LatheGeometry.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @author rfm1201
  3. */
  4. import {
  5. LatheBufferGeometry
  6. } from '../../build/three.module.js';
  7. import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  8. import { UIPoints2 } from './libs/ui.three.js';
  9. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  10. var SidebarGeometryLatheGeometry = function ( editor, object ) {
  11. var strings = editor.strings;
  12. var container = new UIRow();
  13. var geometry = object.geometry;
  14. var parameters = geometry.parameters;
  15. // segments
  16. var segmentsRow = new UIRow();
  17. var segments = new UIInteger( parameters.segments ).onChange( update );
  18. segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/segments' ) ).setWidth( '90px' ) );
  19. segmentsRow.add( segments );
  20. container.add( segmentsRow );
  21. // phiStart
  22. var phiStartRow = new UIRow();
  23. var phiStart = new UINumber( parameters.phiStart * 180 / Math.PI ).onChange( update );
  24. phiStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/phistart' ) ).setWidth( '90px' ) );
  25. phiStartRow.add( phiStart );
  26. container.add( phiStartRow );
  27. // phiLength
  28. var phiLengthRow = new UIRow();
  29. var phiLength = new UINumber( parameters.phiLength * 180 / Math.PI ).onChange( update );
  30. phiLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/philength' ) ).setWidth( '90px' ) );
  31. phiLengthRow.add( phiLength );
  32. container.add( phiLengthRow );
  33. // points
  34. var pointsRow = new UIRow();
  35. pointsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/points' ) ).setWidth( '90px' ) );
  36. var points = new UIPoints2().setValue( parameters.points ).onChange( update );
  37. pointsRow.add( points );
  38. container.add( pointsRow );
  39. function update() {
  40. editor.execute( new SetGeometryCommand( editor, object, new LatheBufferGeometry(
  41. points.getValue(),
  42. segments.getValue(),
  43. phiStart.getValue() / 180 * Math.PI,
  44. phiLength.getValue() / 180 * Math.PI
  45. ) ) );
  46. }
  47. return container;
  48. };
  49. export { SidebarGeometryLatheGeometry };