sunrize 2.7.2 → 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 (47) 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/SetOrientationPopover.js +1 -1
  12. package/src/Controls/Splitter.js +3 -3
  13. package/src/Editors/AnimationEditor.js +16 -8
  14. package/src/Editors/AnimationMemberList.js +1 -0
  15. package/src/Editors/BrowserFrame.js +10 -10
  16. package/src/Editors/Console.js +1 -1
  17. package/src/Editors/Library.js +1 -1
  18. package/src/Editors/MaterialsLibrary.js +9 -4
  19. package/src/Editors/OutlineEditor.js +84 -64
  20. package/src/Editors/OutlineRouteGraph.js +2 -1
  21. package/src/Editors/OutlineView.js +2 -2
  22. package/src/Editors/SceneProperties.js +12 -12
  23. package/src/Editors/ScriptEditor.js +1 -1
  24. package/src/Editors/VideoRecorder.js +415 -51
  25. package/src/Tools/Core/X3DNodeTool.js +4 -5
  26. package/src/Tools/EnvironmentalSensor/X3DEnvironmentalSensorNodeTool.x3d +5 -1
  27. package/src/Tools/Geometry2D/Arc2DTool.js +1 -0
  28. package/src/Tools/Geometry2D/ArcClose2DTool.js +1 -0
  29. package/src/Tools/Geometry2D/Circle2DTool.js +1 -0
  30. package/src/Tools/Geometry2D/Disk2DTool.js +2 -0
  31. package/src/Tools/Geometry2D/Rectangle2DTool.js +1 -0
  32. package/src/Tools/Geometry3D/BoxTool.js +1 -0
  33. package/src/Tools/Geometry3D/ConeTool.js +1 -0
  34. package/src/Tools/Geometry3D/CylinderTool.js +1 -0
  35. package/src/Tools/Geometry3D/SphereTool.js +1 -0
  36. package/src/Tools/Grouping/X3DTransformNodeTool.js +7 -5
  37. package/src/Tools/Grouping/X3DTransformNodeTool.x3d +11 -3
  38. package/src/Tools/Lighting/X3DLightNodeTool.x3d +18 -12
  39. package/src/Tools/Navigation/X3DViewpointNodeTool.x3d +2 -0
  40. package/src/Tools/Rendering/X3DGeometryNodeTool.x3d +1 -1
  41. package/src/Tools/Sound/ListenerPointSourceTool.x3d +8 -2
  42. package/src/Tools/Sound/SoundTool.x3d +10 -0
  43. package/src/Tools/Sound/SpatialSoundTool.x3d +8 -2
  44. package/src/Tools/TextureProjection/X3DTextureProjectorNodeTool.x3d +2 -0
  45. package/src/Undo/Editor.js +33 -21
  46. package/src/assets/html/window.html +1 -1
  47. package/src/assets/themes/default.css +91 -5
@@ -1718,51 +1718,61 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
1718
1718
 
1719
1719
  async saveDataUrlToFile (id, executionContextId, nodeId)
