Sidebar.Geometry.ShapeGeometry.js 1.5 KB

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