@loaders.gl/tile-converter 4.0.0-alpha.6 → 4.0.0-alpha.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 (77) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.js +2 -2
  3. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -3
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -8
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +2 -15
  9. package/dist/converter.min.js +75 -76
  10. package/dist/deps-installer/deps-installer.js +3 -3
  11. package/dist/dist.min.js +1870 -1581
  12. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  13. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -3
  14. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  15. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +2 -10
  16. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  17. package/dist/es5/deps-installer/deps-installer.js +4 -4
  18. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  19. package/dist/es5/i3s-attributes-worker.js +1 -1
  20. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  22. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.js +25 -17
  24. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +1 -4
  26. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  27. package/dist/es5/i3s-converter/i3s-converter.js +0 -7
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  30. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  31. package/dist/es5/pgm-loader.js +1 -1
  32. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +0 -3
  34. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  35. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +2 -8
  36. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  37. package/dist/esm/deps-installer/deps-installer.js +4 -4
  38. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  39. package/dist/esm/i3s-attributes-worker.js +1 -1
  40. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  41. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  42. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -11
  44. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  45. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +1 -4
  46. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  47. package/dist/esm/i3s-converter/i3s-converter.js +0 -7
  48. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  49. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  50. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  51. package/dist/esm/pgm-loader.js +1 -1
  52. package/dist/i3s-attributes-worker.d.ts +10 -2
  53. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  54. package/dist/i3s-attributes-worker.js +2 -2
  55. package/dist/i3s-attributes-worker.js.map +3 -3
  56. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +4 -2
  57. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  58. package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  60. package/dist/i3s-converter/helpers/geometry-converter.js +51 -43
  61. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/gltf-attributes.js +1 -4
  63. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  64. package/dist/i3s-converter/i3s-converter.js +7 -6
  65. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  66. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  67. package/dist/lib/utils/geometry-utils.js +18 -0
  68. package/package.json +15 -16
  69. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -3
  70. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +2 -16
  71. package/src/deps-installer/deps-installer.ts +3 -3
  72. package/src/i3s-attributes-worker.ts +11 -2
  73. package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -14
  74. package/src/i3s-converter/helpers/geometry-converter.ts +105 -78
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +1 -4
  76. package/src/i3s-converter/i3s-converter.ts +8 -7
  77. package/src/lib/utils/geometry-utils.ts +14 -0
@@ -1,4 +1,6 @@
1
- import { GLTFAccessorPostprocessed, GLTFImagePostprocessed, GLTFMeshPrimitivePostprocessed } from '@loaders.gl/gltf';
1
+ import { GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed } from '@loaders.gl/gltf';
2
+ import type { NumericArray } from '@loaders.gl/loader-utils';
3
+ import { TextureImageProperties } from '../../i3s-attributes-worker';
2
4
  /**
3
5
  * Getting batchIds from 3DTilesNext extensions.
4
6
  * @param attributes - gltf accessors
@@ -7,5 +9,5 @@ import { GLTFAccessorPostprocessed, GLTFImagePostprocessed, GLTFMeshPrimitivePos
7
9
  */
8
10
  export declare function handleBatchIdsExtensions(attributes: {
9
11
  [key: string]: GLTFAccessorPostprocessed;
10
- }, primitive: GLTFMeshPrimitivePostprocessed, images: GLTFImagePostprocessed[]): number[];
12
+ }, primitive: GLTFMeshPrimitivePostprocessed, images: (TextureImageProperties | null)[]): NumericArray;
11
13
  //# sourceMappingURL=batch-ids-extensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,kBAAkB,CAAC;AAS1B;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,sBAAsB,EAAE,GAC/B,MAAM,EAAE,CAwBV"}
1
+ {"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAM3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AAKnE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,CAAC,sBAAsB,GAAG,IAAI,CAAC,EAAE,GACxC,YAAY,CAwBd"}
@@ -115,7 +115,7 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
115
115
  const image = images[textureIndex];
116
116
  const batchIds = [];
117
117
  const channels = CHANNELS_MAP[featureChannel];
