@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,218 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { zipSync, strToU8 } from 'three/addons/libs/fflate.module.js';
4
+
5
+ import { UIButton, UICheckbox, UIPanel, UIInput, UIRow, UIText } from './libs/ui.js';
6
+
7
+ function SidebarProjectApp( editor ) {
8
+
9
+ const config = editor.config;
10
+ const signals = editor.signals;
11
+ const strings = editor.strings;
12
+
13
+ const save = editor.utils.save;
14
+
15
+ const container = new UIPanel();
16
+ container.setId( 'app' );
17
+
18
+ const headerRow = new UIRow();
19
+ headerRow.add( new UIText( strings.getKey( 'sidebar/project/app' ).toUpperCase() ) );
20
+ container.add( headerRow );
21
+
22
+ // Title
23
+
24
+ const titleRow = new UIRow();
25
+ const title = new UIInput( config.getKey( 'project/title' ) ).setLeft( '100px' ).setWidth( '150px' ).onChange( function () {
26
+
27
+ config.setKey( 'project/title', this.getValue() );
28
+
29
+ } );
30
+
31
+ titleRow.add( new UIText( strings.getKey( 'sidebar/project/app/title' ) ).setClass( 'Label' ) );
32
+ titleRow.add( title );
33
+
34
+ container.add( titleRow );
35
+
36
+ // Editable
37
+
38
+ const editableRow = new UIRow();
39
+ const editable = new UICheckbox( config.getKey( 'project/editable' ) ).setLeft( '100px' ).onChange( function () {
40
+
41
+ config.setKey( 'project/editable', this.getValue() );
42
+
43
+ } );
44
+
45
+ editableRow.add( new UIText( strings.getKey( 'sidebar/project/app/editable' ) ).setClass( 'Label' ) );
46
+ editableRow.add( editable );
47
+
48
+ container.add( editableRow );
49
+
50
+ // Play/Stop
51
+
52
+ let isPlaying = false;
53
+
54
+ const playButton = new UIButton( strings.getKey( 'sidebar/project/app/play' ) );
55
+ playButton.setWidth( '170px' );
56
+ playButton.setMarginLeft( '120px' );
57
+ playButton.setMarginBottom( '10px' );
58
+ playButton.onClick( function () {
59
+
60
+ if ( isPlaying === false ) {
61
+
62
+ isPlaying = true;
63
+ playButton.setTextContent( strings.getKey( 'sidebar/project/app/stop' ) );
64
+ signals.startPlayer.dispatch();
65
+
66
+ } else {
67
+
68
+ isPlaying = false;
69
+ playButton.setTextContent( strings.getKey( 'sidebar/project/app/play' ) );
70
+ signals.stopPlayer.dispatch();
71
+
72
+ }
73
+
74
+ } );
75
+
76
+ container.add( playButton );
77
+
78
+ // Publish
79
+
80
+ const publishButton = new UIButton( strings.getKey( 'sidebar/project/app/publish' ) );
81
+ publishButton.setWidth( '170px' );
82
+ publishButton.setMarginLeft( '120px' );
83
+ publishButton.setMarginBottom( '10px' );
84
+ publishButton.onClick( function () {
85
+
86
+ const toZip = {};
87
+
88
+ const rendererType = config.getKey( 'project/renderer/type' );
89
+
90
+ //
91
+
92
+ let output = editor.toJSON();
93
+ output.metadata.type = 'App';
94
+ delete output.history;
95
+
96
+ output = JSON.stringify( output, null, '\t' );
97
+ output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
98
+
99
+ toZip[ 'app.json' ] = strToU8( output );
100
+
101
+ //
102
+
103
+ const title = config.getKey( 'project/title' );
104
+
105
+ const manager = new THREE.LoadingManager( function () {
106
+
107
+ const zipped = zipSync( toZip, { level: 9 } );
108
+
109
+ const blob = new Blob( [ zipped.buffer ], { type: 'application/zip' } );
110
+
111
+ save( blob, ( title !== '' ? title : 'untitled' ) + '.zip' );
112
+
113
+ } );
114
+
115
+ const loader = new THREE.FileLoader( manager );
116
+ loader.load( 'js/libs/app/index.html', function ( content ) {
117
+
118
+ content = content.replace( '<!-- title -->', title );
119
+
120
+ //
121
+
122
+ const IMPORTMAP = {
123
+ WebGLRenderer: {
124
+ imports: {
125
+ 'three': './js/three.module.js'
126
+ }
127
+ },
128
+ WebGPURenderer: {
129
+ imports: {
130
+ 'three': './js/three.webgpu.js',
131
+ 'three/webgpu': './js/three.webgpu.js'
132
+ }
133
+ }
134
+ };
135
+ const importmap = JSON.stringify( IMPORTMAP[ rendererType ], null, '\t' );
136
+ content = content.replace( '<!-- importmap -->', indent( '\n' + indent( importmap, 1 ) + '\n', 2 ) );
137
+
138
+ //
139
+
140
+ let editButton = '';
141
+
142
+ if ( config.getKey( 'project/editable' ) ) {
143
+
144
+ editButton = [
145
+ ' let button = document.createElement( \'a\' );',
146
+ ' button.href = \'https://threejs.org/editor/#file=\' + location.href.split( \'/\' ).slice( 0, - 1 ).join( \'/\' ) + \'/app.json\';',
147
+ ' button.style.cssText = \'position: absolute; bottom: 20px; right: 20px; padding: 10px 16px; color: #fff; border: 1px solid #fff; border-radius: 20px; text-decoration: none;\';',
148
+ ' button.target = \'_blank\';',
149
+ ' button.textContent = \'EDIT\';',
150
+ ' document.body.appendChild( button );',
151
+ ].join( '\n' );
152
+
153
+ }
154
+
155
+ content = content.replace( '\t\t\t/* edit button */', editButton );
156
+
157
+ toZip[ 'index.html' ] = strToU8( content );
158
+
159
+ } );
160
+ loader.load( 'js/libs/app.js', function ( content ) {
161
+
162
+ toZip[ 'js/app.js' ] = strToU8( content );
163
+
164
+ } );
165
+ loader.load( '../build/three.core.js', function ( content ) {
166
+
167
+ toZip[ 'js/three.core.js' ] = strToU8( content );
168
+
169
+ } );
170
+
171
+ if ( rendererType === 'WebGPURenderer' ) {
172
+
173
+ loader.load( '../build/three.webgpu.js', function ( content ) {
174
+
175
+ toZip[ 'js/three.webgpu.js' ] = strToU8( content );
176
+
177
+ } );
178
+
179
+ } else {
180
+
181
+ loader.load( '../build/three.module.js', function ( content ) {
182
+
183
+ toZip[ 'js/three.module.js' ] = strToU8( content );
184
+
185
+ } );
186
+
187
+ }
188
+
189
+ } );
190
+ container.add( publishButton );
191
+
192
+ // Signals
193
+
194
+ signals.editorCleared.add( function () {
195
+
196
+ title.setValue( '' );
197
+ config.setKey( 'project/title', '' );
198
+
199
+ } );
200
+
201
+ return container;
202
+
203
+ }
204
+
205
+ //
206
+
207
+ function indent( text, count, space = '\t' ) {
208
+
209
+ return text
210
+ .split( '\n' )
211
+ .map( line => space.repeat( count ) + line )
212
+ .join( '\n' );
213
+
214
+ }
215
+
216
+ //
217
+
218
+ export { SidebarProjectApp };
@@ -0,0 +1,82 @@
1
+ import { UIBreak, UIPanel, UIRow, UIText, UIListbox, UIButton } from './libs/ui.js';
2
+
3
+ import { SetMaterialCommand } from './commands/SetMaterialCommand.js';
4
+
5
+ function SidebarProjectMaterials( editor ) {
6
+
7
+ const signals = editor.signals;
8
+ const strings = editor.strings;
9
+
10
+ const container = new UIPanel();
11
+
12
+ const headerRow = new UIRow();
13
+ headerRow.add( new UIText( strings.getKey( 'sidebar/project/materials' ).toUpperCase() ) );
14
+
15
+ container.add( headerRow );
16
+
17
+ const listbox = new UIListbox();
18
+ container.add( listbox );
19
+
20
+ container.add( new UIBreak() );
21
+
22
+ const buttonsRow = new UIRow();
23
+ container.add( buttonsRow );
24
+
25
+ const assignMaterial = new UIButton( strings.getKey( 'sidebar/project/Assign' ) );
26
+ assignMaterial.onClick( function () {
27
+
28
+ const selectedObject = editor.selected;
29
+
30
+ if ( selectedObject !== null ) {
31
+
32
+ const oldMaterial = selectedObject.material;
33
+
34
+ // only passing materials to objects with a material property (e.g. avoid assigning material to THREE.Group)
35
+
36
+ if ( oldMaterial !== undefined ) {
37
+
38
+ const material = editor.getMaterialById( parseInt( listbox.getValue() ) );
39
+
40
+ if ( material !== undefined ) {
41
+
42
+ editor.removeMaterial( oldMaterial );
43
+ editor.execute( new SetMaterialCommand( editor, selectedObject, material ) );
44
+ editor.addMaterial( material );
45
+
46
+ }
47
+
48
+ }
49
+
50
+ }
51
+
52
+ } );
53
+ buttonsRow.add( assignMaterial );
54
+
55
+ // Signals
56
+
57
+ function refreshMaterialBrowserUI() {
58
+
59
+ listbox.setItems( Object.values( editor.materials ) );
60
+
61
+ }
62
+
63
+ signals.objectSelected.add( function ( object ) {
64
+
65
+ if ( object !== null ) {
66
+
67
+ const index = Object.values( editor.materials ).indexOf( object.material );
68
+ listbox.selectIndex( index );
69
+
70
+ }
71
+
72
+ } );
73
+
74
+ signals.materialAdded.add( refreshMaterialBrowserUI );
75
+ signals.materialChanged.add( refreshMaterialBrowserUI );
76
+ signals.materialRemoved.add( refreshMaterialBrowserUI );
77
+
78
+ return container;
79
+
80
+ }
81
+
82
+ export { SidebarProjectMaterials };
@@ -0,0 +1,193 @@
1
+ import * as THREE from 'three';
2
+
3
+ import { UINumber, UIPanel, UIRow, UISelect, UIText } from './libs/ui.js';
4
+ import { UIBoolean } from './libs/ui.three.js';
5
+
6
+ function SidebarProjectRenderer( editor ) {
7
+
8
+ const config = editor.config;
9
+ const signals = editor.signals;
10
+ const strings = editor.strings;
11
+
12
+ let currentRenderer = null;
13
+
14
+ const container = new UIPanel();
15
+ container.setBorderTop( '0px' );
16
+
17
+ // Camera
18
+
19
+ const cameraRow = new UIRow();
20
+ container.add( cameraRow );
21
+
22
+ cameraRow.add( new UIText( strings.getKey( 'sidebar/project/camera' ) ).setClass( 'Label' ) );
23
+
24
+ const cameraTypeSelect = new UISelect().setOptions( {
25
+ 'perspective': 'Perspective',
26
+ 'orthographic': 'Orthographic'
27
+ } ).setWidth( '150px' ).onChange( function () {
28
+
29
+ editor.setCameraType( this.getValue() );
30
+
31
+ } );
32
+ cameraTypeSelect.setValue( config.getKey( 'project/camera' ) );
33
+ cameraRow.add( cameraTypeSelect );
34
+
35
+ if ( config.getKey( 'project/camera' ) === 'orthographic' ) {
36
+
37
+ editor.setCameraType( 'orthographic' );
38
+
39
+ }
40
+
41
+ // Renderer
42
+
43
+ const rendererRow = new UIRow();
44
+ container.add( rendererRow );
45
+
46
+ rendererRow.add( new UIText( strings.getKey( 'sidebar/project/renderer' ) ).setClass( 'Label' ) );
47
+
48
+ const rendererTypeSelect = new UISelect().setOptions( {
49
+ 'WebGLRenderer': 'WebGL'
50
+ } ).setWidth( '150px' ).onChange( createRenderer );
51
+ rendererTypeSelect.setValue( config.getKey( 'project/renderer/type' ) );
52
+ rendererRow.add( rendererTypeSelect );
53
+
54
+ // Antialias
55
+
56
+ const antialiasRow = new UIRow();
57
+ container.add( antialiasRow );
58
+
59
+ antialiasRow.add( new UIText( strings.getKey( 'sidebar/project/antialias' ) ).setClass( 'Label' ) );
60
+
61
+ const antialiasBoolean = new UIBoolean( config.getKey( 'project/renderer/antialias' ) ).onChange( createRenderer );
62
+ antialiasRow.add( antialiasBoolean );
63
+
64
+ // Shadows
65
+
66
+ const shadowsRow = new UIRow();
67
+ container.add( shadowsRow );
68
+
69
+ shadowsRow.add( new UIText( strings.getKey( 'sidebar/project/shadows' ) ).setClass( 'Label' ) );
70
+
71
+ const shadowsBoolean = new UIBoolean( config.getKey( 'project/renderer/shadows' ) ).onChange( updateShadows );
72
+ shadowsRow.add( shadowsBoolean );
73
+
74
+ const shadowTypeSelect = new UISelect().setOptions( {
75
+ 0: 'Basic',
76
+ 1: 'PCF',
77
+ 3: 'VSM'
78
+ } ).setWidth( '125px' ).onChange( updateShadows );
79
+ shadowTypeSelect.setValue( config.getKey( 'project/renderer/shadowType' ) );
80
+ shadowsRow.add( shadowTypeSelect );
81
+
82
+ function updateShadows() {
83
+
84
+ currentRenderer.shadowMap.enabled = shadowsBoolean.getValue();
85
+ currentRenderer.shadowMap.type = parseFloat( shadowTypeSelect.getValue() );
86
+
87
+ signals.rendererUpdated.dispatch();
88
+
89
+ }
90
+
91
+ // Tonemapping
92
+
93
+ const toneMappingRow = new UIRow();
94
+ container.add( toneMappingRow );
95
+
96
+ toneMappingRow.add( new UIText( strings.getKey( 'sidebar/project/toneMapping' ) ).setClass( 'Label' ) );
97
+
98
+ const toneMappingSelect = new UISelect().setOptions( {
99
+ 0: 'No',
100
+ 1: 'Linear',
101
+ 2: 'Reinhard',
102
+ 3: 'Cineon',
103
+ 4: 'ACESFilmic',
104
+ 6: 'AgX',
105
+ 7: 'Neutral'
106
+ } ).setWidth( '120px' ).onChange( updateToneMapping );
107
+ toneMappingSelect.setValue( config.getKey( 'project/renderer/toneMapping' ) );
108
+ toneMappingRow.add( toneMappingSelect );
109
+
110
+ const toneMappingExposure = new UINumber( config.getKey( 'project/renderer/toneMappingExposure' ) );
111
+ toneMappingExposure.setDisplay( toneMappingSelect.getValue() === '0' ? 'none' : '' );
112
+ toneMappingExposure.setWidth( '30px' ).setMarginLeft( '10px' );
113
+ toneMappingExposure.setRange( 0, 10 );
114
+ toneMappingExposure.onChange( updateToneMapping );
115
+ toneMappingRow.add( toneMappingExposure );
116
+
117
+ function updateToneMapping() {
118
+
119
+ toneMappingExposure.setDisplay( toneMappingSelect.getValue() === '0' ? 'none' : '' );
120
+
121
+ currentRenderer.toneMapping = parseFloat( toneMappingSelect.getValue() );
122
+ currentRenderer.toneMappingExposure = toneMappingExposure.getValue();
123
+ signals.rendererUpdated.dispatch();
124
+
125
+ }
126
+
127
+ //
128
+
129
+ function createRenderer() {
130
+
131
+ const antialias = antialiasBoolean.getValue();
132
+
133
+ currentRenderer = new THREE.WebGLRenderer( { antialias: antialias, reversedDepthBuffer: true } );
134
+
135
+ currentRenderer.shadowMap.enabled = shadowsBoolean.getValue();
136
+ currentRenderer.shadowMap.type = parseFloat( shadowTypeSelect.getValue() );
137
+ currentRenderer.toneMapping = parseFloat( toneMappingSelect.getValue() );
138
+ currentRenderer.toneMappingExposure = toneMappingExposure.getValue();
139
+
140
+ signals.rendererCreated.dispatch( currentRenderer );
141
+ signals.rendererUpdated.dispatch();
142
+
143
+ }
144
+
145
+ createRenderer();
146
+
147
+
148
+ // Signals
149
+
150
+ signals.cameraResetted.add( function () {
151
+
152
+ const type = editor.camera.isOrthographicCamera ? 'orthographic' : 'perspective';
153
+
154
+ cameraTypeSelect.setValue( type );
155
+ config.setKey( 'project/camera', type );
156
+
157
+ } );
158
+
159
+ signals.editorCleared.add( function () {
160
+
161
+ currentRenderer.shadowMap.enabled = true;
162
+ currentRenderer.shadowMap.type = THREE.PCFShadowMap;
163
+ currentRenderer.toneMapping = THREE.NeutralToneMapping;
164
+ currentRenderer.toneMappingExposure = 1;
165
+
166
+ shadowsBoolean.setValue( currentRenderer.shadowMap.enabled );
167
+ shadowTypeSelect.setValue( currentRenderer.shadowMap.type );
168
+ toneMappingSelect.setValue( currentRenderer.toneMapping );
169
+ toneMappingExposure.setValue( currentRenderer.toneMappingExposure );
170
+ toneMappingExposure.setDisplay( currentRenderer.toneMapping === 0 ? 'none' : '' );
171
+
172
+ signals.rendererUpdated.dispatch();
173
+
174
+ } );
175
+
176
+ signals.rendererUpdated.add( function () {
177
+
178
+ config.setKey(
179
+ 'project/renderer/type', rendererTypeSelect.getValue(),
180
+ 'project/renderer/antialias', antialiasBoolean.getValue(),
181
+ 'project/renderer/shadows', shadowsBoolean.getValue(),
182
+ 'project/renderer/shadowType', parseFloat( shadowTypeSelect.getValue() ),
183
+ 'project/renderer/toneMapping', parseFloat( toneMappingSelect.getValue() ),
184
+ 'project/renderer/toneMappingExposure', toneMappingExposure.getValue()
185
+ );
186
+
187
+ } );
188
+
189
+ return container;
190
+
191
+ }
192
+
193
+ export { SidebarProjectRenderer };