Sidebar.Geometry.TubeGeometry.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @author Temdog007 / http://github.com/Temdog007
  3. */
  4. Sidebar.Geometry.TubeGeometry = function ( editor, object ) {
  5. var strings = editor.strings;
  6. var container = new UI.Row();
  7. var geometry = object.geometry;
  8. var parameters = geometry.parameters;
  9. // points
  10. var pointsRow = new UI.Row();
  11. pointsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/path' ) ).setWidth( '90px' ) );
  12. var points = new UI.Points3().setValue( parameters.path.points ).onChange( update );
  13. pointsRow.add( points );
  14. container.add( pointsRow );
  15. // radius
  16. var radiusRow = new UI.Row();
  17. var radius = new UI.Number( parameters.radius ).onChange( update );
  18. radiusRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/radius' ) ).setWidth( '90px' ) );
  19. radiusRow.add( radius );
  20. container.add( radiusRow );
  21. // tubularSegments
  22. var tubularSegmentsRow = new UI.Row();
  23. var tubularSegments = new UI.Integer( parameters.tubularSegments ).onChange( update );
  24. tubularSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/tubularsegments' ) ).setWidth( '90px' ) );
  25. tubularSegmentsRow.add( tubularSegments );
  26. container.add( tubularSegmentsRow );
  27. // radialSegments
  28. var radialSegmentsRow = new UI.Row();
  29. var radialSegments = new UI.Integer( parameters.radialSegments ).onChange( update );
  30. radialSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/radialsegments' ) ).setWidth( '90px' ) );
  31. radialSegmentsRow.add( radialSegments );
  32. container.add( radialSegmentsRow );
  33. // closed
  34. var closedRow = new UI.Row();
  35. var closed = new UI.Checkbox( parameters.closed ).onChange( update );
  36. closedRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/closed' ) ).setWidth( '90px' ) );
  37. closedRow.add( closed );
  38. container.add( closedRow );
  39. // curveType
  40. var curveTypeRow = new UI.Row();
  41. var curveType = new UI.Select().setOptions( { centripetal: 'centripetal', chordal: 'chordal', catmullrom: 'catmullrom' } ).setValue( parameters.path.curveType ).onChange( update );
  42. curveTypeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/curvetype' ) ).setWidth( '90px' ), curveType );
  43. container.add( curveTypeRow );
  44. // tension
  45. var tensionRow = new UI.Row().setDisplay( curveType.getValue() == 'catmullrom' ? '' : 'none' );
  46. var tension = new UI.Number( parameters.path.tension ).setStep( 0.01 ).onChange( update );
  47. tensionRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/tube_geometry/tension' ) ).setWidth( '90px' ), tension );
  48. container.add( tensionRow );
  49. //
  50. function update() {
  51. tensionRow.setDisplay( curveType.getValue() == 'catmullrom' ? '' : 'none' );
  52. editor.execute( new SetGeometryCommand( editor, object, new THREE[ geometry.type ](
  53. new THREE.CatmullRomCurve3( points.getValue(), closed.getValue(), curveType.getValue(), tension.getValue() ),
  54. tubularSegments.getValue(),
  55. radius.getValue(),
  56. radialSegments.getValue(),
  57. closed.getValue()
  58. ) ) );
  59. }
  60. return container;
  61. };
  62. Sidebar.Geometry.TubeBufferGeometry = Sidebar.Geometry.TubeGeometry;