x_ite 8.10.0 → 8.11.0

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 (138) hide show
  1. package/Makefile +3 -0
  2. package/build/bin/version.pl +28 -20
  3. package/build/docs/glTF-samples.pl +151 -0
  4. package/build/docs/nodes.pl +1 -1
  5. package/build/src/nodes.pl +41 -0
  6. package/dist/assets/components/Annotation.js +13 -13
  7. package/dist/assets/components/Annotation.min.js +1 -1
  8. package/dist/assets/components/CADGeometry.js +13 -13
  9. package/dist/assets/components/CADGeometry.min.js +1 -1
  10. package/dist/assets/components/CubeMapTexturing.js +30 -26
  11. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  12. package/dist/assets/components/DIS.js +14 -14
  13. package/dist/assets/components/DIS.min.js +1 -1
  14. package/dist/assets/components/EventUtilities.js +9 -9
  15. package/dist/assets/components/EventUtilities.min.js +1 -1
  16. package/dist/assets/components/Geometry2D.js +19 -19
  17. package/dist/assets/components/Geometry2D.min.js +1 -1
  18. package/dist/assets/components/Geospatial.js +33 -33
  19. package/dist/assets/components/Geospatial.min.js +1 -1
  20. package/dist/assets/components/HAnim.js +394 -30
  21. package/dist/assets/components/HAnim.min.js +1 -1
  22. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  23. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  24. package/dist/assets/components/Layout.js +26 -26
  25. package/dist/assets/components/Layout.min.js +1 -1
  26. package/dist/assets/components/NURBS.js +24 -24
  27. package/dist/assets/components/NURBS.min.js +1 -1
  28. package/dist/assets/components/ParticleSystems.js +73 -74
  29. package/dist/assets/components/ParticleSystems.min.js +1 -1
  30. package/dist/assets/components/Picking.js +18 -18
  31. package/dist/assets/components/Picking.min.js +1 -1
  32. package/dist/assets/components/RigidBodyPhysics.js +18 -18
  33. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  34. package/dist/assets/components/Scripting.js +37 -37
  35. package/dist/assets/components/Scripting.min.js +1 -1
  36. package/dist/assets/components/Text.js +55 -63
  37. package/dist/assets/components/Text.min.js +1 -1
  38. package/dist/assets/components/TextureProjector.js +14 -14
  39. package/dist/assets/components/TextureProjector.min.js +1 -1
  40. package/dist/assets/components/Texturing3D.js +35 -31
  41. package/dist/assets/components/Texturing3D.min.js +1 -1
  42. package/dist/assets/components/VolumeRendering.js +20 -20
  43. package/dist/assets/components/VolumeRendering.min.js +1 -1
  44. package/dist/assets/components/X_ITE.js +9 -9
  45. package/dist/assets/components/X_ITE.min.js +1 -1
  46. package/dist/x_ite.css +1 -1
  47. package/dist/x_ite.js +1456 -844
  48. package/dist/x_ite.min.js +1 -1
  49. package/dist/x_ite.zip +0 -0
  50. package/docs/_config.yml +2 -2
  51. package/docs/_posts/components/Core/MetadataBoolean.md +6 -4
  52. package/docs/_posts/components/Core/MetadataDouble.md +6 -4
  53. package/docs/_posts/components/Core/MetadataFloat.md +6 -4
  54. package/docs/_posts/components/Core/MetadataInteger.md +6 -4
  55. package/docs/_posts/components/Core/MetadataSet.md +6 -4
  56. package/docs/_posts/components/Core/MetadataString.md +6 -4
  57. package/docs/_posts/components/DIS/DISEntityTypeMapping.md +1 -1
  58. package/docs/_posts/components/HAnim/HAnimMotion.md +48 -48
  59. package/docs/_posts/components/RigidBodyPhysics/Contact.md +1 -1
  60. package/docs/_posts/getting-started.md +45 -35
  61. package/docs/_posts/reference/browser-services.md +6 -0
  62. package/docs/_posts/what's-new.md +23 -0
  63. package/docs/_tabs/playground.html +215 -15
  64. package/docs/assets/css/style.scss +35 -2
  65. package/docs/assets/js/example.js +95 -3
  66. package/docs/laboratory/gltf-sample-viewer.html +617 -240
  67. package/package.json +2 -2
  68. package/src/assets/shaders/Types.glsl.js +4 -0
  69. package/src/assets/shaders/webgl1/include/Hatch.glsl.js +2 -3
  70. package/src/assets/shaders/webgl2/Compose.fs.js +29 -0
  71. package/src/assets/shaders/webgl2/Compose.vs.js +14 -0
  72. package/src/assets/shaders/webgl2/include/Fragment.glsl.js +24 -2
  73. package/src/assets/shaders/webgl2/include/Hatch.glsl.js +2 -3
  74. package/src/assets/shaders/webgl2/include/Stipple.glsl.js +5 -3
  75. package/src/bookmarks.js +92 -5
  76. package/src/examples.js +1 -0
  77. package/src/standard/Math/Numbers/Quaternion.js +191 -13
  78. package/src/standard/Math/Numbers/Rotation4.js +23 -0
  79. package/src/standard/Time/{MicroTime.js → Time.js} +21 -28
  80. package/src/x_ite/Base/X3DChildObject.js +5 -4
  81. package/src/x_ite/Browser/Core/BrowserOptions.js +71 -60
  82. package/src/x_ite/Browser/Core/Context.js +2 -2
  83. package/src/x_ite/Browser/Core/X3DCoreContext.js +6 -0
  84. package/src/x_ite/Browser/DOMIntegration.js +0 -17
  85. package/src/x_ite/Browser/Navigation/ExamineViewer.js +5 -4
  86. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +7 -4
  87. package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +20 -15
  88. package/src/x_ite/Browser/Shaders/Shaders.js +19 -15
  89. package/src/x_ite/Browser/Text/X3DTextContext.js +16 -16
  90. package/src/x_ite/Browser/Time/X3DTimeContext.js +3 -2
  91. package/src/x_ite/Browser/VERSION.js +1 -1
  92. package/src/x_ite/Browser/VolumeRendering/VolumeMaterial.js +2 -2
  93. package/src/x_ite/Browser/X3DBrowser.js +1 -2
  94. package/src/x_ite/Browser/X3DBrowserContext.js +0 -5
  95. package/src/x_ite/Components/Core/MetadataBoolean.js +8 -1
  96. package/src/x_ite/Components/Core/MetadataDouble.js +8 -1
  97. package/src/x_ite/Components/Core/MetadataFloat.js +8 -1
  98. package/src/x_ite/Components/Core/MetadataInteger.js +8 -1
  99. package/src/x_ite/Components/Core/MetadataSet.js +8 -1
  100. package/src/x_ite/Components/Core/MetadataString.js +8 -1
  101. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +9 -6
  102. package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +2 -1
  103. package/src/x_ite/Components/DIS/DISEntityTypeMapping.js +1 -1
  104. package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +5 -1
  105. package/src/x_ite/Components/Grouping/X3DGroupingNode.js +2 -0
  106. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +34 -2
  107. package/src/x_ite/Components/HAnim/HAnimMotion.js +331 -15
  108. package/src/x_ite/Components/Lighting/DirectionalLight.js +1 -3
  109. package/src/x_ite/Components/Lighting/PointLight.js +1 -3
  110. package/src/x_ite/Components/Lighting/SpotLight.js +1 -3
  111. package/src/x_ite/Components/Networking/X3DUrlObject.js +5 -4
  112. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +47 -51
  113. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +4 -2
  114. package/src/x_ite/Components/RigidBodyPhysics/Contact.js +1 -1
  115. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +1 -1
  116. package/src/x_ite/Components/Shape/FillProperties.js +4 -0
  117. package/src/x_ite/Components/Shape/LineProperties.js +4 -0
  118. package/src/x_ite/Components/Shape/PointProperties.js +4 -0
  119. package/src/x_ite/Components/Shape/X3DMaterialNode.js +44 -20
  120. package/src/x_ite/Components/Sound/AudioClip.js +2 -1
  121. package/src/x_ite/Components/Text/X3DFontStyleNode.js +13 -23
  122. package/src/x_ite/Components/Texturing/ImageTexture.js +2 -1
  123. package/src/x_ite/Components/Texturing/MovieTexture.js +2 -1
  124. package/src/x_ite/Components/Texturing3D/ImageTextureAtlas.js +2 -1
  125. package/src/x_ite/Components/Time/TimeSensor.js +25 -24
  126. package/src/x_ite/Components/Time/X3DTimeDependentNode.js +5 -4
  127. package/src/x_ite/Execution/BindableList.js +3 -3
  128. package/src/x_ite/Execution/X3DScene.js +2 -0
  129. package/src/x_ite/Parser/XMLParser.js +12 -2
  130. package/src/x_ite/Rendering/MultiSampleFrameBuffer.js +264 -26
  131. package/src/x_ite/Rendering/PointingBuffer.js +5 -7
  132. package/src/x_ite/Rendering/TextureBuffer.js +6 -14
  133. package/src/x_ite/Rendering/X3DRenderObject.js +28 -28
  134. package/src/x_ite/X3D.js +0 -1
  135. package/src/x_ite/X3DCanvasElement.js +2 -0
  136. package/src/x_ite.html +23 -24
  137. package/x_ite.min.html +23 -24
  138. /package/build/{bin → docs}/tags.pl +0 -0
