sunrize 2.7.1 → 2.8.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 (49) hide show
  1. package/package.json +5 -5
  2. package/src/Application/Document.js +123 -1
  3. package/src/Application/Footer.js +1 -3
  4. package/src/Application/Registry.js +29 -22
  5. package/src/Controls/AddPrototypePopover.js +1 -1
  6. package/src/Controls/AnimationPropertiesPopover.js +3 -3
  7. package/src/Controls/EditNodePopover.js +3 -3
  8. package/src/Controls/EditUserDefinedFieldPopover.js +3 -3
  9. package/src/Controls/ExportNodePopover.js +2 -2
  10. package/src/Controls/ImportNodePopover.js +2 -2
  11. package/src/Controls/MaterialPreviewPopover.js +5 -6
  12. package/src/Controls/SetOrientationPopover.js +1 -1
  13. package/src/Controls/Splitter.js +3 -3
  14. package/src/Controls/TexturePreviewPopover.js +1 -0
  15. package/src/Editors/AnimationEditor.js +16 -8
  16. package/src/Editors/AnimationMemberList.js +1 -0
  17. package/src/Editors/BrowserFrame.js +10 -10
  18. package/src/Editors/Console.js +1 -1
  19. package/src/Editors/Library.js +1 -1
  20. package/src/Editors/MaterialsLibrary.js +9 -4
  21. package/src/Editors/OutlineEditor.js +101 -64
  22. package/src/Editors/OutlineRouteGraph.js +7 -5
  23. package/src/Editors/OutlineView.js +3 -3
  24. package/src/Editors/SceneProperties.js +12 -12
  25. package/src/Editors/ScriptEditor.js +1 -1
  26. package/src/Editors/VideoRecorder.js +415 -51
  27. package/src/Tools/Core/X3DNodeTool.js +4 -5
  28. package/src/Tools/EnvironmentalSensor/X3DEnvironmentalSensorNodeTool.x3d +5 -1
  29. package/src/Tools/Geometry2D/Arc2DTool.js +1 -0
  30. package/src/Tools/Geometry2D/ArcClose2DTool.js +1 -0
  31. package/src/Tools/Geometry2D/Circle2DTool.js +1 -0
  32. package/src/Tools/Geometry2D/Disk2DTool.js +2 -0
  33. package/src/Tools/Geometry2D/Rectangle2DTool.js +1 -0
  34. package/src/Tools/Geometry3D/BoxTool.js +1 -0
  35. package/src/Tools/Geometry3D/ConeTool.js +1 -0
  36. package/src/Tools/Geometry3D/CylinderTool.js +1 -0
  37. package/src/Tools/Geometry3D/SphereTool.js +1 -0
  38. package/src/Tools/Grouping/X3DTransformNodeTool.js +5 -21
  39. package/src/Tools/Grouping/X3DTransformNodeTool.x3d +11 -3
  40. package/src/Tools/Lighting/X3DLightNodeTool.x3d +18 -12
  41. package/src/Tools/Navigation/X3DViewpointNodeTool.x3d +2 -0
  42. package/src/Tools/Rendering/X3DGeometryNodeTool.x3d +1 -1
  43. package/src/Tools/Sound/ListenerPointSourceTool.x3d +8 -2
  44. package/src/Tools/Sound/SoundTool.x3d +10 -0
  45. package/src/Tools/Sound/SpatialSoundTool.x3d +8 -2
  46. package/src/Tools/TextureProjection/X3DTextureProjectorNodeTool.x3d +2 -0
  47. package/src/Undo/Editor.js +33 -21
  48. package/src/assets/html/window.html +1 -1
  49. package/src/assets/themes/default.css +107 -21
@@ -3,75 +3,302 @@
3
3
 
4
4
  const
5
5
  $ = require ("jquery"),
6
+ X3D = require ("../X3D"),
6
7
  Interface = require ("../Application/Interface"),
8
+ Splitter = require ("../Controls/Splitter"),
7
9
  electron = require ("electron"),
10
+ path = require ("path"),
11
+ url = require ("url"),
8
12
  fs = require ("fs"),
9
13
  _ = require ("../Application/GetText");
10
14
 
11
15
  module .exports = class VideoRecorder extends Interface