118
- if (!image.compressed) {
118
+ if (image && image?.width && image?.height && image?.components) {
119
119
  for (let index = 0; index < textureCoordinates.length; index += 2) {
120
120
  const u = textureCoordinates[index];
121
121
  const v = textureCoordinates[index + 1];
@@ -127,7 +127,7 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
127
127
  }
128
128
  }
129
129
  else {
130
- console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);
130
+ console.warn(`Can't get batch Ids from ${image?.mimeType || ''} compressed texture`);
131
131
  }
132
132
  return batchIds;
133
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAsBxE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EAAC,kBAAkB,EAAsC,MAAM,6BAA6B,CAAC;AAsCpG;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GACpC,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CA0DzC;AA6ID;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAgD3C;AAkoCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAoBlF"}
1
+ {"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAsBxE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AACrC,+DAA+D;AAC/D,OAAO,EACL,kBAAkB,EAEnB,MAAM,6BAA6B,CAAC;AAsCrC;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,YAAY,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,GACpC,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CA0DzC;AA6ID;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAgD3C;AAwpCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAoBlF"}
@@ -40,6 +40,7 @@ const gltf_attributes_1 = require("./gltf-attributes");
40
40
  const batch_ids_extensions_1 = require("./batch-ids-extensions");
41
41
  const feature_attributes_1 = require("./feature-attributes");
42
42
  const math_1 = require("@loaders.gl/math");
43
+ const geometry_utils_1 = require("../../lib/utils/geometry-utils");
43
44
  // Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/pbrMetallicRoughness.cmn.md
44
45
  const DEFAULT_ROUGHNESS_FACTOR = 1;
45
46
  const DEFAULT_METALLIC_FACTOR = 1;
@@ -324,18 +325,19 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
324
325
  let outputAttributes = null;
325
326
  let materialUvRegion;
326
327
  if (primitive.material) {
327
- outputAttributes = attributesMap.get(primitive.material.uniqueId);
328
- materialUvRegion = outputAttributes?.mergedMaterials.find(({ originalMaterialId }) => originalMaterialId === primitive.material?.uniqueId)?.uvRegion;
328
+ outputAttributes = attributesMap.get(primitive.material.id);
329
+ materialUvRegion = outputAttributes?.mergedMaterials.find(({ originalMaterialId }) => originalMaterialId === primitive.material?.id)?.uvRegion;
329
330
  }
330
331
  else if (attributesMap.has('default')) {
331
332
  outputAttributes = attributesMap.get('default');
332
333
  }
333
334
  (0, core_2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
335
+ (0, core_2.assert)(primitive.mode === math_1.GL.TRIANGLES || primitive.mode === math_1.GL.TRIANGLE_STRIP, `Primitive - unsupported mode ${primitive.mode}`);
334
336
  const attributes = primitive.attributes;
335
337
  if (!outputAttributes) {
336
338
  continue;
337
339
  }
338
- const indices = getIndices(primitive);
340
+ const indices = normalizeIndices(primitive);
339
341
  outputAttributes.positions = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
340
342
  vertices: attributes.POSITION.value,
341
343
  cartographicOrigin,
@@ -365,11 +367,15 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
365
367
  }
366
368
  /**
367
369
  * Converts TRIANGLE-STRIPS to independent TRIANGLES
368
- * @param {MeshPrimitive} primitive - the primitive to get the indices from
370
+ * @param primitive - the primitive to get the indices from
369
371
  * @returns indices of vertices of the independent triangles
370
372
  */
