@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,121 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UINumber, UIInteger } 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().setPrecision( 3 ).setValue( parameters.width ).onChange( update );
21
+
22
+ widthRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_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().setPrecision( 3 ).setValue( parameters.height ).onChange( update );
31
+
32
+ heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/height' ) ).setClass( 'Label' ) );
33
+ heightRow.add( height );
34
+
35
+ container.add( heightRow );
36
+
37
+ // depth
38
+
39
+ const depthRow = new UIRow();
40
+ const depth = new UINumber().setPrecision( 3 ).setValue( parameters.depth ).onChange( update );
41
+
42
+ depthRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/depth' ) ).setClass( 'Label' ) );
43
+ depthRow.add( depth );
44
+
45
+ container.add( depthRow );
46
+
47
+ // widthSegments
48
+
49
+ const widthSegmentsRow = new UIRow();
50
+ const widthSegments = new UIInteger( parameters.widthSegments ).setRange( 1, Infinity ).onChange( update );
51
+
52
+ widthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/widthseg' ) ).setClass( 'Label' ) );
53
+ widthSegmentsRow.add( widthSegments );
54
+
55
+ container.add( widthSegmentsRow );
56
+
57
+ // heightSegments
58
+
59
+ const heightSegmentsRow = new UIRow();
60
+ const heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
61
+
62
+ heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/heightseg' ) ).setClass( 'Label' ) );
63
+ heightSegmentsRow.add( heightSegments );
64
+
65
+ container.add( heightSegmentsRow );
66
+
67
+ // depthSegments
68
+
69
+ const depthSegmentsRow = new UIRow();
70
+ const depthSegments = new UIInteger( parameters.depthSegments ).setRange( 1, Infinity ).onChange( update );
71
+
72
+ depthSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/box_geometry/depthseg' ) ).setClass( 'Label' ) );
73
+ depthSegmentsRow.add( depthSegments );
74
+
75
+ container.add( depthSegmentsRow );
76
+
77
+ //
78
+
79
+ function refreshUI() {
80
+
81
+ const parameters = object.geometry.parameters;
82
+
83
+ width.setValue( parameters.width );
84
+ height.setValue( parameters.height );
85
+ depth.setValue( parameters.depth );
86
+ widthSegments.setValue( parameters.widthSegments );
87
+ heightSegments.setValue( parameters.heightSegments );
88
+ depthSegments.setValue( parameters.depthSegments );
89
+
90
+ }
91
+
92
+ signals.geometryChanged.add( function ( mesh ) {
93
+
94
+ if ( mesh === object ) {
95
+
96
+ refreshUI();
97
+
98
+ }
99
+
100
+ } );
101
+
102
+ //
103
+
104
+ function update() {
105
+
106
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.BoxGeometry(
107
+ width.getValue(),
108
+ height.getValue(),
109
+ depth.getValue(),
110
+ widthSegments.getValue(),
111
+ heightSegments.getValue(),
112
+ depthSegments.getValue()
113
+ ) ) );
114
+
115
+ }
116
+
117
+ return container;
118
+
119
+ }
120
+
121
+ export { GeometryParametersPanel };
@@ -0,0 +1,124 @@
1
+ import { UIRow, UIText, UISpan, UIBreak, UICheckbox } from './libs/ui.js';
2
+
3
+ function SidebarGeometryBufferGeometry( editor ) {
4
+
5
+ const strings = editor.strings;
6
+
7
+ const signals = editor.signals;
8
+
9
+ const container = new UIRow();
10
+
11
+ function update( object ) {
12
+
13
+ if ( object === null ) return; // objectSelected.dispatch( null )
14
+ if ( object === undefined ) return;
15
+
16
+ const geometry = object.geometry;
17
+
18
+ if ( geometry ) {
19
+
20
+ container.clear();
21
+ container.setDisplay( 'block' );
22
+
23
+ // attributes
24
+
25
+ const attributesRow = new UIRow();
26
+
27
+ const textAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass( 'Label' );
28
+ attributesRow.add( textAttributes );
29
+
30
+ const containerAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
31
+ attributesRow.add( containerAttributes );
32
+
33
+ const index = geometry.index;
34
+
35
+ if ( index !== null ) {
36
+
37
+ containerAttributes.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '70px' ) );
38
+ containerAttributes.add( new UIText( editor.utils.formatNumber( index.count ) ).setFontSize( '12px' ) );
39
+ containerAttributes.add( new UIBreak() );
40
+
41
+ }
42
+
43
+ const attributes = geometry.attributes;
44
+
45
+ for ( const name in attributes ) {
46
+
47
+ const attribute = attributes[ name ];
48
+
49
+ containerAttributes.add( new UIText( name ).setWidth( '70px' ) );
50
+
51
+ let info = editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')';
52
+
53
+ if ( attribute.isInterleavedBufferAttribute ) {
54
+
55
+ info += ' (' + attribute.data.stride + ')';
56
+
57
+ }
58
+
59
+ containerAttributes.add( new UIText( info ).setFontSize( '12px' ) );
60
+ containerAttributes.add( new UIBreak() );
61
+
62
+ }
63
+
64
+ container.add( attributesRow );
65
+
66
+ // morph targets
67
+
68
+ const morphAttributes = geometry.morphAttributes;
69
+ const hasMorphTargets = Object.keys( morphAttributes ).length > 0;
70
+
71
+ if ( hasMorphTargets === true ) {
72
+
73
+ // morph attributes
74
+
75
+ const rowMorphAttributes = new UIRow();
76
+
77
+ const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass( 'Label' );
78
+ rowMorphAttributes.add( textMorphAttributes );
79
+
80
+ const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
81
+ rowMorphAttributes.add( containerMorphAttributes );
82
+
83
+ for ( const name in morphAttributes ) {
84
+
85
+ const morphTargets = morphAttributes[ name ];
86
+
87
+ containerMorphAttributes.add( new UIText( name ).setWidth( '70px' ) );
88
+ containerMorphAttributes.add( new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize( '12px' ) );
89
+ containerMorphAttributes.add( new UIBreak() );
90
+
91
+ }
92
+
93
+ container.add( rowMorphAttributes );
94
+
95
+ // morph relative
96
+
97
+ const rowMorphRelative = new UIRow();
98
+
99
+ const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass( 'Label' );
100
+ rowMorphRelative.add( textMorphRelative );
101
+
102
+ const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
103
+ rowMorphRelative.add( checkboxMorphRelative );
104
+
105
+ container.add( rowMorphRelative );
106
+
107
+ }
108
+
109
+ } else {
110
+
111
+ container.setDisplay( 'none' );
112
+
113
+ }
114
+
115
+ }
116
+
117
+ signals.objectSelected.add( update );
118
+ signals.geometryChanged.add( update );
119
+
120
+ return container;
121
+
122
+ }
123
+
124
+ export { SidebarGeometryBufferGeometry };
@@ -0,0 +1,109 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UINumber, UIInteger } 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/capsule_geometry/radius' ) ).setClass( 'Label' ) );
23
+ radiusRow.add( radius );
24
+
25
+ container.add( radiusRow );
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/capsule_geometry/height' ) ).setClass( 'Label' ) );
33
+ heightRow.add( height );
34
+
35
+ container.add( heightRow );
36
+
37
+ // capSegments
38
+
39
+ const capSegmentsRow = new UIRow();
40
+ const capSegments = new UIInteger( parameters.capSegments ).setRange( 1, Infinity ).onChange( update );
41
+
42
+ capSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/capseg' ) ).setClass( 'Label' ) );
43
+ capSegmentsRow.add( capSegments );
44
+
45
+ container.add( capSegmentsRow );
46
+
47
+ // radialSegments
48
+
49
+ const radialSegmentsRow = new UIRow();
50
+ const radialSegments = new UIInteger( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
51
+
52
+ radialSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/radialseg' ) ).setClass( 'Label' ) );
53
+ radialSegmentsRow.add( radialSegments );
54
+
55
+ container.add( radialSegmentsRow );
56
+
57
+ // heightSegments
58
+
59
+ const heightSegmentsRow = new UIRow();
60
+ const heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
61
+
62
+ heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/capsule_geometry/heightseg' ) ).setClass( 'Label' ) );
63
+ heightSegmentsRow.add( heightSegments );
64
+
65
+ container.add( heightSegmentsRow );
66
+
67
+ //
68
+
69
+ function refreshUI() {
70
+
71
+ const parameters = object.geometry.parameters;
72
+
73
+ radius.setValue( parameters.radius );
74
+ height.setValue( parameters.height );
75
+ capSegments.setValue( parameters.capSegments );
76
+ radialSegments.setValue( parameters.radialSegments );
77
+ heightSegments.setValue( parameters.heightSegments );
78
+
79
+ }
80
+
81
+ signals.geometryChanged.add( function ( mesh ) {
82
+
83
+ if ( mesh === object ) {
84
+
85
+ refreshUI();
86
+
87
+ }
88
+
89
+ } );
90
+
91
+ //
92
+
93
+ function update() {
94
+
95
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.CapsuleGeometry(
96
+ radius.getValue(),
97
+ height.getValue(),
98
+ capSegments.getValue(),
99
+ radialSegments.getValue(),
100
+ heightSegments.getValue()
101
+ ) ) );
102
+
103
+ }
104
+
105
+ return container;
106
+
107
+ }
108
+
109
+ 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
+ // 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/circle_geometry/radius' ) ).setClass( 'Label' ) );
23
+ radiusRow.add( radius );
24
+
25
+ container.add( radiusRow );
26
+
27
+ // segments
28
+
29
+ const segmentsRow = new UIRow();
30
+ const segments = new UIInteger( parameters.segments ).setRange( 3, Infinity ).onChange( update );
31
+
32
+ segmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/segments' ) ).setClass( 'Label' ) );
33
+ segmentsRow.add( segments );
34
+
35
+ container.add( segmentsRow );
36
+
37
+ // thetaStart
38
+
39
+ const thetaStartRow = new UIRow();
40
+ const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );
41
+
42
+ thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetastart' ) ).setClass( 'Label' ) );
43
+ thetaStartRow.add( thetaStart );
44
+
45
+ container.add( thetaStartRow );
46
+
47
+ // thetaLength
48
+
49
+ const thetaLengthRow = new UIRow();
50
+ const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );
51
+
52
+ thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetalength' ) ).setClass( 'Label' ) );
53
+ thetaLengthRow.add( thetaLength );
54
+
55
+ container.add( thetaLengthRow );
56
+
57
+ //
58
+
59
+ function refreshUI() {
60
+
61
+ const parameters = object.geometry.parameters;
62
+
63
+ radius.setValue( parameters.radius );
64
+ segments.setValue( parameters.segments );
65
+ thetaStart.setValue( parameters.thetaStart * THREE.MathUtils.RAD2DEG );
66
+ thetaLength.setValue( parameters.thetaLength * THREE.MathUtils.RAD2DEG );
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.CircleGeometry(
85
+ radius.getValue(),
86
+ segments.getValue(),
87
+ thetaStart.getValue() * THREE.MathUtils.DEG2RAD,
88
+ thetaLength.getValue() * THREE.MathUtils.DEG2RAD
89
+ ) ) );
90
+
91
+ }
92
+
93
+ return container;
94
+
95
+ }
96
+
97
+ export { GeometryParametersPanel };
@@ -0,0 +1,121 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UIDiv, UIRow, UIText, UIInteger, UICheckbox, 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
+ // radiusTop
18
+
19
+ const radiusTopRow = new UIRow();
20
+ const radiusTop = new UINumber( parameters.radiusTop ).onChange( update );
21
+
22
+ radiusTopRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radiustop' ) ).setClass( 'Label' ) );
23
+ radiusTopRow.add( radiusTop );
24
+
25
+ container.add( radiusTopRow );
26
+
27
+ // radiusBottom
28
+
29
+ const radiusBottomRow = new UIRow();
30
+ const radiusBottom = new UINumber( parameters.radiusBottom ).onChange( update );
31
+
32
+ radiusBottomRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radiusbottom' ) ).setClass( 'Label' ) );
33
+ radiusBottomRow.add( radiusBottom );
34
+
35
+ container.add( radiusBottomRow );
36
+
37
+ // height
38
+
39
+ const heightRow = new UIRow();
40
+ const height = new UINumber( parameters.height ).onChange( update );
41
+
42
+ heightRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/height' ) ).setClass( 'Label' ) );
43
+ heightRow.add( height );
44
+
45
+ container.add( heightRow );
46
+
47
+ // radialSegments
48
+
49
+ const radialSegmentsRow = new UIRow();
50
+ const radialSegments = new UIInteger( parameters.radialSegments ).setRange( 1, Infinity ).onChange( update );
51
+
52
+ radialSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/radialsegments' ) ).setClass( 'Label' ) );
53
+ radialSegmentsRow.add( radialSegments );
54
+
55
+ container.add( radialSegmentsRow );
56
+
57
+ // heightSegments
58
+
59
+ const heightSegmentsRow = new UIRow();
60
+ const heightSegments = new UIInteger( parameters.heightSegments ).setRange( 1, Infinity ).onChange( update );
61
+
62
+ heightSegmentsRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/heightsegments' ) ).setClass( 'Label' ) );
63
+ heightSegmentsRow.add( heightSegments );
64
+
65
+ container.add( heightSegmentsRow );
66
+
67
+ // openEnded
68
+
69
+ const openEndedRow = new UIRow();
70
+ const openEnded = new UICheckbox( parameters.openEnded ).onChange( update );
71
+
72
+ openEndedRow.add( new UIText( strings.getKey( 'sidebar/geometry/cylinder_geometry/openended' ) ).setClass( 'Label' ) );
73
+ openEndedRow.add( openEnded );
74
+
75
+ container.add( openEndedRow );
76
+
77
+ //
78
+
79
+ function refreshUI() {
80
+
81
+ const parameters = object.geometry.parameters;
82
+
83
+ radiusTop.setValue( parameters.radiusTop );
84
+ radiusBottom.setValue( parameters.radiusBottom );
85
+ height.setValue( parameters.height );
86
+ radialSegments.setValue( parameters.radialSegments );
87
+ heightSegments.setValue( parameters.heightSegments );
88
+ openEnded.setValue( parameters.openEnded );
89
+
90
+ }
91
+
92
+ signals.geometryChanged.add( function ( mesh ) {
93
+
94
+ if ( mesh === object ) {
95
+
96
+ refreshUI();
97
+
98
+ }
99
+
100
+ } );
101
+
102
+ //
103
+
104
+ function update() {
105
+
106
+ editor.execute( new SetGeometryCommand( editor, object, new THREE.CylinderGeometry(
107
+ radiusTop.getValue(),
108
+ radiusBottom.getValue(),
109
+ height.getValue(),
110
+ radialSegments.getValue(),
111
+ heightSegments.getValue(),
112
+ openEnded.getValue()
113
+ ) ) );
114
+
115
+ }
116
+
117
+ return container;
118
+
119
+ }
120
+
121
+ 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/dodecahedron_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/dodecahedron_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.DodecahedronGeometry(
63
+ radius.getValue(),
64
+ detail.getValue()
65
+ ) ) );
66
+
67
+ }
68
+
69
+ return container;
70
+
71
+ }
72
+
73
+ export { GeometryParametersPanel };