Sidebar.Geometry.RingGeometry.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. // innerRadius
  10. const innerRadiusRow = new UIRow();
  11. const innerRadius = new UINumber( parameters.innerRadius ).onChange( update );
  12. innerRadiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/innerRadius' ) ).setWidth( '90px' ) );
  13. innerRadiusRow.add( innerRadius );
  14. container.add( innerRadiusRow );
  15. // outerRadius
  16. const outerRadiusRow = new UIRow();
  17. const outerRadius = new UINumber( parameters.outerRadius ).onChange( update );
  18. outerRadiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/outerRadius' ) ).setWidth( '90px' ) );
  19. outerRadiusRow.add( outerRadius );
  20. container.add( outerRadiusRow );
  21. // thetaSegments
  22. const thetaSegmentsRow = new UIRow();
  23. const thetaSegments = new UIInteger( parameters.thetaSegments ).setRange( 3, Infinity ).onChange( update );
  24. thetaSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetaSegments' ) ).setWidth( '90px' ) );
  25. thetaSegmentsRow.add( thetaSegments );
  26. container.add( thetaSegmentsRow );
  27. // phiSegments
  28. const phiSegmentsRow = new UIRow();
  29. const phiSegments = new UIInteger( parameters.phiSegments ).setRange( 3, Infinity ).onChange( update );
  30. phiSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/phiSegments' ) ).setWidth( '90px' ) );
  31. phiSegmentsRow.add( phiSegments );
  32. container.add( phiSegmentsRow );
  33. // thetaStart
  34. const thetaStartRow = new UIRow();
  35. const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  36. thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetastart' ) ).setWidth( '90px' ) );
  37. thetaStartRow.add( thetaStart );
  38. container.add( thetaStartRow );
  39. // thetaLength
  40. const thetaLengthRow = new UIRow();
  41. const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  42. thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetalength' ) ).setWidth( '90px' ) );
  43. thetaLengthRow.add( thetaLength );
  44. container.add( thetaLengthRow );
  45. //
  46. function update() {
  47. editor.execute( new SetGeometryCommand( editor, object, new THREE.RingGeometry(
  48. innerRadius.getValue(),
  49. outerRadius.getValue(),
  50. thetaSegments.getValue(),
  51. phiSegments.getValue(),
  52. thetaStart.getValue() * THREE.MathUtils.DEG2RAD,
  53. thetaLength.getValue() * THREE.MathUtils.DEG2RAD
  54. ) ) );
  55. }
  56. return container;
  57. }
  58. export { GeometryParametersPanel };