Sidebar.Geometry.TorusKnotGeometry.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Geometry.TorusKnotGeometry = function ( editor, object ) {
  5. var signals = editor.signals;
  6. var container = new UI.Panel();
  7. var parameters = object.geometry.parameters;
  8. // radius
  9. var radiusRow = new UI.Panel();
  10. var radius = new UI.Number( parameters.radius ).onChange( update );
  11. radiusRow.add( new UI.Text( 'Radius' ).setWidth( '90px' ) );
  12. radiusRow.add( radius );
  13. container.add( radiusRow );
  14. // tube
  15. var tubeRow = new UI.Panel();
  16. var tube = new UI.Number( parameters.tube ).onChange( update );
  17. tubeRow.add( new UI.Text( 'Tube' ).setWidth( '90px' ) );
  18. tubeRow.add( tube );
  19. container.add( tubeRow );
  20. // radialSegments
  21. var radialSegmentsRow = new UI.Panel();
  22. var radialSegments = new UI.Integer( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
  23. radialSegmentsRow.add( new UI.Text( 'Radial segments' ).setWidth( '90px' ) );
  24. radialSegmentsRow.add( radialSegments );
  25. container.add( radialSegmentsRow );
  26. // tubularSegments
  27. var tubularSegmentsRow = new UI.Panel();
  28. var tubularSegments = new UI.Integer( parameters.tubularSegments ).setRange( 1, Infinity ).onChange( update );
  29. tubularSegmentsRow.add( new UI.Text( 'Tubular segments' ).setWidth( '90px' ) );
  30. tubularSegmentsRow.add( tubularSegments );
  31. container.add( tubularSegmentsRow );
  32. // p
  33. var pRow = new UI.Panel();
  34. var p = new UI.Number( parameters.p ).onChange( update );
  35. pRow.add( new UI.Text( 'P' ).setWidth( '90px' ) );
  36. pRow.add( p );
  37. container.add( pRow );
  38. // q
  39. var qRow = new UI.Panel();
  40. var q = new UI.Number( parameters.q ).onChange( update );
  41. pRow.add( new UI.Text( 'Q' ).setWidth( '90px' ) );
  42. pRow.add( q );
  43. container.add( qRow );
  44. // heightScale
  45. var heightScaleRow = new UI.Panel();
  46. var heightScale = new UI.Number( parameters.heightScale ).onChange( update );
  47. pRow.add( new UI.Text( 'Height scale' ).setWidth( '90px' ) );
  48. pRow.add( heightScale );
  49. container.add( heightScaleRow );
  50. //
  51. function update() {
  52. editor.execute( new CmdSetGeometry( object, 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. }
  62. return container;
  63. }