x_ite 8.3.1 → 8.3.3

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 (130) hide show
  1. package/.github/workflows/pages-deploy.yml +1 -1
  2. package/.vscode/settings.json +2 -1
  3. package/build/bin/tests.pl +2 -0
  4. package/dist/LICENSE.md +4 -4
  5. package/dist/assets/components/Annotation.js +13 -13
  6. package/dist/assets/components/Annotation.min.js +1 -1
  7. package/dist/assets/components/CADGeometry.js +13 -13
  8. package/dist/assets/components/CADGeometry.min.js +1 -1
  9. package/dist/assets/components/CubeMapTexturing.js +25 -25
  10. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  11. package/dist/assets/components/DIS.js +13 -13
  12. package/dist/assets/components/DIS.min.js +1 -1
  13. package/dist/assets/components/EventUtilities.js +9 -9
  14. package/dist/assets/components/EventUtilities.min.js +1 -1
  15. package/dist/assets/components/Geometry2D.js +19 -19
  16. package/dist/assets/components/Geometry2D.min.js +1 -1
  17. package/dist/assets/components/Geospatial.js +33 -33
  18. package/dist/assets/components/Geospatial.min.js +1 -1
  19. package/dist/assets/components/HAnim.js +61 -74
  20. package/dist/assets/components/HAnim.min.js +1 -1
  21. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  22. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  23. package/dist/assets/components/Layout.js +27 -27
  24. package/dist/assets/components/Layout.min.js +1 -1
  25. package/dist/assets/components/NURBS.js +24 -24
  26. package/dist/assets/components/NURBS.min.js +1 -1
  27. package/dist/assets/components/ParticleSystems.js +23 -23
  28. package/dist/assets/components/ParticleSystems.min.js +1 -1
  29. package/dist/assets/components/Picking.js +19 -19
  30. package/dist/assets/components/Picking.min.js +1 -1
  31. package/dist/assets/components/RigidBodyPhysics.js +17 -17
  32. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  33. package/dist/assets/components/Scripting.js +28 -28
  34. package/dist/assets/components/Scripting.min.js +1 -1
  35. package/dist/assets/components/Text.js +24 -24
  36. package/dist/assets/components/Text.min.js +1 -1
  37. package/dist/assets/components/{ProjectiveTextureMapping.js → TextureProjector.js} +39 -39
  38. package/dist/assets/components/TextureProjector.min.js +1 -0
  39. package/dist/assets/components/Texturing3D.js +46 -46
  40. package/dist/assets/components/Texturing3D.min.js +1 -1
  41. package/dist/assets/components/VolumeRendering.js +19 -19
  42. package/dist/assets/components/VolumeRendering.min.js +1 -1
  43. package/dist/assets/components/X_ITE.js +9 -9
  44. package/dist/assets/components/X_ITE.min.js +1 -1
  45. package/dist/x_ite.css +1 -1
  46. package/dist/x_ite.js +1904 -1570
  47. package/dist/x_ite.min.js +1 -1
  48. package/dist/x_ite.zip +0 -0
  49. package/docs/Gemfile +1 -4
  50. package/docs/_config.yml +3 -2
  51. package/docs/_posts/custom-shaders.md +1 -1
  52. package/docs/_posts/dom-integration.md +52 -25
  53. package/docs/_posts/getting-started.md +148 -442
  54. package/docs/_posts/reference/field-services-and-objects.md +2 -34
  55. package/docs/_posts/reference/scene-services.md +13 -2
  56. package/docs/_posts/tutorials/basic-nodes.md +2 -2
  57. package/docs/_posts/tutorials/building-a-x3d-world.md +20 -4
  58. package/docs/_posts/tutorials/building-primitive-shapes.md +4 -4
  59. package/docs/_posts/tutorials/creating-new-node-types.md +22 -0
  60. package/docs/_posts/tutorials/hello-world.md +6 -6
  61. package/docs/_posts/tutorials/improving-performance.md +2 -2
  62. package/docs/_posts/tutorials/writing-program-scripts-with-ecmascript.md +2 -2
  63. package/docs/_posts/what's-new.md +21 -3
  64. package/docs/_tabs/playground.html +110 -57
  65. package/docs/assets/css/style.scss +25 -1
  66. package/package.json +2 -2
  67. package/src/assets/components/{ProjectiveTextureMapping.js → TextureProjector.js} +5 -5
  68. package/src/examples.js +1 -1
  69. package/src/tests.js +5 -5
  70. package/src/x_ite/Base/X3DArrayField.js +3 -0
  71. package/src/x_ite/Base/X3DBaseNode.js +4 -0
  72. package/src/x_ite/Base/X3DInfoArray.js +28 -24
  73. package/src/x_ite/Base/X3DObject.js +29 -20
  74. package/src/x_ite/Base/X3DObjectArrayField.js +27 -26
  75. package/src/x_ite/Base/X3DTypedArrayField.js +34 -32
  76. package/src/x_ite/Browser/Core/ContextMenu.js +5 -7
  77. package/src/x_ite/Browser/DOMIntegration.js +62 -54
  78. package/src/x_ite/Browser/VERSION.js +1 -1
  79. package/src/x_ite/Browser/X3DBrowser.js +44 -29
  80. package/src/x_ite/Browser/X3DBrowserContext.js +3 -0
  81. package/src/x_ite/Components/Core/X3DNode.js +196 -187
  82. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +114 -91
  83. package/src/x_ite/Components/Grouping/X3DTransformMatrix3DNode.js +18 -43
  84. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +24 -25
  85. package/src/x_ite/Components/HAnim/HAnimJoint.js +19 -31
  86. package/src/x_ite/Components/Networking/Inline.js +21 -2
  87. package/src/x_ite/Components/Sound/X3DSoundProcessingNode.js +14 -1
  88. package/src/x_ite/Components/Sound/X3DSoundSourceNode.js +0 -1
  89. package/src/x_ite/Components/{ProjectiveTextureMapping → TextureProjector}/TextureProjector.js +1 -1
  90. package/src/x_ite/Components/{ProjectiveTextureMapping → TextureProjector}/TextureProjectorParallel.js +1 -1
  91. package/src/x_ite/Components/{ProjectiveTextureMapping → TextureProjector}/X3DTextureProjectorNode.js +0 -0
  92. package/src/x_ite/Components/Time/TimeSensor.js +5 -0
  93. package/src/x_ite/Components/Time/X3DTimeDependentNode.js +1 -0
  94. package/src/x_ite/Configuration/ComponentInfo.js +20 -23
  95. package/src/x_ite/Configuration/ProfileInfo.js +6 -6
  96. package/src/x_ite/Configuration/SupportedComponents.js +22 -20
  97. package/src/x_ite/Configuration/SupportedNodes.js +1 -5
  98. package/src/x_ite/Configuration/SupportedProfiles.js +1 -1
  99. package/src/x_ite/Configuration/UnitInfo.js +24 -27
  100. package/src/x_ite/Execution/X3DExecutionContext.js +28 -59
  101. package/src/x_ite/Execution/X3DExportedNode.js +23 -28
  102. package/src/x_ite/Execution/X3DImportedNode.js +63 -67
  103. package/src/x_ite/Execution/X3DScene.js +98 -117
  104. package/src/x_ite/Fields/ArrayFields.js +57 -55
  105. package/src/x_ite/Fields/SFBool.js +6 -6
  106. package/src/x_ite/Fields/SFColor.js +10 -12
  107. package/src/x_ite/Fields/SFDouble.js +7 -10
  108. package/src/x_ite/Fields/SFFloat.js +7 -10
  109. package/src/x_ite/Fields/SFImage.js +33 -8
  110. package/src/x_ite/Fields/SFInt32.js +6 -6
  111. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +13 -13
  112. package/src/x_ite/Fields/SFNode.js +42 -19
  113. package/src/x_ite/Fields/SFRotation.js +13 -13
  114. package/src/x_ite/Fields/SFString.js +6 -7
  115. package/src/x_ite/Fields/SFTime.js +6 -6
  116. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +10 -10
  117. package/src/x_ite/InputOutput/FileLoader.js +1 -1
  118. package/src/x_ite/InputOutput/Generator.js +117 -17
  119. package/src/x_ite/Parser/VRMLParser.js +24 -27
  120. package/src/x_ite/Parser/X3DParser.js +0 -4
  121. package/src/x_ite/Parser/XMLParser.js +152 -50
  122. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +59 -64
  123. package/src/x_ite/Prototype/X3DProtoDeclaration.js +86 -93
  124. package/src/x_ite/Rendering/X3DRenderObject.js +6 -1
  125. package/src/x_ite/Routing/X3DRoute.js +37 -40
  126. package/src/x_ite.html +3 -3
  127. package/webpack.config.js +2 -2
  128. package/x_ite.min.html +1 -1
  129. package/dist/assets/components/ProjectiveTextureMapping.min.js +0 -1
  130. package/docs/Gemfile.lock +0 -116
