Sidebar.Geometry.TorusKnotGeometry.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Sidebar.Geometry.TorusKnotGeometry = 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. // tube
  13. var tubeRow = new UI.Panel();
  14. var tube = new UI.Number( geometry.tube ).onChange( update );
  15. tubeRow.add( new UI.Text( 'Tube' ).setWidth( '90px' ).setColor( '#666' ) );
  16. tubeRow.add( tube );
  17. container.add( tubeRow );
  18. // radialSegments
  19. var radialSegmentsRow = new UI.Panel();
  20. var radialSegments = new UI.Integer( geometry.radialSegments ).setRange( 1, Infinity ).onChange( update );
  21. radialSegmentsRow.add( new UI.Text( 'Radial segments' ).setWidth( '90px' ).setColor( '#666' ) );
  22. radialSegmentsRow.add( radialSegments );
  23. container.add( radialSegmentsRow );
  24. // tubularSegments
  25. var tubularSegmentsRow = new UI.Panel();
  26. var tubularSegments = new UI.Integer( geometry.tubularSegments ).setRange( 1, Infinity ).onChange( update );
  27. tubularSegmentsRow.add( new UI.Text( 'Tubular segments' ).setWidth( '90px' ).setColor( '#666' ) );
  28. tubularSegmentsRow.add( tubularSegments );
  29. container.add( tubularSegmentsRow );
  30. // p
  31. var pRow = new UI.Panel();
  32. var p = new UI.Number( geometry.p ).onChange( update );
  33. pRow.add( new UI.Text( 'P' ).setWidth( '90px' ).setColor( '#666' ) );
  34. pRow.add( p );
  35. container.add( pRow );
  36. // q
  37. var qRow = new UI.Panel();
  38. var q = new UI.Number( geometry.q ).onChange( update );
  39. pRow.add( new UI.Text( 'Q' ).setWidth( '90px' ).setColor( '#666' ) );
  40. pRow.add( q );
  41. container.add( qRow );
  42. // heightScale
  43. var heightScaleRow = new UI.Panel();
  44. var heightScale = new UI.Number( geometry.heightScale ).onChange( update );
  45. pRow.add( new UI.Text( 'Height scale' ).setWidth( '90px' ).setColor( '#666' ) );
  46. pRow.add( heightScale );
  47. container.add( heightScaleRow );
  48. //
  49. function update() {
  50. delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
  51. object.geometry.dispose();
  52. object.geometry = new THREE.TorusKnotGeometry(
  53. radius.getValue(),
  54. tube.getValue(),
  55. radialSegments.getValue(),
  56. tubularSegments.getValue(),
  57. p.getValue(),
  58. q.getValue(),
  59. heightScale.getValue()
  60. );
  61. object.geometry.computeBoundingSphere();
  62. signals.objectChanged.dispatch( object );
  63. }
  64. return container;
  65. }