x_ite 8.9.0 → 8.9.2

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 (66) hide show
  1. package/README.md +3 -7
  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 +25 -25
  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 +129 -90
  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 +18 -18
  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 +37 -37
  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 +30 -30
  37. package/dist/assets/components/Texturing3D.min.js +1 -1
  38. package/dist/assets/components/VolumeRendering.js +18 -18
  39. package/dist/assets/components/VolumeRendering.min.js +1 -1
  40. package/dist/assets/components/X_ITE.js +9 -9
  41. package/dist/assets/components/X_ITE.min.js +1 -1
  42. package/dist/x_ite.css +1 -1
  43. package/dist/x_ite.js +415 -130
  44. package/dist/x_ite.min.js +1 -1
  45. package/dist/x_ite.zip +0 -0
  46. package/docs/_config.yml +2 -2
  47. package/docs/_posts/components/HAnim/HAnimDisplacer.md +1 -1
  48. package/docs/_posts/components/HAnim/HAnimHumanoid.md +75 -75
  49. package/docs/_posts/components/HAnim/HAnimJoint.md +2 -2
  50. package/docs/_posts/components/HAnim/HAnimMotion.md +22 -22
  51. package/docs/_posts/components/HAnim/HAnimSegment.md +1 -1
  52. package/docs/_posts/components/HAnim/HAnimSite.md +1 -1
  53. package/docs/_posts/getting-started.md +3 -7
  54. package/docs/laboratory/gltf-sample-viewer.html +52 -4
  55. package/package.json +2 -1
  56. package/src/standard/Math/Geometry/Box2.js +12 -2
  57. package/src/standard/Math/Geometry/Box3.js +12 -2
  58. package/src/x_ite/Base/X3DObjectArrayField.js +3 -2
  59. package/src/x_ite/Base/X3DTypedArrayField.js +3 -2
  60. package/src/x_ite/Browser/VERSION.js +1 -1
  61. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +105 -68
  62. package/src/x_ite/Components/HAnim/HAnimMotion.js +3 -3
  63. package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +1 -1
  64. package/src/x_ite/Fields/ArrayFields.js +9 -7
  65. package/src/x_ite/Parser/GLTF2Parser.js +316 -55
  66. package/src/x_ite/Parser/SVGParser.js +1 -1
@@ -85,9 +85,13 @@ function GLTF2Parser (scene)
85
85
  this .samplers = [ ];
86
86
  this .materials = [ ];
87
87
  this .textureTransformNodes = [ ];
88
+ this .meshes = [ ];
88
89
  this .cameras = [ ];
89
90
  this .viewpoints = 0;
90
91
  this .nodes = [ ];
92
+ this .skins = [ ];
93
+ this .joints = new Set ();
94
+ this .skeletons = new Set ();
91
95
  this .animations = 0;
92
96
  }
93
97
 
@@ -130,10 +134,10 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
130
134
  "meshes",
131
135
  "cameras",
132
136
  "nodes",
137
+ "skins",
133
138
  "scenes",
134
139
  "scene",
135
140
  "animations",
136
- "skins",
137
141
  ]);
138
142
 
139
143
  return function ()
@@ -176,6 +180,9 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
176
180
  scene .setEncoding ("GLTF");
177
181
  scene .setProfile (browser .getProfile ("Interchange"));
178
182
 
183
+ if (glTF .skins)
184
+ scene .addComponent (browser .getComponent ("HAnim"));
185
+
179
186
  // Parse root objects.
180
187
 
181
188
  this .assetObject (glTF .asset);
@@ -200,9 +207,9 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
200
207
  this .meshesArray (glTF .meshes);
201
208
  this .camerasArray (glTF .cameras);
202
209
  this .nodesArray (glTF .nodes);
210
+ this .skinsArray (glTF .skins);
203
211
  this .scenesArray (glTF .scenes, glTF .scene);
204
212
  this .animationsArray (glTF .animations);
205
- this .skinsArray (glTF .skins);
206
213
 
207
214
  //this .optimizeSceneGraph (this .getExecutionContext () .getRootNodes ());
208
215
 
@@ -731,8 +738,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
731
738
 
732
739
  const texCoordIndices = this .texCoordIndices ("", material);
733
740
 
734
- this .texCoordIndex = [... texCoordIndices] .reduce (Math .max, -1);
735
-
741
+ this .texCoordIndex = [... texCoordIndices] .reduce (Math .max, -1);
736
742
  this .textureTransformNodes = [ ];
