Sidebar.Geometry.CylinderGeometry.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Sidebar.Geometry.CylinderGeometry = function ( signals, object ) {
  2. var container = new UI.Panel();
  3. var geometry = object.geometry;
  4. // radiusTop
  5. var radiusTopRow = new UI.Panel();
  6. var radiusTop = new UI.Number( geometry.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( geometry.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( geometry.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( geometry.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( geometry.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( geometry.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. delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
  43. object.geometry.dispose();
  44. object.geometry = new THREE.CylinderGeometry(
  45. radiusTop.getValue(),
  46. radiusBottom.getValue(),
  47. height.getValue(),
  48. radialSegments.getValue(),
  49. heightSegments.getValue(),
  50. openEnded.getValue()
  51. );
  52. object.geometry.computeBoundingSphere();
  53. signals.objectChanged.dispatch( object );
  54. }
  55. return container;
  56. }