@thanhthbm/scene-editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +169 -0
  2. package/dist/index.css +921 -0
  3. package/dist/index.js +14076 -0
  4. package/package.json +49 -0
  5. package/src/editor/css/main.css +1030 -0
  6. package/src/editor/js/Animation.js +618 -0
  7. package/src/editor/js/AnimationResizer.js +73 -0
  8. package/src/editor/js/Command.js +40 -0
  9. package/src/editor/js/Config.js +86 -0
  10. package/src/editor/js/Editor.js +1006 -0
  11. package/src/editor/js/EditorControls.js +489 -0
  12. package/src/editor/js/GLTFImportDialog.js +112 -0
  13. package/src/editor/js/History.js +321 -0
  14. package/src/editor/js/Loader.js +1162 -0
  15. package/src/editor/js/LoaderUtils.js +90 -0
  16. package/src/editor/js/Menubar.Add.js +559 -0
  17. package/src/editor/js/Menubar.Edit.js +155 -0
  18. package/src/editor/js/Menubar.File.js +585 -0
  19. package/src/editor/js/Menubar.Help.js +73 -0
  20. package/src/editor/js/Menubar.Render.js +858 -0
  21. package/src/editor/js/Menubar.Status.js +51 -0
  22. package/src/editor/js/Menubar.View.js +193 -0
  23. package/src/editor/js/Menubar.js +29 -0
  24. package/src/editor/js/Player.js +53 -0
  25. package/src/editor/js/Resizer.js +65 -0
  26. package/src/editor/js/Script.js +532 -0
  27. package/src/editor/js/Selector.js +129 -0
  28. package/src/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
  29. package/src/editor/js/Sidebar.Geometry.BufferGeometry.js +124 -0
  30. package/src/editor/js/Sidebar.Geometry.CapsuleGeometry.js +109 -0
  31. package/src/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
  32. package/src/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
  33. package/src/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
  34. package/src/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
  35. package/src/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
  36. package/src/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
  37. package/src/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
  38. package/src/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
  39. package/src/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
  40. package/src/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
  41. package/src/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
  42. package/src/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
  43. package/src/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
  44. package/src/editor/js/Sidebar.Geometry.TextGeometry.js +136 -0
  45. package/src/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
  46. package/src/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
  47. package/src/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
  48. package/src/editor/js/Sidebar.Geometry.js +471 -0
  49. package/src/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
  50. package/src/editor/js/Sidebar.Material.ColorProperty.js +87 -0
  51. package/src/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
  52. package/src/editor/js/Sidebar.Material.MapProperty.js +277 -0
  53. package/src/editor/js/Sidebar.Material.NumberProperty.js +60 -0
  54. package/src/editor/js/Sidebar.Material.Program.js +73 -0
  55. package/src/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
  56. package/src/editor/js/Sidebar.Material.js +751 -0
  57. package/src/editor/js/Sidebar.Object.js +892 -0
  58. package/src/editor/js/Sidebar.Project.App.js +218 -0
  59. package/src/editor/js/Sidebar.Project.Materials.js +82 -0
  60. package/src/editor/js/Sidebar.Project.Renderer.js +193 -0
  61. package/src/editor/js/Sidebar.Project.Resources.js +242 -0
  62. package/src/editor/js/Sidebar.Project.js +21 -0
  63. package/src/editor/js/Sidebar.Properties.js +73 -0
  64. package/src/editor/js/Sidebar.Scene.js +643 -0
  65. package/src/editor/js/Sidebar.Script.js +129 -0
  66. package/src/editor/js/Sidebar.Settings.History.js +146 -0
  67. package/src/editor/js/Sidebar.Settings.Shortcuts.js +198 -0
  68. package/src/editor/js/Sidebar.Settings.js +58 -0
  69. package/src/editor/js/Sidebar.js +41 -0
  70. package/src/editor/js/Storage.js +98 -0
  71. package/src/editor/js/Strings.js +2718 -0
  72. package/src/editor/js/TextureParametersDialog.js +293 -0
  73. package/src/editor/js/Toolbar.js +75 -0
  74. package/src/editor/js/Viewport.Controls.js +98 -0
  75. package/src/editor/js/Viewport.Info.js +144 -0
  76. package/src/editor/js/Viewport.Pathtracer.js +27 -0
  77. package/src/editor/js/Viewport.ViewHelper.js +41 -0
  78. package/src/editor/js/Viewport.XR.js +7 -0
  79. package/src/editor/js/Viewport.js +982 -0
  80. package/src/editor/js/commands/AddObjectCommand.js +68 -0
  81. package/src/editor/js/commands/AddScriptCommand.js +75 -0
  82. package/src/editor/js/commands/Commands.js +24 -0
  83. package/src/editor/js/commands/MoveObjectCommand.js +117 -0
  84. package/src/editor/js/commands/MultiCmdsCommand.js +85 -0
  85. package/src/editor/js/commands/RemoveObjectCommand.js +88 -0
  86. package/src/editor/js/commands/RemoveScriptCommand.js +81 -0
  87. package/src/editor/js/commands/SetColorCommand.js +73 -0
  88. package/src/editor/js/commands/SetGeometryCommand.js +86 -0
  89. package/src/editor/js/commands/SetGeometryValueCommand.js +70 -0
  90. package/src/editor/js/commands/SetMaterialColorCommand.js +87 -0
  91. package/src/editor/js/commands/SetMaterialCommand.js +80 -0
  92. package/src/editor/js/commands/SetMaterialMapCommand.js +144 -0
  93. package/src/editor/js/commands/SetMaterialRangeCommand.js +92 -0
  94. package/src/editor/js/commands/SetMaterialValueCommand.js +91 -0
  95. package/src/editor/js/commands/SetMaterialVectorCommand.js +88 -0
  96. package/src/editor/js/commands/SetPositionCommand.js +84 -0
  97. package/src/editor/js/commands/SetRotationCommand.js +84 -0
  98. package/src/editor/js/commands/SetScaleCommand.js +84 -0
  99. package/src/editor/js/commands/SetSceneCommand.js +104 -0
  100. package/src/editor/js/commands/SetScriptValueCommand.js +80 -0
  101. package/src/editor/js/commands/SetShadowValueCommand.js +73 -0
  102. package/src/editor/js/commands/SetTextureParametersCommand.js +143 -0
  103. package/src/editor/js/commands/SetUuidCommand.js +70 -0
  104. package/src/editor/js/commands/SetValueCommand.js +75 -0
  105. package/src/editor/js/libs/acorn/acorn.js +3236 -0
  106. package/src/editor/js/libs/acorn/acorn_loose.js +1299 -0
  107. package/src/editor/js/libs/acorn/walk.js +344 -0
  108. package/src/editor/js/libs/app/index.html +51 -0
  109. package/src/editor/js/libs/app.js +14 -0
  110. package/src/editor/js/libs/codemirror/addon/dialog.css +32 -0
  111. package/src/editor/js/libs/codemirror/addon/dialog.js +163 -0
  112. package/src/editor/js/libs/codemirror/addon/show-hint.css +36 -0
  113. package/src/editor/js/libs/codemirror/addon/show-hint.js +529 -0
  114. package/src/editor/js/libs/codemirror/addon/tern.css +87 -0
  115. package/src/editor/js/libs/codemirror/addon/tern.js +750 -0
  116. package/src/editor/js/libs/codemirror/codemirror.css +344 -0
  117. package/src/editor/js/libs/codemirror/codemirror.js +9849 -0
  118. package/src/editor/js/libs/codemirror/mode/glsl.js +233 -0
  119. package/src/editor/js/libs/codemirror/mode/javascript.js +959 -0
  120. package/src/editor/js/libs/codemirror/theme/monokai.css +41 -0
  121. package/src/editor/js/libs/esprima.js +6401 -0
  122. package/src/editor/js/libs/jsonlint.js +453 -0
  123. package/src/editor/js/libs/signals.min.js +14 -0
  124. package/src/editor/js/libs/tern-threejs/build-defs.js +233 -0
  125. package/src/editor/js/libs/ternjs/comment.js +87 -0
  126. package/src/editor/js/libs/ternjs/def.js +588 -0
  127. package/src/editor/js/libs/ternjs/doc_comment.js +401 -0
  128. package/src/editor/js/libs/ternjs/infer.js +1635 -0
  129. package/src/editor/js/libs/ternjs/polyfill.js +80 -0
  130. package/src/editor/js/libs/ternjs/signal.js +26 -0
  131. package/src/editor/js/libs/ternjs/tern.js +993 -0
  132. package/src/editor/js/libs/ui.js +1305 -0
  133. package/src/editor/js/libs/ui.three.js +946 -0
  134. package/src/events.js +273 -0
  135. package/src/index.js +284 -0
  136. package/src/presets/machines.js +239 -0
