forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSidebar.Geometry.ExtrudeGeometry.js
147 lines (94 loc) · 4.47 KB
/
Sidebar.Geometry.ExtrudeGeometry.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import * as THREE from 'three';
import { UIDiv, UIRow, UIText, UIInteger, UICheckbox, UIButton, UINumber } from './libs/ui.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;
const options = parameters.options;
options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12;
options.steps = options.steps != undefined ? options.steps : 1;
options.depth = options.depth != undefined ? options.depth : 100;
options.bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4;
options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
// curveSegments
const curveSegmentsRow = new UIRow();
const curveSegments = new UIInteger( options.curveSegments ).onChange( update ).setRange( 1, Infinity );
curveSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setClass( 'Label' ) );
curveSegmentsRow.add( curveSegments );
container.add( curveSegmentsRow );
// steps
const stepsRow = new UIRow();
const steps = new UIInteger( options.steps ).onChange( update ).setRange( 1, Infinity );
stepsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setClass( 'Label' ) );
stepsRow.add( steps );
container.add( stepsRow );
// depth
const depthRow = new UIRow();
const depth = new UINumber( options.depth ).onChange( update ).setRange( 1, Infinity );
depthRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setClass( 'Label' ) );
depthRow.add( depth );
container.add( depthRow );
// enabled
const enabledRow = new UIRow();
const enabled = new UICheckbox( options.bevelEnabled ).onChange( update );
enabledRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setClass( 'Label' ) );
enabledRow.add( enabled );
container.add( enabledRow );
let thickness, size, offset, segments;
if ( options.bevelEnabled === true ) {
// thickness
const thicknessRow = new UIRow();
thickness = new UINumber( options.bevelThickness ).onChange( update );
thicknessRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setClass( 'Label' ) );
thicknessRow.add( thickness );
container.add( thicknessRow );
// size
const sizeRow = new UIRow();
size = new UINumber( options.bevelSize ).onChange( update );
sizeRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setClass( 'Label' ) );
sizeRow.add( size );
container.add( sizeRow );
// offset
const offsetRow = new UIRow();
offset = new UINumber( options.bevelOffset ).onChange( update );
offsetRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setClass( 'Label' ) );
offsetRow.add( offset );
container.add( offsetRow );
// segments
const segmentsRow = new UIRow();
segments = new UIInteger( options.bevelSegments ).onChange( update ).setRange( 0, Infinity );
segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setClass( 'Label' ) );
segmentsRow.add( segments );
container.add( segmentsRow );
}
const button = new UIButton( strings.getKey( 'sidebar/geometry/extrude_geometry/shape' ) ).onClick( toShape ).setClass( 'Label' ).setMarginLeft( '120px' );
container.add( button );
//
function update() {
editor.execute( new SetGeometryCommand( editor, object, new THREE.ExtrudeGeometry(
parameters.shapes,
{
curveSegments: curveSegments.getValue(),
steps: steps.getValue(),
depth: depth.getValue(),
bevelEnabled: enabled.getValue(),
bevelThickness: options.bevelThickness,
bevelSize: size !== undefined ? size.getValue() : options.bevelSize,
bevelOffset: offset !== undefined ? offset.getValue() : options.bevelOffset,
bevelSegments: segments !== undefined ? segments.getValue() : options.bevelSegments
}
) ) );
}
function toShape() {
editor.execute( new SetGeometryCommand( editor, object, new THREE.ShapeGeometry(
parameters.shapes,
options.curveSegments
) ) );
}
return container;
}
export { GeometryParametersPanel };