12
16
  {
13
- static mimeTypes = [
14
- ["MP4", "video/mp4", "mp4"],
15
- ["WebM", "video/webm", "webm"],
16
- ["OGG", "video/ogg", "ogv"],
17
+ static formats = [
18
+ { name: "MP4", mimeType: "video/mp4", ext: "mp4" },
19
+ { name: "WebM", mimeType: "video/webm", ext: "webm" },
20
+ { name: "OGG", mimeType: "video/ogg", ext: "ogv" },
21
+ ];
22
+
23
+ static filters = [
24
+ {
25
+ name: _("Video"),
26
+ extensions: ["mp4", "webm", "ogv"],
27
+ },
17
28
  ];
18
29
 
19
30
  constructor (element)
20
31
  {
21
32
  super (`Sunrize.VideoRecorder.${element .attr ("id")}.`);
22
33
 
23
- this .recorder = element;
34
+ this .videoRecorder = element;
35
+
36
+ const maxRenderbufferSize = this .browser .getRenderingProperty ("MaxRenderbufferSize");
37
+
38
+ // Video Recorder Panel
39
+
40
+ this .verticalSplitter = $("<div></div>")
41
+ .attr ("id", "video-recorder-left")
42
+ .addClass (["video-recorder-left", "vertical-splitter"])
43
+ .appendTo (this .videoRecorder);
44
+
45
+ this .verticalSplitterLeft = $("<div></div>")
46
+ .addClass (["video-recorder-settings-panel", "vertical-splitter-left"])
47
+ .css ("width", "30%")
48
+ .appendTo (this .verticalSplitter);
49
+
50
+ this .verticalSplitterRight = $("<div></div>")
51
+ .addClass (["video-recorder-record-panel", "vertical-splitter-right"])
52
+ .css ("width", "70%")
53
+ .appendTo (this .verticalSplitter);
54
+
55
+ this .vSplitter = new Splitter (this .verticalSplitter, "vertical");
56
+
57
+ this .vSplitter .snapToBorder = true;
58
+
59
+ this .vSplitter .handle .on ("position", () => this .splitterPosition ());
60
+
61
+ // Settings
62
+
63
+ this .settings = $("<div></div>")
64
+ .addClass ("video-recorder-settings")
65
+ .appendTo (this .verticalSplitterLeft);
66
+
67
+ $("<span></span>")
68
+ .addClass ("header")
69
+ .text (_("Video Settings"))
70
+ .appendTo (this .settings);
71
+
72
+ $("<span></span>")
73
+ .text (_("Width"))
74
+ .appendTo (this .settings);
75
+
76
+ this .width = $("<input>")
77
+ .addClass ("settings")
78
+ .attr ("title", _("Width in Pixels"))
79
+ .attr ("type", "number")
80
+ .attr ("min", 1)
81
+ .attr ("max", maxRenderbufferSize)
82
+ .attr ("step", "1")
83
+ .attr ("placeholder", _("Enter a number."))
84
+ .on ("change input", () => this .config .file .width = this .width .val ())
85
+ .on ("change input", () => this .resizeFrame ())
86
+ .on ("change input", () => this .verifySettings ())
87
+ .appendTo (this .settings);
88
+
89
+ $("<span></span>")
90
+ .text (_("Height"))
91
+ .appendTo (this .settings);
92
+
93
+ this .height = $("<input>")
94
+ .addClass ("settings")
95
+ .attr ("title", _("Height in Pixels"))
96
+ .attr ("type", "number")
97
+ .attr ("min", 1)
98
+ .attr ("max", maxRenderbufferSize)
99
+ .attr ("step", "1")
100
+ .attr ("placeholder", _("Enter a number."))
101
+ .on ("change input", () => this .config .file .height = this .height .val ())
102
+ .on ("change input", () => this .resizeFrame ())
103
+ .on ("change input", () => this .verifySettings ())
104
+ .appendTo (this .settings);
105
+
106
+ $("<span></span>")
107
+ .text (_("Duration"))
108
+ .appendTo (this .settings);
109
+
110
+ this .duration = $("<input>")
111
+ .addClass ("settings")
112
+ .attr ("title", _("Duration in Seconds"))
113
+ .attr ("type", "number")
114
+ .attr ("min", 1)
115
+ .attr ("step", "1")
116
+ .attr ("placeholder", _("Enter a number."))
117
+ .on ("change input", () => this .config .file .duration = this .duration .val ())
118
+ .on ("change input", () => this .verifySettings ())
119
+ .appendTo (this .settings);
120
+
121
+ $("<span></span>")
122
+ .text (_("File Type"))
123
+ .appendTo (this .settings);
124
+
125
+ this .fileType = $("<select></select>")
126
+ .addClass ("settings")
127
+ .on ("change", () => this .config .file .fileType = this .fileType .val ())
128
+ .on ("change", () => this .changeFileType ())
129
+ .appendTo (this .settings);
130
+
131
+ for (const [index, { name, mimeType }] of VideoRecorder .formats .entries ())
132
+ {
133
+ if (!MediaRecorder .isTypeSupported (mimeType))
134
+ continue;
24
135
 
25
- this .left = $("<div></div>")
26
- .addClass ("video-recorder-left")
27
- .appendTo (this .recorder);
136
+ $("<option></option>")
137
+ .text (name)
138
+ .val (index)
139
+ .appendTo (this .fileType);
140
+ }
28
141
 
29
- // Toolbar
142
+ $("<span></span>")
143
+ .text (_("Filename"))
144
+ .appendTo (this .settings);
30
145
 
31
- this .toolbar = $("<div></div>")
32
- .addClass (["toolbar", "vertical-toolbar", "secondary-toolbar", "video-recorder-toolbar"])
33
- .appendTo (this .recorder);
146
+ this .filenameBox = $("<div></div>")
147
+ .addClass ("filename-box")
148
+ .appendTo (this .settings);
34
149
 
35
- this .setup ();
36
- }
150
+ this .filename = $("<input>")
151
+ .addClass ("settings")
152
+ .attr ("placeholder", _("Enter a filename."))
153
+ .on ("change input", () => this .config .file .filename = this .getFilename ())
154
+ .on ("change input", () => this .verifySettings ())
155
+ .appendTo (this .filenameBox);
37
156
 
38
- #desktop;
157
+ this .fileChooser = $("<span></span>")
158
+ .addClass (["file-chooser", "button", "material-symbols-outlined"])
159
+ .attr ("title", _("Choose a file."))
160
+ .text ("file_save")
161
+ .appendTo (this .filenameBox)
162
+ .on ("click", () => this .chooseFile ());
39
163
 
40
- async initialize ()
41
- {
42
- this .#desktop = await electron .ipcRenderer .invoke ("path", "desktop");
164
+ // Fills remaining empty space.
165
+ $("<span></span>")
166
+ .css ("flex", 1)
167
+ .appendTo (this .settings);
168
+
169
+ // Record Panel
170
+
171
+ this .recordFrame = $("<div></div>")
172
+ .addClass ("video-recorder-record-frame")
173
+ .appendTo (this .verticalSplitterRight);
174
+
175
+ this .aspectFrame = $("<div></div>")
176
+ .addClass ("video-recorder-aspect-frame")
177
+ .appendTo (this .recordFrame);
178
+
179
+ this .frameObserver = new ResizeObserver (() => this .resizeFrame ());
180
+ this .frameObserver .observe (this .verticalSplitterRight [0]);
181
+
182
+ // Time
183
+
184
+ this .time = $("<div></div>")
185
+ .addClass (["time", "mini-tip", "visible"]);
43
186
 
44
187
  // Toolbar
45
188
 
189
+ this .toolbar = $("<div></div>")
190
+ .addClass (["toolbar", "vertical-toolbar", "secondary-toolbar", "video-recorder-toolbar"])
191
+ .appendTo (this .videoRecorder);
192
+
193
+ this .toggleSidebarButton = $("<span></span>")
194
+ .addClass ("material-symbols-outlined")
195
+ .attr ("title", _("Toggle sidebar."))
196
+ .text ("dock_to_right")
197
+ .appendTo (this .toolbar)
198
+ .on ("click", () => this .toggleSidebar ());
199
+
200
+ $("<span></span>") .addClass ("separator") .appendTo (this .toolbar);
201
+
46
202
  this .recordButton = $("<span></span>")
47
- .addClass (["material-symbols-outlined"])
203
+ .addClass (["disabled", "material-symbols-outlined"])
48
204
  .attr ("title", _("Start recording."))
49
205
  .text ("screen_record")
50
206
  .on ("click", () => this .toggleRecord ())
51
207
  .appendTo (this .toolbar);
52
208
 
53
- this .settingsButton = $("<span></span>")
54
- .addClass (["material-symbols-outlined"])
55
- .attr ("title", _("Edit settings."))
56
- .text ("settings")
57
- .on ("click", () => this .showSettings ())
58
- .appendTo (this .toolbar);
209
+ this .setup ();
210
+ }
59
211
 
60
- this .mimeTypeButton = $("<select></select>");
212
+ configure ()
213
+ {
214
+ super .configure ();
215
+
216
+ this .config .file .setDefaultValues ({
217
+ width: 1920,
218
+ height: 1080,
219
+ duration: 60,
220
+ fileType: 0,
221
+ filename: "",
222
+ });
61
223
 
62
- for (const [name, mimeType] of VideoRecorder .mimeTypes)
63
- {
64
- if (!MediaRecorder .isTypeSupported (mimeType))
65
- continue;
224
+ this .width .val (this .config .file .width);
225
+ this .height .val (this .config .file .height);
226
+ this .duration .val (this .config .file .duration);
227
+ this .fileType .val (this .config .file .fileType);
228
+ this .filename .val (this .config .file .filename);
66
229
 
67
- $("<option></option>")
68
- .text (name)
69
- .val (mimeType)
70
- .appendTo (this .mimeTypeButton);
71
- }
230
+ this .verifySettings ();
231
+ this .resizeFrame ();
232
+ this .showVideoPlayer ();
72
233
  }
73
234
 
235
+ getFilename ()
236
+ {
237
+ return this .filename .val () .trim ();
238
+ }
239
+
240
+ changeFileType ()
241
+ {
242
+ if (!this .getFilename ())
243
+ return;
244
+
245
+ const newFilename = path .format ({
246
+ ... path .parse (this .getFilename ()),
247
+ base: undefined,
248
+ ext: "." + VideoRecorder .formats [this .fileType .val ()] .ext,
249
+ });
250
+
251
+ this .filename .val (newFilename);
252
+ }
253
+
254
+ async chooseFile ()
255
+ {
256
+ const
257
+ worldURL = new URL (this .browser .currentScene .getWorldURL ()),
258
+ name = worldURL .protocol === "data:" ? _("New Scene") : path .parse (worldURL .pathname) .name,
259
+ ext = VideoRecorder .formats [this .fileType .val ()] .ext,
260
+ defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (worldURL))),
261
+ desktop = await electron .ipcRenderer .invoke ("path", "desktop"),
262
+ defaultPath = path .join (defaultDirectory ?? desktop, `${name}.${ext}`),
263
+ filters = VideoRecorder .filters,
264
+ response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath, filters });
265
+
266
+ if (response .canceled)
267
+ return;
268
+
269
+ this .filename .val (response .filePath);
270
+
271
+ this .config .file .filename = response .filePath;
272
+
273
+ this .verifySettings ();
274
+ }
275
+
276
+ verifySettings ()
277
+ {
278
+ const
279
+ width = this .width .val ()|0,
280
+ height = this .height .val ()|0,
281
+ duration = this .duration .val ()|0,
282
+ filename = this .getFilename (),
283
+ maxRenderbufferSize = this .browser .getRenderingProperty ("MaxRenderbufferSize");
284
+
285
+ let ok = true;
286
+
287
+ ok &&= width > 0 && width < maxRenderbufferSize;
288
+ ok &&= height > 0 && height < maxRenderbufferSize;
289
+ ok &&= duration > 0;
290
+ ok &&= filename;
291
+
292
+ if (ok)
293
+ this .recordButton .removeClass ("disabled");
294
+ else
295
+ this .recordButton .addClass ("disabled");
296
+ }
297
+
298
+ #recordCanvas;
299
+ #recordBrowser;
74
300
  #record = false;