737
743
  this .texCoordMappings = new Map ();
738
744
  material .texCoordMappings = this .texCoordMappings;
@@ -1028,7 +1034,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1028
1034
 
1029
1035
  this .meshes = meshes;
1030
1036
  },
1031
- meshObject (mesh)
1037
+ meshObject (mesh, skin)
1032
1038
  {
1033
1039
  if (!(mesh instanceof Object))
1034
1040
  return;
@@ -1036,7 +1042,16 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1036
1042
  if (mesh .shapeNodes)
1037
1043
  return mesh .shapeNodes;
1038
1044
 
1039
- const shapeNodes = this .primitivesArray (mesh .primitives);
1045
+ if (skin instanceof Object)
1046
+ {
1047
+ const scene = this .getScene ();
1048
+
1049
+ skin .textureCoordinateNode = scene .createNode ("TextureCoordinate", false);
1050
+ skin .normalNode = scene .createNode ("Normal", false);
1051
+ skin .coordinateNode = scene .createNode ("Coordinate", false);
1052
+ }
1053
+
1054
+ const shapeNodes = this .primitivesArray (mesh .primitives, skin);
1040
1055
 
1041
1056
  // Name Shape nodes.
1042
1057
 
@@ -1053,9 +1068,16 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1053
1068
  }
1054
1069
  }
1055
1070
 
1071
+ if (skin instanceof Object)
1072
+ {
1073
+ skin .textureCoordinateNode .setup ();
1074
+ skin .normalNode .setup ();
1075
+ skin .coordinateNode .setup ();
1076
+ }
1077
+
1056
1078
  return mesh .shapeNodes = shapeNodes;
1057
1079
  },
1058
- primitivesArray (primitives)
1080
+ primitivesArray (primitives, skin)
1059
1081
  {
1060
1082
  if (!(primitives instanceof Array))
1061
1083
  return [ ];
@@ -1063,11 +1085,11 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1063
1085
  const shapeNodes = [ ];
1064
1086
 
1065
1087
  for (const primitive of primitives)
1066
- this .primitiveObject (primitive, shapeNodes);
1088
+ this .primitiveObject (primitive, skin, shapeNodes);
1067
1089
 
1068
1090
  return shapeNodes;
1069
1091
  },
1070
- primitiveObject (primitive, shapeNodes)
1092
+ primitiveObject (primitive, skin, shapeNodes)
1071
1093
  {
1072
1094
  if (!(primitive instanceof Object))
1073
1095
  return;
@@ -1080,7 +1102,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1080
1102
 
1081
1103
  this .primitiveExtensionsObject (primitive .extensions, primitive)
1082
1104
 
1083
- shapeNodes .push (this .createShape (primitive));
1105
+ shapeNodes .push (this .createShape (primitive, skin));
1084
1106
  },
1085
1107
  attributesObject (attributes)
1086
1108
  {
@@ -1365,7 +1387,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1365
1387
 
1366
1388
  this .nodes = nodes;
1367
1389
  },