371
- function getIndices(primitive) {
373
+ function normalizeIndices(primitive) {
372
374
  let indices = primitive.indices?.value;
375
+ if (!indices) {
376
+ const positions = primitive.attributes.POSITION.value;
377
+ return (0, geometry_utils_1.generateSyntheticIndices)(positions.length / VALUES_PER_VERTEX);
378
+ }
373
379
  if (indices && primitive.mode === math_1.GL.TRIANGLE_STRIP) {
374
380
  /*
375
381
  TRIANGLE_STRIP geometry contains n+2 vertices for n triangles;
@@ -409,7 +415,7 @@ function getIndices(primitive) {
409
415
  * @param args.indices - gltf primitive indices
410
416
  * @param args.attributeSpecificTransformation - function to do attribute - specific transformations
411
417
  * @param args.useCartesianPositions - use coordinates as it is.
412
- * @returns {Float32Array}
418
+ * @returns
413
419
  */
414
420
  function transformVertexArray(args) {
415
421
  const { vertices, indices, attributeSpecificTransformation } = args;
@@ -700,9 +706,8 @@ function convertMaterial(sourceMaterial) {
700
706
  textureSetDefinitionId: 0
701
707
  };
702
708
  }
703
- const uniqueId = (0, uuid_1.v4)();
704
- sourceMaterial.uniqueId = uniqueId;
705
- let mergedMaterials = [{ originalMaterialId: uniqueId }];
709
+ sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, uuid_1.v4)();
710
+ let mergedMaterials = [{ originalMaterialId: sourceMaterial.id }];
706
711
  if (!texture) {
707
712
  // Should use default baseColorFactor if it is not present in source material
708
713
  // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-pbrmetallicroughness
@@ -845,7 +850,7 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
845
850
  // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/image.cmn.md
846
851
  id: generateImageId(texture, nodeId),
847
852
  size: texture.source?.image.width,
848
- length: [texture.source?.image.data.length]
853
+ length: texture.source?.image.data.length ? [texture.source?.image.data.length] : undefined
849
854
  }
850
855
  ]
851
856
  };
@@ -858,7 +863,10 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
858
863
  * @returns calculate image ID according to the spec
859
864
  */
860
865
  function generateImageId(texture, nodeId) {
861
- const { width, height } = texture.source?.image;
866
+ const { width, height } = texture.source?.image || {};
867
+ if (!width || !height) {
868
+ return '';
869
+ }
862
870
  const levelCountOfTexture = 1;
863
871
  const indexOfLevel = 0;
864
872
  const indexOfTextureInStore = nodeId + 1;
@@ -887,10 +895,10 @@ function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, bat
887
895
  }
888
896
  /**
889
897
  * Generate replace map to make featureIds unique.
890
- * @param {Array} featureIds
891
- * @param {Object} batchTable
892
- * @param {Array} featuresHashArray
893
- * @returns {Object}
898
+ * @param featureIds
899
+ * @param batchTable
900
+ * @param featuresHashArray
901
+ * @returns
894
902
  */
895
903
  function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
896
904
  const featureMap = {};
@@ -903,9 +911,9 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
903
911
  }
904
912
  /**
905
913
  * Generates string for unique batch id creation.
906
- * @param {Object} batchTable
907
- * @param {Number} index
908
- * @returns {String}
914
+ * @param batchTable
915
+ * @param index
916
+ * @returns
909
917
  */
910
918
  function generateStringFromBatchTableByIndex(batchTable, index) {
911
919
  let str = '';
@@ -916,10 +924,10 @@ function generateStringFromBatchTableByIndex(batchTable, index) {
916
924
  }
917
925
  /**
918
926
  * Return already exited featureId or creates and returns new to support unique feature ids throw nodes.
919
- * @param {Number} index
920
- * @param {Object} batchTable
921
- * @param {Array} featuresHashArray
922
- * @returns {Number}
927
+ * @param index
928
+ * @param batchTable
929
+ * @param featuresHashArray
930
+ * @returns
923
931
  */
924
932
  function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
925
933
  const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
@@ -931,9 +939,9 @@ function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
931
939
  }
932
940
  /**
933
941
  * Do replacement of indices for making them unique through all nodes.
934
- * @param {Array} indicesArray
935
- * @param {Object} featureMap
936
- * @returns {void}
942
+ * @param indicesArray
943
+ * @param featureMap
944
+ * @returns
937
945
  */
