sunrize 1.11.0 → 1.11.2

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.
@@ -238,9 +238,11 @@ module .exports = class Editor
238
238
  scene = executionContext .getLocalScene (),
239
239
  profile = scene .getProfile (),
240
240
  x_ite = scene .hasComponent ("X_ITE"),
241
- externprotos = new Map (Array .from (executionContext .externprotos, p => [p .getName (), p])),
242
- protos = new Map (Array .from (executionContext .protos, p => [p .getName (), p])),
241
+ externprotos = executionContext .externprotos .copy (),
242
+ protos = executionContext .protos .copy (),
243
243
  rootNodes = executionContext .rootNodes .copy (),
244
+ namedNodes = executionContext .namedNodes .copy (),
245
+ importedNodes = executionContext .importedNodes .copy (),
244
246
  tempScene = await browser .createScene (browser .getProfile ("Core"));
245
247
 
246
248
  scene .setProfile (browser .getProfile ("Full"));
@@ -257,6 +259,13 @@ module .exports = class Editor
257
259
  catch (error)
258
260
  {
259
261
  console .error (error);
262
+
263
+ executionContext .externprotos .assign (externprotos);
264
+ executionContext .protos .assign (protos);
265
+ executionContext .rootNodes .splice (rootNodes .length);
266
+ executionContext .namedNodes .assign (namedNodes);
267
+ executionContext .importedNodes .assign (importedNodes);
268
+
260
269
  return [ ];
261
270
  }
262
271
  finally
@@ -815,17 +824,11 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
815
824
  */
816
825
  static setMetaData (scene, entries, undoManager = UndoManager .shared)