1368
- nodeObject (node)
1390
+ nodeObject (node, index)
1369
1391
  {
1370
1392
  if (!(node instanceof Object))
1371
1393
  return;
@@ -1377,7 +1399,8 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1377
1399
 
1378
1400
  const
1379
1401
  scene = this .getExecutionContext (),
1380
- transformNode = scene .createNode ("Transform", false),
1402
+ typeName = this .joints .has (index) ? "HAnimJoint" : "Transform",
1403
+ transformNode = scene .createNode (typeName, false),
1381
1404
  name = this .sanitizeName (node .name);
1382
1405
 
1383
1406
  // Name
@@ -1386,6 +1409,9 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1386
1409
  {
1387
1410
  scene .addNamedNode (scene .getUniqueName (name), transformNode);
1388
1411
  scene .addExportedNode (scene .getUniqueExportName (name), transformNode);
1412
+
1413
+ if (typeName === "HAnimJoint")
1414
+ transformNode ._name = node .name;
1389
1415
  }
1390
1416
 
1391
1417
  // Set transformation matrix.
@@ -1435,7 +1461,52 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1435
1461
  const mesh = this .meshes [node .mesh];
1436
1462
 
1437
1463
  if (mesh)
1438
- transformNode ._children .push (... this .meshObject (mesh));
1464
+ {
1465
+ const
1466
+ skin = this .skins [node .skin],
1467
+ shapeNodes = this .meshObject (mesh, skin);
1468
+
1469
+ transformNode ._children .push (... shapeNodes);
1470
+
1471
+ if (skin && shapeNodes .length)
1472
+ {
1473
+ var humanoidNode = scene .createNode ("HAnimHumanoid", false);
1474
+
1475
+ const name = this .sanitizeName (skin .name);
1476
+
1477
+ if (name)
1478
+ scene .addNamedNode (scene .getUniqueName (name), humanoidNode);
1479
+
1480
+ humanoidNode ._name = skin .name;
1481
+ humanoidNode ._version = "2.0";
1482
+ humanoidNode ._skeletalConfiguration = "NONE";
1483
+
1484
+ const skeletonNode = this .nodeObject (this .nodes [skin .skeleton], skin .skeleton);
1485
+
1486
+ if (skeletonNode)
1487
+ humanoidNode ._skeleton .push (skeletonNode);
1488
+
1489
+ for (const [i, joint] of skin .joints .entries ())
1490
+ {
1491
+ const inverseBindMatrix = skin .inverseBindMatrices [i] ?? Matrix4 .Identity;
1492
+
1493
+ inverseBindMatrix .get (translation, rotation, scale);
1494
+
1495
+ humanoidNode ._joints .push (this .nodeObject (this .nodes [joint], joint));
1496
+ humanoidNode ._jointBindingPositions .push (translation);
1497
+ humanoidNode ._jointBindingRotations .push (rotation);
1498
+ humanoidNode ._jointBindingScales .push (scale);
1499
+ }
1500
+
1501
+ humanoidNode ._skinBindingNormal = shapeNodes [0] ._geometry .normal ?.getValue () ?.copy ();
1502
+ humanoidNode ._skinBindingCoord = shapeNodes [0] ._geometry .coord ?.getValue () ?.copy ();
1503
+ humanoidNode ._skinNormal = shapeNodes [0] ._geometry .normal;
1504
+ humanoidNode ._skinCoord = shapeNodes [0] ._geometry .coord;
1505
+ humanoidNode ._skin .push (transformNode);
1506
+
1507
+ humanoidNode .setup ();
1508
+ }
1509
+ }
1439
1510
 
1440
1511
  // Get children.
1441
1512
 
@@ -1445,10 +1516,13 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1445
1516
 
1446
1517
  transformNode .setup ();
1447
1518
 
1448
- if (transformNode ._children .length === 0)
1449
- return node .childNode = null;
1519
+ if (typeName === "Transform")
1520
+ {
1521
+ if (!transformNode ._children .length)
1522
+ return node .childNode = null;
1523
+ }
1450
1524
 
1451
- return node .childNode = transformNode;
1525
+ return node .childNode = humanoidNode ?? transformNode;
1452
1526
  },
1453
1527
  nodeExtensions (extensions, transformNode)
1454
1528
  {
@@ -1477,9 +1551,68 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1477
1551
  return [ ];
1478
1552
 
1479
1553
  return children
1554
+ .filter (index => !this .skeletons .has (index))
1480
1555
  .map (index => this .nodeObject (this .nodes [index], index))
1481
1556
  .filter (node => node);
1482
1557
  },
1558
+ skinsArray (skins)
1559
+ {
1560
+ if (!(skins instanceof Array))
1561
+ return;
1562
+
1563
+ this .skins = skins;
1564
+
1565
+ for (const skin of skins)
1566
+ this .skinObject (skin);
1567
+ },
1568
+ skinObject: function (skin)
1569
+ {
1570
+ if (!(skin instanceof Object))
1571
+ return;
1572
+
1573
+ skin .joints = this .jointsArray (skin .joints);
1574
+
1575
+ if (skin .skeleton === undefined)
1576
+ skin .skeleton = this .skeleton (skin .joints);
1577
+
1578
+ this .skeletons .add (skin .skeleton);
1579
+
1580
+ skin .inverseBindMatrices = this .inverseBindMatricesAccessors (this .accessors [skin .inverseBindMatrices]);
1581
+ },
1582
+ jointsArray: function (joints)
1583
+ {
1584
+ if (!(joints instanceof Array))
1585
+ return [ ];
1586
+
1587
+ joints .forEach (index => this .joints .add (index));
1588
+
1589
+ return joints;
1590
+ },
1591
+ skeleton: function (joints)
1592
+ {
1593
+ const children = new Set (joints
1594
+ .map (index => this .nodes [index])
1595
+ .filter (node => node instanceof Object)
1596
+ .filter (node => node .children instanceof Array)
1597
+ .flatMap (node => node .children));
1598
+
1599
+ return joints .filter (index => !children .has (index)) [0];
1600
+ },
1601
+ inverseBindMatricesAccessors: function (inverseBindMatrices)
1602
+ {
1603
+ if (!inverseBindMatrices)
1604
+ return [ ];
1605
+
1606
+ const
1607
+ array = inverseBindMatrices .array,
1608
+ length = array .length,
1609
+ matrices = [ ];
1610
+
1611
+ for (let i = 0; i < length; i += 16)
1612
+ matrices .push (new Matrix4 (... array .subarray (i, i + 16)));
1613
+
1614
+ return matrices;
1615
+ },
1483
1616
  scenesArray (scenes, sceneNumber)