@@ -45,17 +45,27 @@
45
45
  *
46
46
  ******************************************************************************/
47
47
 
48
- import Fields from "../../Fields.js";
49
- import X3DFieldDefinition from "../../Base/X3DFieldDefinition.js";
50
- import FieldDefinitionArray from "../../Base/FieldDefinitionArray.js";
51
- import X3DChildNode from "../Core/X3DChildNode.js";
52
- import X3DConstants from "../../Base/X3DConstants.js";
48
+ import Fields from "../../Fields.js";
49
+ import X3DFieldDefinition from "../../Base/X3DFieldDefinition.js";
50
+ import FieldDefinitionArray from "../../Base/FieldDefinitionArray.js";
51
+ import X3DChildNode from "../Core/X3DChildNode.js";
52
+ import X3DConstants from "../../Base/X3DConstants.js";
53
+ import TimeSensor from "../Time/TimeSensor.js";
54
+ import PositionInterpolator from "../Interpolation/PositionInterpolator.js";
55
+ import OrientationInterpolator from "../Interpolation/OrientationInterpolator.js";
56
+ import Vector3 from "../../../standard/Math/Numbers/Vector3.js";
57
+ import Rotation4 from "../../../standard/Math/Numbers/Rotation4.js";
58
+ import Algorithm from "../../../standard/Math/Algorithm.js";
53
59
 
