@loaders.gl/tile-converter 4.0.0-alpha.19 → 4.0.0-alpha.20

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 (100) hide show
  1. package/dist/constants.d.ts +2 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +3 -1
  4. package/dist/converter-cli.js +10 -2
  5. package/dist/converter.min.js +172 -103
  6. package/dist/dist.min.js +151 -86
  7. package/dist/es5/constants.js +5 -1
  8. package/dist/es5/constants.js.map +1 -1
  9. package/dist/es5/converter-cli.js +7 -2
  10. package/dist/es5/converter-cli.js.map +1 -1
  11. package/dist/es5/deps-installer/deps-installer.js +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
  13. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  14. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
  15. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  16. package/dist/es5/i3s-converter/helpers/geometry-converter.js +67 -59
  17. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
  19. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  20. package/dist/es5/i3s-converter/i3s-converter.js +55 -13
  21. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  22. package/dist/es5/i3s-converter/types.js +11 -11
  23. package/dist/es5/i3s-converter/types.js.map +1 -1
  24. package/dist/es5/i3s-server/controllers/slpk-controller.js +1 -1
  25. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  26. package/dist/es5/index.js +3 -3
  27. package/dist/es5/index.js.map +1 -1
  28. package/dist/es5/pgm-loader.js +1 -1
  29. package/dist/es5/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +9 -9
  30. package/dist/es5/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  31. package/dist/es5/slpk-extractor/slpk-extractor.js +5 -5
  32. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  33. package/dist/esm/constants.js +2 -0
  34. package/dist/esm/constants.js.map +1 -1
  35. package/dist/esm/converter-cli.js +7 -2
  36. package/dist/esm/converter-cli.js.map +1 -1
  37. package/dist/esm/deps-installer/deps-installer.js +1 -1
  38. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
  39. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
  41. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/geometry-converter.js +28 -20
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  44. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
  45. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  46. package/dist/esm/i3s-converter/i3s-converter.js +39 -9
  47. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  48. package/dist/esm/i3s-converter/types.js +9 -9
  49. package/dist/esm/i3s-converter/types.js.map +1 -1
  50. package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
  51. package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
  52. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/pgm-loader.js +1 -1
  56. package/dist/esm/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +3 -3
  57. package/dist/esm/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  58. package/dist/esm/slpk-extractor/slpk-extractor.js +3 -3
  59. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  60. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
  61. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
  63. package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
  64. package/dist/i3s-converter/helpers/geometry-converter.d.ts +6 -3
  65. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/helpers/geometry-converter.js +42 -35
  67. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
  68. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  69. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
  70. package/dist/i3s-converter/i3s-converter.d.ts +2 -0
  71. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  72. package/dist/i3s-converter/i3s-converter.js +40 -10
  73. package/dist/i3s-converter/types.d.ts +4 -2
  74. package/dist/i3s-converter/types.d.ts.map +1 -1
  75. package/dist/i3s-converter/types.js +11 -11
  76. package/dist/i3s-server/controllers/slpk-controller.js +1 -1
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +3 -3
  80. package/dist/slpk-extractor/helpers/{file-handle-provider.d.ts → file-handle-file.d.ts} +5 -5
  81. package/dist/slpk-extractor/helpers/file-handle-file.d.ts.map +1 -0
  82. package/dist/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +5 -5
  83. package/dist/slpk-extractor/slpk-extractor.js +5 -5
  84. package/dist/slpk-extractor.min.js +32 -32
  85. package/package.json +15 -14
  86. package/src/constants.ts +3 -0
  87. package/src/converter-cli.ts +9 -2
  88. package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
  89. package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
  90. package/src/i3s-converter/helpers/geometry-converter.ts +66 -35
  91. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
  92. package/src/i3s-converter/i3s-converter.ts +54 -12
  93. package/src/i3s-converter/types.ts +4 -2
  94. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  95. package/src/index.ts +1 -1
  96. package/src/slpk-extractor/helpers/{file-handle-provider.ts → file-handle-file.ts} +5 -5
  97. package/src/slpk-extractor/slpk-extractor.ts +3 -3
  98. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  99. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  100. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