301
+ #recordTime;
75
302
  #timeoutId;
76
303
  #mimeType;
77
304
  #recorder;
@@ -87,17 +314,93 @@ module .exports = class VideoRecorder extends Interface
87
314
 
88
315
  async startRecord ()
89
316
  {
90
- const stream = this .browser .getElement () .captureStream (30);
317
+ const
318
+ width = this .width .val ()|0,
319
+ height = this .height .val ()|0,
320
+ duration = this .duration .val ()|0;
321
+
322
+ // Disable settings.
323
+
324
+ this .recordButton .addClass ("active");
325
+ this .settings .find ("input") .attr ("readonly", "");
326
+ this .settings .find ("select") .attr ("disabled", "");
327
+ this .settings .find (".button") .addClass ("disabled");
328
+
329
+ // Create browser.
330
+
331
+ this .aspectFrame .empty () .css ({
332
+ "max-width": "fit-content",
333
+ "max-height": "fit-content",
334
+ });
335
+
336
+ this .#recordCanvas = $(`<x3d-canvas splashScreen="false"></x3d-canvas>`) .appendTo (this .aspectFrame);
337
+ this .#recordBrowser = this .#recordCanvas .prop ("browser");
338
+
339
+ this .#recordBrowser .setBrowserOption ("Notifications", false);
340
+ this .#recordBrowser .setBrowserOption ("Timings", false);
341
+ this .#recordBrowser .setBrowserOption ("ContextMenu", false);
342
+ this .#recordBrowser .setBrowserOption ("Mute", true);
343
+ this .#recordBrowser .setBrowserOption ("XRSessionMode", "NONE");
344
+
345
+ const options = [
346
+ "Antialiased",
347
+ "ColorSpace",
348
+ "Exposure",
349
+ "LogarithmicDepthBuffer",
350
+ "Multisampling",
351
+ "OrderIndependentTransparency",
352
+ "PrimitiveQuality",
353
+ "QualityWhenMoving",
354
+ "TextCompression",
355
+ "TextureQuality",
356
+ "ToneMapping",
357
+ ];
358
+
359
+ for (const option of options)
360
+ this .#recordBrowser .setBrowserOption (option, this .browser .getBrowserOption (option));
361
+
362
+ this .#recordBrowser .endUpdate ();
91
363
 
92
- this .#timeoutId = setTimeout (() => this .stopRecord (), 60_000);
93
- this .#mimeType = this .mimeTypeButton .val ();
364
+ const fileURL = this .browser .currentScene .worldURL .startsWith ("data:")
365
+ ? new X3D .MFString (encodeURI (`data:model/x3d+xml,${this .browser .currentScene .toXMLString ()}`))
366
+ : new X3D .MFString (this .browser .getWorldURL ());
367
+
368
+ await this .#recordBrowser .resize (width, height);
369
+ await this .#recordBrowser .loadURL (fileURL);
370
+ this .resizeFrame ();
371
+
372
+ this .#recordBrowser .beginUpdate ();
373
+ this .#recordBrowser .addBrowserEvent ();
374
+
375
+ this .time .text (duration) .appendTo (this .aspectFrame);
376
+
377
+ this .#recordBrowser .prepareEvents () .addFieldCallback (this, () =>
378
+ {
379
+ this .#recordBrowser .addBrowserEvent ();
380
+
381
+ const time = duration - (Date .now () - this .#recordTime) / 1000;
382
+
383
+ this .time .text (time .toFixed (1) + " s");
384
+ });
385
+
386
+ // Toggle state.
387
+
388
+ this .#record = true;
389
+ this .#recordTime = Date .now ();
390
+
391
+ // Create stream.
392
+
393
+ const stream = this .#recordCanvas .get (0) .captureStream (30);
394
+
395
+ this .#timeoutId = setTimeout (() => this .stopRecord (), duration * 1_000);
396
+ this .#mimeType = VideoRecorder .formats [this .fileType .val ()] .mimeType;
94
397
  this .#recorder = new MediaRecorder (stream, { mimeType: this .#mimeType });
95
398
 
96
399
  const chunks = [ ];
97
400
 
98
401
  this .#recorder .addEventListener ("dataavailable", event =>
99
402
  {
100
- if (event .data .size > 0)
403
+ if (event .data .size)
101
404
  chunks .push (event .data);
102
405
  });