1720
1720
  {
1721
- const
1722
- executionContext = this .objects .get (executionContextId),
1723
- urlObject = this .objects .get (nodeId),
1724
- index = urlObject ._url .findIndex (fileURL => fileURL .match (/^\s*(?:data|ecmascript|javascript|vrmlscript):/s)),
1725
- dataURL = Editor .decodeURI (urlObject ._url [index]),
1726
- protocol = dataURL .match (/^\s*(?:data|ecmascript|javascript|vrmlscript):/s),
1727
- match = dataURL .match (/^\s*data:(.*?)(?:;charset=(.*?))?(?:;(base64))?,/s),
1728
- isData = protocol [0] === "data:";
1729
-
1730
- if (!((isData && match) || !isData))
1731
- return;
1721
+ try
1722
+ {
1723
+ const
1724
+ executionContext = this .objects .get (executionContextId),
1725
+ urlObject = this .objects .get (nodeId),
1726
+ index = urlObject ._url .findIndex (fileURL => fileURL .match (/^\s*(?:data|ecmascript|javascript|vrmlscript):/s)),
1727
+ dataURL = Editor .decodeURI (urlObject ._url [index]),
1728
+ protocol = dataURL .match (/^\s*(?:data|ecmascript|javascript|vrmlscript):/s),
1729
+ match = dataURL .match (/^\s*data:(.*?)(?:;charset=(.*?))?(?:;(base64))?,/s),
1730
+ isData = protocol [0] === "data:";
1731
+
1732
+ if (!((isData && match) || !isData))
1733
+ return;
1732
1734
 
1733
- // Open dialog.
1735
+ // Open dialog.
1734
1736
 
1735
- const
1736
- mimeType = isData ? match [1] || "text/plain" : this .protocolToMimeType .get (protocol [0]),
1737
- extension = mime .extension (mimeType),
1738
- defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (executionContext .getWorldURL ()))),
1739
- defaultPath = urlObject .getName () && defaultDirectory ? path .join (defaultDirectory, `${urlObject .getName ()}.${extension}`) : defaultDirectory,
1740
- filters = extension
1741
- ? [{ name: _(`${extension .toUpperCase ()} Document`), extensions: [extension] }]
1742
- : [{ name: _("All Files"), extensions: ["*"] }];
1737
+ const
1738
+ name = urlObject .getName () ,
1739
+ mimeType = isData ? match [1] || "text/plain" : this .protocolToMimeType .get (protocol [0]),
1740
+ extension = mime .extension (mimeType),
1741
+ defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (executionContext .getWorldURL ()))),
1742
+ desktop = await electron .ipcRenderer .invoke ("path", "desktop"),
1743
+ defaultPath = name ? path .join (defaultDirectory ?? desktop, `${name}.${extension}`) : (defaultDirectory ?? desktop);
1743
1744
 
1744
- const response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath, filters });
1745
+ const filters = extension
1746
+ ? [{ name: _(`${extension .toUpperCase ()} Document`), extensions: [extension] }]
1747
+ : [{ name: _("All Files"), extensions: ["*"] }];
1745
1748
 
1746
- if (response .canceled)
1747
- return;
1749
+ const response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath, filters });
1750
+
1751
+ if (response .canceled)
1752
+ return;
1748
1753
 
1749
- // Create file.
1754
+ // Create file.
1750
1755
 
1751
- const
1752
- data = dataURL .substring (dataURL .indexOf (isData ? "," : ":") + 1),
1753
- buffer = Buffer .from (data, isData && match [3] === "base64" ? "base64" : "utf8");
1756
+ const
1757
+ data = dataURL .substring (dataURL .indexOf (isData ? "," : ":") + 1),
1758
+ buffer = Buffer .from (data, isData && match [3] === "base64" ? "base64" : "utf8");
1754
1759
 
1755
- fs .writeFileSync (response .filePath, buffer);
1760
+ fs .writeFileSync (response .filePath, buffer);
1756
1761
 
1757
- // Add undo step.
1762
+ // Add undo step.
1758
1763
 
1759
- const value = urlObject ._url .toSpliced (index, 1, Editor .relativePath (executionContext, response .filePath));
1764
+ const value = urlObject ._url .toSpliced (index, 1, Editor .relativePath (executionContext, response .filePath));
1760
1765
 
1761
- UndoManager .shared .beginUndo (_("Save Data URL to File"));
1766
+ UndoManager .shared .beginUndo (_("Save Data URL to File"));
1762
1767
 
1763
- Editor .setFieldValue (executionContext, urlObject, urlObject ._url, value);
1768
+ Editor .setFieldValue (executionContext, urlObject, urlObject ._url, value);
1764
1769
 
1765
- UndoManager .shared .endUndo ();
1770
+ UndoManager .shared .endUndo ();
1771
+ }
1772
+ catch (error)
1773
+ {
1774
+ console .error (error);
1775
+ }
1766
1776
  }
1767
1777
 
