Sidebar.Geometry.SphereGeometry.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Sidebar.Geometry.SphereGeometry = 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. // radius
  7. var radiusRow = new UI.Panel();
  8. var radius = new UI.Number( geometry.radius ).onChange( update );
  9. radiusRow.add( new UI.Text( 'Radius' ).setWidth( '90px' ).setColor( '#666' ) );
  10. radiusRow.add( radius );
  11. container.add( radiusRow );
  12. // widthSegments
  13. var widthSegmentsRow = new UI.Panel();
  14. var widthSegments = new UI.Integer( geometry.widthSegments ).setRange( 1, Infinity ).onChange( update );
  15. widthSegmentsRow.add( new UI.Text( 'Width segments' ).setWidth( '90px' ).setColor( '#666' ) );
  16. widthSegmentsRow.add( widthSegments );
  17. container.add( widthSegmentsRow );
  18. // heightSegments
  19. var heightSegmentsRow = new UI.Panel();
  20. var heightSegments = new UI.Integer( geometry.heightSegments ).setRange( 1, Infinity ).onChange( update );
  21. heightSegmentsRow.add( new UI.Text( 'Height segments' ).setWidth( '90px' ).setColor( '#666' ) );
  22. heightSegmentsRow.add( heightSegments );
  23. container.add( heightSegmentsRow );
  24. // phiStart
  25. var phiStartRow = new UI.Panel();
  26. var phiStart = new UI.Number( geometry.phiStart ).onChange( update );
  27. phiStartRow.add( new UI.Text( 'Phi start' ).setWidth( '90px' ).setColor( '#666' ) );
  28. phiStartRow.add( phiStart );
  29. container.add( phiStartRow );
  30. // phiLength
  31. var phiLengthRow = new UI.Panel();
  32. var phiLength = new UI.Number( geometry.phiLength ).onChange( update );
  33. phiLengthRow.add( new UI.Text( 'Phi length' ).setWidth( '90px' ).setColor( '#666' ) );
  34. phiLengthRow.add( phiLength );
  35. container.add( phiLengthRow );
  36. // thetaStart
  37. var thetaStartRow = new UI.Panel();
  38. var thetaStart = new UI.Number( geometry.thetaStart ).onChange( update );
  39. thetaStartRow.add( new UI.Text( 'Theta start' ).setWidth( '90px' ).setColor( '#666' ) );
  40. thetaStartRow.add( thetaStart );
  41. container.add( thetaStartRow );
  42. // thetaLength
  43. var thetaLengthRow = new UI.Panel();
  44. var thetaLength = new UI.Number( geometry.thetaLength ).onChange( update );
  45. thetaLengthRow.add( new UI.Text( 'Theta length' ).setWidth( '90px' ).setColor( '#666' ) );
  46. thetaLengthRow.add( thetaLength );
  47. container.add( thetaLengthRow );
  48. //
  49. function update() {
  50. delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
  51. object.geometry.dispose();
  52. object.geometry = new THREE.SphereGeometry(
  53. radius.getValue(),
  54. widthSegments.getValue(),
  55. heightSegments.getValue(),
  56. phiStart.getValue(),
  57. phiLength.getValue(),
  58. thetaStart.getValue(),
  59. thetaLength.getValue()
  60. );
  61. object.geometry.computeBoundingSphere();
  62. signals.objectChanged.dispatch( object );
  63. }
  64. return container;
  65. }