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

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 (107) 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 +33357 -33374
  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 +2 -2
  25. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  26. package/dist/es5/index.js +0 -7
  27. package/dist/es5/index.js.map +1 -1
  28. package/dist/es5/pgm-loader.js +1 -1
  29. package/dist/es5/slpk-extractor/slpk-extractor.js +10 -11
  30. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  31. package/dist/esm/constants.js +2 -0
  32. package/dist/esm/constants.js.map +1 -1
  33. package/dist/esm/converter-cli.js +7 -2
  34. package/dist/esm/converter-cli.js.map +1 -1
  35. package/dist/esm/deps-installer/deps-installer.js +1 -1
  36. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
  37. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  38. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
  39. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-converter.js +28 -20
  41. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
  43. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  44. package/dist/esm/i3s-converter/i3s-converter.js +39 -9
  45. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  46. package/dist/esm/i3s-converter/types.js +9 -9
  47. package/dist/esm/i3s-converter/types.js.map +1 -1
  48. package/dist/esm/i3s-server/bin/i3s-server.min.js +69 -69
  49. package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
  50. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  51. package/dist/esm/index.js +0 -1
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/pgm-loader.js +1 -1
  54. package/dist/esm/slpk-extractor/slpk-extractor.js +3 -4
  55. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  56. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
  57. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  58. package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
  59. package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
  60. package/dist/i3s-converter/helpers/geometry-converter.d.ts +6 -3
  61. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/geometry-converter.js +42 -35
  63. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
  64. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  65. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
  66. package/dist/i3s-converter/i3s-converter.d.ts +2 -0
  67. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  68. package/dist/i3s-converter/i3s-converter.js +40 -10
  69. package/dist/i3s-converter/types.d.ts +4 -2
  70. package/dist/i3s-converter/types.d.ts.map +1 -1
  71. package/dist/i3s-converter/types.js +11 -11
  72. package/dist/i3s-server/controllers/slpk-controller.js +2 -2
  73. package/dist/index.d.ts +0 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +1 -3
  76. package/dist/slpk-extractor/slpk-extractor.d.ts +1 -1
  77. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  78. package/dist/slpk-extractor/slpk-extractor.js +6 -7
  79. package/dist/slpk-extractor.min.js +42 -42
  80. package/package.json +15 -14
  81. package/src/constants.ts +3 -0
  82. package/src/converter-cli.ts +9 -2
  83. package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
  84. package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
  85. package/src/i3s-converter/helpers/geometry-converter.ts +66 -35
  86. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
  87. package/src/i3s-converter/i3s-converter.ts +54 -12
  88. package/src/i3s-converter/types.ts +4 -2
  89. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  90. package/src/index.ts +0 -1
  91. package/src/slpk-extractor/slpk-extractor.ts +3 -4
  92. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +0 -214
  93. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  94. package/dist/es5/slpk-extractor/helpers/fs-promises.js +0 -77
  95. package/dist/es5/slpk-extractor/helpers/fs-promises.js.map +0 -1
  96. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +0 -54
  97. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  98. package/dist/esm/slpk-extractor/helpers/fs-promises.js +0 -32
  99. package/dist/esm/slpk-extractor/helpers/fs-promises.js.map +0 -1
  100. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +0 -51
  101. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
  102. package/dist/slpk-extractor/helpers/file-handle-provider.js +0 -86
  103. package/dist/slpk-extractor/helpers/fs-promises.d.ts +0 -38
  104. package/dist/slpk-extractor/helpers/fs-promises.d.ts.map +0 -1
  105. package/dist/slpk-extractor/helpers/fs-promises.js +0 -51
  106. package/src/slpk-extractor/helpers/file-handle-provider.ts +0 -109
  107. package/src/slpk-extractor/helpers/fs-promises.ts +0 -66
@@ -8,10 +8,11 @@ import { v4 as uuidv4 } from 'uuid';
8
8
  import { generateAttributes } from './geometry-attributes';
9
9
  import { createBoundingVolumesFromGeometry } from './coordinate-converter';
10
10
  import { prepareDataForAttributesConversion } from './gltf-attributes';
11
- import { handleBatchIdsExtensions } from './batch-ids-extensions';
11
+ import { getTextureByMetadataClass, handleBatchIdsExtensions } from './batch-ids-extensions';
12
12
  import { checkPropertiesLength, flattenPropertyTableByFeatureIds } from './feature-attributes';
13
13
  import { GL } from '@loaders.gl/math';
14
14
  import { generateSyntheticIndices } from '../../lib/utils/geometry-utils';
15
+ import { EXT_FEATURE_METADATA, EXT_MESH_FEATURES } from '../../constants';
15
16
  const DEFAULT_ROUGHNESS_FACTOR = 1;
16
17
  const DEFAULT_METALLIC_FACTOR = 1;
17
18
  const VALUES_PER_VERTEX = 3;
@@ -22,15 +23,14 @@ const SHORT_INT_TYPE = 'Int32';
22
23
  const DOUBLE_TYPE = 'Float64';
23
24
  const OBJECT_ID_TYPE = 'Oid32';
