Sidebar.Geometry.ShapeGeometry.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @author Temdog007 / http://github.com/Temdog007
  3. */
  4. import {
  5. ExtrudeBufferGeometry,
  6. ShapeBufferGeometry
  7. } from '../../build/three.module.js';
  8. import { UIRow, UIText, UIInteger, UIButton } from './libs/ui.js';
  9. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  10. var SidebarGeometryShapeGeometry = function ( editor, object ) {
  11. var strings = editor.strings;
  12. var container = new UIRow();
  13. var geometry = object.geometry;
  14. var parameters = geometry.parameters;
  15. // curveSegments
  16. var curveSegmentsRow = new UIRow();
  17. var curveSegments = new UIInteger( parameters.curveSegments || 12 ).onChange( changeShape ).setRange( 1, Infinity );
  18. curveSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/shape_geometry/curveSegments' ) ).setWidth( '90px' ) );
  19. curveSegmentsRow.add( curveSegments );
  20. container.add( curveSegmentsRow );
  21. // to extrude
  22. var button = new UIButton( strings.getKey( 'sidebar/geometry/shape_geometry/extrude' ) ).onClick( toExtrude ).setWidth( '90px' ).setMarginLeft( '90px' );
  23. container.add( button );
  24. //
  25. function changeShape() {
  26. editor.execute( new SetGeometryCommand( editor, object, new ShapeBufferGeometry(
  27. parameters.shapes,
  28. curveSegments.getValue()
  29. ) ) );
  30. }
  31. function toExtrude() {
  32. editor.execute( new SetGeometryCommand( editor, object, new ExtrudeBufferGeometry(
  33. parameters.shapes, {
  34. curveSegments: curveSegments.getValue()
  35. }
  36. ) ) );
  37. }
  38. return container;
  39. };
  40. export { SidebarGeometryShapeGeometry };