x_ite 8.6.5 → 8.6.7

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 (80) hide show
  1. package/Makefile +1 -0
  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 +23 -23
  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 +34 -34
  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/assets/lib/draco_decoder_gltf.js +29 -0
  43. package/dist/x_ite.css +1 -1
  44. package/dist/x_ite.js +2693 -2428
  45. package/dist/x_ite.min.js +1 -1
  46. package/dist/x_ite.zip +0 -0
  47. package/docs/_config.yml +1 -1
  48. package/docs/_posts/components/Navigation/NavigationInfo.md +8 -3
  49. package/docs/_posts/laboratory/x3d-file-converter.md +5 -0
  50. package/docs/_tabs/laboratory.md +2 -2
  51. package/docs/laboratory/gltf-sample-viewer.html +72 -3
  52. package/package.json +2 -2
  53. package/src/assets/lib/draco_decoder_gltf.js +29 -0
  54. package/src/assets/shaders/webgl1/include/Particle.glsl.js +7 -0
  55. package/src/assets/shaders/webgl1/include/Vertex.glsl.js +3 -2
  56. package/src/assets/shaders/webgl2/include/Particle.glsl.js +18 -5
  57. package/src/standard/Utility/ObjectCache.js +9 -10
  58. package/src/x_ite/Base/Events.js +10 -23
  59. package/src/x_ite/Base/X3DObject.js +29 -16
  60. package/src/x_ite/Browser/Networking/URLs.js +4 -0
  61. package/src/x_ite/Browser/Picking/X3DPickingContext.js +1 -1
  62. package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +1 -1
  63. package/src/x_ite/Browser/Shaders/Shaders.js +2 -0
  64. package/src/x_ite/Browser/VERSION.js +1 -1
  65. package/src/x_ite/Browser/X3DBrowser.js +7 -0
  66. package/src/x_ite/Browser/X3DBrowserContext.js +3 -3
  67. package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +1 -1
  68. package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +6 -7
  69. package/src/x_ite/Components/Layering/X3DLayerNode.js +1 -3
  70. package/src/x_ite/Components/Navigation/OrthoViewpoint.js +1 -1
  71. package/src/x_ite/Components/Shape/Material.js +25 -26
  72. package/src/x_ite/Components/Shape/PhysicalMaterial.js +2 -3
  73. package/src/x_ite/Components/Shape/UnlitMaterial.js +2 -3
  74. package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +10 -12
  75. package/src/x_ite/Components/Texturing/ImageTexture.js +7 -17
  76. package/src/x_ite/Components/Texturing/MovieTexture.js +4 -5
  77. package/src/x_ite/Parser/GLTF2Parser.js +194 -36
  78. package/src/x_ite/Parser/SVGParser.js +341 -252
  79. package/src/x_ite/Rendering/X3DRenderObject.js +3 -4
  80. package/webpack.config.js +2 -0
@@ -47,15 +47,14 @@
47
47
 
48
48
  import X3DParser from "./X3DParser.js";
49
49
  import X3DOptimizer from "./X3DOptimizer.js";
50
+ import URLs from "../Browser/Networking/URLs.js";
50
51
  import Vector2 from "../../standard/Math/Numbers/Vector2.js";
51
52
  import Vector3 from "../../standard/Math/Numbers/Vector3.js";
52
53
  import Quaternion from "../../standard/Math/Numbers/Quaternion.js";
53
54
  import Rotation4 from "../../standard/Math/Numbers/Rotation4.js";
54
- import Matrix3 from "../../standard/Math/Numbers/Matrix3.js";
55
55
  import Matrix4 from "../../standard/Math/Numbers/Matrix4.js";
56
56
  import Color3 from "../../standard/Math/Numbers/Color3.js";
57
57
  import Color4 from "../../standard/Math/Numbers/Color4.js";
58
- import Box3 from "../../standard/Math/Geometry/Box3.js";
59
58
  import Algorithm from "../../standard/Math/Algorithm.js";
60
59
  import DEBUG from "../DEBUG.js"
61
60
 
@@ -79,7 +78,7 @@ function GLTF2Parser (scene)
79
78
 
80
79
  // Globals
81
80
 
82
- this .extensionsUsed = new Set ();
81
+ this .extensions = new Set ();
83
82
  this .lights = [ ];
84
83
  this .usedLights = 0;
85
84
  this .buffers = [ ];
@@ -182,13 +181,17 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
182
181
 
183
182
  // Parse root objects.
184
183
 
