x_ite 8.6.7 → 8.6.9

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 (110) hide show
  1. package/.vscode/tasks.json +1 -1
  2. package/dist/assets/components/Annotation.js +13 -13
  3. package/dist/assets/components/Annotation.min.js +1 -1
  4. package/dist/assets/components/CADGeometry.js +13 -13
  5. package/dist/assets/components/CADGeometry.min.js +1 -1
  6. package/dist/assets/components/CubeMapTexturing.js +26 -26
  7. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  8. package/dist/assets/components/DIS.js +13 -13
  9. package/dist/assets/components/DIS.min.js +1 -1
  10. package/dist/assets/components/EventUtilities.js +9 -9
  11. package/dist/assets/components/EventUtilities.min.js +1 -1
  12. package/dist/assets/components/Geometry2D.js +19 -19
  13. package/dist/assets/components/Geometry2D.min.js +1 -1
  14. package/dist/assets/components/Geospatial.js +33 -33
  15. package/dist/assets/components/Geospatial.min.js +1 -1
  16. package/dist/assets/components/HAnim.js +18 -18
  17. package/dist/assets/components/HAnim.min.js +1 -1
  18. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  19. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  20. package/dist/assets/components/Layout.js +27 -27
  21. package/dist/assets/components/Layout.min.js +1 -1
  22. package/dist/assets/components/NURBS.js +24 -24
  23. package/dist/assets/components/NURBS.min.js +1 -1
  24. package/dist/assets/components/ParticleSystems.js +25 -27
  25. package/dist/assets/components/ParticleSystems.min.js +1 -1
  26. package/dist/assets/components/Picking.js +19 -19
  27. package/dist/assets/components/Picking.min.js +1 -1
  28. package/dist/assets/components/RigidBodyPhysics.js +18 -18
  29. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  30. package/dist/assets/components/Scripting.js +28 -28
  31. package/dist/assets/components/Scripting.min.js +1 -1
  32. package/dist/assets/components/Text.js +24 -24
  33. package/dist/assets/components/Text.min.js +1 -1
  34. package/dist/assets/components/TextureProjector.js +14 -14
  35. package/dist/assets/components/TextureProjector.min.js +1 -1
  36. package/dist/assets/components/Texturing3D.js +33 -33
  37. package/dist/assets/components/Texturing3D.min.js +1 -1
  38. package/dist/assets/components/VolumeRendering.js +19 -19
  39. package/dist/assets/components/VolumeRendering.min.js +1 -1
  40. package/dist/assets/components/X_ITE.js +9 -9
  41. package/dist/assets/components/X_ITE.min.js +1 -1
  42. package/dist/x_ite.css +1 -1
  43. package/dist/x_ite.js +907 -689
  44. package/dist/x_ite.min.js +1 -1
  45. package/dist/x_ite.zip +0 -0
  46. package/docs/_config.yml +2 -2
  47. package/docs/laboratory/gltf-sample-viewer.html +4 -4
  48. package/package.json +1 -1
  49. package/src/assets/shaders/webgl1/Pointing.fs.js +1 -1
  50. package/src/assets/shaders/webgl1/include/Fragment.glsl.js +17 -1
  51. package/src/assets/shaders/webgl1/include/Point.glsl.js +10 -2
  52. package/src/assets/shaders/webgl1/include/Texture.glsl.js +31 -1
  53. package/src/assets/shaders/webgl1/include/Vertex.glsl.js +26 -3
  54. package/src/assets/shaders/webgl2/Pointing.fs.js +1 -1
  55. package/src/assets/shaders/webgl2/include/Fragment.glsl.js +18 -0
  56. package/src/assets/shaders/webgl2/include/Particle.glsl.js +9 -23
  57. package/src/assets/shaders/webgl2/include/Point.glsl.js +12 -4
  58. package/src/assets/shaders/webgl2/include/Texture.glsl.js +17 -20
  59. package/src/assets/shaders/webgl2/include/Vertex.glsl.js +24 -0
  60. package/src/bookmarks.js +1 -1
  61. package/src/standard/Math/Numbers/Color3.js +2 -2
  62. package/src/standard/Math/Numbers/Color4.js +1 -1
  63. package/src/tests.js +1 -0
  64. package/src/x_ite/Browser/Core/BrowserOptions.js +3 -0
  65. package/src/x_ite/Browser/Core/BrowserTimings.js +12 -11
  66. package/src/x_ite/Browser/Core/Context.js +64 -64
  67. package/src/x_ite/Browser/Core/ContextMenu.js +0 -9
  68. package/src/x_ite/Browser/Navigation/ExamineViewer.js +1 -1
  69. package/src/x_ite/Browser/Shaders/Shaders.js +0 -2
  70. package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +8 -0
  71. package/src/x_ite/Browser/VERSION.js +1 -1
  72. package/src/x_ite/Browser/X3DBrowser.js +1 -1
  73. package/src/x_ite/Components/Core/X3DBindableNode.js +0 -2
  74. package/src/x_ite/Components/Core/X3DNode.js +3 -8
  75. package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +1 -1
  76. package/src/x_ite/Components/Layering/X3DLayerNode.js +6 -2
  77. package/src/x_ite/Components/Navigation/NavigationInfo.js +1 -0
  78. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +34 -21
  79. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +2 -4
  80. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +5 -19
  81. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +6 -12
  82. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +4 -8
  83. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +28 -27
  84. package/src/x_ite/Components/Shape/Material.js +28 -23
  85. package/src/x_ite/Components/Shape/PhysicalMaterial.js +5 -0
  86. package/src/x_ite/Components/Shape/TwoSidedMaterial.js +1 -0
  87. package/src/x_ite/Components/Shape/UnlitMaterial.js +1 -0
  88. package/src/x_ite/Components/Shape/X3DMaterialNode.js +21 -19
  89. package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +16 -10
  90. package/src/x_ite/Components/Texturing/ImageTexture.js +86 -44
  91. package/src/x_ite/Components/Texturing/MovieTexture.js +5 -4
  92. package/src/x_ite/Components/Texturing/MultiTexture.js +7 -4
  93. package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +19 -16
  94. package/src/x_ite/Components/Texturing/MultiTextureTransform.js +16 -32
  95. package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +1 -1
  96. package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +2 -8
  97. package/src/x_ite/Components/Texturing/X3DSingleTextureTransformNode.js +2 -8
  98. package/src/x_ite/Execution/NamedNodesHandling.js +84 -0
  99. package/src/x_ite/Execution/X3DExecutionContext.js +7 -37
  100. package/src/x_ite/Execution/X3DScene.js +5 -0
  101. package/src/x_ite/InputOutput/FileLoader.js +1 -1
  102. package/src/x_ite/InputOutput/Generator.js +32 -81
  103. package/src/x_ite/Parser/GLTF2Parser.js +112 -52
  104. package/src/x_ite/Parser/OBJParser.js +48 -39
  105. package/src/x_ite/Parser/STLAParser.js +3 -0
  106. package/src/x_ite/Parser/SVGParser.js +4 -0
  107. package/src/x_ite/Rendering/X3DRenderObject.js +2 -0
  108. package/src/x_ite.html +52 -46
  109. package/x_ite.min.html +52 -46
  110. package/src/assets/shaders/webgl1/include/Particle.glsl.js +0 -7