@@ -604,17 +604,13 @@ ContextMenu .prototype = Object .assign (Object .create (X3DBaseNode .prototype)
604
604
 
605
605
  // Menu
606
606
 
607
- const
608
- x = event .pageX - $(document) .scrollLeft (),
609
- y = event .pageY - $(document) .scrollTop ();
610
-
611
607
  const ul = $("<ul></ul>")
612
608
  .hide ()
609
+ .addClass ("context-menu-root")
613
610
  .addClass ("context-menu-list")
614
611
  .addClass (menu .className)
615
- .addClass ("context-menu-root")
616
- .css ({ "left": x, "top": y })
617
- .appendTo (options .appendTo);
612
+ .appendTo (options .appendTo)
613
+ .offset ({ "left": event .pageX, "top": event .pageY });
618
614
 
619
615
  for (const k in menu .items)
620
616
  ul .append (this .createItem (menu .items [k], "context-menu-root", k, level + 1, hide));
@@ -623,6 +619,8 @@ ContextMenu .prototype = Object .assign (Object .create (X3DBaseNode .prototype)
623
619
 
624
620
  // Reposition menu if to right or to low.
625
621
 
622
+ ul .offset ({ "left": event .pageX, "top": event .pageY }); // Do it again!
623
+
626
624
  if (ul .offset () .left - $(document) .scrollLeft () + ul .outerWidth () > $(window) .width ())
627
625
  ul .offset ({ "left": $(document) .scrollLeft () + Math .max (0, $(window) .width () - ul .outerWidth ()) });
628
626
 
@@ -31,25 +31,23 @@ class DOMIntegration
31
31
  {
32
32
  constructor (browser)
33
33
  {
34
- this .browser = browser;
35
- this .rootElement = undefined;
34
+ this .browser = browser;
35
+ this .rootElement = undefined;
36
+ this .canvasObserver = new MutationObserver (() => this .processCanvasMutation (browser));
36
37
 
37
- this .canvasObserver = new MutationObserver (() =>
38
- {
39
- this .observeRoot (this .browser .getElement () .children ("X3D") [0]);
40
- });
41
-
42
- this .canvasObserver .observe (this .browser .getElement () [0], {
38
+ this .canvasObserver .observe (browser .getElement () [0], {
43
39
  childList: true,
44
40
  });
45
41
 
46
- const rootElement = this .browser .getElement () .children ("X3D") [0];
42
+ this .processCanvasMutation (browser)
43
+ }
47
44
 
48
- if (rootElement)
49
- this .observeRoot (rootElement);
45
+ processCanvasMutation (browser)
46
+ {
47
+ this .processRootElement (browser, browser .getElement () .children ("X3D") .get (-1));
50
48
  }
51
49
 
52
- async observeRoot (rootElement)
50
+ async processRootElement (browser, rootElement)
53
51
  {
54
52
  try
55
53
  {
@@ -62,21 +60,20 @@ class DOMIntegration
62
60
  {
63
61
  // Display splash screen.
64
62
 
65
- this .browser .setBrowserLoading (true);
66
- this .browser .addLoadingObject (this);
63
+ browser .setBrowserLoading (true);
64
+ browser .addLoadingObject (this);
67
65
 
68
- // Preprocess script nodes if not xhtml.
66
+ // Now also attached node property to each node element.
69
67
 
70
- if (! location .pathname .toLowerCase () .endsWith (".xhtml"))
71
- this .preprocessScriptElements (rootElement);
68
+ const scene = browser .createScene ();
72
69
 
73
- // Now also attached x3d property to each node element.
70
+ this .parser = new XMLParser (scene);
74
71
 
75
- const importedScene = await this .browser .importDocument (rootElement, true);
72
+ this .parser .setInput (rootElement);
76
73
 
77
- this .browser .replaceWorld (importedScene);
74
+ await new Promise (this .parser .parseIntoScene .bind (this .parser));
78
75
 
79
- this .parser = new XMLParser (importedScene);
76
+ browser .replaceWorld (scene);
80
77
 
81
78
  // Create an observer instance.
82
79
 
@@ -101,11 +98,11 @@ class DOMIntegration
101
98
  this .processInlineElements (rootElement);
102
99
  this .addEventDispatchersAll (rootElement);
103
100
 
104
- this .browser .removeLoadingObject (this);
101
+ browser .removeLoadingObject (this);
105
102
  }
106
103
  else
107
104
  {
108
- this .browser .replaceWorld (null);
105
+ browser .replaceWorld (null);
109
106
  }
110
107
  }
111
108
  catch (error)
@@ -114,27 +111,6 @@ class DOMIntegration
114
111
  }
115
112
  }
116
113
 
117
- preprocessScriptElements (rootElement)
118
- {
119
- const scriptElements = rootElement .querySelectorAll ("Script");
120
-
121
- for (const scriptElement of scriptElements)
122
- this .appendScriptElementChildren (scriptElement);
123
- }
124
-
125
- appendScriptElementChildren (scriptElement)
126
- {
127
- const
128
- domParser = new DOMParser (),
129
- scriptDoc = domParser .parseFromString (scriptElement .outerHTML, "application/xml"),
130
- scriptNodes = scriptDoc .children [0] .childNodes;
131
-
132
- scriptElement .textContent = "// Content moved into childNodes.";
133
-
134
- for (const scriptNode of scriptNodes)
135
- scriptElement .appendChild (scriptNode);
136
- }
137
-
138
114
  processMutation (mutation)
139
115
  {
140
116
  switch (mutation .type)
@@ -159,13 +135,15 @@ class DOMIntegration
159
135
 
160
136
  processAttribute (mutation, element)
161
137
  {
138
+ const parser = this .parser;
139
+
162
140
  if ($.data (element, "node"))
163
141
  {
164
142
  const
165
143
  attributeName = mutation .attributeName,
166
144
  attribute = element .attributes .getNamedItem (attributeName);
167
145
 
168
- this .parser .nodeAttribute (attribute, $.data (element, "node"));
146
+ parser .nodeAttribute (attribute, $.data (element, "node"));
169
147
  }
170
148
  else
171
149
  {
@@ -175,11 +153,11 @@ class DOMIntegration
175
153
  parentNode = element .parentNode,
176
154
  node = $.data (parentNode, "node");
177
155
 
178
- this .parser .pushExecutionContext (node .getExecutionContext ());
179
- this .parser .pushParent (node);
180
- this .parser .childElement (element);
181
- this .parser .popParent ();
182
- this .parser .popExecutionContext ();
156
+ parser .pushExecutionContext (node .getExecutionContext ());
157
+ parser .pushParent (node);
158
+ parser .childElement (element);
159
+ parser .popParent ();
160
+ parser .popExecutionContext ();
183
161
  }
184
162
  }
185
163
 
@@ -275,6 +253,8 @@ class DOMIntegration
275
253
  return;
276
254
 
277
255
  node ._loadState .addInterest ("appendInlineChildElement", this, element);
256
+
257
+ this .appendInlineChildElement (element);
278
258
  }
279
259
 
280
260
  appendInlineChildElement (element)
@@ -309,12 +289,36 @@ class DOMIntegration
309
289
 
310
290
  // Add Inline elements, and connect to node events.
311
291
 
312
- this .processInlineElements (element);
313
- this .addEventDispatchersAll (element);
292
+ this .processInlineElements (X3DElement);
293
+ this .addEventDispatchersAll (X3DElement);
314
294
 
315
295
  break;
316
296
  }
317
297
  }
298
+
299
+ switch (node .checkLoadState ())
300
+ {
301
+ case X3DConstants .COMPLETE_STATE:
302
+ {
303
+ const event = new CustomEvent ("load",
304
+ {
305
+ detail: { node: SFNodeCache .get (node) },
306
+ });
307
+
308
+ element .dispatchEvent (event);
309
+ break;
310
+ }
311
+ case X3DConstants .FAILED_STATE:
312
+ {
313
+ const event = new CustomEvent ("error",
314
+ {
315
+ detail: { node: SFNodeCache .get (node) },
316
+ });
317
+
318
+ element .dispatchEvent (event);
319
+ break;
320
+ }
321
+ }
318
322
  }
319
323
 
320
324
  addEventDispatchersAll (element)
@@ -356,9 +360,13 @@ class DOMIntegration
356
360
  {
357
361
  const node = $.data (element, "node");
358
362
 
359
- const event = new CustomEvent (field .getName (), {
363
+ if (! node)
364
+ return;
365
+
366
+ const event = new CustomEvent (field .getName (),
367
+ {
360
368
  detail: {
361
- node: node ? SFNodeCache .get (node) : null,
369
+ node: SFNodeCache .get (node),
362
370
  value: field .valueOf (),
363
371
  },
364
372
  });
@@ -45,4 +45,4 @@
45
45
  *
46
46
  ******************************************************************************/
47
47
 
48
- export default "8.3.1";
48
+ export default "8.3.3";
@@ -72,7 +72,8 @@ import _ from "../../locale/gettext.js";
72
72
  const
73
73
  _DOMIntegration = Symbol (),
74
74
  _loader = Symbol (),
75
- _browserCallbacks = Symbol ();
75
+ _browserCallbacks = Symbol (),
76
+ _console = Symbol ();
76
77
 
77
78
  function X3DBrowser (element)
78
79
  {
@@ -86,6 +87,7 @@ function X3DBrowser (element)
86
87
  X3DBrowserContext .call (this, element);
87
88
 
88
89
  this [_browserCallbacks] = new Map ();
90
+ this [_console] = document .getElementsByClassName ("x_ite-console");
89
91
 
90
92
  this .setup ();
91
93
  };
@@ -119,25 +121,28 @@ X3DBrowser .prototype = Object .assign (Object .create (X3DBrowserContext .proto
119
121
 
120
122
  if (this .getInstanceId () > 1) return;
121
123
 
122
- this .print ("Welcome to " + this .name + " X3D Browser v" + this .version + ":\n" +
123
- " Current Graphics Renderer\n" +
124
- " Name: " + this .getVendor () + " " + this .getRenderer () + "\n" +
125
- " WebGL version: " + this .getWebGLVersion () + "\n" +
126
- " Shading language: " + this .getShadingLanguageVersion () + "\n" +
127
- " Rendering Properties\n" +
128
- " Antialiased: " + this .getAntialiased () + "\n" +
129
- " Depth size: " + this .getDepthSize () + " bits\n" +
130
- " Color depth: " + this .getColorDepth () + " bits\n" +
131
- " Max clip planes per shape: " + this .getMaxClipPlanes () + "\n" +
132
- " Max lights per shape: " + this .getMaxLights () + "\n" +
133
- " Max multi textures per shape: " + this .getMaxTextures () + "\n" +
134
- " Texture units: " + this .getMaxCombinedTextureUnits () + "\n" +
135
- " Max texture size: " + this .getMaxTextureSize () + " × " + this .getMaxTextureSize () + " pixels\n" +
136
- " Texture memory: " + this .getTextureMemory () + "\n" +
137
- " Max vertex uniform vectors: " + this .getMaxVertexUniformVectors () + "\n" +
138
- " Max fragment uniform vectors: " + this .getMaxFragmentUniformVectors () + "\n" +
139
- " Max vertex attribs: " + this .getMaxVertexAttribs () + "\n" +
140
- " Max varying vectors: " + this .getMaxVaryingVectors () + "\n");
124
+ $(() =>
125
+ {
126
+ this .print ("Welcome to " + this .name + " X3D Browser v" + this .version + ":\n" +
127
+ " Current Graphics Renderer\n" +
128
+ " Name: " + this .getVendor () + " " + this .getRenderer () + "\n" +
129
+ " WebGL version: " + this .getWebGLVersion () + "\n" +
130
+ " Shading language: " + this .getShadingLanguageVersion () + "\n" +
131
+ " Rendering Properties\n" +
132
+ " Antialiased: " + this .getAntialiased () + "\n" +
133
+ " Depth size: " + this .getDepthSize () + " bits\n" +
134
+ " Color depth: " + this .getColorDepth () + " bits\n" +
135
+ " Max clip planes per shape: " + this .getMaxClipPlanes () + "\n" +
136
+ " Max lights per shape: " + this .getMaxLights () + "\n" +
137
+ " Max multi textures per shape: " + this .getMaxTextures () + "\n" +
138
+ " Texture units: " + this .getMaxCombinedTextureUnits () + "\n" +
139
+ " Max texture size: " + this .getMaxTextureSize () + " × " + this .getMaxTextureSize () + " pixels\n" +
140
+ " Texture memory: " + this .getTextureMemory () + "\n" +
141
+ " Max vertex uniform vectors: " + this .getMaxVertexUniformVectors () + "\n" +
142
+ " Max fragment uniform vectors: " + this .getMaxFragmentUniformVectors () + "\n" +
143
+ " Max vertex attribs: " + this .getMaxVertexAttribs () + "\n" +
144
+ " Max varying vectors: " + this .getMaxVaryingVectors () + "\n");
145
+ });
141
146
  },
142
147
  getName: function ()
143
148
  {
@@ -333,7 +338,7 @@ X3DBrowser .prototype = Object .assign (Object .create (X3DBrowserContext .proto
333
338
  if (loadCount .getValue ())
334
339
  return;
335
340
 
336
- this ._loadCount .removeInterest ("checkLoadCount", this);
341
+ loadCount .removeInterest ("checkLoadCount", this);
337
342
  this .initialized () .set (this .getCurrentTime ());
338
343
  this .initialized () .processInterests ();
339
344
  this .callBrowserCallbacks (X3DConstants .INITIALIZED_EVENT);
@@ -781,23 +786,33 @@ X3DBrowser .prototype = Object .assign (Object .create (X3DBrowserContext .proto
781
786
  },
782
787
  print: function ()
783
788
  {
784
- console .log (Array .prototype .join .call (arguments, " "));
789
+ const string = Array .prototype .join .call (arguments, "");
790
+
791
+ console .log (string);
792
+
793
+ for (const element of this [_console])
794
+ element .append (document .createTextNode (string));
785
795
  },
786
796
  println: function ()
787
797
  {
788
- console .log (Array .prototype .join .call (arguments, " "));
798
+ const string = Array .prototype .join .call (arguments, "");
799
+
800
+ console .log (string);
801
+
802
+ for (const element of this [_console])
803
+ element .append (document .createTextNode (string + "\n"));
789
804
  },
790
- toVRMLStream: function (stream)
805
+ toVRMLStream: function (generator)
791
806
  {
792
- this .currentScene .toVRMLStream (stream);
807
+ this .currentScene .toVRMLStream (generator);
793
808
  },
794
- toXMLStream: function (stream)
809
+ toXMLStream: function (generator)
795
810
  {
796
- this .currentScene .toXMLStream (stream);
811
+ this .currentScene .toXMLStream (generator);
797
812
  },
798
- toJSONStream: function (stream)
813
+ toJSONStream: function (generator)
799
814
  {
800
- this .currentScene .toJSONStream (stream);
815
+ this .currentScene .toJSONStream (generator);
801
816
  },
802
817
  });
803
818
 
@@ -341,6 +341,9 @@ Object .assign (X3DBrowserContext,
341
341
  X3D = window [Symbol .for ("X_ITE.X3D")],
342
342
  browser = X3D .getBrowser (canvas);
343
343
 
344
+ if (! browser)
345
+ return;
346
+
344
347
  browserContext .call (browser);
345
348
 
346
349
  if (typeof browserContext .prototype .initialize === "function")