1484
1617
  {
1485
1618
  if (!(scenes instanceof Array))
@@ -1641,7 +1774,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1641
1774
 
1642
1775
  const cycleInterval = samplers
1643
1776
  .map (sampler => this .accessors [sampler .input])
1644
- .filter (input => input && input .array .length)
1777
+ .filter (input => input ?.array .length)
1645
1778
  .reduce ((value, input) => Math .max (value, input .array .at (-1)), 0);
1646
1779
 
1647
1780
  timeSensorNode ._loop = DEVELOPMENT;
@@ -1661,7 +1794,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1661
1794
  if (!(target instanceof Object))
1662
1795
  return null;
1663
1796
 
1664
- const node = this .nodeObject (this .nodes [target .node]);
1797
+ const node = this .nodeObject (this .nodes [target .node], target .node);
1665
1798
 
1666
1799
  if (!node)
1667
1800
  return null;
@@ -1699,11 +1832,6 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1699
1832
 
1700
1833
  return interpolatorNode;
1701
1834
  },
1702
- skinsArray (skins)
1703
- {
1704
- if (!(skins instanceof Array))
1705
- return;
1706
- },
1707
1835
  createNavigationInfo ()
1708
1836
  {
1709
1837
  const
@@ -1716,13 +1844,13 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1716
1844
 
1717
1845
  return navigationInfoNode;
1718
1846
  },
1719
- createShape (primitive)
1847
+ createShape (primitive, skin)
1720
1848
  {
1721
1849
  const
1722
1850
  scene = this .getExecutionContext (),
1723
1851
  shapeNode = scene .createNode ("Shape", false),
1724
1852
  appearanceNode = this .materialObject (primitive .material),
1725
- geometryNode = this .createGeometry (primitive);
1853
+ geometryNode = this .createGeometry (primitive, skin);
1726
1854
 
1727
1855
  shapeNode ._appearance = appearanceNode;
1728
1856
  shapeNode ._geometry = geometryNode;
@@ -1795,54 +1923,54 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1795
1923
  }
1796
1924
  }
1797
1925
  },
1798
- createGeometry (primitive)
1926
+ createGeometry (primitive, skin)
1799
1927
  {
1800
1928
  switch (primitive .mode)
1801
1929
  {
1802
1930
  case 0: // POINTS
1803
1931
  {
1804
- return this .createPointSet (primitive);
1932
+ return this .createPointSet (primitive, skin);
1805
1933
  }
1806
1934
  case 1: // LINES
1807
1935
  {
1808
1936
  if (primitive .indices)
1809
- return this .createIndexedLineSet (primitive, 1);
1937
+ return this .createIndexedLineSet (primitive, skin, 1);
1810
1938
 
1811
- return this .createLineSet (primitive);
1939
+ return this .createLineSet (primitive, skin);
1812
1940
  }
1813
1941
  case 2: // LINE_LOOP
1814
1942
  {
1815
- return this .createIndexedLineSet (primitive, 2);
1943
+ return this .createIndexedLineSet (primitive, skin, 2);
1816
1944
  }
1817
1945
  case 3: // LINE_STRIP
1818
1946
  {
1819
- return this .createIndexedLineSet (primitive, 3);
1947
+ return this .createIndexedLineSet (primitive, skin, 3);
1820
1948
  }
1821
1949
  default:
1822
1950
  case 4: // TRIANGLES
1823
1951
  {
1824
1952
  if (primitive .indices)
1825
- return this .createIndexedTriangleSet (primitive);
1953
+ return this .createIndexedTriangleSet (primitive, skin);
1826
1954
 
1827
- return this .createTriangleSet (primitive);
1955
+ return this .createTriangleSet (primitive, skin);
1828
1956
  }
1829
1957
  case 5: // TRIANGLE_STRIP
1830
1958
  {
1831
1959
  if (primitive .indices)
1832
- return this .createIndexedTriangleStripSet (primitive);
1960
+ return this .createIndexedTriangleStripSet (primitive, skin);
1833
1961
 
1834
- return this .createTriangleStripSet (primitive);
1962
+ return this .createTriangleStripSet (primitive, skin);
1835
1963
  }
1836
1964
  case 6: // TRIANGLE_FAN
1837
1965
  {
1838
1966
  if (primitive .indices)
1839
- return this .createIndexedTriangleFanSet (primitive);
1967
+ return this .createIndexedTriangleFanSet (primitive, skin);
1840
1968
 
1841
- return this .createTriangleFanSet (primitive);
1969
+ return this .createTriangleFanSet (primitive, skin);
1842
1970
  }
1843
1971
  }
1844
1972
  },