103
406
 
@@ -110,36 +413,97 @@ module .exports = class VideoRecorder extends Interface
110
413
  });
111
414
 
112
415
  this .#recorder .start ();
113
-
114
- // Toggle State
115
-
116
- this .#record = true;
117
-
118
- this .recordButton .addClass ("active");
119
416
  }
120
417
 
121
418
  async stopRecord ()
122
419
  {
420
+ // Stop recording.
421
+
123
422
  clearTimeout (this .#timeoutId);
124
423
 
125
424
  this .#recorder .stop ();
126
425
 
426
+ // Dispose browser.
427
+
428
+ this .#recordCanvas .remove ();
429
+ this .#recordBrowser .dispose ();
430
+
431
+ // Save file.
432
+
127
433
  const
128
- suffix = VideoRecorder .mimeTypes .find (([, mimeType]) => mimeType === this .#mimeType) [2],
129
434
  blob = await this .#blob,
130
435
  buffer = Buffer .from (await blob .arrayBuffer ());
131
436
 
132
- fs .writeFileSync (`${this .#desktop}/test.${suffix}`, buffer);
133
-
134
- // Toggle State
437
+ $.try (() => fs .writeFileSync (this .getFilename (), buffer), true);
135
438
 
136
- this .#record = false;
439
+ // Enable settings.
137
440
 
138
441
  this .recordButton .removeClass ("active");
442
+ this .settings .find ("input") .removeAttr ("readonly");
443
+ this .settings .find ("select") .removeAttr ("disabled");
444
+ this .settings .find (".button") .removeClass ("disabled");
445
+ this .time .detach ();
446
+
447
+ // Toggle state.
448
+
449
+ this .#recordCanvas = null;
450
+ this .#recordBrowser = null;
451
+ this .#record = false;
452
+
453
+ // Show video player.
454
+
455
+ this .resizeFrame ();
456
+ this .showVideoPlayer ();
139
457
  }
140
458
 
141
- showSettings ()
459
+ showVideoPlayer ()
142
460
  {
461
+ if (!fs .existsSync (this .getFilename ()))
462
+ return;
143
463
 
464
+ $("<video controls></video>")
465
+ .attr ("src", this .getFilename ())
466
+ .appendTo (this .aspectFrame .empty ());
467
+ }
468
+
469
+ resizeFrame ()
470
+ {
471
+ const
472
+ width = this .width .val ()|0,
473
+ height = this .height .val ()|0,
474
+ aspectRatio = width / height,
475
+ frameAspectRatio = this .recordFrame .innerWidth () / this .recordFrame .innerHeight ();
476
+
477
+ this .aspectFrame .css ({
478
+ "aspect-ratio": `${width} / ${height}`,
479
+ "max-width": width,
480
+ "max-height": height,
481
+ });
482
+
483
+ if (aspectRatio > frameAspectRatio)
484
+ this .aspectFrame .css ({ "width": "100%", "height": "auto" });
485
+ else
486
+ this .aspectFrame .css ({ "width": "auto", "height": "100%" });
487
+
488
+ if (aspectRatio > frameAspectRatio)
489
+ this .#recordCanvas ?.css ("scale", this .recordFrame .innerWidth () / width);
490
+ else
491
+ this .#recordCanvas ?.css ("scale", this .recordFrame .innerHeight () / height);
492
+ }
493
+
494
+ splitterPosition ()
495
+ {
496
+ if (this .vSplitter .position)
497
+ this .toggleSidebarButton .addClass (["active", "fill"]);
498
+ else
499
+ this .toggleSidebarButton .removeClass (["active", "fill"]);
500
+ }
501
+
502
+ toggleSidebar ()
503
+ {
504
+ if (this .vSplitter .position)
505
+ this .vSplitter .toggle ("minimize");
506
+ else
507
+ this .vSplitter .toggle ("restore");
144
508
  }
145
509
  };
@@ -274,9 +274,6 @@ class X3DNodeTool extends X3DBaseTool
274
274
  {
275
275
  // This function is also called in OutlineEditor beginUndoSetFieldValue and endUndoSetFieldValue.
276
276
 
277
- if (!this .tool .undo)
278
- return;
279
-
280
277
  if (active .getValue ())
281
278
  this .prepareUndo ();
282
279
  else
@@ -292,7 +289,8 @@ class X3DNodeTool extends X3DBaseTool
292
289
  name = this .getDisplayName (),
293
290
  description = this .getUndoDescription (this .tool .activeTool, name);
294
291
 
295
- UndoManager .shared .beginUndo (description, typeName, name);
292
+ if (this .tool .undo)
293
+ UndoManager .shared .beginUndo (description, typeName, name);
296
294
 
297
295
  // Prepare undo.
298
296
 
@@ -379,7 +377,8 @@ class X3DNodeTool extends X3DBaseTool
379
377
 
380
378
  this .#groupedTools .clear ();
381
379
 
382
- UndoManager .shared .endUndo ();
380
+ if (this .tool .undo)
381
+ UndoManager .shared .endUndo ();
383
382
  }
384
383
 
385
384
  beginUndo ()
@@ -101,9 +101,13 @@ async function initialize ()
101
101
  tool .bboxEvents = false;
102
102
  }