1768
1778
  textTypes = new Set ([
@@ -1868,50 +1878,59 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
1868
1878
 
1869
1879
  async convertNodeToInlineFile (id, executionContextId, nodeId, typeName)
1870
1880
  {
1871
- const
1872
- executionContext = this .objects .get (executionContextId),
1873
- childNode = this .objects .get (nodeId),
1874
- defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (executionContext .getWorldURL ()))),
1875
- defaultPath = childNode .getDisplayName () && defaultDirectory ? path .join (defaultDirectory, `${childNode .getDisplayName ()}.x3d`) : defaultDirectory,
1876
- response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath });
1881
+ try
1882
+ {
1883
+ const
1884
+ executionContext = this .objects .get (executionContextId),
1885
+ childNode = this .objects .get (nodeId),
1886
+ name = childNode .getDisplayName (),
1887
+ defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (executionContext .getWorldURL ()))),
1888
+ desktop = await electron .ipcRenderer .invoke ("path", "desktop"),
1889
+ defaultPath = name ? path .join (defaultDirectory ?? desktop, `${name}.x3d`) : (defaultDirectory ?? desktop),
1890
+ response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath });
1877
1891
 
1878
- if (response .canceled)
1879
- return;
1892
+ if (response .canceled)
1893
+ return;
1880
1894
 
1881
- switch (typeName)
1882
- {
1883
- case "Inline":
1884
- UndoManager .shared .beginUndo (_("Convert Node to Inline File"));
1885
- break;
1886
- case "InlineGeometry":
1887
- UndoManager .shared .beginUndo (_("Convert Node to InlineGeometry"));
1888
- break;
1889
- }
1895
+ // Create inline file.
1890
1896
 
1891
- // Create inline file.
1897
+ await Editor .convertNodesToInlineFile (executionContext, [childNode], response .filePath);
1892
1898
 
1893
- await Editor .convertNodesToInlineFile (executionContext, [childNode], response .filePath);
1899
+ // Create Inline node.
1894
1900
 
1895
- // Create Inline node.
1901
+ switch (typeName)
1902
+ {
1903
+ case "Inline":
1904
+ UndoManager .shared .beginUndo (_("Convert Node to Inline File"));
1905
+ break;
1906
+ case "InlineGeometry":
1907
+ UndoManager .shared .beginUndo (_("Convert Node to InlineGeometry"));
1908
+ break;
1909
+ }
1896
1910
 
1897
- await Editor .addComponent (executionContext, "Networking");
1911
+ await Editor .addComponent (executionContext, "Networking");
1898
1912
 
1899
- const inlineNode = executionContext .createNode (typeName) .getValue ();
1913
+ const inlineNode = executionContext .createNode (typeName) .getValue ();
1900
1914
 
1901
- inlineNode ._url = [Editor .relativePath (executionContext, response .filePath)];
1915
+ inlineNode ._url = [Editor .relativePath (executionContext, response .filePath)];
1902
1916
 
1903
- if (childNode .getName ())
1904
- Editor .updateNamedNode (executionContext, childNode .getName (), inlineNode);
1917
+ if (childNode .getName ())
1918
+ Editor .updateNamedNode (executionContext, childNode .getName (), inlineNode);
1905
1919
 
1906
- // Insert Inline node.
1920
+ // Insert Inline node.
1907
1921
 
1908
- Editor .replaceAllOccurrences (executionContext, childNode, inlineNode);
1922
+ Editor .replaceAllOccurrences (executionContext, childNode, inlineNode);
1909
1923
 
1910
- UndoManager .shared .endUndo ();
1924
+ UndoManager .shared .endUndo ();
1911
1925
 
1912
- await this .browser .nextFrame ();
1926
+ await this .browser .nextFrame ();
1913
1927
 
1914
- this .expandTo (inlineNode);
1928
+ this .expandTo (inlineNode);
1929
+ }
1930
+ catch (error)
1931
+ {
1932
+ console .error (error);
1933
+ }
1915
1934
  }
1916
1935
 
1917
1936
  addNormalsToGeometry (id, executionContextId, nodeId)
@@ -2284,7 +2303,8 @@ module .exports = class OutlineEditor extends OutlineRouteGraph
2284
2303
  executionContext = this .objects .get (executionContextId),
