2
0

Sidebar.Geometry.SphereGeometry.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. // radius
  10. var radiusRow = new UIRow();
  11. var radius = new UINumber( parameters.radius ).onChange( update );
  12. radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/radius' ) ).setWidth( '90px' ) );
  13. radiusRow.add( radius );
  14. container.add( radiusRow );
  15. // widthSegments
  16. var widthSegmentsRow = new UIRow();
  17. var widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
  18. widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/widthsegments' ) ).setWidth( '90px' ) );
  19. widthSegmentsRow.add( widthSegments );
  20. container.add( widthSegmentsRow );
  21. // heightSegments
  22. var heightSegmentsRow = new UIRow();
  23. var heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  24. heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/heightsegments' ) ).setWidth( '90px' ) );
  25. heightSegmentsRow.add( heightSegments );
  26. container.add( heightSegmentsRow );
  27. // phiStart
  28. var phiStartRow = new UIRow();
  29. var phiStart = new UINumber( parameters.phiStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  30. phiStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/phistart' ) ).setWidth( '90px' ) );
  31. phiStartRow.add( phiStart );
  32. container.add( phiStartRow );
  33. // phiLength
  34. var phiLengthRow = new UIRow();
  35. var phiLength = new UINumber( parameters.phiLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  36. phiLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/philength' ) ).setWidth( '90px' ) );
  37. phiLengthRow.add( phiLength );
  38. container.add( phiLengthRow );
  39. // thetaStart
  40. var thetaStartRow = new UIRow();
  41. var thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  42. thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/thetastart' ) ).setWidth( '90px' ) );
  43. thetaStartRow.add( thetaStart );
  44. container.add( thetaStartRow );
  45. // thetaLength
  46. var thetaLengthRow = new UIRow();
  47. var thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
  48. thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/sphere_geometry/thetalength' ) ).setWidth( '90px' ) );
  49. thetaLengthRow.add( thetaLength );
  50. container.add( thetaLengthRow );
  51. //
  52. function update() {
  53. editor.execute( new SetGeometryCommand( editor, object, new THREE.SphereGeometry(
  54. radius.getValue(),
  55. widthSegments.getValue(),
  56. heightSegments.getValue(),
  57. phiStart.getValue() * THREE.MathUtils.DEG2RAD,
  58. phiLength.getValue() * THREE.MathUtils.DEG2RAD,
  59. thetaStart.getValue() * THREE.MathUtils.DEG2RAD,
  60. thetaLength.getValue() * THREE.MathUtils.DEG2RAD
  61. ) ) );
  62. }
  63. return container;
  64. }
  65. export { GeometryParametersPanel };