@@ -58,6 +58,9 @@ function MultiTextureCoordinate (executionContext)
58
58
 
59
59
  this .addType (X3DConstants .MultiTextureCoordinate);
60
60
 
61
+ const browser = this .getBrowser ();
62
+
63
+ this .maxTexCoords = browser .getMaxTexCoords ();
61
64
  this .textureCoordinateNodes = [ ];
62
65
  }
63
66
 
@@ -110,7 +113,7 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
110
113
  },
111
114
  getCount: function ()
112
115
  {
113
- return Math .min (this .getBrowser () .getMaxTextures (), this .textureCoordinateNodes .length);
116
+ return Math .min (this .maxTexCoords, this .textureCoordinateNodes .length);
114
117
  },
115
118
  isEmpty: function ()
116
119
  {
@@ -136,21 +139,27 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
136
139
  },
137
140
  init: function (multiArray)
138
141
  {
139
- for (const textureCoordinateNode of this .textureCoordinateNodes)
140
- textureCoordinateNode .init (multiArray);
142
+ const
143
+ textureCoordinateNodes = this .textureCoordinateNodes,
144
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
145
+
146
+ for (let i = 0; i < length; ++ i)
147
+ textureCoordinateNodes [i] .init (multiArray);
141
148
  },
142
149
  addPoint: function (index, multiArray)