@@ -0,0 +1,196 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UICheckbox, UIButton, UINumber } from './libs/ui.js';
4
+
5
+ import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
6
+
7
+ function GeometryParametersPanel( editor, object ) {
8
+
9
+ const strings = editor.strings;
10
+ const signals = editor.signals;
11
+
12
+ const container = new UIDiv();
13
+
14
+ const geometry = object.geometry;
15
+ const parameters = geometry.parameters;
16
+ const options = parameters.options;
17
+ options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12;
18
+ options.steps = options.steps != undefined ? options.steps : 1;
19
+ options.depth = options.depth != undefined ? options.depth : 1;
20
+ const bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 0.2;
21
+ options.bevelThickness = bevelThickness;
22
+ options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 0.1;
23
+ options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
24
+ options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
25
+
26
+
27
+ // curveSegments
28
+
29
+ const curveSegmentsRow = new UIRow();
30
+ const curveSegments = new UIInteger( options.curveSegments ).onChange( update ).setRange( 1, Infinity );
31
+
32
+ curveSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setClass( 'Label' ) );
33
+ curveSegmentsRow.add( curveSegments );
34
+
35
+ container.add( curveSegmentsRow );
36
+
37
+ // steps
38
+
39
+ const stepsRow = new UIRow();
40
+ const steps = new UIInteger( options.steps ).onChange( update ).setRange( 1, Infinity );
41
+
42
+ stepsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setClass( 'Label' ) );
43
+ stepsRow.add( steps );
44
+
45
+ container.add( stepsRow );
46
+
47
+ // depth
48
+
49
+ const depthRow = new UIRow();
50
+ const depth = new UINumber( options.depth ).onChange( update ).setRange( 1, Infinity );
51
+
52
+ depthRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setClass( 'Label' ) );
53
+ depthRow.add( depth );
54
+
55
+ container.add( depthRow );
56
+
57
+ // enabled
58
+
59
+ const enabledRow = new UIRow();
60
+ const enabled = new UICheckbox( options.bevelEnabled ).onChange( update );
61
+
62
+ enabledRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setClass( 'Label' ) );
63
+ enabledRow.add( enabled );
64
+
65
+ container.add( enabledRow );
66
+
67
+ // thickness
68
+
69
+ const thicknessRow = new UIRow();
70
+ const thickness = new UINumber( options.bevelThickness ).onChange( update );
71
+
72
+ thicknessRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setClass( 'Label' ) );
73
+ thicknessRow.add( thickness );
74
+
75
+ container.add( thicknessRow );
76
+
77
+ // size
78
+
79
+ const sizeRow = new UIRow();
80
+ const size = new UINumber( options.bevelSize ).onChange( update );
81
+
82
+ sizeRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setClass( 'Label' ) );
83
+ sizeRow.add( size );
84
+
85
+ container.add( sizeRow );
86
+
87
+ // offset
88
+
89
+ const offsetRow = new UIRow();
90
+ const offset = new UINumber( options.bevelOffset ).onChange( update );
91
+
92
+ offsetRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setClass( 'Label' ) );
93
+ offsetRow.add( offset );
94
+
95
+ container.add( offsetRow );
96
+
97
+ // segments
98
+
99
+ const segmentsRow = new UIRow();
100
+ const segments = new UIInteger( options.bevelSegments ).onChange( update ).setRange( 0, Infinity );
101
+
102
+ segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setClass( 'Label' ) );
103
+ segmentsRow.add( segments );
104
+
105
+ container.add( segmentsRow );
106
+
107
+ updateBevelRow( options.bevelEnabled );
108
+
109
+ const button = new UIButton( strings.getKey( 'sidebar/geometry/extrude_geometry/shape' ) ).onClick( toShape ).setClass( 'Label' ).setMarginLeft( '120px' );
110
+ container.add( button );
111
+
112
+ //
113
+
114
+ function updateBevelRow( enabled ) {
115
+
116
+ if ( enabled === true ) {
117
+
118
+ thicknessRow.setDisplay( '' );
119
+ sizeRow.setDisplay( '' );
120
+ offsetRow.setDisplay( '' );
121
+ segmentsRow.setDisplay( '' );
122
+
123
+ } else {
124
+
125
+ thicknessRow.setDisplay( 'none' );
126
+ sizeRow.setDisplay( 'none' );
127
+ offsetRow.setDisplay( 'none' );
128
+ segmentsRow.setDisplay( 'none' );
129
+
130
+ }
131
+
132
+ }
133
+
134
+ function refreshUI() {
135
+
136
+ const options = object.geometry.parameters.options;
137
+
138
+ curveSegments.setValue( options.curveSegments );
139
+ steps.setValue( options.steps );
140
+ depth.setValue( options.depth );
141
+ enabled.setValue( options.bevelEnabled );
142
+ thickness.setValue( options.bevelThickness );
143
+ size.setValue( options.bevelSize );
144
+ offset.setValue( options.bevelOffset );
145
+ segments.setValue( options.bevelSegments );
146
+
147
+ updateBevelRow( options.bevelEnabled );
148
+
149
+ }
150
+
151
+ signals.geometryChanged.add( function ( mesh ) {
152
+
153
+ if ( mesh === object ) {
154
+
155
+ refreshUI();
156
+
157
+ }
158
+
159
+ } );
160
+
161
+ //
162
+
163
+ function update() {
164
+
165
+ updateBevelRow( enabled.getValue() );
166
+
167
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.ExtrudeGeometry(
168
+ parameters.shapes,
169
+ {
170
+ curveSegments: curveSegments.getValue(),
171
+ steps: steps.getValue(),
172
+ depth: depth.getValue(),
173
+ bevelEnabled: enabled.getValue(),
174
+ bevelThickness: thickness !== undefined ? thickness.getValue() : options.bevelThickness,
175
+ bevelSize: size !== undefined ? size.getValue() : options.bevelSize,
176
+ bevelOffset: offset !== undefined ? offset.getValue() : options.bevelOffset,
177
+ bevelSegments: segments !== undefined ? segments.getValue() : options.bevelSegments
178
+ }
179
+ ) ) );
180
+
181
+ }
182
+
183
+ function toShape() {
184
+
185
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.ShapeGeometry(
186
+ parameters.shapes,
187
+ options.curveSegments
188
+ ) ) );
189
+
190
+ }
191
+
192
+ return container;
193
+
194
+ }
195
+
196
+ export { GeometryParametersPanel };
@@ -0,0 +1,73 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
4
+
5
+ import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
6
+
7
+ function GeometryParametersPanel( editor, object ) {
8
+
9
+ const strings = editor.strings;
10
+ const signals = editor.signals;
11
+
12
+ const container = new UIDiv();
13
+
14
+ const geometry = object.geometry;
15
+ const parameters = geometry.parameters;
16
+
17
+ // radius
18
+
19
+ const radiusRow = new UIRow();
20
+ const radius = new UINumber( parameters.radius ).onChange( update );
21
+
22
+ radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/icosahedron_geometry/radius' ) ).setClass( 'Label' ) );
23
+ radiusRow.add( radius );
24
+
25
+ container.add( radiusRow );
26
+
27
+ // detail
28
+
29
+ const detailRow = new UIRow();
30
+ const detail = new UIInteger( parameters.detail ).setRange( 0, Infinity ).onChange( update );
31
+
32
+ detailRow.add( new UIText( strings.getKey( 'sidebar/geometry/icosahedron_geometry/detail' ) ).setClass( 'Label' ) );
33
+ detailRow.add( detail );
34
+
35
+ container.add( detailRow );
36
+
37
+ //
38
+
39
+ function refreshUI() {
40
+
41
+ const parameters = object.geometry.parameters;
42
+
43
+ radius.setValue( parameters.radius );
44
+ detail.setValue( parameters.detail );
45
+
46
+ }
47
+
48
+ signals.geometryChanged.add( function ( mesh ) {
49
+
50
+ if ( mesh === object ) {
51
+
52
+ refreshUI();
53
+
54
+ }
55
+
56
+ } );
57
+
58
+ //
59
+
60
+ function update() {
61
+
62
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.IcosahedronGeometry(
63
+ radius.getValue(),
64
+ detail.getValue()
65
+ ) ) );
66
+
67
+ }
68
+
69
+ return container;
70
+
71
+ }
72
+
73
+ export { GeometryParametersPanel };
@@ -0,0 +1,98 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
4
+ import { UIPoints2 } from './libs/ui.three.js';
5
+
6
+ import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
7
+
8
+ function GeometryParametersPanel( editor, object ) {
9
+
10
+ const strings = editor.strings;
11
+ const signals = editor.signals;
12
+
13
+ const container = new UIDiv();
14
+
15
+ const geometry = object.geometry;
16
+ const parameters = geometry.parameters;
17
+
18
+ // segments
19
+
20
+ const segmentsRow = new UIRow();
21
+ const segments = new UIInteger( parameters.segments ).onChange( update );
22
+
23
+ segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/segments' ) ).setClass( 'Label' ) );
24
+ segmentsRow.add( segments );
25
+
26
+ container.add( segmentsRow );
27
+
28
+ // phiStart
29
+
30
+ const phiStartRow = new UIRow();
31
+ const phiStart = new UINumber( parameters.phiStart * THREE.MathUtils.RAD2DEG ).onChange( update );
32
+
33
+ phiStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/phistart' ) ).setClass( 'Label' ) );
34
+ phiStartRow.add( phiStart );
35
+
36
+ container.add( phiStartRow );
37
+
38
+ // phiLength
39
+
40
+ const phiLengthRow = new UIRow();
41
+ const phiLength = new UINumber( parameters.phiLength * THREE.MathUtils.RAD2DEG ).onChange( update );
42
+
43
+ phiLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/philength' ) ).setClass( 'Label' ) );
44
+ phiLengthRow.add( phiLength );
45
+
46
+ container.add( phiLengthRow );
47
+
48
+ // points
49
+
50
+ const pointsRow = new UIRow();
51
+ pointsRow.add( new UIText( strings.getKey( 'sidebar/geometry/lathe_geometry/points' ) ).setClass( 'Label' ) );
52
+
53
+ const points = new UIPoints2().setValue( parameters.points ).onChange( update );
54
+ pointsRow.add( points );
55
+
56
+ container.add( pointsRow );
57
+
58
+ //
59
+
60
+ function refreshUI() {
61
+
62
+ const parameters = object.geometry.parameters;
63
+
64
+ points.setValue( parameters.points, false );
65
+ segments.setValue( parameters.segments );
66
+ phiStart.setValue( parameters.phiStart * THREE.MathUtils.RAD2DEG );
67
+ phiLength.setValue( parameters.phiLength * THREE.MathUtils.RAD2DEG );
68
+
69
+ }
70
+
71
+ signals.geometryChanged.add( function ( mesh ) {
72
+
73
+ if ( mesh === object ) {
74
+
75
+ refreshUI();
76
+
77
+ }
78
+
79
+ } );
80
+
81
+ //
82
+
83
+ function update() {
84
+
85
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.LatheGeometry(
86
+ points.getValue(),
87
+ segments.getValue(),
88
+ phiStart.getValue() * THREE.MathUtils.DEG2RAD,
89
+ phiLength.getValue() * THREE.MathUtils.DEG2RAD
90
+ ) ) );
91
+
92
+ }
93
+
94
+ return container;
95
+
96
+ }
97
+
98
+ export { GeometryParametersPanel };
@@ -0,0 +1,73 @@
1
+ import { UIDiv, UIButton, UIRow } from './libs/ui.js';
2
+
3
+ import { computeMikkTSpaceTangents } from 'three/addons/utils/BufferGeometryUtils.js';
4
+ import * as MikkTSpace from 'three/addons/libs/mikktspace.module.js';
5
+
6
+ function SidebarGeometryModifiers( editor, object ) {
7
+
8
+ const strings = editor.strings;
9
+
10
+ const signals = editor.signals;
11
+
12
+ const container = new UIDiv().setMarginLeft( '120px' );
13
+
14
+ const geometry = object.geometry;
15
+
16
+ // Compute Vertex Normals
17
+
18
+ const computeVertexNormalsButton = new UIButton( strings.getKey( 'sidebar/geometry/compute_vertex_normals' ) );
19
+ computeVertexNormalsButton.onClick( function () {
20
+
21
+ geometry.computeVertexNormals();
22
+
23
+ signals.geometryChanged.dispatch( object );
24
+
25
+ } );
26
+
27
+ const computeVertexNormalsRow = new UIRow();
28
+ computeVertexNormalsRow.add( computeVertexNormalsButton );
29
+ container.add( computeVertexNormalsRow );
30
+
31
+ // Compute Vertex Tangents
32
+
33
+ if ( geometry.hasAttribute( 'position' ) && geometry.hasAttribute( 'normal' ) && geometry.hasAttribute( 'uv' ) ) {
34
+
35
+ const computeVertexTangentsButton = new UIButton( strings.getKey( 'sidebar/geometry/compute_vertex_tangents' ) );
36
+ computeVertexTangentsButton.onClick( async function () {
37
+
38
+ await MikkTSpace.ready;
39
+
40
+ computeMikkTSpaceTangents( geometry, MikkTSpace );
41
+
42
+ signals.geometryChanged.dispatch( object );
43
+
44
+ } );
45
+
46
+ const computeVertexTangentsRow = new UIRow();
47
+ computeVertexTangentsRow.add( computeVertexTangentsButton );
48
+ container.add( computeVertexTangentsRow );
49
+
50
+ }
51
+
52
+ // Center Geometry
53
+
54
+ const centerButton = new UIButton( strings.getKey( 'sidebar/geometry/center' ) );
55
+ centerButton.onClick( function () {
56
+
57
+ geometry.center();
58
+
59
+ signals.geometryChanged.dispatch( object );
60
+
61
+ } );
62
+
63
+ const centerRow = new UIRow();
64
+ centerRow.add( centerButton );
65
+ container.add( centerRow );
66
+
67
+ //
68
+
69
+ return container;
70
+
71
+ }
72
+
73
+ export { SidebarGeometryModifiers };
@@ -0,0 +1,74 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
4
+
5
+ import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
6
+
7
+ function GeometryParametersPanel( editor, object ) {
8
+
9
+ const strings = editor.strings;
10
+
11
+ const signals = editor.signals;
12
+
13
+ const container = new UIDiv();
14
+
15
+ const geometry = object.geometry;
16
+ const parameters = geometry.parameters;
17
+
18
+ // radius
19
+
20
+ const radiusRow = new UIRow();
21
+ const radius = new UINumber( parameters.radius ).onChange( update );
22
+
23
+ radiusRow.add( new UIText( strings.getKey( 'sidebar/geometry/octahedron_geometry/radius' ) ).setClass( 'Label' ) );
24
+ radiusRow.add( radius );
25
+
26
+ container.add( radiusRow );
27
+
28
+ // detail
29
+
30
+ const detailRow = new UIRow();
31
+ const detail = new UIInteger( parameters.detail ).setRange( 0, Infinity ).onChange( update );
32
+
33
+ detailRow.add( new UIText( strings.getKey( 'sidebar/geometry/octahedron_geometry/detail' ) ).setClass( 'Label' ) );
34
+ detailRow.add( detail );
35
+
36
+ container.add( detailRow );
37
+
38
+ //
39
+
40
+ function refreshUI() {
41
+
42
+ const parameters = object.geometry.parameters;
43
+
44
+ radius.setValue( parameters.radius );
45
+ detail.setValue( parameters.detail );
46
+
47
+ }
48
+
49
+ signals.geometryChanged.add( function ( mesh ) {
50
+
51
+ if ( mesh === object ) {
52
+
53
+ refreshUI();
54
+
55
+ }
56
+
57
+ } );
58
+
59
+ //
60
+
61
+ function update() {
62
+
63
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.OctahedronGeometry(
64
+ radius.getValue(),
65
+ detail.getValue()
66
+ ) ) );
67
+
68
+ }
69
+
70
+ return container;
71
+
72
+ }
73
+
74
+ export { GeometryParametersPanel };
@@ -0,0 +1,97 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
4
+
5
+ import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
6
+
7
+ function GeometryParametersPanel( editor, object ) {
8
+
9
+ const strings = editor.strings;
10
+ const signals = editor.signals;
11
+
12
+ const container = new UIDiv();
13
+
14
+ const geometry = object.geometry;
15
+ const parameters = geometry.parameters;
16
+
17
+ // width
18
+
19
+ const widthRow = new UIRow();
20
+ const width = new UINumber( parameters.width ).onChange( update );
21
+
22
+ widthRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/width' ) ).setClass( 'Label' ) );
23
+ widthRow.add( width );
24
+
25
+ container.add( widthRow );
26
+
27
+ // height
28
+
29
+ const heightRow = new UIRow();
30
+ const height = new UINumber( parameters.height ).onChange( update );
31
+
32
+ heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/height' ) ).setClass( 'Label' ) );
33
+ heightRow.add( height );
34
+
35
+ container.add( heightRow );
36
+
37
+ // widthSegments
38
+
39
+ const widthSegmentsRow = new UIRow();
40
+ const widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
41
+
42
+ widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/widthsegments' ) ).setClass( 'Label' ) );
43
+ widthSegmentsRow.add( widthSegments );
44
+
45
+ container.add( widthSegmentsRow );
46
+
47
+ // heightSegments
48
+
49
+ const heightSegmentsRow = new UIRow();
50
+ const heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
51
+
52
+ heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/plane_geometry/heightsegments' ) ).setClass( 'Label' ) );
53
+ heightSegmentsRow.add( heightSegments );
54
+
55
+ container.add( heightSegmentsRow );
56
+
57
+ //
58
+
59
+ function refreshUI() {
60
+
61
+ const parameters = object.geometry.parameters;
62
+
63
+ width.setValue( parameters.width );
64
+ height.setValue( parameters.height );
65
+ widthSegments.setValue( parameters.widthSegments );
66
+ heightSegments.setValue( parameters.heightSegments );
67
+
68
+ }
69
+
70
+ signals.geometryChanged.add( function ( mesh ) {
71
+
72
+ if ( mesh === object ) {
73
+
74
+ refreshUI();
75
+
76
+ }
77
+
78
+ } );
79
+
80
+ //
81
+
82
+ function update() {
83
+
84
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.PlaneGeometry(
85
+ width.getValue(),
86
+ height.getValue(),
87
+ widthSegments.getValue(),
88
+ heightSegments.getValue()
89
+ ) ) );
90
+
91
+ }
92
+
93
+ return container;
94
+
95
+ }
96
+
97
+ export { GeometryParametersPanel };