103
103
 
104
- function set_selected ()
104
+ async function set_selected ()
105
105
  {
106
106
  set_color ();
107
+
108
+ const tool = await transform .getValue () .addTool () .getToolInstance ();
109
+
110
+ tool .selected = selected;
107
111
  }
108
112
 
109
113
  function set_color ()
@@ -29,6 +29,7 @@ class Arc2DTool extends X3DGeometryNodeTool
29
29
 
30
30
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
31
31
  transformNode .children = [groupNode];
32
+ transformTool .selected = true;
32
33
  transformTool .group = this .getTypeName ();
33
34
  transformTool .undo = false;
34
35
  transformTool .tools = ["SCALE"];
@@ -29,6 +29,7 @@ class ArcClose2DTool extends X3DGeometryNodeTool
29
29
 
30
30
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
31
31
  transformNode .children = [groupNode];
32
+ transformTool .selected = true;
32
33
  transformTool .group = this .getTypeName ();
33
34
  transformTool .undo = false;
34
35
  transformTool .tools = ["SCALE"];
@@ -29,6 +29,7 @@ class Circle2DTool extends X3DGeometryNodeTool
29
29
 
30
30
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
31
31
  transformNode .children = [groupNode];
32
+ transformTool .selected = true;
32
33
  transformTool .group = this .getTypeName ();
