@loaders.gl/tile-converter 3.2.7 → 3.3.0-alpha.3

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/dist/3d-tiles-attributes-worker.js +3 -3
  2. package/dist/3d-tiles-attributes-worker.js.map +1 -1
  3. package/dist/converter-cli.js +30 -7
  4. package/dist/converter.min.js +1 -1
  5. package/dist/dist.min.js +1105 -621
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  8. package/dist/es5/converter-cli.js +42 -12
  9. package/dist/es5/converter-cli.js.map +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +146 -0
  13. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  14. package/dist/es5/i3s-converter/helpers/feature-attributes.js +60 -0
  15. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  16. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +39 -7
  17. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/geometry-converter.js +177 -59
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  20. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +15 -1
  21. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  22. package/dist/es5/i3s-converter/i3s-converter.js +50 -51
  23. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  24. package/dist/es5/lib/utils/write-queue.js +3 -5
  25. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  26. package/dist/es5/pgm-loader.js +1 -1
  27. package/dist/es5/pgm-loader.js.map +1 -1
  28. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  29. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  30. package/dist/esm/converter-cli.js +37 -7
  31. package/dist/esm/converter-cli.js.map +1 -1
  32. package/dist/esm/i3s-attributes-worker.js +1 -1
  33. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  34. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +128 -0
  35. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  36. package/dist/esm/i3s-converter/helpers/feature-attributes.js +34 -0
  37. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  38. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +23 -7
  39. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-converter.js +145 -38
  41. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +15 -1
  43. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  44. package/dist/esm/i3s-converter/i3s-converter.js +21 -27
  45. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  46. package/dist/esm/lib/utils/write-queue.js +3 -5
  47. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  48. package/dist/esm/pgm-loader.js +1 -1
  49. package/dist/esm/pgm-loader.js.map +1 -1
  50. package/dist/i3s-attributes-worker.js +3 -3
  51. package/dist/i3s-attributes-worker.js.map +3 -3
  52. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +12 -0
  53. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  54. package/dist/i3s-converter/helpers/batch-ids-extensions.js +138 -0
  55. package/dist/i3s-converter/helpers/feature-attributes.d.ts +24 -0
  56. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  57. package/dist/i3s-converter/helpers/feature-attributes.js +55 -0
  58. package/dist/i3s-converter/helpers/geometry-attributes.js +26 -7
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -2
  60. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  61. package/dist/i3s-converter/helpers/geometry-converter.js +140 -44
  62. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  63. package/dist/i3s-converter/helpers/gltf-attributes.js +13 -0
  64. package/dist/i3s-converter/i3s-converter.d.ts +7 -14
  65. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/i3s-converter.js +44 -35
  67. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  68. package/dist/lib/utils/write-queue.js +3 -4
  69. package/package.json +15 -15
  70. package/src/converter-cli.ts +33 -7
  71. package/src/i3s-converter/helpers/batch-ids-extensions.ts +199 -0
  72. package/src/i3s-converter/helpers/feature-attributes.ts +65 -0
  73. package/src/i3s-converter/helpers/geometry-attributes.ts +30 -7
  74. package/src/i3s-converter/helpers/geometry-converter.ts +187 -48
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +15 -0
  76. package/src/i3s-converter/i3s-converter.ts +38 -41
  77. package/src/lib/utils/write-queue.ts +7 -5