2285
2304
  proto = this .objects .get (protoNodeId),
2286
2305
  defaultDirectory = $.try (() => path .dirname (url .fileURLToPath (executionContext .getWorldURL ()))),
2287
- defaultPath = defaultDirectory ? path .join (defaultDirectory, `${proto .getName ()}.x3d`) : undefined,
2306
+ desktop = await electron .ipcRenderer .invoke ("path", "desktop"),
2307
+ defaultPath = path .join (defaultDirectory ?? desktop, `${proto .getName ()}.x3d`),
2288
2308
  response = await electron .ipcRenderer .invoke ("file-path", { type: "save", defaultPath });
2289
2309
 
2290
2310
  if (response .canceled)
@@ -302,7 +302,8 @@ module .exports = class OutlineRouteGraph extends OutlineView
302
302
  rect1 = canvas1 .get (0) .getBoundingClientRect (),
303
303
  rect2 = canvas2 .get (0) .getBoundingClientRect ();
304
304
 
305
- canvas1 .height (Math .ceil (rect2 .y - rect1 .y));
305
+ if (!canvas1 .is (".route-value"))
306
+ canvas1 .height (Math .ceil (rect2 .y - rect1 .y));
306
307
 
307
308
  canvas1 .prop ("width", canvas1 .width ());
308
309
  canvas1 .prop ("height", canvas1 .height ());
@@ -2486,7 +2486,7 @@ module .exports = class OutlineView extends Interface
2486
2486
 
2487
2487
  $("<div></div>")
2488
2488
  .addClass (type + "-value-container")
2489
- .append ($("<input></input>"))
2489
+ .append ($("<input>"))
2490
2490
  .appendTo (li);
2491
2491
 
2492
2492
  // Make jsTree.
@@ -2626,7 +2626,7 @@ module .exports = class OutlineView extends Interface
2626
2626
  child .find (".jstree-node")
2627
2627
  .wrapInner ("<div class=\"item no-select\"/>")
2628
2628
  .find (".item")
2629
- .append ("<div class=\"route-curves-wrapper\"><canvas class=\"route-curves\"></canvas></div>");
2629
+ .append ("<div class=\"route-curves-wrapper\"><canvas class=\"route-curves route-value\"></canvas></div>");
2630
2630
 
2631
2631
  this .connectFieldActions (child);
2632
2632
 
@@ -56,7 +56,7 @@ module .exports = new class SceneProperties extends Dialog
56
56
  this .profileAndComponents .table .body = $("<tbody></tbody>") .appendTo (this .profileAndComponents .table);
57
57
  this .profileAndComponents .inputs = { };
58
58
 
59
- this .profileAndComponents .inputs .checkbox = $("<input></input>")
59
+ this .profileAndComponents .inputs .checkbox = $("<input>")
60
60
  .attr ("id", "infer-profile-and-components-checkbox")
61
61
  .attr ("type", "checkbox")
62
62
  .on ("click", () => this .toggleInferProfileAndComponents ());
@@ -81,7 +81,7 @@ module .exports = new class SceneProperties extends Dialog
81
81
  $("<tr></tr>")
