Sidebar.Geometry.OctahedronGeometry.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import * as THREE from 'three';
  2. import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
  3. import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
  4. function GeometryParametersPanel( editor, object ) {
  5. const strings = editor.strings;
  6. const signals = editor.signals;
  7. const container = new UIDiv();
  8. const geometry = object.geometry;
  9. const parameters = geometry.parameters;
  10. // radius
  11. const radiusRow = new UIRow();
  12. const radius = new UINumber( parameters.radius ).onChange( update );
  13. radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/octahedron_geometry/radius' ) ).setClass( 'Label' ) );
  14. radiusRow.add( radius );
  15. container.add( radiusRow );
  16. // detail
  17. const detailRow = new UIRow();
  18. const detail = new UIInteger( parameters.detail ).setRange( 0, Infinity ).onChange( update );
  19. detailRow.add( new UIText( strings.getKey( 'sidebar/geometry/octahedron_geometry/detail' ) ).setClass( 'Label' ) );
  20. detailRow.add( detail );
  21. container.add( detailRow );
  22. //
  23. function refreshUI() {
  24. const parameters = object.geometry.parameters;
  25. radius.setValue( parameters.radius );
  26. detail.setValue( parameters.detail );
  27. }
  28. signals.geometryChanged.add( refreshUI );
  29. //
  30. function update() {
  31. editor.execute( new SetGeometryCommand( editor, object, new THREE.OctahedronGeometry(
  32. radius.getValue(),
  33. detail.getValue()
  34. ) ) );
  35. }
  36. return container;
  37. }
  38. export { GeometryParametersPanel };