@@ -136,13 +136,6 @@ export default class I3SConverter {
136
136
  * @param level - level of node (distanse to root node in the tree)
137
137
  */
138
138
  private _createNode;
139
- /**
140
- * Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
141
- * from B3DM batch table
142
- * @param sourceTileContent - tile content of 3DTile
143
- * @return {void}
144
- */
145
- private _convertAttributeStorageInfo;
146
139
  /**
147
140
  * Convert tile to one or more I3S nodes
148
141
  * @param sourceTile - source tile (3DTile)
@@ -247,7 +240,7 @@ export default class I3SConverter {
247
240
  /**
248
241
  * Generate storage attribute for map segmentation.
249
242
  * @param attributeIndex - order index of attribute (f_0, f_1 ...).
250
- * @param key - attribute key from batch table.\
243
+ * @param key - attribute key from propertyTable.
251
244
  * @param attributeType - attribute type.
252
245
  * @return Updated storageAttribute.
253
246
  */
@@ -255,7 +248,7 @@ export default class I3SConverter {
255
248
  /**
256
249
  * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
257
250
  * @param key - attribute's key
258
- * @param attribute - attribute's type in batchTable
251
+ * @param attribute - attribute's type in propertyTable
259
252
  */
260
253
  private getAttributeType;
261
254
  /**
@@ -280,18 +273,18 @@ export default class I3SConverter {
280
273
  */
281
274
  private _createFieldAttribute;
282
275
  /**
283
- * Do conversion of 3DTiles batch table to I3s node attributes.
284
- * @param batchTable - Table with layer meta data.
276
+ * Do conversion of 3DTiles property table to I3s node attributes.
277
+ * @param propertyTable - Table with layer meta data.
285
278
  */
286
- private _convertBatchTableInfoToNodeAttributes;
279
+ private _convertPropertyTableToNodeAttributes;
287
280
  /**
288
- * Find and return attribute type based on key form Batch table.
281
+ * Find and return attribute type based on key form propertyTable.
289
282
  * @param attributeType
290
283
  */
291
284
  private _getFieldAttributeType;
292
285
  /**
293
286
  * Generate popup info to show metadata on the map.
294
- * @param batchTable - Batch table data with OBJECTID.
287
+ * @param propertyTable - table data with OBJECTID.
295
288
  * @return data for correct rendering of popup.
296
289
  */
297
290
  private _createPopupInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAEV,YAAY,EAYb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,2BAA2B,CAAC;AAM7F,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAkB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CAAC,8BAA8B;IAUtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YAIZ,WAAW;CAsB1B"}
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
23
  };
@@ -15,7 +34,7 @@ const node_pages_1 = __importDefault(require("./helpers/node-pages"));
15
34
  const file_utils_1 = require("../lib/utils/file-utils");
16
35
  const compress_util_1 = require("../lib/utils/compress-util");
17
36
  const statistic_utills_1 = require("../lib/utils/statistic-utills");
18
- const geometry_converter_1 = __importDefault(require("./helpers/geometry-converter"));
37
+ const geometry_converter_1 = __importStar(require("./helpers/geometry-converter"));
19
38
  const coordinate_converter_1 = require("./helpers/coordinate-converter");
20
39
  const create_scene_server_path_1 = require("./helpers/create-scene-server-path");
21
40
  const lod_conversion_utils_1 = require("../lib/utils/lod-conversion-utils");
@@ -426,11 +445,11 @@ class I3SConverter {
426
445
  await this._updateTilesetOptions();
427
446
  await this.sourceTileset._loadTile(sourceTile);
428
447
  let boundingVolumes = (0, coordinate_converter_1.createBoundingVolumes)(sourceTile, this.geoidHeightModel);
429
- const batchTable = sourceTile?.content?.batchTableJson;
430
- if (batchTable) {
431
- this._convertAttributeStorageInfo(sourceTile.content);
448
+ const propertyTable = (0, geometry_converter_1.getPropertyTable)(sourceTile);
449
+ if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
450
+ this._convertPropertyTableToNodeAttributes(propertyTable);
432
451
  }
433
- const resourcesData = await this._convertResources(sourceTile);
452
+ const resourcesData = await this._convertResources(sourceTile, propertyTable);
434
453
  const nodes = [];
435
454
  const nodesInPage = [];
436
455
  const emptyResources = {
@@ -474,19 +493,6 @@ class I3SConverter {
474
493
  });
475
494
  return nodes;
476
495
  }
477
- /**
478
- * Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
479
- * from B3DM batch table
480
- * @param sourceTileContent - tile content of 3DTile
481
- * @return {void}
482
- */
483
- _convertAttributeStorageInfo(sourceTileContent) {
484
- // In legacy b3dm files sometimes sourceTileContent is null.
485
- const batchTable = sourceTileContent && sourceTileContent.batchTableJson;
486
- if (batchTable && !this.layers0?.attributeStorageInfo?.length) {
487
- this._convertBatchTableInfoToNodeAttributes(batchTable);
488
- }
489
- }
490
496
  /**
491
497
  * Convert tile to one or more I3S nodes
492
498
  * @param sourceTile - source tile (3DTile)
@@ -499,11 +505,11 @@ class I3SConverter {
499
505
  * result.attributes - feature attributes
500
506
  * result.featureCount - number of features
501
507
  */
502
- async _convertResources(sourceTile) {
508
+ async _convertResources(sourceTile, propertyTable) {
503
509
  if (!this.isContentSupported(sourceTile)) {
504
510
  return null;
505
511
  }
506
- const resourcesData = await (0, geometry_converter_1.default)(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
512
+ const resourcesData = await (0, geometry_converter_1.default)(sourceTile.content, Number(this.nodePages.nodesCounter), propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
507
513
  return resourcesData;
508
514
  }
509
515
  /**
@@ -707,7 +713,10 @@ class I3SConverter {
707
713
  await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
708
714
  if (this.generateTextures) {
709
715
  formats.push({ name: '1', format: 'ktx2' });
710
- const ktx2TextureData = (0, core_1.encode)(texture.image, textures_1.KTX2BasisWriterWorker, {
716
+ // For Node.js texture.image.data is type of Buffer
717
+ const copyArrayBuffer = texture.image.data.subarray();
718
+ const arrayToEncode = new Uint8Array(copyArrayBuffer);
719
+ const ktx2TextureData = (0, core_1.encode)({ ...texture.image, data: arrayToEncode }, textures_1.KTX2BasisWriterWorker, {
711
720
  ...textures_1.KTX2BasisWriterWorker.options,
712
721
  source: this.workerSource.ktx2,
713
722
  reuseWorkers: true,
@@ -816,7 +825,7 @@ class I3SConverter {
816
825
  /**
817
826
  * Generate storage attribute for map segmentation.
818
827
  * @param attributeIndex - order index of attribute (f_0, f_1 ...).
819
- * @param key - attribute key from batch table.\
828
+ * @param key - attribute key from propertyTable.
820
829
  * @param attributeType - attribute type.
821
830
  * @return Updated storageAttribute.
822
831
  */
@@ -848,7 +857,7 @@ class I3SConverter {
848
857
  /**
849
858
  * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
850
859
  * @param key - attribute's key
851
- * @param attribute - attribute's type in batchTable
860
+ * @param attribute - attribute's type in propertyTable
852
861
  */
853
862
  getAttributeType(key, attribute) {
854
863
  if (key === OBJECT_ID_TYPE) {
@@ -912,22 +921,22 @@ class I3SConverter {
912
921
  };
913
922
  }
914
923
  /**
915
- * Do conversion of 3DTiles batch table to I3s node attributes.
916
- * @param batchTable - Table with layer meta data.
924
+ * Do conversion of 3DTiles property table to I3s node attributes.
925
+ * @param propertyTable - Table with layer meta data.
917
926
  */
918
- _convertBatchTableInfoToNodeAttributes(batchTable) {
927
+ _convertPropertyTableToNodeAttributes(propertyTable) {
919
928
  let attributeIndex = 0;
920
- const batchTableWithObjectId = {
929
+ const propertyTableWithObjectId = {
921
930
  OBJECTID: [0],
922
- ...batchTable
931
+ ...propertyTable
923
932
  };
924
- for (const key in batchTableWithObjectId) {
925
- const firstAttribute = batchTableWithObjectId[key][0];
933
+ for (const key in propertyTableWithObjectId) {
934
+ const firstAttribute = propertyTableWithObjectId[key][0];
926
935
  const attributeType = this.getAttributeType(key, firstAttribute);
927
936
  const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);
928
937
  const fieldAttributeType = this._getFieldAttributeType(attributeType);
929
938
  const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);
930
- const popupInfo = this._createPopupInfo(batchTableWithObjectId);
939
+ const popupInfo = this._createPopupInfo(propertyTableWithObjectId);
931
940
  this.layers0.attributeStorageInfo.push(storageAttribute);
932
941
  this.layers0.fields.push(fieldAttribute);
933
942
  this.layers0.popupInfo = popupInfo;
@@ -936,7 +945,7 @@ class I3SConverter {
936
945
  }
937
946
  }
938
947
  /**
939
- * Find and return attribute type based on key form Batch table.
948
+ * Find and return attribute type based on key form propertyTable.
940
949
  * @param attributeType
941
950
  */
942
951
  _getFieldAttributeType(attributeType) {
@@ -955,16 +964,16 @@ class I3SConverter {
955
964
  }
956
965
  /**
957
966
  * Generate popup info to show metadata on the map.
958
- * @param batchTable - Batch table data with OBJECTID.
967
+ * @param propertyTable - table data with OBJECTID.
959
968
  * @return data for correct rendering of popup.
960
969
  */
961
- _createPopupInfo(batchTable) {
970
+ _createPopupInfo(propertyTable) {
962
971
  const title = '{OBJECTID}';
963
972
  const mediaInfos = [];
964
973
  const fieldInfos = [];
965
974
  const popupElements = [];
966
975
  const expressionInfos = [];
967
- for (const key in batchTable) {
976
+ for (const key in propertyTable) {
968
977
  fieldInfos.push({
969
978
  fieldName: key,
970
979
  visible: true,
@@ -1 +1 @@
1
- {"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["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CAAC,GAAG,IAAI,CAAQ;IAC1C,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;gBAEpB,iBAAiB,GAAE,MAAa,EAAE,gBAAgB,GAAE,MAAY;IAMtE,OAAO,CAAC,GAAG,EAAE,CAAC;IAQpB,cAAc;IAId,aAAa;IAMP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAKjB,OAAO;IAmBrB,OAAO,CAAC,aAAa;CAWtB"}
@@ -57,7 +57,7 @@ class WriteQueue extends queue_1.Queue {
57
57
  archiveKeys.push(archiveKey);
58
58
  promises.push(writePromise);
59
59
  }
60
- const writeResults = await Promise.all(promises);
60
+ const writeResults = await Promise.allSettled(promises);
61
61
  this.updateFileMap(archiveKeys, writeResults);
62
62
  }
63
63
  this.writePromise = null;
@@ -65,10 +65,9 @@ class WriteQueue extends queue_1.Queue {
65
65
  updateFileMap(archiveKeys, writeResults) {
66
66
  for (let i = 0; i < archiveKeys.length; i++) {
67
67
  const archiveKey = archiveKeys[i];
68
- if (!archiveKey) {
69
- continue;
68
+ if (archiveKey && 'value' in writeResults[i]) {
69
+ this.fileMap[archiveKey] = writeResults[i].value;
70
70
  }
71
- this.fileMap[archiveKey] = writeResults[i];
72
71
  }
73
72
  }
74
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "3.2.7",
3
+ "version": "3.3.0-alpha.3",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -43,19 +43,19 @@
43
43
  "build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
44
44
  },
45
45
  "dependencies": {
46
- "@loaders.gl/3d-tiles": "3.2.7",
47
- "@loaders.gl/crypto": "3.2.7",
48
- "@loaders.gl/draco": "3.2.7",
49
- "@loaders.gl/gltf": "3.2.7",
50
- "@loaders.gl/i3s": "3.2.7",
51
- "@loaders.gl/images": "3.2.7",
52
- "@loaders.gl/loader-utils": "3.2.7",
53
- "@loaders.gl/polyfills": "3.2.7",
54
- "@loaders.gl/schema": "3.2.7",
55
- "@loaders.gl/textures": "3.2.7",
56
- "@loaders.gl/tiles": "3.2.7",
57
- "@loaders.gl/worker-utils": "3.2.7",
58
- "@loaders.gl/zip": "3.2.7",
46
+ "@loaders.gl/3d-tiles": "3.3.0-alpha.3",
47
+ "@loaders.gl/crypto": "3.3.0-alpha.3",
48
+ "@loaders.gl/draco": "3.3.0-alpha.3",
49
+ "@loaders.gl/gltf": "3.3.0-alpha.3",
50
+ "@loaders.gl/i3s": "3.3.0-alpha.3",
51
+ "@loaders.gl/images": "3.3.0-alpha.3",
52
+ "@loaders.gl/loader-utils": "3.3.0-alpha.3",
53
+ "@loaders.gl/polyfills": "3.3.0-alpha.3",
54
+ "@loaders.gl/schema": "3.3.0-alpha.3",
55
+ "@loaders.gl/textures": "3.3.0-alpha.3",
56
+ "@loaders.gl/tiles": "3.3.0-alpha.3",
57
+ "@loaders.gl/worker-utils": "3.3.0-alpha.3",
58
+ "@loaders.gl/zip": "3.3.0-alpha.3",
59
59
  "@luma.gl/engine": "^8.5.4",
60
60
  "@math.gl/core": "^3.5.1",
61
61
  "@math.gl/culling": "^3.5.1",
@@ -75,5 +75,5 @@
75
75
  "peerDependencies": {
76
76
  "@loaders.gl/core": "^3.2.0"
77
77
  },
78
- "gitHead": "78b3cc95d3159ac4fc99bd1474ab67008175f2f8"
78
+ "gitHead": "232fdc52fcbee10d8322fd8a4589680943f10517"
79
79
  }
@@ -66,7 +66,9 @@ async function main() {
66
66
  printHelp();
67
67
  }
68
68
 
69
- const options: TileConversionOptions = parseOptions(args);
69
+ const validatedOptionsArr = validateOptionsWithEqual(args);
70
+
71
+ const options: TileConversionOptions = parseOptions(validatedOptionsArr);
70
72
 
71
73
  if (options.installDependencies) {
72
74
  const depthInstaller = new DepsInstaller();
@@ -199,6 +201,19 @@ function validateOptions(options: TileConversionOptions): ValidatedTileConversio
199
201
  return <ValidatedTileConversionOptions>options;
200
202
  }
201
203
 
204
+ function validateOptionsWithEqual(args: string[]): string[] {
205
+ return args.reduce((acc: string[], curr) => {
206
+ const equalSignIndex = curr.indexOf('=');
207
+ const beforeEqual = curr.slice(0, equalSignIndex);
208
+ const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
209
+ const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
210
+ if (condition) {
211
+ return acc.concat(beforeEqual, afterEqual);
212
+ }
213
+ return acc.concat(curr);
214
+ }, []);
215
+ }
216
+
202
217
  /**
203
218
  * Parse option from the cli arguments array
204
219
  * @param args
@@ -237,7 +252,7 @@ function parseOptions(args: string[]): TileConversionOptions {
237
252
  opts.maxDepth = getIntegerValue(index, args);
238
253
  break;
239
254
  case '--slpk':
240
- opts.slpk = true;
255
+ opts.slpk = getBooleanValue(index, args);
241
256
  break;
242
257
  case '--7zExe':
243
258
  opts.sevenZipExe = getStringValue(index, args);
@@ -249,19 +264,19 @@ function parseOptions(args: string[]): TileConversionOptions {
249
264
  opts.token = getStringValue(index, args);
250
265
  break;
251
266
  case '--no-draco':
252
- opts.draco = false;
267
+ opts.draco = getBooleanValue(index, args);
253
268
  break;
254
269
  case '--validate':
255
- opts.validate = true;
270
+ opts.validate = getBooleanValue(index, args);
256
271
  break;
257
272
  case '--install-dependencies':
258
- opts.installDependencies = true;
273
+ opts.installDependencies = getBooleanValue(index, args);
259
274
  break;
260
275
  case '--generate-textures':
261
- opts.generateTextures = true;
276
+ opts.generateTextures = getBooleanValue(index, args);
262
277
  break;
263
278
  case '--generate-bounding-volumes':
264
- opts.generateBoundingVolumes = true;
279
+ opts.generateBoundingVolumes = getBooleanValue(index, args);
265
280
  break;
266
281
  case '--help':
267
282
  printHelp();
@@ -308,3 +323,14 @@ function getIntegerValue(index: number, args: string[]): number {
308
323
  }
309
324
  return NaN;
310
325
  }
326
+
327
+ function getBooleanValue(index: number, args: string[]): boolean {
328
+ const stringValue: string = getStringValue(index, args).toLowerCase().trim();
329
+ if (args[index] === '--no-draco' && !stringValue) {
330
+ return false;
331
+ }
332
+ if (!stringValue || stringValue === 'true') {
333
+ return true;
334
+ }
335
+ return false;
336
+ }
@@ -0,0 +1,199 @@
1
+ import type {GLTFAccessorPostprocessed} from 'modules/gltf/src/lib/types/gltf-types';
2
+ import type {Image, MeshPrimitive} from 'modules/gltf/src/lib/types/gltf-postprocessed-schema';
3
+ import type {
4
+ GLTF_EXT_feature_metadata_attribute,
5
+ GLTF_EXT_feature_metadata_primitive
6
+ } from 'modules/gltf/src/lib/types/gltf-json-schema';
7
+
8
+ const EXT_MESH_FEATURES = 'EXT_mesh_features';
9
+ const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
10
+
11
+ /**
12
+ * Getting batchIds from 3DTilesNext extensions.
13
+ * @param attributes
14
+ * @param primitive
15
+ * @param textures
16
+ */
17
+ export function handleBatchIdsExtensions(
18
+ attributes: {
19
+ [key: string]: GLTFAccessorPostprocessed;
20
+ },
21
+ primitive: MeshPrimitive,
22
+ images: Image[]
23
+ ): number[] {
24
+ const extensions = primitive?.extensions;
25
+
26
+ if (!extensions) {
27
+ return [];
28
+ }
29
+
30
+ for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
31
+ switch (extensionName) {
32
+ case EXT_FEATURE_METADATA:
33
+ return handleExtFeatureMetadataExtension(
34
+ attributes,
35
+ extensionData as GLTF_EXT_feature_metadata_primitive,
36
+ images
37
+ );
38
+ case EXT_MESH_FEATURES:
39
+ console.warn('EXT_mesh_features extension is not supported yet');
40
+ return [];
41
+ default:
42
+ return [];
43
+ }
44
+ }
45
+
46
+ return [];
47
+ }
48
+
49
+ /**
50
+ * Get batchIds from EXT_feature_metadata extension.
51
+ * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata
52
+ * @param attributes
53
+ * @param extFeatureMetadata
54
+ * @param textures
55
+ */
56
+ function handleExtFeatureMetadataExtension(
57
+ attributes: {
58
+ [key: string]: GLTFAccessorPostprocessed;
59
+ },
60
+ extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,
61
+ images: Image[]
62
+ ): number[] {
63
+ // Take only first extension object to get batchIds attribute name.
64
+ const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
65
+
66
+ if (featureIdAttribute?.featureIds?.attribute) {
67
+ const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];
68
+ return batchIdsAttribute.value;
69
+ }
70
+
71
+ if (
72
+ featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&
73
+ featureIdAttribute?.featureIds?.hasOwnProperty('divisor')
74
+ ) {
75
+ const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;
76
+ return generateImplicitFeatureIds(
77
+ featuresCount,
78
+ featureIdAttribute.featureIds.constant,
79
+ featureIdAttribute.featureIds.divisor
80
+ );
81
+ }
82
+
83
+ // Take only first extension object to get batchIds attribute name.
84
+ const featureIdTexture =
85
+ extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];
86
+
87
+ if (featureIdTexture) {
88
+ const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;
89
+ const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;
90
+ const textureCoordinates = attributes[textCoordAttribute].value;
91
+ return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
92
+ }
93
+
94
+ // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.
95
+ const featureTexture =
96
+ extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
97
+
98
+ /**
99
+ * TODO need to get batchIds from root extension
100
+ */
101
+ if (featureTexture) {
102
+ console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive");
103
+ return [];
104
+ }
105
+
106
+ return [];
107
+ }
108
+
109
+ /**
110
+ * Generates implicit feature ids
111
+ * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids
112
+ * @param featuresCount
113
+ * @param constant
114
+ * @param devisor
115
+ */
116
+ function generateImplicitFeatureIds(
117
+ featuresCount: number,
118
+ constant: number = 0,
119
+ divisor: number = 0
120
+ ): number[] {
121
+ let featureIds: number[] = [];
122
+
123
+ if (divisor > 0) {
124
+ let currentValue = constant;
125
+ let devisorCounter = divisor;
126
+
127
+ for (let index = 0; index < featuresCount; index++) {
128
+ featureIds.push(currentValue);
129
+
130
+ devisorCounter -= 1;
131
+
132
+ if (devisorCounter === 0) {
133
+ currentValue++;
134
+ devisorCounter = divisor;
135
+ }
136
+ }
137
+ } else {
138
+ featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);
139
+ }
140
+
141
+ return featureIds;
142
+ }
143
+
144
+ /**
145
+ * Get batchIds from texture.
146
+ * @param primitive
147
+ * @param featureIdTextures
148
+ */
149
+ function generateBatchIdsFromTexture(
150
+ featureIdTexture: GLTF_EXT_feature_metadata_attribute,
151
+ textureCoordinates: Float32Array,
152
+ images: Image[]
153
+ ) {
154
+ const CHANNELS_MAP = {
155
+ r: 0,
156
+ g: 1,
157
+ b: 2,
158
+ a: 3
159
+ };
160
+
161
+ const textureIndex = featureIdTexture?.featureIds?.texture?.index;
162
+ const featureChannel = featureIdTexture?.featureIds?.channels;
163
+
164
+ if (!featureChannel || textureIndex === undefined) {
165
+ return [];
166
+ }
167
+
168
+ const image = images[textureIndex];
169
+ const batchIds: number[] = [];
170
+ const channels = CHANNELS_MAP[featureChannel];
171
+
172
+ if (!image.compressed) {
173
+ for (let index = 0; index < textureCoordinates.length; index += 2) {
174
+ const u = textureCoordinates[index];
175
+ const v = textureCoordinates[index + 1];
176
+
177
+ const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);
178
+ const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);
179
+
180
+ const offset = (ty * image.width + tx) * image.components + channels;
181
+ const batchId = new Uint8Array(image.data)[offset];
182
+
183
+ batchIds.push(batchId);
184
+ }
185
+ } else {
186
+ console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);
187
+ }
188
+
189
+ return batchIds;
190
+ }
191
+
192
+ /**
193
+ * Handle UVs if they are out of range [0,1].
194
+ * @param n
195
+ * @param m
196
+ */
197
+ function emod(n: number): number {
198
+ return ((n % 1) + 1) % 1;
199
+ }
@@ -0,0 +1,65 @@
1
+ import type {FeatureTableJson} from '@loaders.gl/3d-tiles';
2
+
3
+ /**
4
+ * Takes attributes from property table based on featureIds.
5
+ * If there is no property value for particular featureId (index) the property will be null.
6
+ * Example:
7
+ * Initial data:
8
+ * OBJECTID: [0, 1, 5]
9
+ * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
10
+ * Result:
11
+ * OBJECTID: [0, 1, 5]
12
+ * component: ['Windows', 'Frames', 'null']
13
+ * @param featureIds
14
+ * @param propertyTable
15
+ */
16
+ export function flattenPropertyTableByFeatureIds(
17
+ featureIds: number[],
18
+ propertyTable: FeatureTableJson
19
+ ): FeatureTableJson {
20
+ const resultPropertyTable: FeatureTableJson = {};
21
+ for (const propertyName in propertyTable) {
22
+ const properties = propertyTable[propertyName];
23
+ resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);
24
+ }
25
+
26
+ return resultPropertyTable;
27
+ }
28
+
29
+ /**
30
+ * Getting properties by featureId index
31
+ * @param properties
32
+ * @param featureIds
33
+ */
34
+ function getPropertiesByFeatureIds(properties: any[], featureIds: number[]): any[] {
35
+ const resultProperties: any = [];
36
+
37
+ for (const featureId of featureIds) {
38
+ const property = properties[featureId] || null;
39
+ resultProperties.push(property);
40
+ }
41
+
42
+ return resultProperties;
43
+ }
44
+
45
+ /**
46
+ * Check that all attributes in propertyTable have the same length as FeatureIds.
47
+ * If there are differencies between lengths we should flatten property table based on exiesting featureIds.
48
+ * @param featureIds
49
+ * @param propertyTable
50
+ * @returns
51
+ */
52
+ export function checkPropertiesLength(
53
+ featureIds: number[],
54
+ propertyTable: FeatureTableJson
55
+ ): boolean {
56
+ let needFlatten = false;
57
+
58
+ for (const attribute of Object.values(propertyTable)) {
59
+ if (featureIds.length !== attribute.length) {
60
+ needFlatten = true;
61
+ }
62
+ }
63
+
64
+ return needFlatten;
65
+ }