Sidebar.Geometry.TorusKnotGeometry.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.Row();
  7. var parameters = object.geometry.parameters;
  8. // radius
  9. var radiusRow = new UI.Row();
  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.Row();
  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. // tubularSegments
  21. var tubularSegmentsRow = new UI.Row();
  22. var tubularSegments = new UI.Integer( parameters.tubularSegments ).setRange( 1, Infinity ).onChange( update );
  23. tubularSegmentsRow.add( new UI.Text( 'Tubular segments' ).setWidth( '90px' ) );
  24. tubularSegmentsRow.add( tubularSegments );
  25. container.add( tubularSegmentsRow );
  26. // radialSegments
  27. var radialSegmentsRow = new UI.Row();
  28. var radialSegments = new UI.Integer( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
  29. radialSegmentsRow.add( new UI.Text( 'Radial segments' ).setWidth( '90px' ) );
  30. radialSegmentsRow.add( radialSegments );
  31. container.add( radialSegmentsRow );
  32. // p
  33. var pRow = new UI.Row();
  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.Row();
  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. //
  45. function update() {
  46. editor.execute( new SetGeometryCommand( object, new THREE.TorusKnotGeometry(
  47. radius.getValue(),
  48. tube.getValue(),
  49. tubularSegments.getValue(),
  50. radialSegments.getValue(),
  51. p.getValue(),
  52. q.getValue()
  53. ) ) );
  54. }
  55. return container;
  56. }