forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSidebar.Geometry.LatheGeometry.js
72 lines (44 loc) · 1.93 KB
/
Sidebar.Geometry.LatheGeometry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as THREE from 'three';
import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
import { UIPoints2 } from './libs/ui.three.js';
import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
function GeometryParametersPanel( editor, object ) {
const strings = editor.strings;
const container = new UIDiv();
const geometry = object.geometry;
const parameters = geometry.parameters;
// segments
const segmentsRow = new UIRow();
const segments = new UIInteger( parameters.segments ).onChange( update );
segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/segments' ) ).setClass( 'Label' ) );
segmentsRow.add( segments );
container.add( segmentsRow );
// phiStart
const phiStartRow = new UIRow();
const phiStart = new UINumber( parameters.phiStart * 180 / Math.PI ).onChange( update );
phiStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/phistart' ) ).setClass( 'Label' ) );
phiStartRow.add( phiStart );
container.add( phiStartRow );
// phiLength
const phiLengthRow = new UIRow();
const phiLength = new UINumber( parameters.phiLength * 180 / Math.PI ).onChange( update );
phiLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/philength' ) ).setClass( 'Label' ) );
phiLengthRow.add( phiLength );
container.add( phiLengthRow );
// points
const pointsRow = new UIRow();
pointsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/points' ) ).setClass( 'Label' ) );
const points = new UIPoints2().setValue( parameters.points ).onChange( update );
pointsRow.add( points );
container.add( pointsRow );
function update() {
editor.execute( new SetGeometryCommand( editor, object, new THREE.LatheGeometry(
points.getValue(),
segments.getValue(),
phiStart.getValue() / 180 * Math.PI,
phiLength.getValue() / 180 * Math.PI
) ) );
}
return container;
}
export { GeometryParametersPanel };