33
34
  transformTool .undo = false;
34
35
  transformTool .tools = ["SCALE"];
@@ -34,6 +34,7 @@ class Disk2DTool extends X3DGeometryNodeTool
34
34
 
35
35
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
36
36
  transformNode .children = [groupNode];
37
+ transformTool .selected = true;
37
38
  transformTool .group = `${this .getTypeName ()}.outerRadius`;
38
39
  transformTool .undo = false;
39
40
  transformTool .tools = ["SCALE"];
@@ -69,6 +70,7 @@ class Disk2DTool extends X3DGeometryNodeTool
69
70
 
70
71
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
71
72
  transformNode .children = [groupNode];
73
+ transformTool .selected = true;
72
74
  transformTool .group = `${this .getTypeName ()}.innerRadius`;
73
75
  transformTool .undo = false;
74
76
  transformTool .tools = ["SCALE"];
@@ -29,6 +29,7 @@ class Rectangle2DTool extends X3DGeometryNodeTool
29
29
 
30
30
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 0);
31
31
  transformNode .children = [groupNode];
32
+ transformTool .selected = true;
32
33
  transformTool .group = this .getTypeName ();
33
34
  transformTool .undo = false;
34
35
  transformTool .tools = ["SCALE"];
@@ -29,6 +29,7 @@ class BoxTool extends X3DGeometryNodeTool
29
29
 