817
826
  {
818
- const oldEntries = [ ];
819
-
820
- for (const [key, values] of scene .getMetaDatas ())
821
- {
822
- for (const value of values)
823
- oldEntries .push ([key, value]);
824
- }
827
+ const oldEntries = scene .getMetaDatas ();
825
828
 
826
829
  undoManager .beginUndo (_("Change Meta Data"));
827
830
 
828
- for (const key of Array .from (scene .getMetaDatas () .keys ()))
831
+ for (const [key] of scene .getMetaDatas ())
829
832
  scene .removeMetaData (key);
830
833
 
831
834
  for (const [key, value] of entries)
@@ -915,38 +918,10 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
915
918
 
916
919
  undoManager .beginUndo (_("Update Imported Node »%s«"), importedName);
917
920
 
918
- executionContext .updateImportedNode (inlineNode .valueOf (), exportedName, importedName);
919
-
920
- if (oldImportedName && oldImportedName !== importedName)
921
- {
922
- const
923
- oldImportedNode = executionContext .getImportedNodes () .get (oldImportedName),
924
- newImportedNode = executionContext .getImportedNodes () .get (importedName);
925
-
926
- const routes = executionContext .getRoutes () .filter (route =>
927
- {
928
- if (route .sourceNode === oldImportedNode)
929
- return true;
930
-
931
- if (route .destinationNode === oldImportedNode)
932
- return true;
933
-
934
- return false;
935
- });
936
-
937
- executionContext .removeImportedNode (oldImportedName);
938
-
939
- for (let { sourceNode, sourceField, destinationNode, destinationField } of routes)
940
- {
941
- if (sourceNode === oldImportedNode)
942
- sourceNode = newImportedNode;
943
-
944
- if (destinationNode === oldImportedNode)
945
- destinationNode = newImportedNode;
946
-
947
- executionContext .addRoute (sourceNode, sourceField, destinationNode, destinationField);
948
- }
949
- }
921
+ if (oldImportedName)
922
+ executionContext .renameImportedNode (oldImportedName, importedName);
923
+ else
924
+ executionContext .updateImportedNode (inlineNode .valueOf (), exportedName, importedName);
950
925
 
951
926
  undoManager .registerUndo (() =>
952
927
  {
@@ -972,7 +947,8 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
972
947
  const
973
948
  importedNode = executionContext .getImportedNodes () .get (importedName),
974
949
  inlineNode = importedNode .getInlineNode (),
975
- exportedName = importedNode .getExportedName ();
950
+ exportedName = importedNode .getExportedName (),
951
+ exportedNode = importedNode .getExportedNode ();
976
952
 
977
953
  const routes = executionContext .getRoutes () .filter (route =>
978
954
  {
@@ -987,6 +963,51 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
987
963
 
988
964
  undoManager .beginUndo (_("Remove Imported Node »%s«"), importedName);
989
965
 
966
+ // RootNodes:
967
+ {
968
+ const
969
+ node = executionContext,
970
+ field = executionContext .rootNodes;
971
+
972
+ for (const index of Array .from (field .keys ()) .reverse ())
973
+ {
974
+ if (field [index] .getValue () === exportedNode)
975
+ this .removeValueFromArray (executionContext, node, field, index, undoManager);
976
+ }
977
+ }
978
+
979
+ for (const object of executionContext .traverse (Traverse .ROOT_NODES))
980
+ {
981
+ if (!(object instanceof X3D .SFNode))
982
+ continue;
983
+
984
+ const node = object .getValue ();
985
+
986
+ for (const field of node .getFields ())
987
+ {
988
+ switch (field .getType ())
989
+ {
990
+ case X3D .X3DConstants .SFNode:
991
+ {
992
+ if (field .getValue () === exportedNode)
993
+ this .setFieldValue (executionContext, node, field, null, undoManager);
994
+
995
+ break;
996
+ }
997
+ case X3D .X3DConstants .MFNode:
998
+ {
999
+ for (const index of Array .from (field .keys ()) .reverse ())
1000
+ {
1001
+ if (field [index] .getValue () === exportedNode)
1002
+ this .removeValueFromArray (executionContext, node, field, index, undoManager);
1003
+ }
1004
+
1005
+ break;
1006
+ }
1007
+ }
1008
+ }
1009
+ }
1010
+
990
1011
  executionContext .removeImportedNode (importedName);
991
1012
 
992
1013
  undoManager .registerUndo (() =>
@@ -1159,30 +1180,30 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1159
1180
  */
1160
1181
  static setProtoDeclarations (executionContext, protos, undoManager = UndoManager .shared)
1161
1182
  {
1162
- const oldProtos = new Map (Array .from (executionContext .protos, p => [p .getName (), p]))
1183
+ const oldProtos = new Map (Array .from (executionContext .protos, p => [p .getName (), p]));
1163
1184
 
1164
- undoManager .beginUndo (_("Update Proto Declarations"))
1185
+ undoManager .beginUndo (_("Update Proto Declarations"));
1165
1186
 
1166
1187
  for (const name of oldProtos .keys ())
1167
- executionContext .removeProtoDeclaration (name)
1188
+ executionContext .removeProtoDeclaration (name);
1168
1189
 
1169
- if (Array .isArray (protos))
1190
+ if (Array .isArray (protos) || protos instanceof X3D .X3DInfoArray)
1170
1191
  {
1171
1192
  for (const proto of protos)
1172
- executionContext .updateProtoDeclaration (proto .getName (), proto)
1193
+ executionContext .updateProtoDeclaration (proto .getName (), proto);
1173
1194
  }
1174
1195
  else
1175
1196
  {
1176
1197
  for (const [name, proto] of protos)
1177
- executionContext .updateProtoDeclaration (name, proto)
1198
+ executionContext .updateProtoDeclaration (name, proto);
1178
1199
  }
1179
1200
 
1180
1201
  undoManager .registerUndo (() =>
1181
1202
  {
1182
- this .setProtoDeclarations (executionContext, oldProtos, undoManager)
1203
+ this .setProtoDeclarations (executionContext, oldProtos, undoManager);
1183
1204
  });
1184
1205
 
1185
- this .requestUpdateInstances (executionContext, undoManager)
1206
+ this .requestUpdateInstances (executionContext, undoManager);
1186
1207
 
1187
1208
  undoManager .endUndo ();
1188
1209
  }
@@ -1352,7 +1373,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1352
1373
  for (const name of oldExternProtos .keys ())
1353
1374
  executionContext .removeExternProtoDeclaration (name);
1354
1375
 
1355
- if (Array .isArray (externprotos))
1376
+ if (Array .isArray (externprotos) || externprotos instanceof X3D .X3DInfoArray)
1356
1377
  {
1357
1378
  for (const externproto of externprotos)
1358
1379
  executionContext .updateExternProtoDeclaration (externproto .getName (), externproto);
@@ -1802,15 +1823,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1802
1823
 
1803
1824
  undoManager .registerUndo (() =>
1804
1825
  {
1805
- if (sourceNode instanceof X3D .X3DImportedNode)
1806
- sourceNode = executionContext .importedNodes .get (sourceNode .getImportedName ());
1807
-
1808
- if (destinationNode instanceof X3D .X3DImportedNode)
1809
- destinationNode = executionContext .importedNodes .get (destinationNode .getImportedName ());
1810
-
1811
- if (!(sourceNode && destinationNode))
1812
- return; // Imported nodes were manually removed.
1813
-
1814
1826
  this .addRoute (executionContext, sourceNode, sourceField, destinationNode, destinationField, undoManager);
1815
1827
  });
1816
1828
 
@@ -2889,6 +2901,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2889
2901
  const
2890
2902
  instance = node .getType () .includes (X3D .X3DConstants .X3DPrototypeInstance),
2891
2903
  name = field .getName (),
2904
+ oldValue = field .copy (),
2892
2905
  auxiliary = field .create ();
2893
2906
 
2894
2907
  auxiliary .setUnit (field .getUnit ());
@@ -2900,8 +2913,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2900
2913
  return;
2901
2914
  }
2902
2915
 
2903
- const oldValue = field .copy ()
2904
-
2905
2916
  if (node .getDisplayName ())
2906
2917
  undoManager .beginUndo (_("Change Field »%s« of Node %s »%s«"), field .getName (), node .getTypeName (), node .getDisplayName ());
2907
2918
  else
@@ -2938,24 +2949,29 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2938
2949
  const
2939
2950
  instance = node .getType () .includes (X3D .X3DConstants .X3DPrototypeInstance),
2940
2951
  name = field .getName (),
2941
- auxiliary = field .create ();
2952
+ oldValue = field .copy ();
2942
2953
 
2943
- auxiliary .setValue (value);
2954
+ if (!(value instanceof X3D .X3DField))
2955
+ {
2956
+ const auxiliary = field .create ();
2944
2957
 
2945
- if (auxiliary .equals (field))
2958
+ auxiliary .setValue (value);
2959
+
2960
+ value = auxiliary;
2961
+ }
2962
+
2963
+ if (value .equals (field))
2946
2964
  {
2947
2965
  field .addEvent ();
2948
2966
  return;
2949
2967
  }
2950
2968
 
2951
- const oldValue = field .copy ();
2952
-
2953
2969
  if (node .getDisplayName ())
2954
2970
  undoManager .beginUndo (_("Change Field »%s« of Node %s »%s«"), field .getName (), node .getTypeName (), node .getDisplayName ());
2955
2971
  else
2956
2972
  undoManager .beginUndo (_("Change Field »%s« of Node %s"), field .getName (), node .getTypeName ());
2957
2973
 
2958
- field .assign (auxiliary);
2974
+ field .assign (value);
2959
2975
 
2960
2976
  if (node .isDefaultValue (field))
2961
2977
  field .setModificationTime (0);
@@ -2963,7 +2979,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2963
2979
  switch (field .getType ())
2964
2980
  {
2965
2981
  case X3D .X3DConstants .SFNode:
2966
- this .removeNodesFromExecutionContextIfNecessary (executionContext, [oldValue], undoManager);
2982
+ this .removeNodesFromExecutionContextIfNecessary (executionContext, new X3D .MFNode (oldValue), undoManager);
2967
2983
  break;
2968
2984
  case X3D .X3DConstants .MFNode:
2969
2985
  this .removeNodesFromExecutionContextIfNecessary (executionContext, oldValue, undoManager);
@@ -3043,7 +3059,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3043
3059
  * @param {number} index
3044
3060
  * @param {UndoManager} undoManager
3045
3061
  */
3046
- static removeValueFromArray (executionContext, node, field, index, undoManager = UndoManager .shared)
3062
+ static removeValueFromArray (executionContext, node, field, index, undoManager = UndoManager .shared, xxx)
3047
3063
  {
3048
3064
  node = node .valueOf ();
3049
3065
  field = typeof field === "string" ? node .getField (field) : field;
@@ -3453,8 +3469,8 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3453
3469
 
3454
3470
  const nodesToRemove = this .#nodesToRemove .get (executionContext);
3455
3471
 
3456
- for (const node of nodes .filter (node => node))
3457
- nodesToRemove .push (node .valueOf ());
3472
+ for (const node of nodes .getValue () .filter (node => node))
3473
+ nodesToRemove .push (node);
3458
3474
 
3459
3475
  if (undoManager .defer ("removeNodesFromExecutionContextIfNecessary"))
3460
3476
  return;
@@ -3484,6 +3500,9 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3484
3500
 
3485
3501
  for (const node of children)
3486
3502
  {
3503
+ if (executionContext .getLocalizedNode (node) instanceof X3D .X3DImportedNode)
3504
+ continue;
3505
+
3487
3506
  // Rebind X3DBindableNode nodes.
3488
3507
 
3489
3508
  if (node .getType () .includes (X3D .X3DConstants .X3DBindableNode))
@@ -3499,7 +3518,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3499
3518
 
3500
3519
  // Remove named nodes.
3501
3520
 
3502
- if (node .getName ())
3521
+ if (node .getName () && node .getExecutionContext () === executionContext)
3503
3522
  this .removeNamedNode (executionContext, node, undoManager);
3504
3523
 
3505
3524
  // Remove routes.
@@ -2,7 +2,7 @@
2
2
  <!-- X3D Unified Object Model (X3DUOM) X3dUnifiedObjectModel-4.0.xml -->
3
3
  <!-- Online at https://www.web3d.org/specifications/X3dUnifiedObjectModel-4.0.xml -->
4
4
  <!-- This file contains a listing of all abstract and concrete nodes in version 4.0 of X3D -->
5
- <!-- Generated 2025-08-23-07:00 09:15:12.7342832-07:00 -->
5
+ <!-- Generated 2025-10-07-07:00 11:59:45.8550027-07:00 -->
6
6
  <X3dUnifiedObjectModel xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
7
7
  version="4.0"
8
8
  xsd:noNamespaceSchemaLocation="X3dUnifiedObjectModel.xsd">
@@ -30823,6 +30823,12 @@
30823
30823
  description="When time now &gt;= pauseTime, isPaused becomes true and AudioClip becomes paused.">
30824
30824
  <componentInfo name="Time" level="2"/>
30825
30825
  </field>
30826
+ <field name="periodicWave"
30827
+ type="SFNode"
30828
+ accessType="inputOutput"
30829
+ default="NULL"
30830
+ acceptableNodeTypes="PeriodicWave"
30831
+ description="The periodicWave field is an optional PeriodicWave node providing a regular or arbitrary periodic waveform."/>
30826
30832
  <field name="resumeTime"
30827
30833
  type="SFTime"
30828
30834
  accessType="inputOutput"
@@ -38941,7 +38947,7 @@
38941
38947
  <InterfaceDefinition specificationUrl="https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/texturing.html#TextureTransform"
38942
38948
  appinfo="TextureTransform shifts 2D texture coordinates for positioning, orienting and scaling image textures on geometry.">
38943
38949
  <componentInfo name="Texturing" level="1"/>
38944
- <Inheritance baseType="X3DTextureTransformNode"/>
38950
+ <Inheritance baseType="X3DSingleTextureTransformNode"/>
38945
38951
  <field name="center"
38946
38952
  type="SFVec2f"
38947
38953
  accessType="inputOutput"
@@ -38956,6 +38962,7 @@
38956
38962
  <field name="mapping"
38957
38963
  type="SFString"
38958
38964
  accessType="inputOutput"
38965
+ inheritedFrom="X3DSingleTextureTransformNode"
38959
38966
  baseType="xs:NMTOKEN"
38960
38967
  description="The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material."/>
38961
38968
  <field name="metadata"
@@ -39019,7 +39026,7 @@
39019
39026
  <InterfaceDefinition specificationUrl="https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/texture3D.html#TextureTransform3D"
39020
39027
  appinfo="TextureTransform3D applies a 3D transformation to texture coordinates.">
39021
39028
  <componentInfo name="Texturing3D" level="1"/>
39022
- <Inheritance baseType="X3DTextureTransformNode"/>
39029
+ <Inheritance baseType="X3DSingleTextureTransformNode"/>
39023
39030
  <field name="center"
39024
39031
  type="SFVec3f"
39025
39032
  accessType="inputOutput"
@@ -39034,6 +39041,7 @@
39034
39041
  <field name="mapping"
39035
39042
  type="SFString"
39036
39043
  accessType="inputOutput"
39044
+ inheritedFrom="X3DSingleTextureTransformNode"
39037
39045
  baseType="xs:NMTOKEN"
39038
39046
  description="The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material."/>
39039
39047
  <field name="metadata"
@@ -39097,7 +39105,7 @@
39097
39105
  <InterfaceDefinition specificationUrl="https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/texture3D.html#TextureTransformMatrix3D"
39098
39106
  appinfo="TextureTransformMatrix3D applies a 3D transformation to texture coordinates.">
39099
39107
  <componentInfo name="Texturing3D" level="1"/>
39100
- <Inheritance baseType="X3DTextureTransformNode"/>
39108
+ <Inheritance baseType="X3DSingleTextureTransformNode"/>
39101
39109
  <field name="IS"
39102
39110
  type="SFNode"
39103
39111
  accessType="inputOutput"
@@ -39107,6 +39115,7 @@
39107
39115
  <field name="mapping"
39108
39116
  type="SFString"
39109
39117
  accessType="inputOutput"
39118
+ inheritedFrom="X3DSingleTextureTransformNode"
39110
39119
  baseType="xs:NMTOKEN"
39111
39120
  description="The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material."/>
39112
39121
  <field name="matrix"