package/dist/dist.min.js CHANGED
@@ -46551,7 +46551,7 @@ var require_es55 = __commonJS({
46551
46551
 
46552
46552
  // src/index.ts
46553
46553
  __export(exports, {
46554
- FileHandleProvider: () => FileHandleProvider,
46554
+ FileHandleFile: () => FileHandleFile,
46555
46555
  I3SConverter: () => I3SConverter,
46556
46556
  Tiles3DConverter: () => Tiles3DConverter
46557
46557
  });
@@ -49213,12 +49213,12 @@ async function getArrayBufferOrStringFromData(data, loader, options) {
49213
49213
  // ../core/src/lib/loader-utils/get-fetch-function.ts
49214
49214
  function getFetchFunction(options, context) {
49215
49215
  const globalOptions = getGlobalLoaderOptions();
49216
- const fetchOptions = options || globalOptions;
49217
- if (typeof fetchOptions.fetch === "function") {
49218
- return fetchOptions.fetch;
49216
+ const loaderOptions = options || globalOptions;
49217
+ if (typeof loaderOptions.fetch === "function") {
49218
+ return loaderOptions.fetch;
49219
49219
  }
49220
- if (isObject(fetchOptions.fetch)) {
49221
- return (url) => fetchFile(url, fetchOptions);
49220
+ if (isObject(loaderOptions.fetch)) {
49221
+ return (url) => fetchFile(url, loaderOptions.fetch);
49222
49222
  }
49223
49223
  if (context?.fetch) {
49224
49224
  return context?.fetch;
@@ -58337,12 +58337,13 @@ function unifyObjectsByFeatureId(sortedData) {
58337
58337
  const uniqueObjects = [];
58338
58338
  for (let index = 0; index < sortedData.length; index++) {
58339
58339
  const currentObject = sortedData[index];
58340
- const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
58341
- if (existedObject) {
58342
- existedObject.positions = concatenateTypedArrays(existedObject.positions, currentObject.positions);
58343
- existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);
58344
- existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);
58345
- existedObject.texCoords = concatenateTypedArrays(existedObject.texCoords, currentObject.texCoords);
58340
+ const existingObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
58341
+ if (existingObject) {
58342
+ existingObject.positions = concatenateTypedArrays(existingObject.positions, currentObject.positions);
58343
+ existingObject.normals = concatenateTypedArrays(existingObject.normals, currentObject.normals);
58344
+ existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);
58345
+ existingObject.texCoords = concatenateTypedArrays(existingObject.texCoords, currentObject.texCoords);
58346
+ existingObject.uvRegions = concatenateTypedArrays(existingObject.uvRegions, currentObject.uvRegions);
58346
58347
  } else {
58347
58348
  uniqueObjects.push(currentObject);
58348
58349
  }
@@ -58550,10 +58551,26 @@ function prepareNodes(nodes) {
58550
58551
  }
58551
58552
  }
58552
58553
 
58553
- // src/i3s-converter/helpers/batch-ids-extensions.ts
58554
+ // src/constants.ts
58555
+ var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
58554
58556
  var EXT_MESH_FEATURES = "EXT_mesh_features";
58555
58557
  var EXT_FEATURE_METADATA2 = "EXT_feature_metadata";
58556
- function handleBatchIdsExtensions(attributes, primitive, images) {
58558
+
58559
+ // src/i3s-converter/helpers/batch-ids-extensions.ts
58560
+ function getTextureByMetadataClass(tileContent, metadataClass) {
58561
+ const extFeatureMetadata = tileContent.gltf?.extensions?.[EXT_FEATURE_METADATA2];
58562
+ if (!extFeatureMetadata?.featureTextures) {
58563
+ return null;
58564
+ }
58565
+ for (const textureKey in extFeatureMetadata.featureTextures) {
58566
+ const texture = extFeatureMetadata.featureTextures[textureKey];
58567
+ if (texture.class === metadataClass) {
58568
+ return textureKey;
58569
+ }
58570
+ }
58571
+ return null;
58572
+ }
58573
+ function handleBatchIdsExtensions(attributes, primitive, images, featureTexture) {
58557
58574
  const extensions = primitive?.extensions;
58558
58575
  if (!extensions) {
58559
58576
  return [];
@@ -58561,7 +58578,7 @@ function handleBatchIdsExtensions(attributes, primitive, images) {
58561
58578
  for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
58562
58579
  switch (extensionName) {
58563
58580
  case EXT_FEATURE_METADATA2:
58564
- return handleExtFeatureMetadataExtension(attributes, extensionData, images);
58581
+ return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
58565
58582
  case EXT_MESH_FEATURES:
58566
58583
  console.warn("EXT_mesh_features extension is not supported yet");
58567
58584
  return [];
@@ -58571,7 +58588,7 @@ function handleBatchIdsExtensions(attributes, primitive, images) {
58571
58588
  }
58572
58589
  return [];
58573
58590
  }
58574
- function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images) {
58591
+ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images, featureTexture) {
58575
58592
  const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
58576
58593
  if (featureIdAttribute?.featureIds?.attribute) {
58577
58594
  const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];
@@ -58588,7 +58605,6 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
58588
58605
  const textureCoordinates = attributes[textCoordAttribute].value;
58589
58606
  return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
58590
58607
  }
58591
- const featureTexture = extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
58592
58608
  if (featureTexture) {
58593
58609
  const batchIdsAttribute = attributes[featureTexture];
58594
58610
  return batchIdsAttribute.value;
@@ -58809,14 +58825,13 @@ var SHORT_INT_TYPE2 = "Int32";
58809
58825
  var DOUBLE_TYPE2 = "Float64";
58810
58826
  var OBJECT_ID_TYPE2 = "Oid32";
58811
58827
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
58812
- var EXT_FEATURE_METADATA3 = "EXT_feature_metadata";
58813
- var EXT_MESH_FEATURES2 = "EXT_mesh_features";
58814
58828
  var scratchVector4 = new import_core16.Vector3();
58815
- async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries) {
58829
+ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
58816
58830
  const useCartesianPositions = generateBoundingVolumes;
58817
58831
  const materialAndTextureList = await convertMaterials(tileContent.gltf?.materials, shouldMergeMaterials);
58818
58832
  const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent, tileTransform, tileBoundingVolume);
58819
- const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
58833
+ const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
58834
+ const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
58820
58835
  if (generateBoundingVolumes) {
58821
58836
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
58822
58837
  }
@@ -58913,7 +58928,7 @@ async function _makeNodeResources({
58913
58928
  boundingVolumes
58914
58929
  };
58915
58930
  }
58916
- async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
58931
+ async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
58917
58932
  const { nodes, images, cartographicOrigin, cartesianModelMatrix } = attributesData;
58918
58933
  const attributesMap = new Map();
58919
58934
  for (const materialAndTexture of materialAndTextureList) {
@@ -58932,7 +58947,7 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
58932
58947
  attributesMap.set(mergedMaterial.originalMaterialId, attributes);
58933
58948
  }
58934
58949
  }
58935
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
58950
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, void 0, featureTexture);
58936
58951
  for (const attrKey of attributesMap.keys()) {
58937
58952
  const attributes = attributesMap.get(attrKey);
58938
58953
  if (!attributes) {
@@ -58949,10 +58964,10 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
58949
58964
  }
58950
58965
  return attributesMap;
58951
58966
  }
58952
- function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58967
+ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58953
58968
  if (nodes) {
58954
58969
  for (const node2 of nodes) {
58955
- convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
58970
+ convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
58956
58971
  }
58957
58972
  }
58958
58973
  }
@@ -58973,15 +58988,15 @@ function getCompositeTransformationMatrix(node2, matrix) {
58973
58988
  }
58974
58989
  return transformationMatrix;
58975
58990
  }
58976
- function convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58991
+ function convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58977
58992
  const transformationMatrix = getCompositeTransformationMatrix(node2, matrix);
58978
58993
  const mesh = node2.mesh;
58979
58994
  if (mesh) {
58980
- convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
58995
+ convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
58981
58996
  }
58982
- convertNodes(node2.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
58997
+ convertNodes(node2.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
58983
58998
  }
58984
- function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58999
+ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58985
59000
  for (const primitive of mesh.primitives) {
58986
59001
  let outputAttributes = null;
58987
59002
  let materialUvRegion;
@@ -59022,7 +59037,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
59022
59037
  outputAttributes.uvRegions = concatenateTypedArrays(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
59023
59038
  }
59024
59039
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
59025
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
59040
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
59026
59041
  }
59027
59042
  }
59028
59043
  function normalizeIndices(primitive) {
@@ -59139,8 +59154,8 @@ function flattenBatchIds(batchedIds, indices) {
59139
59154
  }
59140
59155
  return newBatchIds;
59141
59156
  }
59142
- function getBatchIds(attributes, primitive, images) {
59143
- const batchIds = handleBatchIdsExtensions(attributes, primitive, images);
59157
+ function getBatchIds(attributes, primitive, images, featureTexture) {
59158
+ const batchIds = handleBatchIdsExtensions(attributes, primitive, images, featureTexture);
59144
59159
  if (batchIds.length) {
59145
59160
  return batchIds;
59146
59161
  }
@@ -59519,7 +59534,7 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
59519
59534
  }
59520
59535
  return orderedFeatureIndices;
59521
59536
  }
59522
- function getPropertyTable(tileContent) {
59537
+ function getPropertyTable(tileContent, metadataClass) {
59523
59538
  if (!tileContent) {
59524
59539
  return null;
59525
59540
  }
@@ -59529,19 +59544,19 @@ function getPropertyTable(tileContent) {
59529
59544
  }
59530
59545
  const { extensionName, extension } = getPropertyTableExtension(tileContent);
59531
59546
  switch (extensionName) {
59532
- case EXT_MESH_FEATURES2: {
59547
+ case EXT_MESH_FEATURES: {
59533
59548
  console.warn("The I3S converter does not yet support the EXT_mesh_features extension");
59534
59549
  return null;
59535
59550
  }
59536
- case EXT_FEATURE_METADATA3: {
59537
- return getPropertyTableFromExtFeatureMetadata(extension);
59551
+ case EXT_FEATURE_METADATA2: {
59552
+ return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
59538
59553
  }
59539
59554
  default:
59540
59555
  return null;
59541
59556
  }
59542
59557
  }
59543
59558
  function getPropertyTableExtension(tileContent) {
59544
- const extensionsWithPropertyTables = [EXT_FEATURE_METADATA3, EXT_MESH_FEATURES2];
59559
+ const extensionsWithPropertyTables = [EXT_FEATURE_METADATA2, EXT_MESH_FEATURES];
59545
59560
  const extensionsUsed = tileContent?.gltf?.extensionsUsed;
59546
59561
  if (!extensionsUsed) {
59547
59562
  return { extensionName: null, extension: null };
@@ -59559,7 +59574,7 @@ function getPropertyTableExtension(tileContent) {
59559
59574
  const extension = tileContent?.gltf?.extensions?.[extensionName];
59560
59575
  return { extensionName, extension };
59561
59576
  }
59562
- function getPropertyTableFromExtFeatureMetadata(extension) {
59577
+ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
59563
59578
  if (extension?.featureTables) {
59564
59579
  const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
59565
59580
  if (firstFeatureTableName) {
@@ -59572,9 +59587,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
59572
59587
  }
59573
59588
  }
59574
59589
  if (extension?.featureTextures) {
59575
- const firstTextureName = Object.keys(extension.featureTextures)?.[0];
59576
- if (firstTextureName) {
59577
- const featureTable = extension?.featureTextures[firstTextureName];
59590
+ let featureTexture;
59591
+ for (const textureKey in extension.featureTextures) {
59592
+ const texture = extension.featureTextures[textureKey];
59593
+ if (texture.class === metadataClass) {
59594
+ featureTexture = textureKey;
59595
+ }
59596
+ }
59597
+ if (typeof featureTexture === "string") {
59598
+ const featureTable = extension?.featureTextures[featureTexture];
59578
59599
  const propertyTable = {};
59579
59600
  for (const propertyName in featureTable.properties) {
59580
59601
  propertyTable[propertyName] = featureTable.properties[propertyName].data;
@@ -60268,16 +60289,16 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
60268
60289
  }
60269
60290
 
60270
60291
  // src/i3s-converter/types.ts
60271
- var GltfPrimitiveModeString;
60272
- (function(GltfPrimitiveModeString2) {
60273
- GltfPrimitiveModeString2["POINTS"] = "POINTS";
60274
- GltfPrimitiveModeString2["LINES"] = "LINES";
60275
- GltfPrimitiveModeString2["LINE_LOOP"] = "LINE_LOOP";
60276
- GltfPrimitiveModeString2["LINE_STRIP"] = "LINE_STRIP";
60277
- GltfPrimitiveModeString2["TRIANGLES"] = "TRIANGLES";
60278
- GltfPrimitiveModeString2["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
60279
- GltfPrimitiveModeString2["TRIANGLE_FAN"] = "TRIANGLE_FAN";
60280
- })(GltfPrimitiveModeString || (GltfPrimitiveModeString = {}));
60292
+ var GLTFPrimitiveModeString;
60293
+ (function(GLTFPrimitiveModeString2) {
60294
+ GLTFPrimitiveModeString2["POINTS"] = "POINTS";
60295
+ GLTFPrimitiveModeString2["LINES"] = "LINES";
60296
+ GLTFPrimitiveModeString2["LINE_LOOP"] = "LINE_LOOP";
60297
+ GLTFPrimitiveModeString2["LINE_STRIP"] = "LINE_STRIP";
60298
+ GLTFPrimitiveModeString2["TRIANGLES"] = "TRIANGLES";
60299
+ GLTFPrimitiveModeString2["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
60300
+ GLTFPrimitiveModeString2["TRIANGLE_FAN"] = "TRIANGLE_FAN";
60301
+ })(GLTFPrimitiveModeString || (GLTFPrimitiveModeString = {}));
60281
60302
 
60282
60303
  // src/lib/utils/queue.ts
60283
60304
  var Queue = class extends Array {
@@ -60367,9 +60388,6 @@ var WriteQueue = class extends Queue {
60367
60388
  }
60368
60389
  };
60369
60390
 
60370
- // src/constants.ts
60371
- var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
60372
-
60373
60391
  // src/i3s-converter/helpers/node-index-document.ts
60374
60392
  var import_path7 = __toModule(require("path"));
60375
60393
  var import_json_map_transform7 = __toModule(require_json_map_transform());
@@ -60688,31 +60706,35 @@ var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessT
60688
60706
 
60689
60707
  // src/i3s-converter/helpers/preprocess-3d-tiles.ts
60690
60708
  var GLTF_PRIMITIVE_MODES = [
60691
- GltfPrimitiveModeString.POINTS,
60692
- GltfPrimitiveModeString.LINES,
60693
- GltfPrimitiveModeString.LINE_LOOP,
60694
- GltfPrimitiveModeString.LINE_STRIP,
60695
- GltfPrimitiveModeString.TRIANGLES,
60696
- GltfPrimitiveModeString.TRIANGLE_STRIP,
60697
- GltfPrimitiveModeString.TRIANGLE_FAN
60709
+ GLTFPrimitiveModeString.POINTS,
60710
+ GLTFPrimitiveModeString.LINES,
60711
+ GLTFPrimitiveModeString.LINE_LOOP,
60712
+ GLTFPrimitiveModeString.LINE_STRIP,
60713
+ GLTFPrimitiveModeString.TRIANGLES,
60714
+ GLTFPrimitiveModeString.TRIANGLE_STRIP,
60715
+ GLTFPrimitiveModeString.TRIANGLE_FAN
60698
60716
  ];
60699
60717
  var analyzeTileContent = async (tileContent) => {
60700
- const result = {
60701
- meshTopologyTypes: new Set()
60718
+ const defaultResult = {
60719
+ meshTopologyTypes: new Set(),
60720
+ metadataClasses: new Set()
60702
60721
  };
60703
60722
  if (!tileContent?.gltfArrayBuffer) {
60704
- return result;
60723
+ return defaultResult;
60705
60724
  }
60706
60725
  const gltfData = await parse(tileContent.gltfArrayBuffer, GLTFLoader, {
60707
60726
  gltf: { normalize: false, loadBuffers: false, loadImages: false, decompressMeshes: false }
60708
60727
  });
60709
60728
  const gltf = gltfData.json;
60710
60729
  if (!gltf) {
60711
- return result;
60730
+ return defaultResult;
60712
60731
  }
60713
- const meshTypes = getMeshTypesFromGltf(gltf);
60714
- result.meshTopologyTypes = meshTypes;
60715
- return result;
60732
+ const meshTopologyTypes = getMeshTypesFromGltf(gltf);
60733
+ const metadataClasses = getMetadataClassesFromGltf(gltf);
60734
+ return {
60735
+ meshTopologyTypes,
60736
+ metadataClasses
60737
+ };
60716
60738
  };
60717
60739
  var getMeshTypesFromGltf = (gltfJson) => {
60718
60740
  const result = new Set();
@@ -60727,14 +60749,27 @@ var getMeshTypesFromGltf = (gltfJson) => {
60727
60749
  }
60728
60750
  return result;
60729
60751
  };
60752
+ var getMetadataClassesFromGltf = (gltfJson) => {
60753
+ const result = new Set();
60754
+ const classes = gltfJson.extensions?.[EXT_FEATURE_METADATA2]?.schema?.classes;
60755
+ if (classes) {
60756
+ for (const classKey of Object.keys(classes)) {
60757
+ result.add(classKey);
60758
+ }
60759
+ }
60760
+ return result;
60761
+ };
60730
60762
  var mergePreprocessData = (object1, object2) => {
60731
60763
  for (const type of object2.meshTopologyTypes) {
60732
60764
  object1.meshTopologyTypes.add(type);
60733
60765
  }
60766
+ for (const metadataClass of object2.metadataClasses) {
60767
+ object1.metadataClasses.add(metadataClass);
60768
+ }
60734
60769
  };
60735
60770
 
60736
60771
  // src/i3s-converter/i3s-converter.ts
60737
- var ION_DEFAULT_TOKEN = import_process2.default.env?.IonToken || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ";
60772
+ var ION_DEFAULT_TOKEN = import_process2.default.env?.IonToken;
60738
60773
  var HARDCODED_NODES_PER_PAGE = 64;
60739
60774
  var _3D_TILES = "3DTILES";
60740
60775
  var _3D_OBJECT_LAYER_TYPE = "3DObject";
@@ -60764,7 +60799,8 @@ var I3SConverter = class {
60764
60799
  this.writeQueue = new WriteQueue();
60765
60800
  this.compressList = null;
60766
60801
  this.preprocessData = {
60767
- meshTopologyTypes: new Set()
60802
+ meshTopologyTypes: new Set(),
60803
+ metadataClasses: new Set()
60768
60804
  };
60769
60805
  this.nodePages = new NodePages(writeFile3, HARDCODED_NODES_PER_PAGE, this);
60770
60806
  this.options = {};
@@ -60806,7 +60842,9 @@ var I3SConverter = class {
60806
60842
  generateTextures,
60807
60843
  generateBoundingVolumes,
60808
60844
  instantNodeWriting = false,
60809
- mergeMaterials: mergeMaterials2 = true
60845
+ mergeMaterials: mergeMaterials2 = true,
60846
+ inquirer,
60847
+ metadataClass
60810
60848
  } = options;
60811
60849
  this.options = {
60812
60850
  maxDepth,
@@ -60817,7 +60855,9 @@ var I3SConverter = class {
60817
60855
  token,
60818
60856
  inputUrl,
60819
60857
  instantNodeWriting,
60820
- mergeMaterials: mergeMaterials2
60858
+ mergeMaterials: mergeMaterials2,
60859
+ inquirer,
60860
+ metadataClass
60821
60861
  };
60822
60862
  this.compressList = this.options.instantNodeWriting && [] || null;
60823
60863
  this.validate = Boolean(validate2);
@@ -60860,16 +60900,41 @@ var I3SConverter = class {
60860
60900
  console.log(`Analyze source tileset`);
60861
60901
  const sourceRootTile = this.sourceTileset.root;
60862
60902
  await traverseDatasetWith(sourceRootTile, null, this.analyzeTile.bind(this), void 0, this.options.maxDepth);
60863
- const { meshTopologyTypes } = this.preprocessData;
60903
+ const { meshTopologyTypes, metadataClasses } = this.preprocessData;
60864
60904
  console.log(`------------------------------------------------`);
60865
60905
  console.log(`Preprocess results:`);
60866
60906
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
60907
+ if (metadataClasses.size) {
60908
+ console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(", ")}`);
60909
+ } else {
60910
+ console.log("Feature metadata classes have not been found");
60911
+ }
60867
60912
  console.log(`------------------------------------------------`);
60868
- if (!meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLE_STRIP)) {
60913
+ if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
60869
60914
  console.log("The tileset is of unsupported mesh topology types. The conversion will be interrupted.");
60870
60915
  console.log(`------------------------------------------------`);
60871
60916
  return false;
60872
60917
  }
60918
+ if (metadataClasses.size > 1) {
60919
+ if (this.options.metadataClass?.length) {
60920
+ console.log(`${this.options.metadataClass} has been selected`);
60921
+ } else if (this.options.inquirer) {
60922
+ const result = await this.options.inquirer.prompt([
60923
+ {
60924
+ name: "metadataClass",
60925
+ type: "list",
60926
+ message: "Select feature metadata data class to convert...",
60927
+ choices: Array.from(metadataClasses)
60928
+ }
60929
+ ]);
60930
+ this.options.metadataClass = result.metadataClass;
60931
+ console.log(`${result.metadataClass} has been selected`);
60932
+ } else {
60933
+ console.log(`A feature metadata class has not been selected. Start the converter with option "--metadata-class". For example, "npx tile-converter ... --metadata-class ${Array.from(metadataClasses)[0]}"`);
60934
+ console.log(`------------------------------------------------`);
60935
+ return false;
60936
+ }
60937
+ }
60873
60938
  return true;
60874
60939
  }
60875
60940
  async analyzeTile(sourceTile, traversalProps) {
@@ -61032,7 +61097,7 @@ var I3SConverter = class {
61032
61097
  }
61033
61098
  const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
61034
61099
  let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
61035
- const propertyTable = getPropertyTable(tileContent);
61100
+ const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
61036
61101
  if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
61037
61102
  this._convertPropertyTableToNodeAttributes(propertyTable);
61038
61103
  }
@@ -61086,7 +61151,7 @@ var I3SConverter = class {
61086
61151
  halfSize: [],
61087
61152
  quaternion: []
61088
61153
  };
61089
- const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules);
61154
+ const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
61090
61155
  return resourcesData;
61091
61156
  }
61092
61157
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
@@ -61389,7 +61454,7 @@ var import_process3 = __toModule(require("process"));
61389
61454
  var import_json_map_transform10 = __toModule(require_json_map_transform());
61390
61455
 
61391
61456
  // ../i3s/src/lib/parsers/constants.ts
61392
- var import_constants11 = __toModule(require_es55());
61457
+ var import_constants14 = __toModule(require_es55());
61393
61458
  function getConstructorForDataFormat(dataType) {
61394
61459
  switch (dataType) {
61395
61460
  case "UInt8":
@@ -61407,11 +61472,11 @@ function getConstructorForDataFormat(dataType) {
61407
61472
  }
61408
61473
  }
61409
61474
  var GL_TYPE_MAP = {
61410
- UInt8: import_constants11.default.UNSIGNED_BYTE,
61411
- UInt16: import_constants11.default.UNSIGNED_SHORT,
61412
- Float32: import_constants11.default.FLOAT,
61413
- UInt32: import_constants11.default.UNSIGNED_INT,
61414
- UInt64: import_constants11.default.DOUBLE
61475
+ UInt8: import_constants14.default.UNSIGNED_BYTE,
61476
+ UInt16: import_constants14.default.UNSIGNED_SHORT,
61477
+ Float32: import_constants14.default.FLOAT,
61478
+ UInt32: import_constants14.default.UNSIGNED_INT,
61479
+ UInt64: import_constants14.default.DOUBLE
61415
61480
  };
61416
61481
  function sizeOf(dataType) {
61417
61482
  switch (dataType) {
@@ -62903,11 +62968,11 @@ FileHandle.open = async (path2) => {
62903
62968
  return new _FileHandle(fd, stats);
62904
62969
  };
62905
62970
 
62906
- // src/slpk-extractor/helpers/file-handle-provider.ts
62907
- var FileHandleProvider = class {
62971
+ // src/slpk-extractor/helpers/file-handle-file.ts
62972
+ var FileHandleFile = class {
62908
62973
  static async from(path2) {
62909
62974
  const fileDescriptor = await FileHandle.open(path2);
62910
- return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);
62975
+ return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
62911
62976
  }
62912
62977
  constructor(fileDescriptor, size) {
62913
62978
  this.fileDescriptor = fileDescriptor;
@@ -62955,7 +63020,7 @@ var FileHandleProvider = class {
62955
63020
  };
62956
63021
  // Annotate the CommonJS export names for ESM import in node:
62957
63022
  0 && (module.exports = {
62958
- FileHandleProvider,
63023
+ FileHandleFile,
62959
63024
  I3SConverter,
62960
63025
  Tiles3DConverter
62961
63026
  });
@@ -3,7 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.BROWSER_ERROR_MESSAGE = void 0;
6
+ exports.EXT_MESH_FEATURES = exports.EXT_FEATURE_METADATA = exports.BROWSER_ERROR_MESSAGE = void 0;
7
7
  var BROWSER_ERROR_MESSAGE = 'Tile converter does not work in browser, only in node js environment';
8
8
  exports.BROWSER_ERROR_MESSAGE = BROWSER_ERROR_MESSAGE;
9
+ var EXT_MESH_FEATURES = 'EXT_mesh_features';
10
+ exports.EXT_MESH_FEATURES = EXT_MESH_FEATURES;
11
+ var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
12
+ exports.EXT_FEATURE_METADATA = EXT_FEATURE_METADATA;
9
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["BROWSER_ERROR_MESSAGE","exports"],"sources":["../../src/constants.ts"],"sourcesContent":["export const BROWSER_ERROR_MESSAGE =\n 'Tile converter does not work in browser, only in node js environment';\n"],"mappings":";;;;;;AAAO,IAAMA,qBAAqB,GAChC,sEAAsE;AAACC,OAAA,CAAAD,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"file":"constants.js","names":["BROWSER_ERROR_MESSAGE","exports","EXT_MESH_FEATURES","EXT_FEATURE_METADATA"],"sources":["../../src/constants.ts"],"sourcesContent":["export const BROWSER_ERROR_MESSAGE =\n 'Tile converter does not work in browser, only in node js environment';\n\nexport const EXT_MESH_FEATURES = 'EXT_mesh_features';\nexport const EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n"],"mappings":";;;;;;AAAO,IAAMA,qBAAqB,GAChC,sEAAsE;AAACC,OAAA,CAAAD,qBAAA,GAAAA,qBAAA;AAElE,IAAME,iBAAiB,GAAG,mBAAmB;AAACD,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAC9C,IAAMC,oBAAoB,GAAG,sBAAsB;AAACF,OAAA,CAAAE,oBAAA,GAAAA,oBAAA"}
@@ -6,6 +6,7 @@ var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray")
6
6
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
7
7
  require("@loaders.gl/polyfills");
8
8
  var _path = require("path");
9
+ var _inquirer = _interopRequireDefault(require("inquirer"));
9
10
  var _tileConverter = require("@loaders.gl/tile-converter");
10
11
  var _depsInstaller = require("./deps-installer/deps-installer");
11
12
  var _cliUtils = require("./lib/utils/cli-utils");
@@ -67,7 +68,8 @@ function printHelp() {
67
68
  console.log('--token [Token for Cesium ION tilesets authentication]');
68
69
  console.log('--no-draco [Disable draco compression for geometry]');
69
70
  console.log('--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]');
70
- console.log('--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]');
71
+ console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');
72
+ console.log('--metadata-class [One of the list of feature metadata classes, detected by converter on "analyze" stage, default: not set]');
71
73
  console.log('--validate [Enable validation]');
72
74
  process.exit(0);
73
75
  }
@@ -114,7 +116,8 @@ function _convert() {
114
116
  generateTextures: options.generateTextures,
115
117
  generateBoundingVolumes: options.generateBoundingVolumes,
116
118
  validate: options.validate,
117
- instantNodeWriting: options.instantNodeWriting
119
+ instantNodeWriting: options.instantNodeWriting,
120
+ inquirer: _inquirer.default
118
121
  });
119
122
  case 13:
120
123
  return _context2.abrupt("break", 15);
@@ -230,6 +233,8 @@ function parseOptions(args) {
230
233
  case '--generate-bounding-volumes':
231
234
  opts.generateBoundingVolumes = (0, _cliUtils.getBooleanValue)(index, args);
232
235
  break;
236
+ case '--metadata-class':
237
+ opts.metadataClass = (0, _cliUtils.getStringValue)(index, args);
233
238
  case '--help':
234
239
  printHelp();
235
240
  break;