Sidebar.Geometry.CylinderGeometry.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Sidebar.Geometry.CylinderGeometry = function ( signals, object ) {
  2. var container = new UI.Panel();
  3. var parameters = object.geometry.parameters;
  4. // radiusTop
  5. var radiusTopRow = new UI.Panel();
  6. var radiusTop = new UI.Number( parameters.radiusTop ).onChange( update );
  7. radiusTopRow.add( new UI.Text( 'Radius top' ).setWidth( '90px' ) );
  8. radiusTopRow.add( radiusTop );
  9. container.add( radiusTopRow );
  10. // radiusBottom
  11. var radiusBottomRow = new UI.Panel();
  12. var radiusBottom = new UI.Number( parameters.radiusBottom ).onChange( update );
  13. radiusBottomRow.add( new UI.Text( 'Radius bottom' ).setWidth( '90px' ) );
  14. radiusBottomRow.add( radiusBottom );
  15. container.add( radiusBottomRow );
  16. // height
  17. var heightRow = new UI.Panel();
  18. var height = new UI.Number( parameters.height ).onChange( update );
  19. heightRow.add( new UI.Text( 'Height' ).setWidth( '90px' ) );
  20. heightRow.add( height );
  21. container.add( heightRow );
  22. // radialSegments
  23. var radialSegmentsRow = new UI.Panel();
  24. var radialSegments = new UI.Integer( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
  25. radialSegmentsRow.add( new UI.Text( 'Radial segments' ).setWidth( '90px' ) );
  26. radialSegmentsRow.add( radialSegments );
  27. container.add( radialSegmentsRow );
  28. // heightSegments
  29. var heightSegmentsRow = new UI.Panel();
  30. var heightSegments = new UI.Integer( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
  31. heightSegmentsRow.add( new UI.Text( 'Height segments' ).setWidth( '90px' ) );
  32. heightSegmentsRow.add( heightSegments );
  33. container.add( heightSegmentsRow );
  34. // openEnded
  35. var openEndedRow = new UI.Panel();
  36. var openEnded = new UI.Checkbox( parameters.openEnded ).onChange( update );
  37. openEndedRow.add( new UI.Text( 'Open ended' ).setWidth( '90px' ) );
  38. openEndedRow.add( openEnded );
  39. container.add( openEndedRow );
  40. //
  41. function update() {
  42. object.geometry.dispose();
  43. object.geometry = new THREE.CylinderGeometry(
  44. radiusTop.getValue(),
  45. radiusBottom.getValue(),
  46. height.getValue(),
  47. radialSegments.getValue(),
  48. heightSegments.getValue(),
  49. openEnded.getValue()
  50. );
  51. object.geometry.computeBoundingSphere();
  52. signals.geometryChanged.dispatch( object );
  53. }
  54. return container;
  55. }