Sidebar.Geometry.CylinderGeometry.js 2.3 KB

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