1845
- createPointSet ({ attributes, material })
1973
+ createPointSet ({ attributes, material }, skin)
1846
1974
  {
1847
1975
  const
1848
1976
  scene = this .getExecutionContext (),
@@ -1852,11 +1980,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1852
1980
  geometryNode ._normal = this .createNormal (attributes .NORMAL);
1853
1981
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
1854
1982
 
1983
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
1984
+ this .skinGeometry (skin, geometryNode);
1985
+
1855
1986
  geometryNode .setup ();
1856
1987
 
1857
1988
  return geometryNode;
1858
1989
  },
1859
- createIndexedLineSet ({ attributes, indices, material }, mode)
1990
+ createIndexedLineSet ({ attributes, indices, material }, skin, mode)
1860
1991
  {
1861
1992
  const
1862
1993
  scene = this .getExecutionContext (),
@@ -1878,7 +2009,7 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1878
2009
  for (let i = 0; i < length; i += 2)
1879
2010
  coordIndex .push (array [i], array [i + 1], -1);
1880
2011
 
1881
- break
2012
+ break;
1882
2013
  }
1883
2014
  case 2: // LINE_LOOP
1884
2015
  {
@@ -1886,7 +2017,8 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1886
2017
 
1887
2018
  if (indices)
1888
2019
  {
1889
- coordIndex .push (... indices .array);
2020
+ for (const i of indices .array)
2021
+ coordIndex .push (i);
1890
2022
 
1891
2023
  if (coordIndex .length)
1892
2024
  coordIndex .push (coordIndex [0], -1);
@@ -1895,10 +2027,16 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1895
2027
  {
1896
2028
  const coord = geometryNode ._coord;
1897
2029
 
1898
- if (coord && coord .point .length)
1899
- coordIndex .push (... coord .point .keys (), 0, -1);
2030
+ if (coord ?.point .length)
2031
+ {
2032
+ for (const i of coord .point .keys ())
2033
+ coordIndex .push (i);
2034
+
2035
+ coordIndex .push (0, -1);
2036
+ }
1900
2037
  }
1901
- break
2038
+
2039
+ break;
1902
2040
  }
1903
2041
  case 3: // LINE_STRIP
1904
2042
  {
@@ -1906,7 +2044,8 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1906
2044
 
1907
2045
  if (indices)
1908
2046
  {
1909
- coordIndex .push (... indices .array);
2047
+ for (const i of indices .array)
2048
+ coordIndex .push (i);
1910
2049
 
1911
2050
  if (coordIndex .length)
1912
2051
  coordIndex .push (-1);
@@ -1915,19 +2054,27 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1915
2054
  {
1916
2055
  const coord = geometryNode ._coord;
1917
2056
 
1918
- if (coord && coord .point .length)
1919
- coordIndex .push (... coord .point .keys (), -1);
2057
+ if (coord ?.point .length)
2058
+ {
2059
+ for (const i of coord .point .keys ())
2060
+ coordIndex .push (i);
2061
+
2062
+ coordIndex .push (-1);
2063
+ }
1920
2064
  }
1921
2065
 
1922
- break
2066
+ break;
1923
2067
  }
1924
2068
  }
1925
2069
 
2070
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2071
+ this .skinGeometry (skin, geometryNode);
2072
+
1926
2073
  geometryNode .setup ();
1927
2074
 
1928
2075
  return geometryNode;
1929
2076
  },
