sunrize 1.11.1 → 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.
@@ -1,32 +1,32 @@
1
1
  const
2
2
  $ = require ("jquery"),
3
- Editor = require ("../Undo/Editor")
3
+ Editor = require ("../Undo/Editor");
4
4
 
5
5
  $.fn.SFStringInput = function (node, field)
6
6
  {
7
7
  if (arguments .length === 0)
8
8
  {
9
- this .off ("change.SFStringInput")
10
- this .data ("field.SFStringInput") .removeFieldCallback (this .get (0))
9
+ this .off ("change.SFStringInput");
10
+ this .data ("field.SFStringInput") .removeFieldCallback (this .get (0));
11
11
  }
12
12
  else
13
13
  {
14
14
  if (typeof field === "string")
15
- field = node .getField (field)
15
+ field = node .getField (field);
16
16
 
17
- this .data ("field.SFStringInput", field)
17
+ this .data ("field.SFStringInput", field);
18
18
 
19
19
  this .val (field .getValue ()) .on ("change.SFStringInput", () =>
20
20
  {
21
- Editor .setFieldValue (node .getExecutionContext (), node, field, this .val ())
22
- })
21
+ Editor .setFieldValue (node .getExecutionContext (), node, field, this .val ());
22
+ });
23
23
 
24
24
  field .addFieldCallback (this .get (0), () =>
25
25
  {
26
- this .val (field .getValue ())
27
- this .trigger ("blur")
28
- })
26
+ this .val (field .getValue ());
27
+ this .trigger ("blur");
28
+ });
29
29
  }
30
30
 
31
- return this
32
- }
31
+ return this;
32
+ };
@@ -100,7 +100,7 @@ class X3DNodeTool extends X3DBaseTool
100
100
 
101
101
  replaceNode (node, replacement)