82
82
  .append ($("<td></td>")
83
83
  .width ("15px")
84
- .append ($("<input></input>")
84
+ .append ($("<input>")
85
85
  .attr ("type", "checkbox")
86
86
  .attr ("id", `scene-properties-${component .name}`)
87
87
  .attr ("component", component .name)
@@ -92,7 +92,7 @@ module .exports = new class SceneProperties extends Dialog
92
92
  .text (component .title)))
93
93
  .append ($("<td></td>")
94
94
  .width ("15px")
95
- .append ($("<input></input>")
95
+ .append ($("<input>")
96
96
  .attr ("component", component .name)
97
97
  .attr ("level", component .level)
98
98
  .val (component .level)
@@ -128,8 +128,8 @@ module .exports = new class SceneProperties extends Dialog
128
128
 
129
129
  this .units .inputs = new Map (Units .map (unit => [unit .category,
130
130
  {
131
- name: $("<input></input>") .attr ("list", unit .category),
132
- conversionFactor: $("<input></input>") .attr ("category", unit .category),
131
+ name: $("<input>") .attr ("list", unit .category),
132
+ conversionFactor: $("<input>") .attr ("category", unit .category),
133
133
  }]));
134
134
 
135
135
  $("<tr></tr>")
@@ -185,7 +185,7 @@ module .exports = new class SceneProperties extends Dialog
185
185
  this .metaDataOptions = $("<table></table>") .appendTo (this .metaData);
186
186
  this .metaDataOptions .body = $("<tbody></tbody>") .appendTo (this .metaDataOptions);
187
187
 
188
- this .commonMetaData = $("<input></input>")
188
+ this .commonMetaData = $("<input>")
189
189
  .attr ("id", "common-metadata")
190
190
  .attr ("type", "checkbox")
191
191
  .on ("click", () => this .toggleCommonMetaData ());
@@ -247,12 +247,12 @@ module .exports = new class SceneProperties extends Dialog
247
247
  this .worldInfo .table .body = $("<tbody></tbody>") .appendTo (this .worldInfo .table);
248
248
  this .worldInfo .inputs = { };
249
249
 
250
- this .worldInfo .inputs .checkbox = $("<input></input>")
250
+ this .worldInfo .inputs .checkbox = $("<input>")
251
251
  .attr ("id", "world-info-checkbox")
252
252
  .attr ("type", "checkbox")
253
253
  .on ("click", () => this .toggleWorldInfo ());
254
254
 
255
- this .worldInfo .inputs .title = $("<input></input>") .attr ("spellcheck", "true");
255
+ this .worldInfo .inputs .title = $("<input>") .attr ("spellcheck", "true");
256
256
  this .worldInfo .inputs .info = $("<textarea></textarea>") .attr ("spellcheck", "true") .height ("100%") .css ("resize", "none");
257
257
 
258
258
  this .worldInfo .checkboxRow = $("<tr></tr>")
@@ -495,14 +495,14 @@ module .exports = new class SceneProperties extends Dialog
495
495
  .addClass (this .config .file .sortMetaData ? ["disabled"] : [ ])
496
496
  .text ("drag_handle")))
497
497
  .append ($("<td></td>")
498
- .append ($("<input></input>")
498
+ .append ($("<input>")
499
499
  .attr ("index", 0)
500
500
  .attr ("placeholder", _("Insert meta key here."))
501
501
  .attr ("spellcheck", "true")
502
502
  .val (key) .on ("change", (event) => this .changeMetaData (event, key))))
503
503
  .append ($("<td></td>")
504
504
  .addClass ("meta-value")
505
- .append ($("<input></input>")
505
+ .append ($("<input>")
506
506
  .attr ("index", 1)
507
507
  .attr ("placeholder", _("Insert meta value here."))
508
508
  .attr ("spellcheck", "true")
@@ -566,12 +566,12 @@ module .exports = new class SceneProperties extends Dialog
566
566
  $("<tr></tr>")
567
567
  .append ($("<td></td>"))
568
568
  .append ($("<td></td>")
569
- .append ($("<input></input>")
569
+ .append ($("<input>")
570
570
  .attr ("placeholder", _("Add new meta key."))
571
571
  .attr ("spellcheck", "true")
572
572
  .on ("change", event => this .changeMetaData (event, ""))))
573
573
  .append ($("<td></td>")
574
- .append ($("<input></input>")
574
+ .append ($("<input>")
575
575
  .prop ("readonly", true)
576
576
  .attr ("spellcheck", "true")
577
577
  .on ("change", event => this .changeMetaData (event, ""))))
@@ -130,7 +130,7 @@ module .exports = class ScriptEditor extends Interface
130
130
  .addClass (["alternating", "node-list"])
131
131
  .appendTo (this .horizontalSplitterTop);
132
132
 
133
- this .nodeName = $("<input></input>")
133
+ this .nodeName = $("<input>")
134
134
  .addClass ("node-name")
135
135
  .attr ("title", _("Rename node."))
136
136
  .attr ("placeholder", _("Enter node name."))