1930
- createLineSet ({ attributes, material })
2077
+ createLineSet ({ attributes, material }, skin)
1931
2078
  {
1932
2079
  const
1933
2080
  scene = this .getExecutionContext (),
@@ -1937,11 +2084,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1937
2084
  geometryNode ._normal = this .createNormal (attributes .NORMAL);
1938
2085
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
1939
2086
 
2087
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2088
+ this .skinGeometry (skin, geometryNode);
2089
+
1940
2090
  geometryNode .setup ();
1941
2091
 
1942
2092
  return geometryNode;
1943
2093
  },
1944
- createIndexedTriangleSet ({ attributes, indices, material })
2094
+ createIndexedTriangleSet ({ attributes, indices, material }, skin)
1945
2095
  {
1946
2096
  const
1947
2097
  scene = this .getExecutionContext (),
@@ -1955,11 +2105,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1955
2105
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
1956
2106
  geometryNode ._normalPerVertex = !! geometryNode ._normal;
1957
2107
 
2108
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2109
+ this .skinGeometry (skin, geometryNode);
2110
+
1958
2111
  geometryNode .setup ();
1959
2112
 
1960
2113
  return geometryNode;
1961
2114
  },
1962
- createTriangleSet ({ attributes, material })
2115
+ createTriangleSet ({ attributes, material }, skin)
1963
2116
  {
1964
2117
  const
1965
2118
  scene = this .getExecutionContext (),
@@ -1972,11 +2125,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1972
2125
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
1973
2126
  geometryNode ._normalPerVertex = !! geometryNode ._normal;
1974
2127
 
2128
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2129
+ this .skinGeometry (skin, geometryNode);
2130
+
1975
2131
  geometryNode .setup ();
1976
2132
 
1977
2133
  return geometryNode;
1978
2134
  },
1979
- createIndexedTriangleStripSet ({ attributes, indices, material })
2135
+ createIndexedTriangleStripSet ({ attributes, indices, material }, skin)
1980
2136
  {
1981
2137
  const
1982
2138
  scene = this .getExecutionContext (),
@@ -1990,11 +2146,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
1990
2146
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
1991
2147
  geometryNode ._normalPerVertex = !! geometryNode ._normal;
1992
2148
 
2149
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2150
+ this .skinGeometry (skin, geometryNode);
2151
+
1993
2152
  geometryNode .setup ();
1994
2153
 
1995
2154
  return geometryNode;
1996
2155
  },
1997
- createTriangleStripSet ({ attributes, material })
2156
+ createTriangleStripSet ({ attributes, material }, skin)
1998
2157
  {
1999
2158
  const
2000
2159
  scene = this .getExecutionContext (),
@@ -2015,11 +2174,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
2015
2174
  geometryNode ._stripCount = [coord .point .length];
2016
2175
  }
2017
2176
 
2177
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2178
+ this .skinGeometry (skin, geometryNode);
2179
+
2018
2180
  geometryNode .setup ();
2019
2181
 
2020
2182
  return geometryNode;
2021
2183
  },
2022
- createIndexedTriangleFanSet ({ attributes, indices, material })
2184
+ createIndexedTriangleFanSet ({ attributes, indices, material }, skin)
2023
2185
  {
2024
2186
  const
2025
2187
  scene = this .getExecutionContext (),
@@ -2033,11 +2195,14 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
2033
2195
  geometryNode ._coord = this .createCoordinate (attributes .POSITION);
2034
2196
  geometryNode ._normalPerVertex = !! geometryNode ._normal;
2035
2197
 
2198
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2199
+ this .skinGeometry (skin, geometryNode);
2200
+
2036
2201
  geometryNode .setup ();
2037
2202
 
2038
2203
  return geometryNode;
2039
2204
  },
2040
- createTriangleFanSet ({ attributes, material })
2205
+ createTriangleFanSet ({ attributes, material }, skin)
2041
2206
  {
2042
2207
  const
2043
2208
  scene = this .getExecutionContext (),
@@ -2058,6 +2223,9 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
2058
2223
  geometryNode ._fanCount = [coord .point .length];
2059
2224
  }
2060
2225
 
