x_ite 4.7.6 → 4.7.10

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 (148) hide show
  1. package/.vscode/settings.json +1 -2
  2. package/Makefile +1 -0
  3. package/build/components/annotation.build.js +2 -2
  4. package/build/components/cad-geometry.build.js +2 -2
  5. package/build/components/cube-map-texturing.build.js +2 -2
  6. package/build/components/dis.build.js +2 -2
  7. package/build/components/event-utilities.build.js +2 -2
  8. package/build/components/geometry2d.build.js +2 -2
  9. package/build/components/geospatial.build.js +2 -2
  10. package/build/components/h-anim.build.js +2 -2
  11. package/build/components/key-device-sensor.build.js +2 -2
  12. package/build/components/layout.build.js +2 -2
  13. package/build/components/nurbs.build.js +2 -2
  14. package/build/components/particle-systems.build.js +2 -2
  15. package/build/components/picking.build.js +2 -2
  16. package/build/components/projective-texture-mapping.build.js +2 -2
  17. package/build/components/rigid-body-physics.build.js +2 -2
  18. package/build/components/scripting.build.js +2 -2
  19. package/build/components/texturing-3d.build.js +2 -2
  20. package/build/components/volume-rendering.build.js +2 -2
  21. package/build/components/x_ite.build.js +2 -2
  22. package/build/parts/default.end.frag.js +2 -0
  23. package/build/parts/default.start.frag.js +8 -0
  24. package/build/parts/{x_ite.end.frag → x_ite.end.frag.js} +2 -8
  25. package/build/parts/x_ite.start.frag.js +11 -0
  26. package/build/x_ite.build.js +2 -2
  27. package/dist/assets/components/annotation.js +9 -7
  28. package/dist/assets/components/annotation.min.js +1 -1
  29. package/dist/assets/components/cad-geometry.js +9 -7
  30. package/dist/assets/components/cad-geometry.min.js +1 -1
  31. package/dist/assets/components/cube-map-texturing.js +9 -7
  32. package/dist/assets/components/cube-map-texturing.min.js +1 -1
  33. package/dist/assets/components/dis.js +9 -7
  34. package/dist/assets/components/dis.min.js +1 -1
  35. package/dist/assets/components/event-utilities.js +9 -7
  36. package/dist/assets/components/event-utilities.min.js +1 -1
  37. package/dist/assets/components/geometry2d.js +9 -7
  38. package/dist/assets/components/geometry2d.min.js +1 -1
  39. package/dist/assets/components/geospatial.js +9 -7
  40. package/dist/assets/components/geospatial.min.js +2 -2
  41. package/dist/assets/components/h-anim.js +9 -7
  42. package/dist/assets/components/h-anim.min.js +1 -1
  43. package/dist/assets/components/key-device-sensor.js +9 -7
  44. package/dist/assets/components/key-device-sensor.min.js +1 -1
  45. package/dist/assets/components/layout.js +9 -7
  46. package/dist/assets/components/layout.min.js +1 -1
  47. package/dist/assets/components/nurbs.js +9 -7
  48. package/dist/assets/components/nurbs.min.js +2 -2
  49. package/dist/assets/components/particle-systems.js +9 -7
  50. package/dist/assets/components/particle-systems.min.js +2 -2
  51. package/dist/assets/components/picking.js +13 -11
  52. package/dist/assets/components/picking.min.js +1 -1
  53. package/dist/assets/components/projective-texture-mapping.js +9 -7
  54. package/dist/assets/components/projective-texture-mapping.min.js +1 -1
  55. package/dist/assets/components/rigid-body-physics.js +9 -7
  56. package/dist/assets/components/rigid-body-physics.min.js +17 -17
  57. package/dist/assets/components/scripting.js +16 -9
  58. package/dist/assets/components/scripting.min.js +1 -1
  59. package/dist/assets/components/texturing-3d.js +9 -7
  60. package/dist/assets/components/texturing-3d.min.js +3 -3
  61. package/dist/assets/components/volume-rendering.js +11 -9
  62. package/dist/assets/components/volume-rendering.min.js +3 -3
  63. package/dist/assets/components/x_ite.js +9 -7
  64. package/dist/assets/components/x_ite.min.js +1 -1
  65. package/dist/assets/shaders/webgl1/FallbackUnlit.fs +3 -4
  66. package/dist/assets/shaders/webgl1/Gouraud.vs +0 -1
  67. package/dist/assets/shaders/webgl1/Phong.fs +0 -1
  68. package/dist/assets/shaders/webgl1/Unlit.fs +0 -3
  69. package/dist/assets/shaders/webgl2/Gouraud.vs +0 -1
  70. package/dist/assets/shaders/webgl2/Phong.fs +0 -1
  71. package/dist/assets/shaders/webgl2/Unlit.fs +0 -3
  72. package/dist/example.html +2 -2
  73. package/dist/x_ite.css +14 -9
  74. package/dist/x_ite.js +29499 -28932
  75. package/dist/x_ite.min.js +41 -41
  76. package/dist/x_ite.zip +0 -0
  77. package/docs/Accessing-the-External-Browser.md +19 -4
  78. package/docs/What's-New.md +23 -0
  79. package/docs/_config.yml +1 -1
  80. package/docs/index.md +42 -14
  81. package/docs/reference/Browser-Services.md +38 -10
  82. package/docs/reference/Script-Node-Authoring-Interface.md +12 -4
  83. package/package.json +6 -5
  84. package/src/assets/components/picking.js +2 -2
  85. package/src/assets/components/volume-rendering.js +2 -2
  86. package/src/assets/shaders/webgl1/FallbackUnlit.fs +3 -4
  87. package/src/assets/shaders/webgl1/Gouraud.vs +0 -1
  88. package/src/assets/shaders/webgl1/Phong.fs +0 -1
  89. package/src/assets/shaders/webgl1/Unlit.fs +0 -3
  90. package/src/assets/shaders/webgl2/Gouraud.vs +0 -1
  91. package/src/assets/shaders/webgl2/Phong.fs +0 -1
  92. package/src/assets/shaders/webgl2/Unlit.fs +0 -3
  93. package/src/bookmarks.js +8 -11
  94. package/src/examples.js +1 -1
  95. package/src/locale/de.po +19 -75
  96. package/src/locale/fr.po +18 -75
  97. package/src/standard/Time/MicroTime.js +3 -1
  98. package/src/standard/Utility/DataStorage.js +23 -12
  99. package/src/tests.js +1 -1
  100. package/src/x_ite/Browser/Core/BrowserOptions.js +40 -28
  101. package/src/x_ite/Browser/Core/BrowserTimings.js +13 -24
  102. package/src/x_ite/Browser/Core/ContextMenu.js +94 -16
  103. package/src/x_ite/Browser/Core/X3DCoreContext.js +95 -42
  104. package/src/x_ite/Browser/Navigation/ExamineViewer.js +3 -0
  105. package/src/x_ite/Browser/Navigation/LookAtViewer.js +3 -0
  106. package/src/x_ite/Browser/Navigation/PlaneViewer.js +3 -0
  107. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +3 -0
  108. package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +1 -3
  109. package/src/x_ite/Browser/Picking/VolumePicker.js +1 -1
  110. package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +4 -1
  111. package/src/x_ite/Browser/Shaders/ShaderTest.js +3 -3
  112. package/src/x_ite/Browser/VERSION.js +1 -1
  113. package/src/x_ite/Browser/X3DBrowser.js +70 -50
  114. package/src/x_ite/Components/Picking/PointPickSensor.js +1 -1
  115. package/src/x_ite/Components/Scripting/Script.js +7 -2
  116. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +10 -12
  117. package/src/x_ite/Components/Shaders.js +9 -9
  118. package/src/x_ite/Execution/X3DExecutionContext.js +9 -11
  119. package/src/x_ite/Fields/SFColor.js +20 -7
  120. package/src/x_ite/Fields/SFColorRGBA.js +6 -6
  121. package/src/x_ite/Fields/SFDouble.js +2 -2
  122. package/src/x_ite/Fields/SFFloat.js +2 -2
  123. package/src/x_ite/Fields/SFImage.js +13 -13
  124. package/src/x_ite/Fields/SFMatrix3.js +5 -5
  125. package/src/x_ite/Fields/SFMatrix4.js +6 -6
  126. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +14 -3
  127. package/src/x_ite/Fields/SFNode.js +23 -19
  128. package/src/x_ite/Fields/SFNodeCache.js +14 -10
  129. package/src/x_ite/Fields/SFRotation.js +10 -10
  130. package/src/x_ite/Fields/SFString.js +1 -1
  131. package/src/x_ite/Fields/SFTime.js +1 -1
  132. package/src/x_ite/Fields/SFVec2.js +6 -6
  133. package/src/x_ite/Fields/SFVec3.js +7 -7
  134. package/src/x_ite/Fields/SFVec4.js +8 -8
  135. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +7 -6
  136. package/src/x_ite/InputOutput/Generator.js +85 -65
  137. package/src/x_ite/Parser/X3DParser.js +6 -0
  138. package/src/x_ite/Parser/XMLParser.js +1 -1
  139. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +1 -1
  140. package/src/x_ite/X3D.js +8 -2
  141. package/src/x_ite.config.js +0 -5
  142. package/src/x_ite.css +14 -8
  143. package/src/x_ite.html +3 -3
  144. package/src/x_ite.js +21 -12
  145. package/x_ite.min.html +3 -3
  146. package/build/parts/default.end.frag +0 -2
  147. package/build/parts/default.start.frag +0 -6
  148. package/build/parts/x_ite.start.frag +0 -8