185
- this .assetObject (glTF .asset);
186
- this .extensionsUsedObject (glTF .extensionsUsed);
187
- this .extensionsObject (glTF .extensions);
184
+ this .assetObject (glTF .asset);
185
+ this .extensionsArray (glTF .extensionsUsed, this .extensions);
186
+ this .extensionsArray (glTF .extensionsRequired, this .extensions);
187
+ this .extensionsObject (glTF .extensions);
188
188
 
189
189
  await this .loadComponents ();
190
190
  await this .buffersArray (glTF .buffers);
191
191
 
192
+ if (this .extensions .has ("KHR_draco_mesh_compression"))
193
+ this .draco = await this .createDraco ();
194
+
192
195
  this .bufferViewsArray (glTF .bufferViews);
193
196
  this .accessorsArray (glTF .accessors);
194
197
  this .samplersArray (glTF .samplers);
@@ -249,19 +252,19 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
249
252
 
250
253
  scene .getRootNodes () .push (worldInfoNode);
251
254
  },
252
- extensionsUsedObject: function (extensionsUsed)
255
+ extensionsArray: function (extensions, set)
253
256
  {
254
- if (!(extensionsUsed instanceof Array))
257
+ if (!(extensions instanceof Array))
255
258
  return;
256
259
 
257
260
  const
258
261
  browser = this .getBrowser (),
259
262
  scene = this .getExecutionContext ();
260
263
 
261
- this .extensionsUsed = new Set (extensionsUsed);
262
-
263
- for (const extension of extensionsUsed)
264
+ for (const extension of extensions)
264
265
  {
266
+ set .add (extension);
267
+
265
268
  switch (extension)
266
269
  {
267
270
  case "KHR_texture_transform":
@@ -312,8 +315,10 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
312
315
  scene = this .getExecutionContext (),
313
316
  name = this .sanitizeName (light .name);
314
317
 
315
- if (light .color instanceof Array)
316
- lightNode ._color = new Color3 (... light .color);
318
+ const color = new Color3 (1, 1, 1);
319
+
320
+ if (this .vectorValue (light .color, color))
321
+ lightNode ._color = color;
317
322
 
318
323
  lightNode ._intensity = this .numberValue (light .intensity, 1);
319
324
 
@@ -375,20 +380,21 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
375
380
 
376
381
  this .buffers = await Promise .all (buffers .map ((buffer, i) => this .bufferObject (buffer, i)));
377
382
  },
378
- bufferObject: function (buffer, i)
383
+ bufferObject: async function (buffer, i)
379
384
  {
380
385
  if (!(buffer instanceof Object))
381
386
  return;
382
387
 
383
388
  if (!buffer .uri)
384
- return Promise .resolve (this .buffers [i]);
389
+ return this .buffers [i];
385
390
 
386
- const url = new URL (buffer .uri, this .getExecutionContext () .getWorldURL ());
391
+ const
392
+ url = new URL (buffer .uri, this .getExecutionContext () .getWorldURL ()),
393
+ response = await fetch (url),
394
+ blob = await response .blob (),
395
+ arrayBuffer = await blob .arrayBuffer ();
387
396
 
388
- return fetch (url)
389
- .then (response => response .blob ())
390
- .then (blob => blob .arrayBuffer ())
391
- .then (arrayBuffer => $.ungzip (arrayBuffer));
397
+ return $.ungzip (arrayBuffer);
392
398
  },
393
399
  bufferViewsArray: function (bufferViews)
394
400
  {
@@ -459,7 +465,7 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
459
465
  {
460
466
  const
461
467
  TypedArray = TypedArrays .get (accessor .componentType),
462
- bufferView = this .bufferViews [accessor .bufferView],
468
+ bufferView = this .bufferViews [accessor .bufferView || 0],
463
469
  byteOffset = accessor .byteOffset || 0,
464
470
  byteStride = bufferView .byteStride || 0,
465
471
  components = Components .get (accessor .type),
@@ -690,8 +696,7 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
690
696
  if (name)
691
697
  scene .addNamedNode (scene .getUniqueName (name), textureNode);
692
698
 
693
- textureNode ._url = [image .uri];
694
- textureNode ._flipVertically = true;
699
+ textureNode ._url = [image .uri];
695
700
 
696
701
  const sampler = this .samplers [texture .sampler];
697
702
 
@@ -921,14 +926,21 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
921
926
  if (!(KHR_materials_emissive_strength instanceof Object))
922
927
  return;
923
928
 
924
- materialNode ._emissiveStrength = this .numberValue( KHR_materials_emissive_strength .emissiveStrength, 1);
929
+ const emissiveStrength = this .numberValue (KHR_materials_emissive_strength .emissiveStrength, 1);
930
+
931
+ // Will not always get the desired result, because colors are clamped values,
932
+ // especially if there is an emissiveTexture.
933
+
934
+ materialNode ._emissiveColor .r *= emissiveStrength;
935
+ materialNode ._emissiveColor .g *= emissiveStrength;
936
+ materialNode ._emissiveColor .b *= emissiveStrength;
925
937
  },
926
938
  textureTransformObject: function (KHR_texture_transform, mapping)
927
939
  {
928
940
  if (!(KHR_texture_transform instanceof Object))
929
941
  return;
930
942
 
931
- if (!this .extensionsUsed .has ("KHR_texture_transform"))
943
+ if (!this .extensions .has ("KHR_texture_transform"))
932
944
  return;
933
945
 
934
946
  const
@@ -1009,6 +1021,8 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
1009
1021
  primitive .indices = this .accessors [primitive .indices];
1010
1022
  primitive .material = this .materials [primitive .material];
1011
1023
 
1024
+ this .primitiveExtensionsObject (primitive .extensions, primitive)
1025
+
1012
1026
  shapeNodes .push (this .createShape (primitive));
1013
1027
  },
1014
1028
  attributesObject: function (attributes)
@@ -1016,32 +1030,176 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
1016
1030
  if (!(attributes instanceof Object))
1017
1031
  return;
1018
1032
 
1019
- attributes .TANGENT = this .accessors [attributes .TANGENT];
1020
- attributes .NORMAL = this .accessors [attributes .NORMAL];
1021
- attributes .POSITION = this .accessors [attributes .POSITION];
1033
+ for (const key in attributes)
1034
+ attributes [key] = this .accessors [attributes [key]];
1022
1035
 
1023
1036
  attributes .TEXCOORD = [ ];
1024
1037
  attributes .COLOR = [ ];
1025
1038
  attributes .JOINTS = [ ];
1026
1039
  attributes .WEIGHTS = [ ];
1027
1040
 
1028
- for (let i = 0; Number .isInteger (attributes ["TEXCOORD_" + i]); ++ i)
1029
- attributes .TEXCOORD .push (this .accessors [attributes ["TEXCOORD_" + i]]);
1041
+ for (let i = 0; attributes ["TEXCOORD_" + i]; ++ i)
1042
+ attributes .TEXCOORD .push (attributes ["TEXCOORD_" + i]);
1030
1043
 
1031
- for (let i = 0; Number .isInteger (attributes ["COLOR_" + i]); ++ i)
1032
- attributes .COLOR .push (this .accessors [attributes ["COLOR_" + i]]);
1044
+ for (let i = 0; attributes ["COLOR_" + i]; ++ i)
1045
+ attributes .COLOR .push (attributes ["COLOR_" + i]);
1033
1046
 
1034
- for (let i = 0; Number .isInteger (attributes ["JOINTS_" + i]); ++ i)
1035
- attributes .JOINTS .push (this .accessors [attributes ["JOINTS_" + i]]);
1047
+ for (let i = 0; attributes ["JOINTS_" + i]; ++ i)
1048
+ attributes .JOINTS .push (attributes ["JOINTS_" + i]);
1036
1049
 
1037
- for (let i = 0; Number .isInteger (attributes ["WEIGHTS_" + i]); ++ i)
1038
- attributes .WEIGHTS .push (this .accessors [attributes ["WEIGHTS_" + i]]);
1050
+ for (let i = 0; attributes ["WEIGHTS_" + i]; ++ i)
1051
+ attributes .WEIGHTS .push (attributes ["WEIGHTS_" + i]);
1039
1052
  },
1040
1053
  targetsArray: function (targets)
1041
1054
  {
1042
1055
  if (!(targets instanceof Array))
1043
1056
  return;
1044
1057
  },
1058
+ primitiveExtensionsObject: function (extensions, primitive)
1059
+ {
1060
+ if (!(extensions instanceof Object))
1061
+ return;
1062
+
1063
+ for (const [key, value] of Object .entries (extensions))
1064
+ {
1065
+ switch (key)
1066
+ {
1067
+ case "KHR_draco_mesh_compression":
1068
+ return this .khrDracoMeshCompressionObject (value, primitive);
1069
+ }
1070
+ }
1071
+ },
1072
+ khrDracoMeshCompressionObject: function (draco, primitive)
1073
+ {
1074
+ if (!(draco instanceof Object))
1075
+ return;
1076
+
1077
+ if (!this .draco)
1078
+ return;
1079
+
1080
+ function indicesCallback (array)
1081
+ {
1082
+ Object .defineProperty (primitive .indices, "array", { value: array });
1083
+ }
1084
+
1085
+ function attributeCallback (key, array)
1086
+ {
1087
+ if (attributes [key])
1088
+ Object .defineProperty (attributes [key], "array", { value: array });
1089
+ }
1090
+
1091
+ const
1092
+ attributes = primitive .attributes,
1093
+ dataView = new Uint8Array (this .bufferViews [draco .bufferView] .buffer);
1094
+
1095
+ this .dracoDecodeMesh (this .draco, dataView, draco .attributes, indicesCallback, attributeCallback);
1096
+ },
1097
+ dracoDecodeMesh: function (draco, dataView, attributes, indicesCallback, attributeCallback)
1098
+ {
1099
+ const
1100
+ buffer = new draco .DecoderBuffer (),
1101
+ decoder = new draco .Decoder ();
1102
+
1103
+ buffer .Init (dataView, dataView .byteLength);
1104
+
1105
+ let geometry, status;
1106
+
1107
+ try
1108
+ {
1109
+ const type = decoder .GetEncodedGeometryType (buffer);
1110
+
1111
+ switch (type)
1112
+ {
1113
+ case draco .TRIANGULAR_MESH:
1114
+ geometry = new draco .Mesh ();
1115
+ status = decoder .DecodeBufferToMesh (buffer, geometry);
1116
+ break;
1117
+ case draco .POINT_CLOUD:
1118
+ geometry = new draco .PointCloud ();
1119
+ status = decoder .DecodeBufferToPointCloud (buffer, geometry);
1120
+ break;
1121
+ default:
1122
+ throw new Error (`Invalid geometry type ${type}.`);
1123
+ }
1124
+
1125
+ if (!status .ok () || !geometry .ptr)
1126
+ throw new Error (status .error_msg ());
1127
+
1128
+ if (type === draco .TRIANGULAR_MESH)
1129
+ {
1130
+ const
1131
+ numFaces = geometry .num_faces (),
1132
+ numIndices = numFaces * 3,
1133
+ byteLength = numIndices * 4,
1134
+ ptr = draco ._malloc (byteLength);
1135
+
1136
+ try
1137
+ {
1138
+ const indices = new Uint32Array (numIndices);
1139
+
1140
+ decoder .GetTrianglesUInt32Array (geometry, byteLength, ptr);
1141
+
1142
+ indices .set (new Uint32Array (draco .HEAPF32 .buffer, ptr, numIndices));
1143
+
1144
+ indicesCallback (indices);
1145
+ }
1146
+ finally
1147
+ {
1148
+ draco ._free (ptr);
1149
+ }
1150
+ }
1151
+
1152
+ for (const [key, id] of Object .entries (attributes))
1153
+ {
1154
+ const
1155
+ attribute = decoder .GetAttributeByUniqueId (geometry, id),
1156
+ numComponents = attribute .num_components (),
1157
+ numPoints = geometry .num_points (),
1158
+ numValues = numPoints * numComponents,
1159
+ byteLength = numValues * Float32Array .BYTES_PER_ELEMENT,
1160
+ ptr = draco ._malloc (byteLength);
1161
+
1162
+ try
1163
+ {
1164
+ const array = new Float32Array (numValues);
1165
+
1166
+ decoder .GetAttributeDataArrayForAllPoints (geometry, attribute, draco .DT_FLOAT32, byteLength, ptr);
1167
+
1168
+ array .set (new Float32Array (draco .HEAPF32 .buffer, ptr, numValues));
1169
+
1170
+ attributeCallback (key, array);
1171
+ }
1172
+ finally
1173
+ {
1174
+ draco ._free (ptr);
1175
+ }
1176
+ }
1177
+ }
1178
+ finally
1179
+ {
1180
+ if (geometry)
1181
+ draco .destroy (geometry);
1182
+
1183
+ draco .destroy (decoder);
1184
+ draco .destroy (buffer);
1185
+ }
1186
+ },
1187
+ createDraco: async function ()
1188
+ {
1189
+ if (this .constructor .draco)
1190
+ {
1191
+ return this .constructor .draco;
1192
+ }
1193
+ else
1194
+ {
1195
+ const
1196
+ response = await fetch (URLs .getLibUrl ("draco_decoder_gltf.js")),
1197
+ text = await response .text (),
1198
+ draco = await new Function (text) () ();
1199
+
1200
+ return this .constructor .draco = draco;
1201
+ }
1202
+ },
1045
1203
  camerasArray: function (cameras)
1046
1204
  {
1047
1205
  if (!(cameras instanceof Array))