Sidebar.Geometry.CylinderGeometry.js 2.2 KB

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