@@ -56,7 +56,6 @@ define ([
56
56
  "x_ite/Browser/Core/PrimitiveQuality",
57
57
  "x_ite/Browser/Core/Shading",
58
58
  "x_ite/Browser/Core/TextureQuality",
59
- "x_ite/Browser/Navigation/X3DFlyViewer",
60
59
  ],
61
60
  function (Fields,
62
61
  X3DFieldDefinition,
@@ -65,8 +64,7 @@ function (Fields,
65
64
  X3DConstants,
66
65
  PrimitiveQuality,
67
66
  Shading,
68
- TextureQuality,
69
- X3DFlyViewer)
67
+ TextureQuality)
70
68
  {
71
69
  "use strict";
72
70
 
@@ -111,6 +109,7 @@ function (Fields,
111
109
  new X3DFieldDefinition (X3DConstants .inputOutput, "Gravity", new Fields .SFFloat (9.80665)),
112
110
  new X3DFieldDefinition (X3DConstants .inputOutput, "StraightenHorizon", new Fields .SFBool (true)),
113
111
  new X3DFieldDefinition (X3DConstants .inputOutput, "LogarithmicDepthBuffer", new Fields .SFBool (false)),
112
+ new X3DFieldDefinition (X3DConstants .inputOutput, "Timings", new Fields .SFBool (false)),
114
113
  ]),
115
114
  getTypeName: function ()
116
115
  {
@@ -135,34 +134,37 @@ function (Fields,
135
134
  this .Shading_ .addInterest ("set_shading__", this);
136
135
  this .StraightenHorizon_ .addInterest ("set_straightenHorizon__", this);
137
136
  this .LogarithmicDepthBuffer_ .addInterest ("set_logarithmicDepthBuffer__", this);
137
+ this .Timings_ .addInterest ("set_timings__", this);
138
138
 
139
139
  this .configure ();
140
140
  },
141
141
  configure: function ()
142
142
  {
143
- if (! this .isInitialized ())
143
+ if (!this .isInitialized ())
144
144
  return;
145
145
 
146
- var fieldDefinitions = this .getFieldDefinitions ();
146
+ const
147
+ browser = this .getBrowser (),
148
+ localStorage = browser .getLocalStorage (),
149
+ fieldDefinitions = this .getFieldDefinitions ();
147
150
 
148
- for (var i = 0; i < fieldDefinitions .length; ++ i)
151
+ for (const fieldDefinition of fieldDefinitions)
149
152
  {
150
- var
151
- fieldDefinition = fieldDefinitions [i],
152
- field = this .getField (fieldDefinition .name);
153
+ const field = this .getField (fieldDefinition .name);
153
154
 
154
- if (this .getBrowser () .getLocalStorage () ["BrowserOptions." + fieldDefinition .name] !== undefined)
155
+ if (localStorage ["BrowserOptions." + fieldDefinition .name] !== undefined)
155
156
  continue;
156
157
 
157
- if (! field .equals (fieldDefinition .value))
158
+ if (!field .equals (fieldDefinition .value))
158
159
  field .setValue (fieldDefinition .value);
159
160
  }
160
161
 
161
- var
162
- rubberband = this .getBrowser () .getLocalStorage () ["BrowserOptions.Rubberband"],
163
- primitiveQuality = this .getBrowser () .getLocalStorage () ["BrowserOptions.PrimitiveQuality"],
164
- textureQuality = this .getBrowser () .getLocalStorage () ["BrowserOptions.TextureQuality"],
165
- straightenHorizon = this .getBrowser () .getLocalStorage () ["BrowserOptions.StraightenHorizon"];
162
+ const
163
+ rubberband = localStorage ["BrowserOptions.Rubberband"],
164
+ primitiveQuality = localStorage ["BrowserOptions.PrimitiveQuality"],
165
+ textureQuality = localStorage ["BrowserOptions.TextureQuality"],
166
+ straightenHorizon = localStorage ["BrowserOptions.StraightenHorizon"],
167
+ timings = localStorage ["BrowserOptions.Timings"];
166
168
 
167
169
  this .setAttributeSplashScreen ();
168
170
 
@@ -177,6 +179,9 @@ function (Fields,
177
179
 
178
180
  if (straightenHorizon !== undefined && straightenHorizon !== this .StraightenHorizon_ .getValue ())
179
181
  this .StraightenHorizon_ = straightenHorizon;
182
+
183
+ if (timings !== undefined && timings !== this .Timings_ .getValue ())
184
+ this .Timings_ = timings;
180
185
  },
181
186
  setAttributeSplashScreen: function ()
182
187
  {
@@ -202,10 +207,6 @@ function (Fields,
202
207
  {
203
208
  return toBoolean (this .getBrowser () .getElement () .attr ("splashScreen"), true);
204
209
  },
205
- getTimings: function ()
206
- {
207
- return toBoolean (this .getBrowser () .getElement () .attr ("timings"), true);
208
- },
209
210
  getPrimitiveQuality: function ()
210
211
  {
211
212
  return this .primitiveQuality;
@@ -229,13 +230,14 @@ function (Fields,
229
230
  },
230
231
  set_primitiveQuality__: function (value)
231
232
  {
232
- var
233
+ const
233
234
  browser = this .getBrowser (),
235
+ localStorage = browser .getLocalStorage (),
234
236
  primitiveQuality = value .getValue () .toUpperCase ();
235
237
 
236
- browser .getLocalStorage () ["BrowserOptions.PrimitiveQuality"] = primitiveQuality;
238
+ localStorage ["BrowserOptions.PrimitiveQuality"] = primitiveQuality;
237
239
 
238
- var
240
+ const
239
241
  cone = browser .getConeOptions (),
240
242
  cylinder = browser .getCylinderOptions (),
241
243
  sphere = browser .getSphereOptions ();
@@ -294,11 +296,14 @@ function (Fields,
294
296
  },
295
297
  set_textureQuality__: function (value)
296
298
  {
297
- var textureQuality = value .getValue () .toUpperCase ();
299
+ const
300
+ browser = this .getBrowser (),
301
+ localStorage = browser .getLocalStorage (),
302
+ textureQuality = value .getValue () .toUpperCase ();
298
303
 
299
- this .getBrowser () .getLocalStorage () ["BrowserOptions.TextureQuality"] = textureQuality;
304
+ localStorage ["BrowserOptions.TextureQuality"] = textureQuality;
300
305
 
301
- var textureProperties = this .getBrowser () .getDefaultTextureProperties ();
306
+ const textureProperties = this .getBrowser () .getDefaultTextureProperties ();
302
307
 
303
308
  switch (textureQuality)
304
309
  {
@@ -354,7 +359,7 @@ function (Fields,
354
359
  },
355
360
  set_shading__: function (value)
356
361
  {
357
- var shading = value .getValue () .toUpperCase ();
362
+ const shading = value .getValue () .toUpperCase ();
358
363
 
359
364
  switch (shading)
360
365
  {
@@ -394,7 +399,7 @@ function (Fields,
394
399
  },
395
400
  set_logarithmicDepthBuffer__: function (logarithmicDepthBuffer)
396
401
  {
397
- var
402
+ const
398
403
  browser = this .getBrowser (),
399
404
  gl = browser .getContext ();
400
405
 
@@ -439,6 +444,13 @@ function (Fields,
439
444
  browser .getShadowShader () .parts_ [1] .getValue () .url_ .addEvent ();
440
445
  }
441
446
  },
447
+ set_timings__: function (timings)
448
+ {
449
+ const browser = this .getBrowser ();
450
+
451
+ browser .getLocalStorage () ["BrowserOptions.Timings"] = timings .getValue ();
452
+ browser .getBrowserTimings () .setEnabled (timings .getValue ());
453
+ },
442
454
  });
443
455
 
444
456
  return BrowserOptions;
@@ -49,24 +49,22 @@
49
49
 
50
50
  define ([
51
51
  "jquery",
52
- "x_ite/Fields/SFBool",
53
52
  "x_ite/Basic/X3DBaseNode",
54
53
  "locale/gettext",
55
54
  ],
56
55
  function ($,
57
- SFBool,
58
56
  X3DBaseNode,
59
57
  _)
60
58
  {
61
59
  "use strict";
62
60
 
63
- function f2 (n) { return Math .floor (n * 100) / 100; }
61
+ function f2 (n) { return n .toFixed (2); }
64
62
 
65
63
  function BrowserTimings (executionContext)
66
64
  {
67
65
  X3DBaseNode .call (this, executionContext);
68
66
 
69
- this .addChildObjects ("enabled", new SFBool ());
67
+ this .enabled = false;
70
68
  }
71
69
 
72
70
  BrowserTimings .prototype = Object .assign (Object .create (X3DBaseNode .prototype),
@@ -88,8 +86,6 @@ function ($,
88
86
  {
89
87
  X3DBaseNode .prototype .initialize .call (this);
90
88
 
91
- this .enabled_ .addInterest ("set_enabled__", this);
92
-
93
89
  this .localeOptions = { minimumFractionDigits: 2, maximumFractionDigits: 2 };
94
90
  this .type = this .getBrowser () .getLocalStorage () ["BrowserTimings.type"] || "LESS";
95
91
  this .startTime = 0;
@@ -104,26 +100,19 @@ function ($,
104
100
  this .rows = [ ];
105
101
 
106
102
  this .set_button__ ();
107
-
108
- if (this .getBrowser () .getLocalStorage () ["BrowserTimings.enabled"])
109
- this .enabled_ = true;
110
- },
111
- setEnabled: function (value)
112
- {
113
- this .enabled_ = value;
114
103
  },
115
104
  getEnabled: function ()
116
105
  {
117
- return this .enabled_ .getValue ();
106
+ return this .enabled;
118
107
  },
119
- set_enabled__: function (enabled)
108
+ setEnabled: function (enabled)
120
109
  {
121
- if (! this .getBrowser () .getBrowserOptions () .getTimings ())
110
+ if (this .enabled === enabled)
122
111
  return;
123
112
 
124
- this .getBrowser () .getLocalStorage () ["BrowserTimings.enabled"] = enabled .getValue ();
113
+ this .enabled = enabled;
125
114
 
126
- if (enabled .getValue ())
115
+ if (enabled)
127
116
  {
128
117
  this .element .fadeIn ();
129
118
  this .getBrowser () .prepareEvents () .addInterest ("update", this);
@@ -205,15 +194,15 @@ function ($,
205
194
  rows [1] .addClass ("x_ite-private-more");
206
195
 
207
196
  rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Browser") + ":")) .append ($("<td></td>") .text (f2(systemTime) .toLocaleString (language, fixed) + " " + _("ms")));
208
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("X3D") + ":")) .append ($("<td></td>") .text (f2(browser .browserTime) .toLocaleString (language, fixed) + " " + _("ms")));
209
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Routing") + ":")) .append ($("<td></td>") .text (f2(routingTime) .toLocaleString (language, fixed) + " " + _("ms")));
197
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("X3D total") + ":")) .append ($("<td></td>") .text (f2(browser .browserTime) .toLocaleString (language, fixed) + " " + _("ms")));
198
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Event Processing") + ":")) .append ($("<td></td>") .text (f2(routingTime) .toLocaleString (language, fixed) + " " + _("ms")));
210
199
  rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Pointer") + ":")) .append ($("<td></td>") .text (f2(browser .pointerTime) .toLocaleString (language, fixed) + " " + _("ms")));
211
200
  rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Camera") + ":")) .append ($("<td></td>") .text (f2(browser .cameraTime) .toLocaleString (language, fixed) + " " + _("ms")));
212
201
  rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Picking") + ":")) .append ($("<td></td>") .text (f2(browser .pickingTime) .toLocaleString (language, fixed) + " " + _("ms")));
213
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Collision") + ":")) .append ($("<td></td>") .text (f2(collisionTime) .toLocaleString (language, fixed) + " " + _("ms")));
214
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Display") + ":")) .append ($("<td></td>") .text (f2(browser .displayTime) .toLocaleString (language, fixed) + " " + _("ms")));
215
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Shapes") + ":")) .append ($("<td></td>") .text (opaqueShapes + " + " + transparentShapes));
216
- rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Sensors") + ":")) .append ($("<td></td>") .text (prepareEvents + sensors));
202
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Collision Detection") + ":")) .append ($("<td></td>") .text (f2(collisionTime) .toLocaleString (language, fixed) + " " + _("ms")));
203
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Rendering") + ":")) .append ($("<td></td>") .text (f2(browser .displayTime) .toLocaleString (language, fixed) + " " + _("ms")));
204
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Number of Shapes") + ":")) .append ($("<td></td>") .text (opaqueShapes + " + " + transparentShapes));
205
+ rows [r++] = $("<tr></tr>") .append ($("<td></td>") .text (_("Number of Sensors") + ":")) .append ($("<td></td>") .text (prepareEvents + sensors));
217
206
  }
218
207
 
219
208
  rows .length = r;
@@ -63,6 +63,9 @@ function ($,
63
63
  function ContextMenu (executionContext)
64
64
  {
65
65
  X3DBaseNode .call (this, executionContext);
66
+
67
+ this .userMenu = null;
68
+ this .active = false;
66
69
  }
67
70
 
68
71
  ContextMenu .prototype = Object .assign (Object .create (X3DBaseNode .prototype),
@@ -98,6 +101,8 @@ function ($,
98
101
  {
99
102
  show: function (options)
100
103
  {
104
+ this .active = true;
105
+
101
106
  if (browser .getElement () .fullScreen ())
102
107
  {
103
108
  browser .getElement () .append (options .$menu);
@@ -112,19 +117,79 @@ function ($,
112
117
  },
113
118
  1);
114
119
  }
115
-
120
+ },
121
+ activated: function (options)
122
+ {
116
123
  // Display submenus on left side if there is no space on right side.
117
124
 
118
125
  if (options .$menu .hasClass ("x_ite-private-menu-submenus-left"))
119
126
  {
120
- options .$menu .find (".context-menu-item > .context-menu-list") .css ({
121
- "right": options .$menu .width () + "px",
127
+ options .$menu .find (".context-menu-list") .each (function (i, e)
128
+ {
129
+ $(e) .css ("right", $(e) .parent () .parent () .css ("width"));
122
130
  });
123
131
  }
124
- },
132
+ else
133
+ {
134
+ options .$menu .find (".context-menu-list") .each (function (i, e)
135
+ {
136
+ $(e) .css ("left", (parseInt ($(e) .parent () .parent () .css ("width")) - 2) + "px");
137
+ });
138
+ }
139
+
140
+ // If the submenu is higher than vh, add scrollbars.
141
+ options .$menu .find (".context-menu-list") .each (function (i, e)
142
+ {
143
+ if ($(e) .height () > $(window) .height ())
144
+ {
145
+ $(e) .css ({
146
+ "overflow-y": "scroll",
147
+ "max-height": "100vh",
148
+ });
149
+ }
150
+ });
151
+
152
+ // If the submenu is higher than vh, reposition it.
153
+ options .$menu .find (".context-menu-item") .on ("mouseenter", function (event)
154
+ {
155
+ event .stopImmediatePropagation ();
156
+
157
+ const
158
+ t = $(event .target),
159
+ e = t .children (".context-menu-list");
160
+
161
+ if (!e .length)
162
+ return;
163
+
164
+ e .css ("top", "");
165
+
166
+ const bottom = e .offset () .top + e .height () - $(window) .scrollTop () - $(window) .height ();
167
+
168
+ if (bottom > 0)
169
+ e .offset ({ "top": e .offset () .top - bottom });
170
+ });
171
+ }
172
+ .bind (this),
173
+ hide: function (options)
174
+ {
175
+ this .active = false;
176
+ }
177
+ .bind (this),
125
178
  },
126
179
  });
127
180
  },
181
+ getUserMenu: function ()
182
+ {
183
+ return this .userMenu;
184
+ },
185
+ setUserMenu: function (userMenu)
186
+ {
187
+ this .userMenu = userMenu;
188
+ },
189
+ getActive: function ()
190
+ {
191
+ return this .active;
192
+ },
128
193
  build: function (trigger, event)
129
194
  {
130
195
  const
@@ -313,19 +378,19 @@ function ($,
313
378
  .bind (this),
314
379
  },
315
380
  },
316
- "browser-timings": browser .getBrowserOptions () .getTimings () ? {
381
+ "browser-timings": {
317
382
  name: _("Browser Timings"),
318
383
  type: "checkbox",
319
- selected: browser .getBrowserTimings () .getEnabled (),
384
+ selected: browser .getBrowserOption ("Timings"),
320
385
  events: {
321
386
  click: function (event)
322
387
  {
323
- browser .getBrowserTimings () .setEnabled ($(event .target) .is (":checked"));
388
+ browser .setBrowserOption ("Timings", $(event .target) .is (":checked"));
324
389
  browser .getSurface () .focus ();
325
390
  }
326
391
  .bind (this),
327
392
  },
328
- } : undefined,
393
+ },
329
394
  "fullscreen": {
330
395
  name: fullscreen ? _("Leave Fullscreen") : _("Fullscreen"),
331
396
  className: "context-menu-icon " + (fullscreen ? "x_ite-private-icon-leave-fullscreen" : "x_ite-private-icon-fullscreen"),
@@ -354,9 +419,9 @@ function ($,
354
419
  priv = browser .getElement () .find (".x_ite-private-browser"),
355
420
  overlay = $("<div></div>") .addClass ("x_ite-private-world-info-overlay") .appendTo (priv),
356
421
  div = $("<div></div>") .addClass ("x_ite-private-world-info") .appendTo (overlay),
357
- worldInfo = browser .getExecutionContext () .getWorldInfo (),
358
- title = worldInfo .title_ .getValue (),
359
- info = worldInfo .info_;
422
+ worldInfo = browser .getExecutionContext () .getWorldInfos () [0],
423
+ title = worldInfo .title,
424
+ info = worldInfo .info;
360
425
 
361
426
  converter .setOption ("omitExtraWLInCodeBlocks", true);
362
427
  converter .setOption ("simplifiedAutoLink", true);
@@ -372,9 +437,9 @@ function ($,
372
437
  $("<div></div>") .addClass ("x_ite-private-world-info-title") .text (title) .appendTo (div);
373
438
  }
374
439
 
375
- for (var i = 0, length = info .length; i < length; ++ i)
440
+ for (const line of info)
376
441
  {
377
- $("<div></div>") .addClass ("x_ite-private-world-info-info") .html (converter .makeHtml (info [i])) .appendTo (div);
442
+ $("<div></div>") .addClass ("x_ite-private-world-info-info") .html (converter .makeHtml (line)) .appendTo (div);
378
443
  }
379
444
 
380
445
  div .find ("a") .on ("click", function (event) { event .stopPropagation (); });
@@ -400,9 +465,22 @@ function ($,
400
465
  window .open (browser .getProviderUrl ());
401
466
  },
402
467
  },
403
- }
468
+ },
404
469
  };
405
470
 
471
+ if ($.isFunction (this .userMenu))
472
+ {
473
+ const userMenu = this .userMenu ();
474
+
475
+ if ($.isPlainObject (userMenu))
476
+ {
477
+ Object .assign (menu .items, { "separator4": "--------" });
478
+
479
+ for (const key in userMenu)
480
+ menu .items ["user-" + key] = userMenu [key];
481
+ }
482
+ }
483
+
406
484
  if (leftSubMenus)
407
485
  menu .className += " x_ite-private-menu-submenus-left";
408
486
 
@@ -422,9 +500,9 @@ function ($,
422
500
  delete menu .items ["straighten-horizon"];
423
501
  }
424
502
 
425
- const worldInfo = browser .getExecutionContext () .getWorldInfo ();
503
+ const worldInfo = browser .getExecutionContext () .getWorldInfos () [0];
426
504
 
427
- if (!worldInfo || (worldInfo .title_ .getValue () .length === 0 && worldInfo .info_ .length === 0))
505
+ if (!worldInfo || (worldInfo .title .length === 0 && worldInfo .info .length === 0))
428
506
  {
429
507
  delete menu .items ["world-info"];
430
508
  }
@@ -50,29 +50,31 @@
50
50
  define ([
51
51
  "jquery",
52
52
  "x_ite/Fields",
53
+ "x_ite/Browser/Core/BrowserTimings",
53
54
  "x_ite/Browser/Core/BrowserOptions",
54
55
  "x_ite/Browser/Core/BrowserProperties",
55
56
  "x_ite/Browser/Core/RenderingProperties",
56
57
  "x_ite/Browser/Core/Notification",
57
- "x_ite/Browser/Core/BrowserTimings",
58
58
  "x_ite/Browser/Core/ContextMenu",
59
59
  "x_ite/Execution/Scene",
60
60
  "x_ite/Parser/Parser",
61
61
  "standard/Utility/DataStorage",
62
- "x_ite/DEBUG",
62
+ "standard/Math/Numbers/Vector3",
63
+ "locale/gettext",
63
64
  ],
64
65
  function ($,
65
66
  Fields,
67
+ BrowserTimings,
66
68
  BrowserOptions,
67
69
  BrowserProperties,
68
70
  RenderingProperties,
69
71
  Notification,
70
- BrowserTimings,
71
72
  ContextMenu,
72
73
  Scene,
73
74
  Parser,
74
75
  DataStorage,
75
- DEBUG)
76
+ Vector3,
77
+ _)
76
78
  {
77
79
  "use strict";
78
80
 
@@ -178,11 +180,11 @@ function ($,
178
180
  return gl;
179
181
  }
180
182
 
181
- let browserId = 0;
183
+ let browserNumber = 0;
182
184
 
183
185
  function X3DCoreContext (element)
184
186
  {
185
- this .number = ++ browserId;
187
+ this .number = ++ browserNumber;
186
188
  this .element = element;
187
189
 
188
190
  // Get canvas & context.
@@ -212,16 +214,16 @@ function ($,
212
214
  },
213
215
  this);
214
216
 
217
+ this .localStorage = new DataStorage (localStorage, "X_ITE.X3DBrowser(" + this .number + ").");
218
+ this .mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i .test (navigator .userAgent);
219
+
220
+ this .browserTimings = new BrowserTimings (this .getPrivateScene ());
215
221
  this .browserOptions = new BrowserOptions (this .getPrivateScene ());
216
222
  this .browserProperties = new BrowserProperties (this .getPrivateScene ());
217
223
  this .renderingProperties = new RenderingProperties (this .getPrivateScene ());
218
224
  this .notification = new Notification (this .getPrivateScene ());
219
- this .browserTimings = new BrowserTimings (this .getPrivateScene ());
220
225
  this .contextMenu = new ContextMenu (this .getPrivateScene ());
221
226
 
222
- this .localStorage = new DataStorage (localStorage, "X_ITE.X3DBrowser(" + this .number + ").");
223
- this .mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i .test (navigator .userAgent);
224
-
225
227
  $(".x_ite-console") .empty ();
226
228
 
227
229
  this .addChildObjects ("controlKey", new Fields .SFBool (),
@@ -236,11 +238,11 @@ function ($,
236
238
  {
237
239
  // Setup browser nodes.
238
240
 
241
+ this .browserTimings .setup ();
239
242
  this .browserOptions .setup ()
240
243
  this .browserProperties .setup ()
241
244
  this .renderingProperties .setup ();
242
245
  this .notification .setup ();
243
- this .browserTimings .setup ();
244
246
  this .contextMenu .setup ();
245
247
 
246
248
  // Observe Element's attributes.
@@ -333,6 +335,18 @@ function ($,
333
335
  {
334
336
  return this .extensions [name];
335
337
  },
338
+ getMobile: function ()
339
+ {
340
+ return this .mobile;
341
+ },
342
+ getLocalStorage: function ()
343
+ {
344
+ return this .localStorage;
345
+ },
346
+ getBrowserTimings: function ()
347
+ {
348
+ return this .browserTimings;
349
+ },
336
350
  getBrowserOptions: function ()
337
351
  {
338
352
  return this .browserOptions;
@@ -349,17 +363,9 @@ function ($,
349
363
  {
350
364
  return this .notification;
351
365
  },
352
- getBrowserTimings: function ()
353
- {
354
- return this .browserTimings;
355
- },
356
- getLocalStorage: function ()
357
- {
358
- return this .localStorage;
359
- },
360
- getMobile: function ()
366
+ getContextMenu: function ()
361
367
  {
362
- return this .mobile;
368
+ return this .contextMenu;
363
369
  },
364
370
  getPrivateScene: function ()
365
371
  {
@@ -627,7 +633,7 @@ function ($,
627
633
  if (this .getControlKey ())
628
634
  {
629
635
  event .preventDefault ();
630
- this .getBrowserTimings () .setEnabled (! this .getBrowserTimings () .getEnabled ());
636
+ this .setBrowserOption ("Timings", !this .getBrowserOption ("Timings"));
631
637
  }
632
638
 
633
639
  break;
@@ -664,21 +670,69 @@ function ($,
664
670
 
665
671
  const viewpoint = this .getActiveViewpoint ();
666
672
 
667
- if (! viewpoint)
673
+ if (!viewpoint)
668
674
  break;
669
675
 
670
- let text = "";
676
+ const vp = this .getPrivateScene () .createNode (viewpoint .getTypeName ());
677
+
678
+ switch (viewpoint .getTypeName ())
679
+ {
680
+ case "Viewpoint":
681
+ {
682
+ vp .position = viewpoint .getUserPosition ();
683
+ vp .orientation = viewpoint .getUserOrientation ();
684
+ vp .centerOfRotation = viewpoint .getUserCenterOfRotation ();
685
+ vp .fieldOfView = viewpoint .getFieldOfView ();
686
+ break;
687
+ }
688
+ case "OrthoViewpoint":
689
+ {
690
+ vp .position = viewpoint .getUserPosition ();
691
+ vp .orientation = viewpoint .getUserOrientation ();
692
+ vp .centerOfRotation = viewpoint .getUserCenterOfRotation ();
693
+ vp .fieldOfView = new Fields .MFFloat (viewpoint .getMinimumX (), viewpoint .getMinimumY (), viewpoint .getMaximumX (), viewpoint .getMaximumY ());
694
+ break;
695
+ }
696
+ case "GeoViewpoint":
697
+ {
698
+ const
699
+ geoOrigin = viewpoint .geoOrigin_,
700
+ geoCoord = new Vector3 (0, 0, 0);
701
+
702
+ if (geoOrigin .getValue () && geoOrigin .getNodeTypeName () === "GeoOrigin")
703
+ {
704
+ const go = this .getPrivateScene () .createNode ("GeoOrigin");
705
+
706
+ vp .geoOrigin = go;
707
+ go .geoSystem = geoOrigin .geoSystem;
708
+ go .geoCoords = geoOrigin .geoCoords;
709
+ go .rotateYUp = geoOrigin .rotateYUp;
710
+ }
711
+
712
+ vp .geoSystem = viewpoint .geoSystem_;
713
+ vp .position = viewpoint .getGeoCoord (viewpoint .getUserPosition (), geoCoord);
714
+ vp .orientation = viewpoint .getUserOrientation ();
715
+ vp .centerOfRotation = viewpoint .getGeoCoord (viewpoint .getUserCenterOfRotation (), geoCoord);
716
+ vp .fieldOfView = viewpoint .getFieldOfView ();
717
+ break;
718
+ }
719
+ }
671
720
 
672
- text += "Viewpoint {\n";
673
- text += " position " + viewpoint .getUserPosition () + "\n";
674
- text += " orientation " + viewpoint .getUserOrientation () + "\n";
675
- text += " centerOfRotation " + viewpoint .getUserCenterOfRotation () + "\n";
676
- text += "}";
721
+ let text;
677
722
 
678
- console .log (text);
679
- copyToClipboard (text);
723
+ switch (this .getExecutionContext () .getEncoding ())
724
+ {
725
+ case "ASCII":
726
+ case "VRML": text = vp .toVRMLString (); break;
727
+ case "JSON": text = vp .toVRMLString (); break;
728
+ default: text = vp .toXMLString (); break;
729
+ }
730
+
731
+ text += "\n";
680
732
 
681
- this .getNotification () .string_ = "Copied viewpoint to clipboard.";
733
+ console .log (text);
734
+ this .copyToClipboard (text);
735
+ this .getNotification () .string_ = _ ("Viewpoint is copied to clipboard.");
682
736
  }
683
737
 
684
738
  break;
@@ -722,17 +776,16 @@ function ($,
722
776
  }
723
777
  }
724
778
  },
779
+ copyToClipboard: function (text)
780
+ {
781
+ // The textarea must be visible to make copy work.
782
+ const $temp = $("<textarea></textarea>");
783
+ this .getElement () .find (".x_ite-private-browser") .prepend ($temp);
784
+ $temp .text (text) .select ();
785
+ document .execCommand ("copy");
786
+ $temp .remove ();
787
+ },
725
788
  };
726
789
 
727
- function copyToClipboard (text)
728
- {
729
- const $temp = $("<textarea>");
730
-
731
- $("body") .append ($temp);
732
- $temp .val (text) .select ();
733
- document .execCommand ("copy");
734
- $temp .remove ();
735
- }
736
-
737
790
  return X3DCoreContext;
738
791
  });
@@ -173,6 +173,9 @@ function ($,
173
173
  },
174
174
  mousedown: function (event)
175
175
  {
176
+ if (this .getBrowser () .getContextMenu () .getActive ())
177
+ return;
178
+
176
179
  if (this .button >= 0)
177
180
  return;
178
181