1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import * as THREE from 'three';
- import { UIDiv, UIRow, UIText, UIInteger, UIButton } from './libs/ui.js';
- import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
- function GeometryParametersPanel( editor, object ) {
- const strings = editor.strings;
- const signals = editor.signals;
- const container = new UIDiv();
- const geometry = object.geometry;
- const parameters = geometry.parameters;
- // curveSegments
- const curveSegmentsRow = new UIRow();
- const curveSegments = new UIInteger( parameters.curveSegments || 12 ).onChange( changeShape ).setRange( 1, Infinity );
- curveSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/shape_geometry/curveSegments' ) ).setClass( 'Label' ) );
- curveSegmentsRow.add( curveSegments );
- container.add( curveSegmentsRow );
- // to extrude
- const button = new UIButton( strings.getKey( 'sidebar/geometry/shape_geometry/extrude' ) ).onClick( toExtrude ).setClass( 'Label' ).setMarginLeft( '120px' );
- container.add( button );
- //
- function refreshUI() {
- const parameters = object.geometry.parameters;
- curveSegments.setValue( parameters.curveSegments );
- }
- signals.geometryChanged.add( refreshUI );
- //
- function changeShape() {
- editor.execute( new SetGeometryCommand( editor, object, new THREE.ShapeGeometry(
- parameters.shapes,
- curveSegments.getValue()
- ) ) );
- }
- function toExtrude() {
- editor.execute( new SetGeometryCommand( editor, object, new THREE.ExtrudeGeometry(
- parameters.shapes, {
- curveSegments: curveSegments.getValue()
- }
- ) ) );
- }
- return container;
- }
- export { GeometryParametersPanel };
|