143
150
  {
144
- const textureCoordinateNodes = this .textureCoordinateNodes;
151
+ const
152
+ textureCoordinateNodes = this .textureCoordinateNodes,
153
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
145
154
 
146
- for (let i = 0, length = textureCoordinateNodes .length; i < length; ++ i)
155
+ for (let i = 0; i < length; ++ i)
147
156
  textureCoordinateNodes [i] .addPointToChannel (index, multiArray [i]);
148
157
  },
149
158
  getTextureCoordinateMapping: function (textureCoordinateMapping)
150
159
  {
151
160
  const
152
161
  textureCoordinateNodes = this .textureCoordinateNodes,
153
- length = Math .min (this .getBrowser () .getMaxTextures (), textureCoordinateNodes .length);
162
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
154
163
 
155
164
  for (let i = 0; i < length; ++ i)
156
165
  textureCoordinateNodes [i] .getTextureCoordinateMapping (textureCoordinateMapping, i);
@@ -159,22 +168,16 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
159
168
  {
160
169
  const
161
170
  textureCoordinateNodes = this .textureCoordinateNodes,
162
- length = Math .min (shaderObject .x3d_MaxTextures, textureCoordinateNodes .length);
163
-
164
- for (let i = 0; i < length; ++ i)
165
- textureCoordinateNodes [i] .setShaderUniformsToChannel (gl, shaderObject, i);
171
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
166
172
 
167
173
  if (length)
168
174
  {
169
- const last = textureCoordinateNodes .at (-1);
170
-
171
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
172
- last .setShaderUniformsToChannel (gl, shaderObject, i);
175
+ for (let i = 0; i < length; ++ i)
176
+ textureCoordinateNodes [i] .setShaderUniforms (gl, shaderObject, i);
173
177
  }
174
178
  else
175
179
  {
176
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
177
- gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [i], 0);
180
+ this .getBrowser () .getDefaultTextureCoordinate () .setShaderUniforms (gl, shaderObject, 0);
178
181
  }
179
182
  },
180
183
  });
@@ -51,7 +51,6 @@ import FieldDefinitionArray from "../../Base/FieldDefinitionArray.js";
51
51
  import X3DTextureTransformNode from "./X3DTextureTransformNode.js";
52
52
  import X3DConstants from "../../Base/X3DConstants.js";
53
53
  import X3DCast from "../../Base/X3DCast.js";
54
- import Matrix4 from "../../../standard/Math/Numbers/Matrix4.js";
55
54
 
56
55
  function MultiTextureTransform (executionContext)
57
56
  {
@@ -59,6 +58,9 @@ function MultiTextureTransform (executionContext)
59
58
 
60
59
  this .addType (X3DConstants .MultiTextureTransform);
61
60
 
61
+ const browser = this .getBrowser ();
62
+
63
+ this .maxTextureTransforms = browser .getMaxTextureTransforms ();
62
64
  this .textureTransformNodes = [ ];
63
65
  }
64
66
 
@@ -102,53 +104,35 @@ MultiTextureTransform .prototype = Object .assign (Object .create (X3DTextureTra
102
104
  if (textureTransformNode)
103
105
  textureTransformNodes .push (textureTransformNode);
104
106
  }
107
+
108
+ if (!textureTransformNodes .length)
109
+ textureTransformNodes .push (this .getBrowser () .getDefaultTextureTransform ());
105
110
  },
106
111
  getCount: function ()
107
112
  {
108
- return Math .min (this .getBrowser () .getMaxTextures (), this .textureTransformNodes .length);
113
+ return Math .min (this .maxTextureTransforms, this .textureTransformNodes .length);
109
114
  },
110
115
  getTextureTransformMapping: function (textureTransformMapping)
111
116
  {
112
117
  const
113
118
  textureTransformNodes = this .textureTransformNodes,
114
- length = Math .min (this .getBrowser () .getMaxTextures (), textureTransformNodes .length);
119
+ length = Math .min (this .maxTextureTransforms, textureTransformNodes .length);
115
120
 
116
121
  for (let i = 0; i < length; ++ i)
117
122
  textureTransformNodes [i] .getTextureTransformMapping (textureTransformMapping, i);
118
123
  },
