forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSidebar.Geometry.TorusGeometry.js
85 lines (51 loc) · 2.27 KB
/
Sidebar.Geometry.TorusGeometry.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
import * as THREE from 'three';
import { UIDiv, UIRow, UIText, UIInteger, 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;
// radius
const radiusRow = new UIRow();
const radius = new UINumber( parameters.radius ).onChange( update );
radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/radius' ) ).setClass( 'Label' ) );
radiusRow.add( radius );
container.add( radiusRow );
// tube
const tubeRow = new UIRow();
const tube = new UINumber( parameters.tube ).onChange( update );
tubeRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/tube' ) ).setClass( 'Label' ) );
tubeRow.add( tube );
container.add( tubeRow );
// radialSegments
const radialSegmentsRow = new UIRow();
const radialSegments = new UIInteger( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
radialSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/radialsegments' ) ).setClass( 'Label' ) );
radialSegmentsRow.add( radialSegments );
container.add( radialSegmentsRow );
// tubularSegments
const tubularSegmentsRow = new UIRow();
const tubularSegments = new UIInteger( parameters.tubularSegments ).setRange( 1, Infinity ).onChange( update );
tubularSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/tubularsegments' ) ).setClass( 'Label' ) );
tubularSegmentsRow.add( tubularSegments );
container.add( tubularSegmentsRow );
// arc
const arcRow = new UIRow();
const arc = new UINumber( parameters.arc * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
arcRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/arc' ) ).setClass( 'Label' ) );
arcRow.add( arc );
container.add( arcRow );
//
function update() {
editor.execute( new SetGeometryCommand( editor, object, new THREE.TorusGeometry(
radius.getValue(),
tube.getValue(),
radialSegments.getValue(),
tubularSegments.getValue(),
arc.getValue() * THREE.MathUtils.DEG2RAD
) ) );
}
return container;
}
export { GeometryParametersPanel };