30
30
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 2);
31
31
  transformNode .children = [groupNode];
32
+ transformTool .selected = true;
32
33
  transformTool .group = this .getTypeName ();
33
34
  transformTool .undo = false;
34
35
  transformTool .tools = ["SCALE"];
@@ -30,6 +30,7 @@ class ConeTool extends X3DGeometryNodeTool
30
30
 
31
31
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 2);
32
32
  transformNode .children = [groupNode];
33
+ transformTool .selected = true;
33
34
  transformTool .group = this .getTypeName ();
34
35
  transformTool .undo = false;
35
36
  transformTool .tools = ["SCALE"];
@@ -30,6 +30,7 @@ class CylinderTool extends X3DGeometryNodeTool
30
30
 
31
31
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 2);
32
32
  transformNode .children = [groupNode];
33
+ transformTool .selected = true;
33
34
  transformTool .group = this .getTypeName ();
34
35
  transformTool .undo = false;
35
36
  transformTool .tools = ["SCALE"];
@@ -30,6 +30,7 @@ class SphereTool extends X3DGeometryNodeTool
30
30
 
31
31
  groupNode .bboxSize = new X3D .Vector3 (2, 2, 2);
32
32
  transformNode .children = [groupNode];
33
+ transformTool .selected = true;
33
34
  transformTool .group = this .getTypeName ();
34
35
  transformTool .undo = false;
35
36
  transformTool .tools = ["SCALE"];