Sidebar.Geometry.ShapeGeometry.js 1.4 KB

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