119
- setShaderUniforms: (function ()
124
+ setShaderUniforms: function (gl, shaderObject)
120
125
  {
121
- const matrixArray = new Float32Array (Matrix4 .Identity);
122
-
123
- return function (gl, shaderObject)
124
- {
125
- const
126
- textureTransformNodes = this .textureTransformNodes,
127
- length = Math .min (shaderObject .x3d_MaxTextures, textureTransformNodes .length);
128
-
129
- for (let i = 0; i < length; ++ i)
130
- textureTransformNodes [i] .setShaderUniformsToChannel (gl, shaderObject, i);
131
-
132
- if (length)
133
- {
134
- const last = textureTransformNodes .at (-1);
126
+ const
127
+ textureTransformNodes = this .textureTransformNodes,
128
+ length = Math .min (this .maxTextureTransforms, textureTransformNodes .length);
135
129
 
136
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
137
- last .setShaderUniformsToChannel (gl, shaderObject, i);
138
- }
139
- else
140
- {
141
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
142
- gl .uniformMatrix4fv (shaderObject .x3d_TextureMatrix [i], false, matrixArray);
143
- }
144
- };
145
- })(),
130
+ for (let i = 0; i < length; ++ i)
131
+ textureTransformNodes [i] .setShaderUniforms (gl, shaderObject, i);
132
+ },
146
133
  transformPoint: function (texCoord)
147
134
  {
148
- if (this .textureTransformNodes .length)
149
- return this .textureTransformNodes [0] .transformPoint (texCoord);
150
-
151
- return texCoord;
135
+ return this .textureTransformNodes [0] .transformPoint (texCoord);
152
136
  },
153
137
  });
154
138
 