2226
+ this .attributesJointsArray (skin, attributes .JOINTS, attributes .WEIGHTS);
2227
+ this .skinGeometry (skin, geometryNode);
2228
+
2061
2229
  geometryNode .setup ();
2062
2230
 
2063
2231
  return geometryNode;
@@ -2204,6 +2372,99 @@ Object .assign (Object .setPrototypeOf (GLTF2Parser .prototype, X3DParser .proto
2204
2372
 
2205
2373
  return position .coordinateNode = coordinateNode;
2206
2374
  },
2375
+ attributesJointsArray: function (skin, joints, weights)
2376
+ {
2377
+ if (!(skin instanceof Object))
2378
+ return;
2379
+
2380
+ if (!(joints instanceof Array))
2381
+ return;
2382
+
2383
+ if (!(weights instanceof Array))
2384
+ return;
2385
+
2386
+ for (let i = 0, length = joints .length; i < length; ++ i)
2387
+ this .attributesJointsObject (skin, joints [i], weights [i]);
2388
+ },
2389
+ attributesJointsObject: function (skin, joints, weights)
2390
+ {
2391
+ if (!(joints instanceof Object))
2392
+ return;
2393
+
2394
+ if (!(weights instanceof Object))
2395
+ return;
2396
+
2397
+ if (joints .type !== "VEC4")
2398
+ return;
2399
+
2400
+ if (weights .type !== "VEC4")
2401
+ return;
2402
+
2403
+ const
2404
+ start = skin .coordinateNode ._point .length,
2405
+ jointsArray = joints .array,
2406
+ weightsArray = weights .array,
2407
+ numVertices = jointsArray .length / 4;
2408
+
2409
+ for (let v = 0; v < numVertices; ++ v)
2410
+ {
2411
+ for (let i = 0; i < 4; ++ i)
2412
+ {
2413
+ const w = weightsArray [v * 4 + i];
2414
+
2415
+ if (w === 0)
2416
+ continue;
2417
+
2418
+ const
2419
+ index = skin .joints [jointsArray [v * 4 + i]],
2420
+ jointNode = this .nodeObject (this .nodes [index], index);
2421
+
2422
+ jointNode ._skinCoordIndex .push (v + start);
2423
+ jointNode ._skinCoordWeight .push (w);
2424
+ }
2425
+ }
2426
+ },
2427
+ skinGeometry: function (skin, geometryNode)
2428
+ {
2429
+ if (!(skin instanceof Object))
2430
+ return;
2431
+
2432
+ const
2433
+ skinTextureCoordinateNode = skin .textureCoordinateNode,
2434
+ skinNormalNode = skin .normalNode,
2435
+ skinCoordinateNode = skin .coordinateNode,
2436
+ start = skinCoordinateNode ._point .length,
2437
+ textureCoordinateNode = geometryNode ._texCoord ?.getValue (),
2438
+ normalNode = geometryNode ._normal ?.getValue (),
2439
+ coordinateNode = geometryNode ._coord ?.getValue ();
2440
+
2441
+ if (geometryNode ._coordIndex)
2442
+ geometryNode ._coordIndex = geometryNode ._coordIndex .map (index => index < 0 ? -1 : index + start);
2443
+
2444
+ if (geometryNode ._index)
2445
+ geometryNode ._index = geometryNode ._index .map (index => index < 0 ? -1 : index + start);
2446
+
2447
+ if (textureCoordinateNode)
2448
+ {
2449
+ const point = skinTextureCoordinateNode ._point;
2450
+ textureCoordinateNode ._point .forEach ((p, i) => point [i + start] = p);
2451
+ geometryNode ._texCoord = skinTextureCoordinateNode;
2452
+ }
2453
+
2454
+ if (normalNode)
2455
+ {
2456
+ const vector = skinNormalNode ._vector;
2457
+ normalNode ._vector .forEach ((v, i) => vector [i + start] = v);
2458
+ geometryNode ._normal = skinNormalNode;
2459
+ }
2460
+
2461
+ if (coordinateNode)
2462
+ {
2463
+ const point = skinCoordinateNode ._point;
2464
+ coordinateNode ._point .forEach ((p, i) => point [i + start] = p);
2465
+ geometryNode ._coord = skinCoordinateNode;
2466
+ }
2467
+ },
2207
2468
  createInterpolator (path, interpolation, times, keyValues, cycleInterval)
2208
2469
  {
2209
2470
  const scene = this .getExecutionContext ();