24
25
  const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
25
- const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
26
- const EXT_MESH_FEATURES = 'EXT_mesh_features';
27
26
  let scratchVector = new Vector3();
28
- export default async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries) {
27
+ export default async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
29
28
  var _tileContent$gltf;
30
29
  const useCartesianPositions = generateBoundingVolumes;
31
30
  const materialAndTextureList = await convertMaterials((_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.materials, shouldMergeMaterials);
32
31
  const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent, tileTransform, tileBoundingVolume);
33
- const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
32
+ const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
33
+ const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
34
34
  if (generateBoundingVolumes) {
35
35
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
36
36
  }
@@ -141,7 +141,7 @@ async function _makeNodeResources(_ref) {
141
141
  boundingVolumes
142
142
  };
143
143
  }
144
- export async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
144
+ export async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
145
145
  const {
146
146
  nodes,
147
147
  images,
@@ -165,7 +165,7 @@ export async function convertAttributes(attributesData, materialAndTextureList,
165
165
  attributesMap.set(mergedMaterial.originalMaterialId, attributes);
166
166
  }
167
167
  }
168
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
168
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, undefined, featureTexture);
169
169
  for (const attrKey of attributesMap.keys()) {
170
170
  const attributes = attributesMap.get(attrKey);
171
171
  if (!attributes) {
@@ -184,9 +184,10 @@ export async function convertAttributes(attributesData, materialAndTextureList,
184
184
  }
185
185
  function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
186
186
  let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
187
+ let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
187
188
  if (nodes) {
188
189
  for (const node of nodes) {
189
- convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
190
+ convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
190
191
  }
191
192
  }
192
193
  }
@@ -214,16 +215,18 @@ function getCompositeTransformationMatrix(node, matrix) {
214
215
  }
215
216
  function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
216
217
  let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
218
+ let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
217
219
  const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
218
220
  const mesh = node.mesh;
219
221
  if (mesh) {
220
- convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
222
+ convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
221
223
  }
222
- convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
224
+ convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
223
225
  }
224
226
  function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
225
227
  let useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
226
228
  let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
229
+ let featureTexture = arguments.length > 7 ? arguments[7] : undefined;
227
230
  for (const primitive of mesh.primitives) {
228
231
  let outputAttributes = null;
229
232
  let materialUvRegion;
@@ -271,7 +274,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
271
274
  outputAttributes.uvRegions = concatenateTypedArrays(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
272
275
  }
273
276
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
274
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
277
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
275
278
  }
276
279
  }
277
280
  function normalizeIndices(primitive) {
@@ -401,8 +404,8 @@ function flattenBatchIds(batchedIds, indices) {
401
404
  }
402
405
  return newBatchIds;
403
406
  }
404
- function getBatchIds(attributes, primitive, images) {
405
- const batchIds = handleBatchIdsExtensions(attributes, primitive, images);
407
+ function getBatchIds(attributes, primitive, images, featureTexture) {
408
+ const batchIds = handleBatchIdsExtensions(attributes, primitive, images, featureTexture);
406
409
  if (batchIds.length) {
407
410
  return batchIds;
408
411
  }
@@ -829,7 +832,7 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
829
832
  }
830
833
  return orderedFeatureIndices;
831
834
  }
832
- export function getPropertyTable(tileContent) {
835
+ export function getPropertyTable(tileContent, metadataClass) {
833
836
  if (!tileContent) {
834
837
  return null;
835
838
  }
@@ -849,7 +852,7 @@ export function getPropertyTable(tileContent) {
849
852
  }
850
853
  case EXT_FEATURE_METADATA:
851
854
  {
852
- return getPropertyTableFromExtFeatureMetadata(extension);
855
+ return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
853
856
  }
854
857
  default:
855
858
  return null;
@@ -885,7 +888,7 @@ function getPropertyTableExtension(tileContent) {
885
888
  extension
886
889
  };
887
890
  }
888
- function getPropertyTableFromExtFeatureMetadata(extension) {
891
+ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
889
892
  if (extension !== null && extension !== void 0 && extension.featureTables) {
890
893
  var _Object$keys;
891
894
  const firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
@@ -899,10 +902,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
899
902
  }
900
903
  }
901
904
  if (extension !== null && extension !== void 0 && extension.featureTextures) {
902
- var _Object$keys2;
903
- const firstTextureName = (_Object$keys2 = Object.keys(extension.featureTextures)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2[0];
904
- if (firstTextureName) {
905
- const featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTextures[firstTextureName];
905
+ let featureTexture;
906
+ for (const textureKey in extension.featureTextures) {
907
+ const texture = extension.featureTextures[textureKey];
908
+ if (texture.class === metadataClass) {
909
+ featureTexture = textureKey;
910
+ }
911
+ }
912
+ if (typeof featureTexture === 'string') {
913
+ const featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTextures[featureTexture];
906
914
  const propertyTable = {};
907
915
  for (const propertyName in featureTable.properties) {
908
916
  propertyTable[propertyName] = featureTable.properties[propertyName].data;