@@ -138,7 +138,7 @@ TextureCoordinateGenerator .prototype = Object .assign (Object .create (X3DSingl
138
138
  {
139
139
  array .push (0, 0, 0, 1);
140
140
  },
141
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
141
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
142
142
  {
143
143
  gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [channel], this .mode);
144
144
  gl .uniform1fv (shaderObject .x3d_TextureCoordinateGeneratorParameter [channel], this .parameter);
@@ -77,15 +77,9 @@ X3DSingleTextureCoordinateNode .prototype = Object .assign (Object .create (X3DT
77
77
  },
78
78
  getTextureCoordinateMapping: function (textureCoordinateMapping, channel = 0)
79
79
  {
80
- if (this ._mapping .getValue ())
81
- textureCoordinateMapping .set (this ._mapping .getValue (), channel);
80
+ textureCoordinateMapping .set (this ._mapping .getValue () || channel, channel);
82
81
  },
83
- setShaderUniforms: function (gl, shaderObject)
84
- {
85
- for (let i = 0, length = shaderObject .x3d_MaxTextures; i < length; ++ i)
86
- this .setShaderUniformsToChannel (gl, shaderObject, i);
87
- },
88
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
82
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
89
83
  {
90
84
  gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [channel], 0);
91
85
  },
@@ -71,15 +71,9 @@ X3DSingleTextureTransformNode .prototype = Object .assign (Object .create (X3DTe
71
71
  },
72
72
  getTextureTransformMapping: function (textureTransformMapping, channel = 0)
73
73
  {
74
- if (this ._mapping .getValue ())
75
- textureTransformMapping .set (this ._mapping .getValue (), channel);
74
+ textureTransformMapping .set (this ._mapping .getValue () || channel, channel);
76
75
  },
77
- setShaderUniforms: function (gl, shaderObject)
78
- {
79
- for (let i = 0, length = shaderObject .x3d_MaxTextures; i < length; ++ i)
80
- this .setShaderUniformsToChannel (gl, shaderObject, i);
81
- },
82
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
76
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
83
77
  {
84
78
  gl .uniformMatrix4fv (shaderObject .x3d_TextureMatrix [channel], false, this .matrixArray);
85
79
  },
@@ -0,0 +1,84 @@
1
+ /*******************************************************************************
2
+ *
3
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
+ *
5
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
6
+ *
7
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
8
+ *
9
+ * The copyright notice above does not evidence any actual of intended
10
+ * publication of such source code, and is an unpublished work by create3000.
11
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
12
+ * create3000.
13
+ *
14
+ * No permission is granted to copy, distribute, or create derivative works from
15
+ * the contents of this software, in whole or in part, without the prior written
16
+ * permission of create3000.
17
+ *
18
+ * NON-MILITARY USE ONLY
19
+ *
20
+ * All create3000 software are effectively free software with a non-military use
21
+ * restriction. It is free. Well commented source is provided. You may reuse the
22
+ * source in any way you please with the exception anything that uses it must be
23
+ * marked to indicate is contains 'non-military use only' components.
24
+ *
25
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26
+ *
27
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
28
+ *
29
+ * This file is part of the X_ITE Project.
30
+ *
31
+ * X_ITE is free software: you can redistribute it and/or modify it under the
32
+ * terms of the GNU General Public License version 3 only, as published by the
33
+ * Free Software Foundation.
34
+ *
35
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
36
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
37
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
38
+ * details (a copy is included in the LICENSE file that accompanied this code).
39
+ *
40
+ * You should have received a copy of the GNU General Public License version 3
41
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
42
+ * copy of the GPLv3 License.
43
+ *
44
+ * For Silvio, Joy and Adi.
45
+ *
46
+ ******************************************************************************/
47
+
48
+ export const getUniqueName = function (array, name = "", number = false)
49
+ {
50
+ name = String (name) .replace (/_\d+$/, "");
51
+
52
+ let
53
+ newName = number ? `${name}_1` : name,
54
+ lo = 1,
55
+ hi = 1;
56
+
57
+ while (array .has (newName) || newName .length === 0)
58
+ {
59
+ lo = hi;
60
+ hi <<= 1;
61
+
62
+ newName = `${name}_${lo}`;
63
+ }
64
+
65
+ lo >>>= 1;
66
+ hi >>>= 1;
67
+
68
+ if (lo && hi)
69
+ {
70
+ while (lo < hi)
71
+ {
72
+ const m = (lo + hi) >>> 1;
73
+
74
+ if (array .has (`${name}_${m}`))
75
+ lo = m + 1;
76
+ else
77
+ hi = m;
78
+ }
79
+
80
+ newName = `${name}_${lo}`;
81
+ }
82
+
83
+ return newName;
84
+ };
@@ -48,6 +48,7 @@
48
48
  import SupportedNodes from "../Configuration/SupportedNodes.js";
49
49
  import Fields from "../Fields.js";
50
50
  import X3DBaseNode from "../Base/X3DBaseNode.js";
51
+ import { getUniqueName } from "./NamedNodesHandling.js";
51
52
  import NamedNodesArray from "./NamedNodesArray.js";
52
53
  import X3DImportedNode from "./X3DImportedNode.js";
53
54
  import ImportedNodesArray from "./ImportedNodesArray.js";
@@ -60,7 +61,6 @@ import X3DRoute from "../Routing/X3DRoute.js";
60
61
  import X3DCast from "../Base/X3DCast.js";
61
62
  import X3DConstants from "../Base/X3DConstants.js";
62
63
  import SFNodeCache from "../Fields/SFNodeCache.js";
63
- import Algorithm from "../../standard/Math/Algorithm.js";
64
64
 
65
65
  SupportedNodes .addAbstractType ("X3DExecutionContext", X3DExecutionContext);
66
66
 
@@ -281,9 +281,9 @@ X3DExecutionContext .prototype = Object .assign (Object .create (X3DBaseNode .pr
281
281
  {
282
282
  return this [_namedNodes];
283
283
  },
284
- getUniqueName: function (name = "")
284
+ getUniqueName: function (name)
285
285
  {
286
- return getUniqueName .call (this, _namedNodes, name);
286
+ return getUniqueName (this [_namedNodes], name);
287
287
  },
288
288
  addImportedNode: function (inlineNode, exportedName, importedName)
289
289
  {
@@ -464,9 +464,9 @@ X3DExecutionContext .prototype = Object .assign (Object .create (X3DBaseNode .pr
464
464
  {
465
465
  return this [_protos];
466
466
  },
467
- getUniqueProtoName: function (name = "")
467
+ getUniqueProtoName: function (name)
468
468
  {
469
- return getUniqueName .call (this, _protos, name);
469
+ return getUniqueName (this [_protos], name);
470
470
  },
471
471
  getExternProtoDeclaration: function (name)
472
472
  {
@@ -528,9 +528,9 @@ X3DExecutionContext .prototype = Object .assign (Object .create (X3DBaseNode .pr
528
528
  {
529
529
  return this [_externprotos];
530
530
  },
531
- getUniqueExternProtoName: function (name = "")
531
+ getUniqueExternProtoName: function (name)
532
532
  {
533
- return getUniqueName .call (this, _externprotos, name);
533
+ return getUniqueName (this [_externprotos], name);
534
534
  },
535
535
  addRoute: function (sourceNode, sourceField, destinationNode, destinationField)
536
536
  {
@@ -917,36 +917,6 @@ X3DExecutionContext .prototype = Object .assign (Object .create (X3DBaseNode .pr
917
917
  },
918
918
  });
919
919
 
920
- const getUniqueName = (function ()
921
- {
922
- const _TrailingNumbers = /_\d+$/;
923
-
924
- return function (array, name = "")
925
- {
926
- name = String (name) .replace (_TrailingNumbers, "");
927
-
928
- let
929
- newName = name,
930
- i = 64;
931
-
932
- for (; i;)
933
- {
934
- if (! (this [array] .has (newName) || newName .length === 0))
935
- break;
936
-
937
- const
938
- min = i,
939
- max = i <<= 1;
940
-
941
- newName = name;
942
- newName += '_';
943
- newName += Math .round (Algorithm .random (min, max));
944
- }
945
-
946
- return newName;
947
- };
948
- })();
949
-
950
920
  for (const key of Reflect .ownKeys (X3DExecutionContext .prototype))
951
921
  Object .defineProperty (X3DExecutionContext .prototype, key, { enumerable: false });
952
922
 
@@ -48,6 +48,7 @@
48
48
  import SupportedNodes from "../Configuration/SupportedNodes.js";
49
49
  import Fields from "../Fields.js";
50
50
  import X3DExecutionContext from "./X3DExecutionContext.js";
51
+ import { getUniqueName } from "./NamedNodesHandling.js";
51
52
  import ComponentInfoArray from "../Configuration/ComponentInfoArray.js";
52
53
  import UnitInfo from "../Configuration/UnitInfo.js";
53
54
  import UnitInfoArray from "../Configuration/UnitInfoArray.js";
@@ -357,6 +358,10 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
357
358
  {
358
359
  return this [_exportedNodes];
359
360
  },
361
+ getUniqueExportName: function (name)
362
+ {
363
+ return getUniqueName (this [_exportedNodes], name);
364
+ },
360
365
  addRootNode: function (node)
361
366
  {
362
367
  node = SFNodeCache .get (X3DCast (X3DConstants .X3DNode, node, false));
@@ -132,7 +132,7 @@ FileLoader .prototype = Object .assign (Object .create (X3DObject .prototype),
132
132
  else
133
133
  scene .setExecutionContext (this .executionContext);
134
134
 
135
- scene .setWorldURL (decodeURI (new URL (worldURL, this .getReferer ()) .href));
135
+ scene .setWorldURL (new URL (worldURL, this .getReferer ()) .href);
136
136
 
137
137
  if (success)
138
138
  success = this .setScene .bind (this, scene, success, error);
@@ -45,7 +45,8 @@
45
45
  *
46
46
  ******************************************************************************/
47
47
 
48
- import X3DConstants from "../Base/X3DConstants.js";
48
+ import X3DConstants from "../Base/X3DConstants.js";
49
+ import { getUniqueName } from "../Execution/NamedNodesHandling.js";
49
50
 
50
51
  function Generator ({ style = "TIDY", precision = 7, doublePrecision = 15 })
51
52
  {
@@ -67,12 +68,11 @@ function Generator ({ style = "TIDY", precision = 7, doublePrecision = 15 })
67
68
  this .importedNames = new Map ();
68
69
  this .routeNodes = new Set ();
69
70
  this .level = 0;
70
- this .newName = 0;
71
71
  this .containerFields = [ ];
72
72
  this .units = true;
73
73
  this .unitCategories = [ ];
74
74
 
75
- this .names .set (null, new Map ());
75
+ this .names .set (null, new Set ());
76
76
  }
77
77
 
78
78
  Generator .prototype =
@@ -212,7 +212,7 @@ Generator .prototype =
212
212
  this .executionContextStack .push (executionContext);
213
213
 
214
214
  if (! this .names .has (executionContext))
215
- this .names .set (executionContext, new Map ());
215
+ this .names .set (executionContext, Object .assign (new Set (), { index: 0 }));
216
216
 
217
217
  if (! this .importedNodesIndex .has (executionContext))
218
218
  this .importedNodesIndex .set (executionContext, new Set ());
@@ -236,9 +236,6 @@ Generator .prototype =
236
236
  },
237
237
  EnterScope: function ()
238
238
  {
239
- if (this .level === 0)
240
- this .newName = 0;
241
-
242
239
  ++ this .level;
243
240
  },
244
241
  LeaveScope: function ()
@@ -306,79 +303,47 @@ Generator .prototype =
306
303
  {
307
304
  return this .nodes .has (baseNode);
308
305
  },
309
- Name: (function ()
306
+ Name: function (baseNode)
310
307
  {
311
- const _TrailingNumbers = /_\d+$/;
308
+ // Is the node already in index.
312
309
 
313
- return function (baseNode)
314
- {
315
- // Is the node already in index
310
+ const name = this .namesByNode .get (baseNode);
316
311
 
317
- const name = this .namesByNode .get (baseNode);
312
+ if (name !== undefined)
313
+ {
314
+ return name;
315
+ }
316
+ else
317
+ {
318
+ const
319
+ name = baseNode .getName (),
320
+ match = name .match (/^(.*?)(_\d+)?$/),
321
+ names = this .names .get (this .ExecutionContext ());
318
322
 
319
- if (name !== undefined)
323
+ if (match [1])
320
324
  {
321
- return name;
325
+ // The node has a name.
326
+
327
+ var newName = getUniqueName (names, name, !! match [2]);
322
328
  }
323
329
  else
324
330
  {
325
- const names = this .names .get (this .ExecutionContext ());
326
-
327
- // The node has no name
328
-
329
- if (baseNode .getName () .length === 0)
330
- {
331
- if (this .NeedsName (baseNode))
332
- {
333
- const name = this .UniqueName ();
334
-
335
- names .set (name, baseNode);
336
- this .namesByNode .set (baseNode, name);
337
-
338
- return name;
339
- }
340
-
341
- // The node doesn't need a name
342
-
343
- return baseNode .getName ();
344
- }
345
-
346
- // The node has a name
347
-
348
- let name = baseNode .getName ();
349
- const hasNumber = name .match (_TrailingNumbers) !== null;
331
+ // The node has no name.
350
332
 
351
- name = name .replace (_TrailingNumbers, "");
333
+ if (!this .NeedsName (baseNode))
334
+ return "";
352
335
 
353
- if (name .length === 0)
354
- {
355
- if (this .NeedsName (baseNode))
356
- name = this .UniqueName ();
357
-
358
- else
359
- return "";
360
- }
361
- else
362
- {
363
- let
364
- i = 0,
365
- newName = hasNumber ? name + '_' + (++ i) : name;
366
-
367
- while (names .has (newName))
368
- {
369
- newName = name + '_' + (++ i);
370
- }
336
+ var newName = `_${++ names .index}`;
337
+ }
371
338
 
372
- name = newName;
373
- }
339
+ // Add to indices.
374
340
 
375
- names .set (name, baseNode);
376
- this .namesByNode .set (baseNode, name);
341
+ names .add (newName);
342
+ this .namesByNode .set (baseNode, newName);
377
343
 
378
- return name;
379
- }
380
- };
381
- })(),
344
+ return newName;
345
+ }
346
+ },
382
347
  NeedsName: function (baseNode)
383
348
  {
384
349
  if (baseNode .getCloneCount () > 1)
@@ -409,20 +374,6 @@ Generator .prototype =
409
374
  return false;
410
375
  }
411
376
  },
412
- UniqueName: function ()
413
- {
414
- const names = this .names .get (this .ExecutionContext ());
415
-
416
- for (; ;)
417
- {
418
- const name = '_' + (++ this .newName);
419
-
420
- if (names .has (name))
421
- continue;
422
-
423
- return name;
424
- }
425
- },
426
377
  LocalName: function (baseNode)
427
378
  {
428
379
  const importedName = this .importedNames .get (baseNode);