938
946
  function replaceIndicesByUnique(indicesArray, featureMap) {
939
947
  for (let index = 0; index < indicesArray.length; index++) {
@@ -942,10 +950,10 @@ function replaceIndicesByUnique(indicesArray, featureMap) {
942
950
  }
943
951
  /**
944
952
  * Convert property table data to attribute buffers.
945
- * @param {Array} featureIds
946
- * @param {Object} propertyTable - table with metadata for particular feature.
947
- * @param {Array} attributeStorageInfo
948
- * @returns {Array} - Array of file buffers.
953
+ * @param featureIds
954
+ * @param propertyTable - table with metadata for particular feature.
955
+ * @param attributeStorageInfo
956
+ * @returns - Array of file buffers.
949
957
  */
950
958
  function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
951
959
  const attributeBuffers = [];
@@ -990,9 +998,9 @@ function generateAttributeBuffer(type, value) {
990
998
  }
991
999
  /**
992
1000
  * Return attribute type.
993
- * @param {String} key
994
- * @param {Array} attributeStorageInfo
995
- * @returns {String} attribute type.
1001
+ * @param key
1002
+ * @param attributeStorageInfo
1003
+ * @returns attribute type.
996
1004
  */
997
1005
  function getAttributeType(key, attributeStorageInfo) {
998
1006
  const attribute = attributeStorageInfo.find((attr) => attr.name === key);
@@ -1000,8 +1008,8 @@ function getAttributeType(key, attributeStorageInfo) {
1000
1008
  }
1001
1009
  /**
1002
1010
  * Convert short integer to attribute arrayBuffer.
1003
- * @param {Array} featureIds
1004
- * @returns {ArrayBuffer} - Buffer with objectId data.
1011
+ * @param featureIds
1012
+ * @returns - Buffer with objectId data.
1005
1013
  */
1006
1014
  function generateShortIntegerAttributeBuffer(featureIds) {
1007
1015
  const count = new Uint32Array([featureIds.length]);
@@ -1010,8 +1018,8 @@ function generateShortIntegerAttributeBuffer(featureIds) {
1010
1018
  }
1011
1019
  /**
1012
1020
  * Convert double to attribute arrayBuffer.
1013
- * @param {Array} featureIds
1014
- * @returns {ArrayBuffer} - Buffer with objectId data.
1021
+ * @param featureIds
1022
+ * @returns - Buffer with objectId data.
1015
1023
  */
1016
1024
  function generateDoubleAttributeBuffer(featureIds) {
1017
1025
  const count = new Uint32Array([featureIds.length]);
@@ -1021,8 +1029,8 @@ function generateDoubleAttributeBuffer(featureIds) {
1021
1029
  }
1022
1030
  /**
1023
1031
  * Convert batch table attributes to array buffer with batch table data.
1024
- * @param {Array} batchAttributes
1025
- * @returns {ArrayBuffer} - Buffer with batch table data.
1032
+ * @param batchAttributes
1033
+ * @returns - Buffer with batch table data.
1026
1034
  */
1027
1035
  function generateStringAttributeBuffer(batchAttributes) {
1028
1036
  const stringCountArray = new Uint32Array([batchAttributes.length]);
@@ -1042,8 +1050,8 @@ function generateStringAttributeBuffer(batchAttributes) {
1042
1050
  }
1043
1051
  /**
1044
1052
  * Convert featureIds to BigUint64Array.
1045
- * @param {Array} featureIds
1046
- * @returns {BigUint64Array} - Array of feature ids in BigUint64 format.
1053
+ * @param featureIds
1054
+ * @returns - Array of feature ids in BigUint64 format.
1047
1055
  */
1048
1056
  function generateBigUint64Array(featureIds) {
1049
1057
  const typedFeatureIds = new BigUint64Array(featureIds.length);
@@ -1102,9 +1110,9 @@ async function generateCompressedGeometry(vertexCount, convertedAttributes, attr
1102
1110
  }
1103
1111
  /**
1104
1112
  * Generates ordered feature indices based on face range
1105
- * @param {Uint32Array} featureIndex
1106
- * @param {Uint32Array} faceRange
1107
- * @returns {Uint32Array}
1113
+ * @param featureIndex
1114
+ * @param faceRange
1115
+ * @returns
1108
1116
  */
1109
1117
  function generateFeatureIndexAttribute(featureIndex, faceRange) {
1110
1118
  const orderedFeatureIndices = new Uint32Array(featureIndex.length);
@@ -1 +1 @@
1
- {"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAsBpE;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,kBAAkB,CAyC/F"}
1
+ {"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAsBpE;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,kBAAkB,CAsC/F"}
@@ -27,10 +27,7 @@ function prepareDataForAttributesConversion(tileContent) {
27
27
  const images = tileContent.gltf?.images?.map((imageObject) => {
28
28
  // Need data only for uncompressed images because we can't get batchIds from compressed textures.
29
29
  if (imageObject?.image?.compressed) {
30
- return {
31
- data: null,
32
- compressed: true
33
- };
30
+ return null;
34
31
  }
35
32
  else {
36
33
  const data = imageObject?.image?.data;
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,SAAS,EAAC,MAAM,mBAA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IACH,OAAO,CAAC,kBAAkB;YAIZ,WAAW;CAsB1B"}
@@ -154,12 +154,13 @@ class I3SConverter {
154
154
  loadOptions: {
155
155
  _nodeWorkers: true,
156
156
  reuseWorkers: true,
157
- basis: { format: 'rgba32' },
158
- 'basis-nodejs': {
159
- format: 'rgba32',
160
- workerUrl: './modules/textures/dist/basis-nodejs-worker.js'
161
- },
162
- 'draco-nodejs': { workerUrl: './modules/draco/dist/draco-nodejs-worker.js' }
157
+ basis: { format: 'rgba32' }
158
+ // TODO - should no longer be needed with new Node workers
159
+ // 'basis-nodejs': {
160
+ // format: 'rgba32',
161
+ // workerUrl: './modules/textures/dist/basis-worker-node.js'
162
+ // },
163
+ // 'draco-nodejs': {workerUrl: './modules/draco/dist/draco-worker-node.js'}
163
164
  }
164
165
  };
165
166
  if (preloadOptions.headers) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * luma.gl can not work without indices now:
3
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
4
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
5
+ * @param {number} vertexCount - vertex count in the geometry
6
+ * @returns {Uint32Array} indices array.
7
+ */
8
+ export declare const generateSyntheticIndices: (vertexCount: number) => Uint32Array;
9
+ //# sourceMappingURL=geometry-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/geometry-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,gBAAiB,MAAM,KAAG,WAM9D,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSyntheticIndices = void 0;
4
+ /**
5
+ * luma.gl can not work without indices now:
6
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
7
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
8
+ * @param {number} vertexCount - vertex count in the geometry
9
+ * @returns {Uint32Array} indices array.
10
+ */
11
+ const generateSyntheticIndices = (vertexCount) => {
12
+ const result = new Uint32Array(vertexCount);
13
+ for (let index = 0; index < vertexCount; index++) {
14
+ result[index] = index;
15
+ }
16
+ return result;
17
+ };
18
+ exports.generateSyntheticIndices = generateSyntheticIndices;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -44,19 +44,18 @@
44
44
  "build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
45
45
  },
46
46
  "dependencies": {
47
- "@loaders.gl/3d-tiles": "4.0.0-alpha.6",
48
- "@loaders.gl/crypto": "4.0.0-alpha.6",
49
- "@loaders.gl/draco": "4.0.0-alpha.6",
50
- "@loaders.gl/gltf": "4.0.0-alpha.6",
51
- "@loaders.gl/i3s": "4.0.0-alpha.6",
52
- "@loaders.gl/images": "4.0.0-alpha.6",
53
- "@loaders.gl/loader-utils": "4.0.0-alpha.6",
54
- "@loaders.gl/polyfills": "4.0.0-alpha.6",
55
- "@loaders.gl/schema": "4.0.0-alpha.6",
56
- "@loaders.gl/textures": "4.0.0-alpha.6",
57
- "@loaders.gl/tiles": "4.0.0-alpha.6",
58
- "@loaders.gl/worker-utils": "4.0.0-alpha.6",
59
- "@loaders.gl/zip": "4.0.0-alpha.6",
47
+ "@loaders.gl/3d-tiles": "4.0.0-alpha.7",
48
+ "@loaders.gl/crypto": "4.0.0-alpha.7",
49
+ "@loaders.gl/draco": "4.0.0-alpha.7",
50
+ "@loaders.gl/gltf": "4.0.0-alpha.7",
51
+ "@loaders.gl/i3s": "4.0.0-alpha.7",
52
+ "@loaders.gl/images": "4.0.0-alpha.7",
53
+ "@loaders.gl/loader-utils": "4.0.0-alpha.7",
54
+ "@loaders.gl/polyfills": "4.0.0-alpha.7",
55
+ "@loaders.gl/textures": "4.0.0-alpha.7",
56
+ "@loaders.gl/tiles": "4.0.0-alpha.7",
57
+ "@loaders.gl/worker-utils": "4.0.0-alpha.7",
58
+ "@loaders.gl/zip": "4.0.0-alpha.7",
60
59
  "@math.gl/core": "^3.5.1",
61
60
  "@math.gl/culling": "^3.5.1",
62
61
  "@math.gl/geoid": "^3.5.1",
@@ -73,11 +72,11 @@
73
72
  "uuid": "^8.1.0"
74
73
  },
75
74
  "peerDependencies": {
76
- "@loaders.gl/core": "4.0.0-alpha.5"
75
+ "@loaders.gl/core": "4.0.0-alpha.6"
77
76
  },
78
77
  "quarantinedDependencies": {
79
78
  "join-images": "^1.1.3",
80
79
  "sharp": "^0.31.3"
81
80
  },
82
- "gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
81
+ "gitHead": "afb59c4d8e5d8ebb9c28f111cb0c96c5527d0ffd"
83
82
  }
@@ -86,10 +86,11 @@ export default class Tiles3DConverter {
86
86
  loadOptions: {
87
87
  _nodeWorkers: true,
88
88
  reuseWorkers: true,
89
- 'i3s-content-nodejs': {
90
- workerUrl: './modules/i3s/dist/i3s-content-nodejs-worker.js'
91
- },
92
89
  i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}
90
+ // TODO should no longer be needed with new workers
91
+ // 'i3s-content-nodejs': {
92
+ // workerUrl: './modules/i3s/dist/i3s-content-nodejs-worker.js'
93
+ // }
93
94
  }
94
95
  });
95
96
 
@@ -6,6 +6,7 @@ import {Tile3DWriter} from '@loaders.gl/3d-tiles';
6
6
  import {Matrix4, Vector3} from '@math.gl/core';
7
7
  import {Ellipsoid} from '@math.gl/geospatial';
8
8
  import {convertTextureAtlas} from './texture-atlas';
9
+ import {generateSyntheticIndices} from '../../lib/utils/geometry-utils';
9
10
 
10
11
  const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
11
12
  const scratchVector = new Vector3();
@@ -85,7 +86,7 @@ export default class B3dmConverter {
85
86
  delete attributes.normals;
86
87
  }
87
88
  const indices =
88
- originalIndices || this._generateSynteticIndices(positionsValue.length / positions.size);
89
+ originalIndices || generateSyntheticIndices(positionsValue.length / positions.size);
89
90
  const meshIndex = gltfBuilder.addMesh({
90
91
  attributes,
91
92
  indices,
@@ -191,21 +192,6 @@ export default class B3dmConverter {
191
192
  };
192
193
  }
193
194
 
194
- /**
195
- * luma.gl can not work without indices now:
196
- * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
197
- * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
198
- * @param {number} vertexCount - vertex count in the geometry
199
- * @returns {Uint32Array} indices array.
200
- */
201
- _generateSynteticIndices(vertexCount) {
202
- const result = new Uint32Array(vertexCount);
203
- for (let index = 0; index < vertexCount; index++) {
204
- result.set([index], index);
205
- }
206
- return result;
207
- }
208
-
209
195
  /**
210
196
  * Deduce mime type by format from `textureSetDefinition.formats[0].format`
211
197
  * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
@@ -35,13 +35,13 @@ export class DepsInstaller {
35
35
  await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
36
36
 
37
37
  console.log('Installing "I3S Content Loader worker"'); // eslint-disable-line no-console
38
- await this.installWorker('i3s', 'i3s-content-nodejs-worker.js', workersPath);
38
+ await this.installWorker('i3s', 'i3s-content-worker-node.js', workersPath);
39
39
 
40
40
  console.log('Installing "Draco Loader worker"'); // eslint-disable-line no-console
41
- await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);
41
+ await this.installWorker('draco', 'draco-worker-node.js', workersPath);
42
42
 
43
43
  console.log('Installing "Basis Loader worker"'); // eslint-disable-line no-console
44
- await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);
44
+ await this.installWorker('textures', 'basis-worker-node.js', workersPath);
45
45
 
46
46
  console.log('Installing "join-images" npm package');
47
47
  const childProcess = new ChildProcessProxy();
@@ -1,7 +1,7 @@
1
1
  import type {WorkerObject} from '@loaders.gl/worker-utils';
2
2
  import type {ConvertedAttributes} from './i3s-converter/types';
3
3
  import type {Matrix4, Vector3} from '@math.gl/core';
4
- import type {GLTFImagePostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';
4
+ import type {GLTFNodePostprocessed} from '@loaders.gl/gltf';
5
5
 
6
6
  import {processOnWorker} from '@loaders.gl/worker-utils';
7
7
 
@@ -16,10 +16,19 @@ export type I3SAttributesWorkerOptions = {
16
16
  source: string;
17
17
  };
18
18
 
19
+ export type TextureImageProperties = {
20
+ data: Uint8Array;
21
+ compressed?: boolean;
22
+ height?: number;
23
+ width?: number;
24
+ components?: number;
25
+ mimeType?: string;
26
+ };
27
+
19
28
  export type B3DMAttributesData = {
20
29
  gltfMaterials?: {id: string}[];
21
30
  nodes: GLTFNodePostprocessed[];
22
- images: GLTFImagePostprocessed[];
31
+ images: (null | TextureImageProperties)[];
23
32
  cartographicOrigin: Vector3;
24
33
  cartesianModelMatrix: Matrix4;
25
34
  };
@@ -1,12 +1,11 @@
1
- import {
2
- GLTFAccessorPostprocessed,
3
- GLTFImagePostprocessed,
4
- GLTFMeshPrimitivePostprocessed
5
- } from '@loaders.gl/gltf';
1
+ import {GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed} from '@loaders.gl/gltf';
2
+ import type {NumericArray} from '@loaders.gl/loader-utils';
6
3
  import type {
7
4
  GLTF_EXT_feature_metadata_attribute,
8
5
  GLTF_EXT_feature_metadata_primitive
9
- } from 'modules/gltf/src/lib/types/gltf-json-schema';
6
+ } from '@loaders.gl/gltf';
7
+ import {TypedArray} from '@math.gl/core';
8
+ import {TextureImageProperties} from '../../i3s-attributes-worker';
10
9
 
11
10
  const EXT_MESH_FEATURES = 'EXT_mesh_features';
12
11
  const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
@@ -22,8 +21,8 @@ export function handleBatchIdsExtensions(
22
21
  [key: string]: GLTFAccessorPostprocessed;
23
22
  },
24
23
  primitive: GLTFMeshPrimitivePostprocessed,
25
- images: GLTFImagePostprocessed[]
26
- ): number[] {
24
+ images: (TextureImageProperties | null)[]
25
+ ): NumericArray {
27
26
  const extensions = primitive?.extensions;
28
27
 
29
28
  if (!extensions) {
@@ -61,8 +60,8 @@ function handleExtFeatureMetadataExtension(
61
60
  [key: string]: GLTFAccessorPostprocessed;
62
61
  },
63
62
  extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,
64
- images: GLTFImagePostprocessed[]
65
- ): number[] {
63
+ images: (TextureImageProperties | null)[]
64
+ ): NumericArray {
66
65
  // Take only first extension object to get batchIds attribute name.
67
66
  const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
68
67
 
@@ -151,8 +150,8 @@ function generateImplicitFeatureIds(
151
150
  */
152
151
  function generateBatchIdsFromTexture(
153
152
  featureIdTexture: GLTF_EXT_feature_metadata_attribute,
154
- textureCoordinates: Float32Array,
155
- images: GLTFImagePostprocessed[]
153
+ textureCoordinates: TypedArray,
154
+ images: (TextureImageProperties | null)[]
156
155
  ) {
157
156
  if (!images?.length) {
158
157
  return [];
@@ -176,7 +175,7 @@ function generateBatchIdsFromTexture(
176
175
  const batchIds: number[] = [];
177
176
  const channels = CHANNELS_MAP[featureChannel];
178
177
 
179
- if (!image.compressed) {
178
+ if (image && image?.width && image?.height && image?.components) {
180
179
  for (let index = 0; index < textureCoordinates.length; index += 2) {
181
180
  const u = textureCoordinates[index];
182
181
  const v = textureCoordinates[index + 1];
@@ -190,7 +189,7 @@ function generateBatchIdsFromTexture(
190
189
  batchIds.push(batchId);
191
190
  }
192
191
  } else {
193
- console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);
192
+ console.warn(`Can't get batch Ids from ${image?.mimeType || ''} compressed texture`);
194
193
  }
195
194
 
196
195
  return batchIds;