54
60
  function HAnimMotion (executionContext)
55
61
  {
56
62
  X3DChildNode .call (this, executionContext);
57
63
 
58
64
  this .addType (X3DConstants .HAnimMotion);
65
+
66
+ this .timeSensor = new TimeSensor (this .getExecutionContext ());
67
+ this .interpolators = [ ];
68
+ this .jointsIndex = new Map ();
59
69
  }
60
70
 
61
71
  Object .assign (Object .setPrototypeOf (HAnimMotion .prototype, X3DChildNode .prototype),
@@ -63,6 +73,312 @@ Object .assign (Object .setPrototypeOf (HAnimMotion .prototype, X3DChildNode .pr
63
73
  initialize ()
64
74
  {
65
75
  X3DChildNode .prototype .initialize .call (this);
76
+
77
+ this ._loop .addFieldInterest (this .timeSensor ._loop);
78
+
79
+ this .timeSensor ._cycleTime .addFieldInterest (this ._cycleTime);
80
+ this .timeSensor ._elapsedTime .addFieldInterest (this ._elapsedTime);
81
+
82
+ this .timeSensor ._enabled = false;
83
+ this .timeSensor ._loop = this ._loop;
84
+ this .timeSensor ._stopTime = 1;
85
+
86
+ this .timeSensor .setup ();
87
+
88
+ this ._enabled .addInterest ("set_enabled__", this);
89
+ this ._joints .addInterest ("set_connectInterpolators__", this);
90
+ this ._channelsEnabled .addInterest ("set_connectInterpolators__", this);
91
+ this ._channels .addInterest ("set_interpolators__", this);
92
+ this ._values .addInterest ("set_interpolators__", this);
93
+ this ._next .addInterest ("set_next_or_previous__", this, 1);
94
+ this ._previous .addInterest ("set_next_or_previous__", this, -1);
95
+ this ._frameIndex .addInterest ("set_frameIndex__", this);
96
+ this ._frameDuration .addInterest ("set_frameDuration__", this);
97
+ this ._frameIncrement .addInterest ("set_timeSensor_enabled__", this);
98
+ this ._startFrame .addInterest ("set_start_or_endFrame__", this);
99
+ this ._endFrame .addInterest ("set_start_or_endFrame__", this);
100
+
101
+ this .set_enabled__ ();
102
+ this .set_interpolators__ ();
103
+ },
104
+ setJoints (jointNodes)
105
+ {
106
+ // Create joints index.
107
+
108
+ const jointsIndex = this .jointsIndex;
109
+
110
+ jointsIndex .clear ();
111
+
112
+ for (const jointNode of jointNodes)
113
+ jointsIndex .set (jointNode ._name .getValue () .trim (), jointNode);
114
+
115
+ jointsIndex .delete ("IGNORED");
116
+
117
+ // Connect joint nodes.
118
+
119
+ this .set_timeSensor_enabled__ ();
120
+ this .set_enabled__ ();
121
+ this .set_connectInterpolators__ ();
122
+ },
123
+ set_timeSensor_enabled__ ()
124
+ {
125
+ this .timeSensor ._enabled = this .jointsIndex .size && this ._frameIncrement .getValue ();
126
+ },
127
+ set_enabled__ ()
128
+ {
129
+ if (this ._enabled .getValue ())
130
+ this .timeSensor ._startTime = Time .now () / 1000;
131
+ else
132
+ this .timeSensor ._stopTime = Time .now () / 1000;
133
+ },
134
+ set_interpolators__ ()
135
+ {
136
+ // Disconnect old interpolators.
137
+
138
+ const timeSensor = this .timeSensor;
139
+
140
+ for (const field of timeSensor ._fraction_changed .getFieldInterests ())
141
+ timeSensor ._fraction_changed .removeFieldInterest (field);
142
+
143
+ // Create interpolators.
144
+
145
+ const channels = this ._channels .getValue ()
146
+ .replace (/^[\s,\d]+|[\s,\d]+$/sg, "")
147
+ .split (/[\s,]+\d+[\s,]+/s)
148
+ .map (string => string .split (/[\s,]+/s));
149
+
150
+ const
151
+ values = this ._values,
152
+ numChannels = channels .reduce ((v, c) => v + c .length, 0),
153
+ frameCount = Math .floor (numChannels ? values .length / numChannels : 0),
154
+ types = new Map (),
155
+ interpolators = Array .from ({length: channels .length}, () => ({ }));
156
+
157
+ this .interpolators = interpolators;
158
+
159
+ for (let frame = 0, v = 0; frame < frameCount; ++ frame)
160
+ {
161
+ for (const [j, joint] of channels .entries ())
162
+ {
163
+ types .clear ();
164
+
165
+ for (const channel of joint)
166
+ types .set (channel, values [v ++]);
167
+
168
+ if (types .has ("Xposition") || types .has ("Yposition") || types .has ("Zposition"))
169
+ {
170
+ const interpolator = interpolators [j] .positionInterpolator
171
+ ?? this .createPositionInterpolator (interpolators, j);
172
+
173
+ const
174
+ key = frame / (frameCount - 1),
175
+ keyValue = new Vector3 (types .get ("Xposition") ?? 0,
176
+ types .get ("Yposition") ?? 0,
177
+ types .get ("Zposition") ?? 0);
178
+
179
+ interpolator ._key .push (key);
180
+ interpolator ._keyValue .push (keyValue);
181
+ }
182
+
183
+ if (types .has ("Xrotation") || types .has ("Yrotation") || types .has ("Zrotation"))
184
+ {
185
+ const interpolator = interpolators [j] .orientationInterpolator
186
+ ?? this .createOrientationInterpolator (interpolators, j);
187
+
188
+ const
189
+ key = frame / (frameCount - 1),
190
+ keyValue = Rotation4 .fromEuler (Algorithm .radians (types .get ("Xrotation") ?? 0),
191
+ Algorithm .radians (types .get ("Yrotation") ?? 0),
192
+ Algorithm .radians (types .get ("Zrotation") ?? 0));
193
+
194
+ interpolator ._key .push (key);
195
+ interpolator ._keyValue .push (keyValue);
196
+ }
197
+
198
+ if (types .has ("Xscale") || types .has ("Yscale") || types .has ("Zscale"))
199
+ {
200
+ const interpolator = interpolators [j] .scaleInterpolator
201
+ ?? this .createScaleInterpolator (interpolators, j);
202
+
203
+ const
204
+ key = frame / (frameCount - 1),
205
+ keyValue = new Vector3 (types .get ("Xscale") ?? 1,
206
+ types .get ("Yscale") ?? 1,
207
+ types .get ("Zscale") ?? 1);
208
+
209
+ interpolator ._key .push (key);
210
+ interpolator ._keyValue .push (keyValue);
211
+ }
212
+ }
213
+ }
214
+
215
+ for (const { positionInterpolator, orientationInterpolator, scaleInterpolator } of interpolators)
216
+ {
217
+ positionInterpolator ?.setup ();
218
+ orientationInterpolator ?.setup ();
219
+ scaleInterpolator ?.setup ();
220
+ }
221
+
222
+ this ._frameIndex = 0;
223
+ this ._startFrame = 0;
224
+ this ._endFrame = frameCount - 1;
225
+ this ._frameCount = frameCount;
226
+
227
+ this .set_connectInterpolators__ ();
228
+ this .set_frameDuration__ ();
229
+ },
230
+ set_connectInterpolators__ ()
231
+ {
232
+ const
233
+ timeSensor = this .timeSensor,
234
+ channelsEnabled = this ._channelsEnabled,
235
+ joints = this ._joints .getValue () .replace (/^[\s,]+|[\s,]+$/sg, "") .split (/[\s,]+/s),
236
+ jointsIndex = this .jointsIndex;
237
+
238
+ // Disconnect old joint nodes.
239
+
240
+ for (const { positionInterpolator, orientationInterpolator, scaleInterpolator } of this .interpolators)
241
+ {
242
+ if (positionInterpolator)
243
+ {
244
+ for (const field of positionInterpolator ._value_changed .getFieldInterests ())
245
+ positionInterpolator ._value_changed .removeFieldInterest (field);
246
+ }
247
+
248
+ if (orientationInterpolator)
249
+ {
250
+ for (const field of orientationInterpolator ._value_changed .getFieldInterests ())
251
+ orientationInterpolator ._value_changed .removeFieldInterest (field);
252
+ }
253
+
254
+ if (scaleInterpolator)
255
+ {
256
+ for (const field of scaleInterpolator ._value_changed .getFieldInterests ())
257
+ scaleInterpolator ._value_changed .removeFieldInterest (field);
258
+ }
259
+ }
260
+
261
+ // Connect interpolators.
262
+
263
+ if (!jointsIndex .size)
264
+ return;
265
+
266
+ for (const [j, { positionInterpolator, orientationInterpolator, scaleInterpolator }] of this .interpolators .entries ())
267
+ {
268
+ if (j < channelsEnabled .length && !channelsEnabled [j])
269
+ continue;
270
+
271
+ if (j >= joints .length)
272
+ continue;
273
+
274
+ const jointNode = jointsIndex .get (joints [j])
275
+ ?? (positionInterpolator && jointsIndex .get ("humanoid_root"));
276
+
277
+ if (!jointNode)
278
+ continue;
279
+
280
+ if (positionInterpolator)
281
+ {
282
+ timeSensor ._fraction_changed .addFieldInterest (positionInterpolator ._set_fraction);
283
+ positionInterpolator ._value_changed .addFieldInterest (jointNode ._translation);
284
+ }
285
+
286
+ if (orientationInterpolator)
287
+ {
288
+ timeSensor ._fraction_changed .addFieldInterest (orientationInterpolator ._set_fraction);
289
+ orientationInterpolator ._value_changed .addFieldInterest (jointNode ._rotation);
290
+ }
291
+
292
+ if (scaleInterpolator)
293
+ {
294
+ timeSensor ._fraction_changed .addFieldInterest (scaleInterpolator ._set_fraction);
295
+ scaleInterpolator ._value_changed .addFieldInterest (jointNode ._scale);
296
+ }
297
+ }
298
+ },
299
+ set_next_or_previous__ (direction, field)
300
+ {
301
+ if (!field .getValue ())
302
+ return;
303
+
304
+ const
305
+ fraction = this .getFraction (),
306
+ frameCount = this ._frameCount .getValue (),
307
+ frameIncrement = this ._frameIncrement .getValue (),
308
+ frameIndex = (frameCount > 1 ? Math .floor (fraction * (frameCount - 1)) : 0) + frameIncrement * direction;
309
+
310
+ if (frameIndex > this .endFrame)
311
+ {
312
+ if (!this ._loop .getValue ())
313
+ return;
314
+
315
+ this ._frameIndex = this .startFrame;
316
+ }
317
+ else if (frameIndex < this .startFrame)
318
+ {
319
+ if (!this ._loop .getValue ())
320
+ return;
321
+
322
+ this ._frameIndex = this .endFrame;
323
+ }
324
+ else
325
+ {
326
+ this ._frameIndex = frameIndex;
327
+ }
328
+ },
329
+ set_frameIndex__ ()
330
+ {
331
+ const
332
+ frameCount = this ._frameCount .getValue (),
333
+ frameIndex = Algorithm .clamp (this ._frameIndex .getValue (), 0, frameCount),
334
+ fraction = frameCount > 1 ? frameIndex / (frameCount - 1) : 0;
335
+
336
+ this .timeSensor ._range [0] = fraction;
337
+
338
+ if (this .timeSensor ._isActive .getValue ())
339
+ return;
340
+
341
+ for (const field of this .timeSensor ._fraction_changed .getFieldInterests ())
342
+ field .setValue (fraction);
343
+ },
344
+ set_frameDuration__ ()
345
+ {
346
+ const
347
+ frameCount = this ._frameCount .getValue (),
348
+ frameDuration = Math .max (this ._frameDuration .getValue (), 0);
349
+
350
+ this .timeSensor ._cycleInterval = frameCount > 1 ? (frameCount - 1) * frameDuration : 0;
351
+ },
352
+ set_start_or_endFrame__ ()
353
+ {
354
+ const
355
+ frameCount = this ._frameCount .getValue (),
356
+ startFrame = Algorithm .clamp (this ._startFrame .getValue (), 0, frameCount),
357
+ endFrame = Algorithm .clamp (this ._endFrame .getValue (), 0, frameCount);
358
+
359
+ this .startFrame = Math .min (startFrame, endFrame);
360
+ this .endFrame = Math .max (startFrame, endFrame);
361
+ this .timeSensor ._range [1] = frameCount > 1 ? this .startFrame / (frameCount - 1) : 0;
362
+ this .timeSensor ._range [2] = frameCount > 1 ? this .endFrame / (frameCount - 1) : 0;
363
+ },
364
+ createPositionInterpolator (interpolators, j)
365
+ {
366
+ return interpolators [j] .positionInterpolator = new PositionInterpolator (this .getExecutionContext ());
367
+ },
368
+ createOrientationInterpolator (interpolators, j)
369
+ {
370
+ return interpolators [j] .orientationInterpolator = new OrientationInterpolator (this .getExecutionContext ());
371
+ },
372
+ createScaleInterpolator (interpolators, j)
373
+ {
374
+ return interpolators [j] .scaleInterpolator = new PositionInterpolator (this .getExecutionContext ());
375
+ },
376
+ getFraction ()
377
+ {
378
+ for (const field of this .timeSensor ._fraction_changed .getFieldInterests ())
379
+ return field .getValue ();
380
+
381
+ return 0;
66
382
  },
67
383
  });
68
384
 
@@ -80,7 +396,7 @@ Object .defineProperties (HAnimMotion,
80
396
  },
81
397
  containerField:
82
398
  {
83
- value: "children",
399
+ value: "motions",
84
400
  enumerable: true,
85
401
  },
86
402
  specificationRange:
@@ -94,19 +410,19 @@ Object .defineProperties (HAnimMotion,
94
410
  new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
95
411
  new X3DFieldDefinition (X3DConstants .inputOutput, "description", new Fields .SFString ()),
96
412
  new X3DFieldDefinition (X3DConstants .inputOutput, "enabled", new Fields .SFBool (true)),
413
+ new X3DFieldDefinition (X3DConstants .inputOutput, "loa", new Fields .SFInt32 (-1)),
414
+ new X3DFieldDefinition (X3DConstants .inputOutput, "joints", new Fields .SFString ()),
415
+ new X3DFieldDefinition (X3DConstants .inputOutput, "channelsEnabled", new Fields .MFBool ()),
416
+ new X3DFieldDefinition (X3DConstants .inputOutput, "channels", new Fields .SFString ()),
417
+ new X3DFieldDefinition (X3DConstants .inputOutput, "values", new Fields .MFFloat ()),
418
+ new X3DFieldDefinition (X3DConstants .inputOutput, "loop", new Fields .SFBool ()),
97
419
  new X3DFieldDefinition (X3DConstants .inputOnly, "next", new Fields .SFBool ()),
98
420
  new X3DFieldDefinition (X3DConstants .inputOnly, "previous", new Fields .SFBool ()),
99
- new X3DFieldDefinition (X3DConstants .inputOutput, "startFrame", new Fields .SFInt32 ()),
100
- new X3DFieldDefinition (X3DConstants .inputOutput, "endFrame", new Fields .SFInt32 ()),
421
+ new X3DFieldDefinition (X3DConstants .inputOutput, "frameIndex", new Fields .SFInt32 (0)),
101
422
  new X3DFieldDefinition (X3DConstants .inputOutput, "frameDuration", new Fields .SFTime (0.1)),
102
423
  new X3DFieldDefinition (X3DConstants .inputOutput, "frameIncrement", new Fields .SFInt32 (1)),
103
- new X3DFieldDefinition (X3DConstants .inputOutput, "frameIndex", new Fields .SFInt32 (0)),
104
- new X3DFieldDefinition (X3DConstants .inputOutput, "loop", new Fields .SFBool ()),
105
- new X3DFieldDefinition (X3DConstants .inputOutput, "channelsEnabled", new Fields .MFBool ()),
106
- new X3DFieldDefinition (X3DConstants .inputOutput, "channels", new Fields .SFString ()),
107
- new X3DFieldDefinition (X3DConstants .inputOutput, "joints", new Fields .SFString ()),
108
- new X3DFieldDefinition (X3DConstants .inputOutput, "loa", new Fields .SFInt32 (-1)),
109
- new X3DFieldDefinition (X3DConstants .inputOutput, "values", new Fields .MFFloat ()),
424
+ new X3DFieldDefinition (X3DConstants .inputOutput, "startFrame", new Fields .SFInt32 ()),
425
+ new X3DFieldDefinition (X3DConstants .inputOutput, "endFrame", new Fields .SFInt32 ()),
110
426
  new X3DFieldDefinition (X3DConstants .outputOnly, "cycleTime", new Fields .SFTime ()),
111
427
  new X3DFieldDefinition (X3DConstants .outputOnly, "elapsedTime", new Fields .SFTime ()),
112
428
  new X3DFieldDefinition (X3DConstants .outputOnly, "frameCount", new Fields .SFInt32 ()),
@@ -162,9 +162,7 @@ Object .assign (DirectionalLightContainer .prototype,
162
162
  if (this .shadowBuffer)
163
163
  {
164
164
  const textureUnit = this .global
165
- ? (this .textureUnit = this .textureUnit !== undefined
166
- ? this .textureUnit
167
- : this .browser .popTexture2DUnit ())
165
+ ? (this .textureUnit = this .textureUnit ?? this .browser .popTexture2DUnit ())
168
166
  : this .browser .getTexture2DUnit ();
169
167
 
170
168
  if (textureUnit !== undefined)
@@ -194,9 +194,7 @@ Object .assign (PointLightContainer .prototype,
194
194
  if (this .shadowBuffer)
195
195
  {
196
196
  const textureUnit = this .global
197
- ? (this .textureUnit = this .textureUnit !== undefined
198
- ? this .textureUnit
199
- : this .browser .popTexture2DUnit ())
197
+ ? (this .textureUnit = this .textureUnit ?? this .browser .popTexture2DUnit ())
200
198
  : this .browser .getTexture2DUnit ();
201
199
 
202
200
  if (textureUnit !== undefined)
@@ -181,9 +181,7 @@ Object .assign (SpotLightContainer .prototype,
181
181
  if (this .shadowBuffer)
182
182
  {
183
183
  const textureUnit = this .global
184
- ? (this .textureUnit = this .textureUnit !== undefined
185
- ? this .textureUnit
186
- : this .browser .popTexture2DUnit ())
184
+ ? (this .textureUnit = this .textureUnit ?? this .browser .popTexture2DUnit ())
187
185
  : this .browser .getTexture2DUnit ();
188
186
 
189
187
  if (textureUnit !== undefined)
@@ -47,6 +47,7 @@
47
47
 
48
48
  import Fields from "../../Fields.js";
49
49
  import X3DConstants from "../../Base/X3DConstants.js";
50
+ import Time from "../../../standard/Time/Time.js";
50
51
 
51
52
  const
52
53
  _cache = Symbol (),
@@ -62,7 +63,7 @@ function X3DUrlObject (executionContext)
62
63
  X3DConstants .inputOutput, "loadData", new Fields .SFTime ());
63
64
 
64
65
  this [_cache] = true;
65
- this [_autoRefreshStartTime] = Date .now ();
66
+ this [_autoRefreshStartTime] = Time .now ();
66
67
  }
67
68
 
68
69
  Object .assign (X3DUrlObject .prototype,
@@ -83,7 +84,7 @@ Object .assign (X3DUrlObject .prototype,
83
84
 
84
85
  if (value === X3DConstants .COMPLETE_STATE)
85
86
  {
86
- this [_autoRefreshCompleteTime] = Date .now ();
87
+ this [_autoRefreshCompleteTime] = Time .now ();
87
88
  this .setAutoRefreshTimer (this ._autoRefresh .getValue ());
88
89
  }
89
90
 
@@ -227,7 +228,7 @@ Object .assign (X3DUrlObject .prototype,
227
228
 
228
229
  if (autoRefreshTimeLimit !== 0)
229
230
  {
230
- if ((Date .now () - this [_autoRefreshStartTime]) / 1000 > autoRefreshTimeLimit - autoRefreshInterval)
231
+ if ((Time .now () - this [_autoRefreshStartTime]) / 1000 > autoRefreshTimeLimit - autoRefreshInterval)
231
232
  return;
232
233
  }
233
234
 
@@ -266,7 +267,7 @@ Object .assign (X3DUrlObject .prototype,
266
267
  return;
267
268
 
268
269
  const
269
- elapsedTime = (Date .now () - this [_autoRefreshCompleteTime]) / 1000,
270
+ elapsedTime = (Time .now () - this [_autoRefreshCompleteTime]) / 1000,
270
271
  autoRefresh = this ._autoRefresh .getValue ();
271
272
 
272
273
  let autoRefreshInterval = autoRefresh - elapsedTime;
@@ -60,6 +60,7 @@ import Vector3 from "../../../standard/Math/Numbers/Vector3.js";
60
60
  import Matrix4 from "../../../standard/Math/Numbers/Matrix4.js";
61
61
  import Matrix3 from "../../../standard/Math/Numbers/Matrix3.js";
62
62
  import BVH from "../../../standard/Math/Utility/BVH.js";
63
+ import Time from "../../../standard/Time/Time.js";
63
64
 
64
65
  const PointGeometry = new Float32Array ([0, 0, 0, 1]);
65
66
 
@@ -261,7 +262,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
261
262
 
262
263
  if (this .pauseTime)
263
264
  {
264
- this .creationTime += Date .now () / 1000 - this .pauseTime;
265
+ this .creationTime += Time .now () / 1000 - this .pauseTime;
265
266
  this .pauseTime = 0;
266
267
  }
267
268
  }
@@ -273,7 +274,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
273
274
  this .getBrowser () .sensorEvents () .removeInterest ("animateParticles", this);
274
275
 
275
276
  if (this .pauseTime === 0)
276
- this .pauseTime = Date .now () / 1000;
277
+ this .pauseTime = Time .now () / 1000;
277
278
  }
278
279
  }
279
280
  },
@@ -291,7 +292,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
291
292
  }
292
293
  else
293
294
  {
294
- this .pauseTime = Date .now () / 1000;
295
+ this .pauseTime = Time .now () / 1000;
295
296
  }
296
297
 
297
298
  this ._isActive = true;
@@ -408,7 +409,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
408
409
  this .numParticles = Math .min (lastNumParticles, maxParticles);
409
410
 
410
411
  if (! this .emitterNode .isExplosive ())
411
- this .creationTime = Date .now () / 1000;
412
+ this .creationTime = Time .now () / 1000;
412
413
 
413
414
  this .resizeBuffers (lastNumParticles);
414
415
  this .updateVertexArrays ();
@@ -695,7 +696,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
695
696
  if (emitterNode .isExplosive ())
696
697
  {
697
698
  const
698
- now = Date .now () / 1000,
699
+ now = Time .now () / 1000,
699
700
  particleLifetime = this .particleLifetime + this .particleLifetime * this .lifetimeVariation;
700
701
 
701
702
  if (now - this .creationTime > particleLifetime)
@@ -716,7 +717,7 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
716
717
  if (this .numParticles < this .maxParticles)
717
718
  {
718
719
  const
719
- now = Date .now () / 1000,
720
+ now = Time .now () / 1000,
720
721
  newParticles = Math .max (0, Math .floor ((now - this .creationTime) * this .maxParticles / this .particleLifetime));
721
722
 
722
723
  if (newParticles)
@@ -899,19 +900,19 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
899
900
  },
900
901
  display (gl, renderContext)
901
902
  {
903
+ if (!this .numParticles)
904
+ return;
905
+
902
906
  // Display geometry.
903
907
 
904
908
  switch (this .geometryType)
905
909
  {
906
910
  case GeometryTypes .GEOMETRY:
907
911
  {
908
- if (this .numParticles)
909
- {
910
- const geometryNode = this .getGeometry ();
912
+ const geometryNode = this .getGeometry ();
911
913
 
912
- if (geometryNode)
913
- geometryNode .displayParticles (gl, renderContext, this);
914
- }
914
+ if (geometryNode)
915
+ geometryNode .displayParticles (gl, renderContext, this);
915
916
 
916
917
  break;
917
918
  }
@@ -927,7 +928,6 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
927
928
 
928
929
  gl .frontFace (positiveScale ? gl .CCW : gl .CW);
929
930
  gl .enable (gl .CULL_FACE);
930
- gl .cullFace (gl .BACK);
931
931
 
932
932
  // [fall trough]
933
933
  }
@@ -939,60 +939,56 @@ Object .assign (Object .setPrototypeOf (ParticleSystem .prototype, X3DShapeNode
939
939
  shaderNode = appearanceNode .getShader (this .geometryContext, renderContext),
940
940
  primitiveMode = browser .getPrimitiveMode (this .primitiveMode);
941
941
 
942
- if (this .numParticles)
943
- {
944
- // Setup shader.
945
-
946
- const blendModeNode = appearanceNode .getBlendMode ();
942
+ // Setup shader.
947
943
 
948
- blendModeNode ?.enable (gl);
944
+ const blendModeNode = appearanceNode .getBlendMode ();
949
945
 
950
- shaderNode .enable (gl);
951
- shaderNode .setUniforms (gl, this .geometryContext, renderContext);
946
+ blendModeNode ?.enable (gl);
952
947
 
953
- if (this .numTexCoords)
954
- {
955
- const textureUnit = browser .getTexture2DUnit ();
948
+ shaderNode .enable (gl);
949
+ shaderNode .setUniforms (gl, this .geometryContext, renderContext);
956
950
 
957
- gl .activeTexture (gl .TEXTURE0 + textureUnit);
958
- gl .bindTexture (gl .TEXTURE_2D, this .texCoordRampTexture);
959
- gl .uniform1i (shaderNode .x3d_TexCoordRamp, textureUnit);
960
- }
951
+ if (this .numTexCoords)
952
+ {
953
+ const textureUnit = browser .getTexture2DUnit ();
961
954
 
962
- // Setup vertex attributes.
955
+ gl .activeTexture (gl .TEXTURE0 + textureUnit);
956
+ gl .bindTexture (gl .TEXTURE_2D, this .texCoordRampTexture);
957
+ gl .uniform1i (shaderNode .x3d_TexCoordRamp, textureUnit);
958
+ }
963
959
 
964
- const outputParticles = this .outputParticles;
960
+ // Setup vertex attributes.
965
961
 
966
- if (outputParticles .vertexArrayObject .enable (shaderNode))
967
- {
968
- const particleStride = this .particleStride;
962
+ const outputParticles = this .outputParticles;
969
963
 
970
- shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, this .particleOffset, 1);
971
- shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, this .matrixOffset, 1);
964
+ if (outputParticles .vertexArrayObject .enable (shaderNode))
965
+ {
966
+ const particleStride = this .particleStride;
972
967
 
973
- if (this .geometryContext .colorMaterial)
974
- {
975
- shaderNode .enableColorAttribute (gl, outputParticles, particleStride, this .colorOffset);
976
- shaderNode .colorAttributeDivisor (gl, 1);
977
- }
968
+ shaderNode .enableParticleAttribute (gl, outputParticles, particleStride, this .particleOffset, 1);
969
+ shaderNode .enableParticleMatrixAttribute (gl, outputParticles, particleStride, this .matrixOffset, 1);
978
970
 
979
- if (this .texCoordCount)
980
- shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers, 0, this .texCoordOffset);
971
+ if (this .geometryContext .colorMaterial)
972
+ {
973
+ shaderNode .enableColorAttribute (gl, outputParticles, particleStride, this .colorOffset);
974
+ shaderNode .colorAttributeDivisor (gl, 1);
975
+ }
981
976
 
982
- if (this .hasNormals)
983
- {
984
- shaderNode .enableNormalAttribute (gl, this .geometryBuffer, 0, this .normalOffset);
985
- shaderNode .normalAttributeDivisor (gl, this .maxParticles);
986
- }
977
+ if (this .texCoordCount)
978
+ shaderNode .enableTexCoordAttribute (gl, this .texCoordBuffers, 0, this .texCoordOffset);
987
979
 
988
- shaderNode .enableVertexAttribute (gl, this .geometryBuffer, 0, this .verticesOffset);
980
+ if (this .hasNormals)
981
+ {
982
+ shaderNode .enableNormalAttribute (gl, this .geometryBuffer, 0, this .normalOffset);
983
+ shaderNode .normalAttributeDivisor (gl, this .maxParticles);
989
984
  }
990
985
 
991
- gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, this .numParticles);
992
-
993
- blendModeNode ?.disable (gl);
986
+ shaderNode .enableVertexAttribute (gl, this .geometryBuffer, 0, this .verticesOffset);
994
987
  }
995
988
 
989
+ gl .drawArraysInstanced (primitiveMode, 0, this .vertexCount, this .numParticles);
990
+
991
+ blendModeNode ?.disable (gl);
996
992
  break;
997
993
  }
998
994
  }
@@ -950,10 +950,11 @@ Object .assign (Object .setPrototypeOf (X3DGeometryNode .prototype, X3DNode .pro
950
950
  display (gl, renderContext)
951
951
  {
952
952
  const
953
+ browser = this .getBrowser (),
953
954
  appearanceNode = renderContext .appearanceNode,
954
955
  shaderNode = appearanceNode .getShader (this, renderContext);
955
956
 
956
- if (this .solid || !appearanceNode .getBackMaterial () || this .getBrowser () .getWireframe ())
957
+ if (this .solid || !appearanceNode .getBackMaterial () || browser .getWireframe ())
957
958
  {
958
959
  this .displayGeometry (gl, renderContext, appearanceNode, shaderNode, true, true);
959
960
  }
@@ -1072,10 +1073,11 @@ Object .assign (Object .setPrototypeOf (X3DGeometryNode .prototype, X3DNode .pro
1072
1073
  displayParticles (gl, renderContext, particleSystem)
1073
1074
  {
1074
1075
  const
1076
+ browser = this .getBrowser (),
1075
1077
  appearanceNode = renderContext .appearanceNode,
1076
1078
  shaderNode = appearanceNode .getShader (this, renderContext);
1077
1079
 
1078
- if (this .solid || !appearanceNode .getBackMaterial () || this .getBrowser () .getWireframe ())
1080
+ if (this .solid || !appearanceNode .getBackMaterial () || browser .getWireframe ())
1079
1081
  {
1080
1082
  this .displayParticlesGeometry (gl, renderContext, appearanceNode, shaderNode, true, true, particleSystem);
1081
1083
  }