102
102
  {
103
- for (const parent of new Set (node .getParents ()))
103
+ for (const parent of Array .from (node .getParents ()))
104
104
  {
105
105
  if (parent instanceof X3D .SFNode)
106
106
  parent .setValue (replacement);
@@ -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
@@ -909,38 +918,10 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
909
918
 
910
919
  undoManager .beginUndo (_("Update Imported Node »%s«"), importedName);
911
920
 
912
- executionContext .updateImportedNode (inlineNode .valueOf (), exportedName, importedName);
913
-
914
- if (oldImportedName && oldImportedName !== importedName)
915
- {
916
- const
917
- oldImportedNode = executionContext .getImportedNodes () .get (oldImportedName),
918
- newImportedNode = executionContext .getImportedNodes () .get (importedName);
919
-
920
- const routes = executionContext .getRoutes () .filter (route =>
921
- {
922
- if (route .sourceNode === oldImportedNode)
923
- return true;
924
-
925
- if (route .destinationNode === oldImportedNode)
926
- return true;
927
-
928
- return false;
929
- });
930
-
931
- executionContext .removeImportedNode (oldImportedName);
932
-
933
- for (let { sourceNode, sourceField, destinationNode, destinationField } of routes)
934
- {
935
- if (sourceNode === oldImportedNode)
936
- sourceNode = newImportedNode;
937
-
938
- if (destinationNode === oldImportedNode)
939
- destinationNode = newImportedNode;
940
-
941
- executionContext .addRoute (sourceNode, sourceField, destinationNode, destinationField);
942
- }
943
- }
921
+ if (oldImportedName)
922
+ executionContext .renameImportedNode (oldImportedName, importedName);
923
+ else
924
+ executionContext .updateImportedNode (inlineNode .valueOf (), exportedName, importedName);
944
925
 
945
926
  undoManager .registerUndo (() =>
946
927
  {
@@ -966,7 +947,8 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
966
947
  const
967
948
  importedNode = executionContext .getImportedNodes () .get (importedName),
968
949
  inlineNode = importedNode .getInlineNode (),
969
- exportedName = importedNode .getExportedName ();
950
+ exportedName = importedNode .getExportedName (),
951
+ exportedNode = importedNode .getExportedNode ();
970
952
 
971
953
  const routes = executionContext .getRoutes () .filter (route =>
972
954
  {
@@ -981,6 +963,51 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
981
963
 
982
964
  undoManager .beginUndo (_("Remove Imported Node »%s«"), importedName);
983
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
+
984
1011
  executionContext .removeImportedNode (importedName);
985
1012
 
986
1013
  undoManager .registerUndo (() =>
@@ -1153,30 +1180,30 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1153
1180
  */
1154
1181
  static setProtoDeclarations (executionContext, protos, undoManager = UndoManager .shared)
1155
1182
  {
1156
- 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]));
1157
1184
 
1158
- undoManager .beginUndo (_("Update Proto Declarations"))
1185
+ undoManager .beginUndo (_("Update Proto Declarations"));
1159
1186
 
1160
1187
  for (const name of oldProtos .keys ())
1161
- executionContext .removeProtoDeclaration (name)
1188
+ executionContext .removeProtoDeclaration (name);
1162
1189
 
1163
- if (Array .isArray (protos))
1190
+ if (Array .isArray (protos) || protos instanceof X3D .X3DInfoArray)
1164
1191
  {
1165
1192
  for (const proto of protos)
1166
- executionContext .updateProtoDeclaration (proto .getName (), proto)
1193
+ executionContext .updateProtoDeclaration (proto .getName (), proto);
1167
1194
  }
1168
1195
  else
1169
1196
  {
1170
1197
  for (const [name, proto] of protos)
1171
- executionContext .updateProtoDeclaration (name, proto)
1198
+ executionContext .updateProtoDeclaration (name, proto);
1172
1199
  }
1173
1200
 
1174
1201
  undoManager .registerUndo (() =>
1175
1202
  {
1176
- this .setProtoDeclarations (executionContext, oldProtos, undoManager)
1203
+ this .setProtoDeclarations (executionContext, oldProtos, undoManager);
1177
1204
  });
1178
1205
 
1179
- this .requestUpdateInstances (executionContext, undoManager)
1206
+ this .requestUpdateInstances (executionContext, undoManager);
1180
1207
 
1181
1208
  undoManager .endUndo ();
1182
1209
  }
@@ -1346,7 +1373,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1346
1373
  for (const name of oldExternProtos .keys ())
1347
1374
  executionContext .removeExternProtoDeclaration (name);
1348
1375
 
1349
- if (Array .isArray (externprotos))
1376
+ if (Array .isArray (externprotos) || externprotos instanceof X3D .X3DInfoArray)
1350
1377
  {
1351
1378
  for (const externproto of externprotos)
1352
1379
  executionContext .updateExternProtoDeclaration (externproto .getName (), externproto);
@@ -1796,15 +1823,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
1796
1823
 
1797
1824
  undoManager .registerUndo (() =>
1798
1825
  {
1799
- if (sourceNode instanceof X3D .X3DImportedNode)
1800
- sourceNode = executionContext .importedNodes .get (sourceNode .getImportedName ());
1801
-
1802
- if (destinationNode instanceof X3D .X3DImportedNode)
1803
- destinationNode = executionContext .importedNodes .get (destinationNode .getImportedName ());
1804
-
1805
- if (!(sourceNode && destinationNode))
1806
- return; // Imported nodes were manually removed.
1807
-
1808
1826
  this .addRoute (executionContext, sourceNode, sourceField, destinationNode, destinationField, undoManager);
1809
1827
  });
1810
1828
 
@@ -2883,6 +2901,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2883
2901
  const
2884
2902
  instance = node .getType () .includes (X3D .X3DConstants .X3DPrototypeInstance),
2885
2903
  name = field .getName (),
2904
+ oldValue = field .copy (),
2886
2905
  auxiliary = field .create ();
2887
2906
 
2888
2907
  auxiliary .setUnit (field .getUnit ());
@@ -2894,8 +2913,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2894
2913
  return;
2895
2914
  }
2896
2915
 
2897
- const oldValue = field .copy ()
2898
-
2899
2916
  if (node .getDisplayName ())
2900
2917
  undoManager .beginUndo (_("Change Field »%s« of Node %s »%s«"), field .getName (), node .getTypeName (), node .getDisplayName ());
2901
2918
  else
@@ -2932,24 +2949,29 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2932
2949
  const
2933
2950
  instance = node .getType () .includes (X3D .X3DConstants .X3DPrototypeInstance),
2934
2951
  name = field .getName (),
2935
- auxiliary = field .create ();
2952
+ oldValue = field .copy ();
2936
2953
 
2937
- auxiliary .setValue (value);
2954
+ if (!(value instanceof X3D .X3DField))
2955
+ {
2956
+ const auxiliary = field .create ();
2938
2957
 
2939
- if (auxiliary .equals (field))
2958
+ auxiliary .setValue (value);
2959
+
2960
+ value = auxiliary;
2961
+ }
2962
+
2963
+ if (value .equals (field))
2940
2964
  {
2941
2965
  field .addEvent ();
2942
2966
  return;
2943
2967
  }
2944
2968
 
2945
- const oldValue = field .copy ();
2946
-
2947
2969
  if (node .getDisplayName ())
2948
2970
  undoManager .beginUndo (_("Change Field »%s« of Node %s »%s«"), field .getName (), node .getTypeName (), node .getDisplayName ());
2949
2971
  else
2950
2972
  undoManager .beginUndo (_("Change Field »%s« of Node %s"), field .getName (), node .getTypeName ());
2951
2973
 
2952
- field .assign (auxiliary);
2974
+ field .assign (value);
2953
2975
 
2954
2976
  if (node .isDefaultValue (field))
2955
2977
  field .setModificationTime (0);
@@ -2957,7 +2979,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
2957
2979
  switch (field .getType ())
2958
2980
  {
2959
2981
  case X3D .X3DConstants .SFNode:
2960
- this .removeNodesFromExecutionContextIfNecessary (executionContext, [oldValue], undoManager);
2982
+ this .removeNodesFromExecutionContextIfNecessary (executionContext, new X3D .MFNode (oldValue), undoManager);
2961
2983
  break;
2962
2984
  case X3D .X3DConstants .MFNode:
2963
2985
  this .removeNodesFromExecutionContextIfNecessary (executionContext, oldValue, undoManager);
@@ -3037,7 +3059,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3037
3059
  * @param {number} index
3038
3060
  * @param {UndoManager} undoManager
3039
3061
  */
3040
- static removeValueFromArray (executionContext, node, field, index, undoManager = UndoManager .shared)
3062
+ static removeValueFromArray (executionContext, node, field, index, undoManager = UndoManager .shared, xxx)
3041
3063
  {
3042
3064
  node = node .valueOf ();
3043
3065
  field = typeof field === "string" ? node .getField (field) : field;
@@ -3447,8 +3469,8 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3447
3469
 
3448
3470
  const nodesToRemove = this .#nodesToRemove .get (executionContext);
3449
3471
 
3450
- for (const node of nodes .filter (node => node))
3451
- nodesToRemove .push (node .valueOf ());
3472
+ for (const node of nodes .getValue () .filter (node => node))
3473
+ nodesToRemove .push (node);
3452
3474
 
3453
3475
  if (undoManager .defer ("removeNodesFromExecutionContextIfNecessary"))
3454
3476
  return;
@@ -3478,6 +3500,9 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3478
3500
 
3479
3501
  for (const node of children)
3480
3502
  {
3503
+ if (executionContext .getLocalizedNode (node) instanceof X3D .X3DImportedNode)
3504
+ continue;
3505
+
3481
3506
  // Rebind X3DBindableNode nodes.
3482
3507
 
3483
3508
  if (node .getType () .includes (X3D .X3DConstants .X3DBindableNode))
@@ -3493,7 +3518,7 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3493
3518
 
3494
3519
  // Remove named nodes.
3495
3520
 
3496
- if (node .getName ())
3521
+ if (node .getName () && node .getExecutionContext () === executionContext)
3497
3522
  this .removeNamedNode (executionContext, node, undoManager);
3498
3523
 
3499
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"