Sidebar.Geometry.RingGeometry.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @author Temdog007 / http://github.com/Temdog007
  3. */
  4. import {
  5. RingBufferGeometry
  6. } from '../../build/three.module.js';
  7. import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  8. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  9. var SidebarGeometryRingGeometry = function ( editor, object ) {
  10. var strings = editor.strings;
  11. var container = new UIRow();
  12. var geometry = object.geometry;
  13. var parameters = geometry.parameters;
  14. // innerRadius
  15. var innerRadiusRow = new UIRow();
  16. var innerRadius = new UINumber( parameters.innerRadius ).onChange( update );
  17. innerRadiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/innerRadius' ) ).setWidth( '90px' ) );
  18. innerRadiusRow.add( innerRadius );
  19. container.add( innerRadiusRow );
  20. // outerRadius
  21. var outerRadiusRow = new UIRow();
  22. var outerRadius = new UINumber( parameters.outerRadius ).onChange( update );
  23. outerRadiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/outerRadius' ) ).setWidth( '90px' ) );
  24. outerRadiusRow.add( outerRadius );
  25. container.add( outerRadiusRow );
  26. // thetaSegments
  27. var thetaSegmentsRow = new UIRow();
  28. var thetaSegments = new UIInteger( parameters.thetaSegments ).setRange( 3, Infinity ).onChange( update );
  29. thetaSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetaSegments' ) ).setWidth( '90px' ) );
  30. thetaSegmentsRow.add( thetaSegments );
  31. container.add( thetaSegmentsRow );
  32. // phiSegments
  33. var phiSegmentsRow = new UIRow();
  34. var phiSegments = new UIInteger( parameters.phiSegments ).setRange( 3, Infinity ).onChange( update );
  35. phiSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/phiSegments' ) ).setWidth( '90px' ) );
  36. phiSegmentsRow.add( phiSegments );
  37. container.add( phiSegmentsRow );
  38. // thetaStart
  39. var thetaStartRow = new UIRow();
  40. var thetaStart = new UINumber( parameters.thetaStart * THREE.Math.RAD2DEG ).setStep( 10 ).onChange( update );
  41. thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetastart' ) ).setWidth( '90px' ) );
  42. thetaStartRow.add( thetaStart );
  43. container.add( thetaStartRow );
  44. // thetaLength
  45. var thetaLengthRow = new UIRow();
  46. var thetaLength = new UINumber( parameters.thetaLength * THREE.Math.RAD2DEG ).setStep( 10 ).onChange( update );
  47. thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetalength' ) ).setWidth( '90px' ) );
  48. thetaLengthRow.add( thetaLength );
  49. container.add( thetaLengthRow );
  50. //
  51. function update() {
  52. editor.execute( new SetGeometryCommand( editor, object, new RingBufferGeometry(
  53. innerRadius.getValue(),
  54. outerRadius.getValue(),
  55. thetaSegments.getValue(),
  56. phiSegments.getValue(),
  57. thetaStart.getValue() * THREE.Math.DEG2RAD,
  58. thetaLength.getValue() * THREE.Math.DEG2RAD
  59. ) ) );
  60. }
  61. return container;
  62. };
  63. export { SidebarGeometryRingGeometry };