Sidebar.Geometry.CircleGeometry.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import * as THREE from 'three';
  2. import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  3. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  4. function GeometryParametersPanel( editor, object ) {
  5. const strings = editor.strings;
  6. const container = new UIDiv();
  7. const geometry = object.geometry;
  8. const parameters = geometry.parameters;
  9. // radius
  10. const radiusRow = new UIRow();
  11. const radius = new UINumber( parameters.radius ).onChange( update );
  12. radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/radius' ) ).setWidth( '90px' ) );
  13. radiusRow.add( radius );
  14. container.add( radiusRow );
  15. // segments
  16. const segmentsRow = new UIRow();
  17. const segments = new UIInteger( parameters.segments ).setRange( 3, Infinity ).onChange( update );
  18. segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/segments' ) ).setWidth( '90px' ) );
  19. segmentsRow.add( segments );
  20. container.add( segmentsRow );
  21. // thetaStart
  22. const thetaStartRow = new UIRow();
  23. const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  24. thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetastart' ) ).setWidth( '90px' ) );
  25. thetaStartRow.add( thetaStart );
  26. container.add( thetaStartRow );
  27. // thetaLength
  28. const thetaLengthRow = new UIRow();
  29. const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  30. thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetalength' ) ).setWidth( '90px' ) );
  31. thetaLengthRow.add( thetaLength );
  32. container.add( thetaLengthRow );
  33. //
  34. function update() {
  35. editor.execute( new SetGeometryCommand( editor, object, new THREE.CircleGeometry(
  36. radius.getValue(),
  37. segments.getValue(),
  38. thetaStart.getValue() * THREE.MathUtils.DEG2RAD,
  39. thetaLength.getValue() * THREE.MathUtils.DEG2RAD
  40. ) ) );
  41. }
  42. return container;
  43. }
  44. export { GeometryParametersPanel };