@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.0-alpha.6

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 (192) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -4
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +349 -293
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +261 -200
  6. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
  7. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/load-i3s.js +83 -77
  9. package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
  10. package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
  11. package/dist/constants.js +0 -1
  12. package/dist/converter-cli.js +257 -234
  13. package/dist/converter.min.cjs +95 -105
  14. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  15. package/dist/deps-installer/deps-installer.js +78 -59
  16. package/dist/i3s-converter/helpers/attribute-metadata-info.js +210 -153
  17. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  18. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  19. package/dist/i3s-converter/helpers/batch-ids-extensions.js +146 -103
  20. package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
  21. package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
  22. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  23. package/dist/i3s-converter/helpers/feature-attributes.js +170 -105
  24. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
  25. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  26. package/dist/i3s-converter/helpers/geometry-attributes.js +205 -212
  27. package/dist/i3s-converter/helpers/geometry-converter.d.ts +17 -3
  28. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  29. package/dist/i3s-converter/helpers/geometry-converter.js +1189 -830
  30. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  31. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  32. package/dist/i3s-converter/helpers/gltf-attributes.js +109 -97
  33. package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
  34. package/dist/i3s-converter/helpers/node-debug.js +98 -54
  35. package/dist/i3s-converter/helpers/node-index-document.d.ts +11 -4
  36. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  37. package/dist/i3s-converter/helpers/node-index-document.js +255 -177
  38. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  39. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  40. package/dist/i3s-converter/helpers/node-pages.js +299 -193
  41. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
  42. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  43. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
  44. package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
  45. package/dist/i3s-converter/helpers/progress.js +139 -83
  46. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +9 -2
  47. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  48. package/dist/i3s-converter/helpers/tileset-traversal.js +33 -13
  49. package/dist/i3s-converter/i3s-converter.d.ts +7 -7
  50. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  51. package/dist/i3s-converter/i3s-converter.js +1165 -895
  52. package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
  53. package/dist/i3s-converter/json-templates/layers.js +120 -121
  54. package/dist/i3s-converter/json-templates/metadata.js +19 -20
  55. package/dist/i3s-converter/json-templates/node.js +73 -71
  56. package/dist/i3s-converter/json-templates/scene-server.js +25 -26
  57. package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
  58. package/dist/i3s-converter/json-templates/store.js +96 -94
  59. package/dist/i3s-converter/types.js +35 -23
  60. package/dist/i3s-server/app.js +15 -12
  61. package/dist/i3s-server/bin/i3s-server.min.cjs +69 -69
  62. package/dist/i3s-server/bin/www.js +16 -7
  63. package/dist/i3s-server/controllers/index-controller.js +18 -15
  64. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  65. package/dist/i3s-server/controllers/slpk-controller.js +24 -11
  66. package/dist/i3s-server/routes/index.js +13 -9
  67. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  68. package/dist/i3s-server/routes/slpk-router.js +26 -19
  69. package/dist/i3s-server/utils/create-scene-server.js +15 -10
  70. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
  71. package/dist/i3s-server/utils/server-utils.js +52 -32
  72. package/dist/index.cjs +616 -967
  73. package/dist/index.cjs.map +7 -0
  74. package/dist/index.d.ts +2 -2
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +0 -1
  77. package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
  78. package/dist/lib/utils/cli-utils.d.ts.map +1 -1
  79. package/dist/lib/utils/cli-utils.js +65 -36
  80. package/dist/lib/utils/compress-util.js +20 -15
  81. package/dist/lib/utils/conversion-dump.d.ts +10 -2
  82. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  83. package/dist/lib/utils/conversion-dump.js +242 -197
  84. package/dist/lib/utils/file-utils.d.ts +1 -1
  85. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  86. package/dist/lib/utils/file-utils.js +120 -74
  87. package/dist/lib/utils/geometry-utils.js +13 -7
  88. package/dist/lib/utils/lod-conversion-utils.js +65 -33
  89. package/dist/lib/utils/queue.js +12 -13
  90. package/dist/lib/utils/statistic-utills.d.ts +6 -23
  91. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  92. package/dist/lib/utils/statistic-utills.js +58 -55
  93. package/dist/lib/utils/write-queue.d.ts +2 -2
  94. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  95. package/dist/lib/utils/write-queue.js +72 -86
  96. package/dist/pgm-loader.js +17 -13
  97. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  98. package/dist/slpk-extractor/slpk-extractor.js +60 -50
  99. package/dist/slpk-extractor-cli.d.ts.map +1 -1
  100. package/dist/slpk-extractor-cli.js +90 -59
  101. package/dist/slpk-extractor.min.cjs +1 -1
  102. package/package.json +27 -26
  103. package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
  104. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
  105. package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
  106. package/src/converter-cli.ts +4 -2
  107. package/src/deps-installer/deps-installer.ts +7 -0
  108. package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
  109. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
  110. package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
  111. package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
  112. package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
  113. package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
  114. package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
  115. package/src/i3s-converter/helpers/node-index-document.ts +18 -10
  116. package/src/i3s-converter/helpers/node-pages.ts +27 -29
  117. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
  118. package/src/i3s-converter/helpers/progress.ts +1 -0
  119. package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
  120. package/src/i3s-converter/i3s-converter.ts +173 -114
  121. package/src/i3s-converter/json-templates/node.ts +1 -1
  122. package/src/i3s-server/bin/www.ts +6 -4
  123. package/src/i3s-server/controllers/slpk-controller.ts +4 -2
  124. package/src/i3s-server/routes/index.ts +10 -7
  125. package/src/i3s-server/routes/slpk-router.ts +22 -16
  126. package/src/i3s-server/utils/server-utils.ts +6 -4
  127. package/src/lib/utils/cli-utils.ts +2 -0
  128. package/src/lib/utils/conversion-dump.ts +35 -20
  129. package/src/lib/utils/file-utils.ts +11 -11
  130. package/src/lib/utils/statistic-utills.ts +5 -6
  131. package/src/lib/utils/write-queue.ts +2 -2
  132. package/src/slpk-extractor/slpk-extractor.ts +2 -1
  133. package/src/slpk-extractor-cli.ts +16 -8
  134. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  135. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  136. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  137. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  138. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  139. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  140. package/dist/constants.js.map +0 -1
  141. package/dist/converter-cli.js.map +0 -1
  142. package/dist/deps-installer/deps-installer.js.map +0 -1
  143. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
  144. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  145. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  146. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  147. package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
  148. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  149. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  150. package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  151. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  152. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  153. package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
  154. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  155. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  156. package/dist/i3s-converter/helpers/progress.js.map +0 -1
  157. package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  158. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  159. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  160. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  161. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  162. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  163. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  164. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  165. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  166. package/dist/i3s-converter/types.js.map +0 -1
  167. package/dist/i3s-server/README.md +0 -63
  168. package/dist/i3s-server/app.js.map +0 -1
  169. package/dist/i3s-server/bin/www.js.map +0 -1
  170. package/dist/i3s-server/certs/cert.pem +0 -19
  171. package/dist/i3s-server/certs/key.pem +0 -27
  172. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  173. package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
  174. package/dist/i3s-server/routes/index.js.map +0 -1
  175. package/dist/i3s-server/routes/slpk-router.js.map +0 -1
  176. package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
  177. package/dist/i3s-server/utils/server-utils.js.map +0 -1
  178. package/dist/index.js.map +0 -1
  179. package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
  180. package/dist/lib/utils/cli-utils.js.map +0 -1
  181. package/dist/lib/utils/compress-util.js.map +0 -1
  182. package/dist/lib/utils/conversion-dump.js.map +0 -1
  183. package/dist/lib/utils/file-utils.js.map +0 -1
  184. package/dist/lib/utils/geometry-utils.js.map +0 -1
  185. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  186. package/dist/lib/utils/queue.js.map +0 -1
  187. package/dist/lib/utils/statistic-utills.js.map +0 -1
  188. package/dist/lib/utils/write-queue.js.map +0 -1
  189. package/dist/pgm-loader.js.map +0 -1
  190. package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
  191. package/dist/slpk-extractor-cli.js.map +0 -1
  192. package/src/lib/utils/statistic-utills.d.ts +0 -25
package/dist/index.cjs CHANGED
@@ -27,15 +27,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
30
+ // dist/index.js
31
+ var dist_exports = {};
32
+ __export(dist_exports, {
33
33
  I3SConverter: () => I3SConverter,
34
34
  Tiles3DConverter: () => Tiles3DConverter
35
35
  });
36
- module.exports = __toCommonJS(src_exports);
36
+ module.exports = __toCommonJS(dist_exports);
37
37
 
38
- // src/i3s-converter/types.ts
38
+ // dist/i3s-converter/types.js
39
+ var GLTFPrimitiveModeString;
40
+ (function(GLTFPrimitiveModeString2) {
41
+ GLTFPrimitiveModeString2["POINTS"] = "POINTS";
42
+ GLTFPrimitiveModeString2["LINES"] = "LINES";
43
+ GLTFPrimitiveModeString2["LINE_LOOP"] = "LINE_LOOP";
44
+ GLTFPrimitiveModeString2["LINE_STRIP"] = "LINE_STRIP";
45
+ GLTFPrimitiveModeString2["TRIANGLES"] = "TRIANGLES";
46
+ GLTFPrimitiveModeString2["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
47
+ GLTFPrimitiveModeString2["TRIANGLE_FAN"] = "TRIANGLE_FAN";
48
+ })(GLTFPrimitiveModeString || (GLTFPrimitiveModeString = {}));
39
49
  var AttributeType = {
40
50
  /** Type of attribute that is linked with feature ids */
41
51
  OBJECT_ID_TYPE: "OBJECTID",
@@ -46,9 +56,20 @@ var AttributeType = {
46
56
  /** Integer data type name for feature attributes */
47
57
  SHORT_INT_TYPE: "Int32"
48
58
  };
59
+ var ResourceType;
60
+ (function(ResourceType2) {
61
+ ResourceType2["ATTRIBUTES"] = "ATTRIBUTES";
62
+ ResourceType2["DRACO_GEOMETRY"] = "DRACO_GEOMETRY";
63
+ ResourceType2["GEOMETRY"] = "GEOMETRY";
64
+ ResourceType2["SHARED"] = "SHARED";
65
+ ResourceType2["TEXTURE"] = "TEXTURE";
66
+ })(ResourceType || (ResourceType = {}));
49
67
 
50
- // src/i3s-converter/helpers/attribute-metadata-info.ts
68
+ // dist/i3s-converter/helpers/attribute-metadata-info.js
51
69
  var AttributeMetadataInfo = class {
70
+ _attributeStorageInfo;
71
+ _fields;
72
+ _popupInfo;
52
73
  constructor() {
53
74
  this._attributeStorageInfo = [];
54
75
  this._fields = [];
@@ -109,7 +130,7 @@ var AttributeMetadataInfo = class {
109
130
  }
110
131
  if (isUpdated) {
111
132
  const attributeNames = [];
112
- for (let info of this._attributeStorageInfo) {
133
+ for (const info of this._attributeStorageInfo) {
113
134
  attributeNames.push(info.name);
114
135
  }
115
136
  this._popupInfo = this.createPopupInfo(attributeNames);
@@ -256,7 +277,7 @@ var AttributeMetadataInfo = class {
256
277
  }
257
278
  };
258
279
 
259
- // src/i3s-converter/i3s-converter.ts
280
+ // dist/i3s-converter/i3s-converter.js
260
281
  var import_core9 = require("@loaders.gl/core");
261
282
  var import_d_tiles2 = require("@loaders.gl/3d-tiles");
262
283
  var import_path7 = require("path");
@@ -265,11 +286,11 @@ var import_process4 = __toESM(require("process"), 1);
265
286
  var import_json_map_transform8 = __toESM(require("json-map-transform"), 1);
266
287
  var import_md52 = __toESM(require("md5"), 1);
267
288
 
268
- // src/i3s-converter/helpers/node-pages.ts
289
+ // dist/i3s-converter/helpers/node-pages.js
269
290
  var import_path2 = require("path");
270
291
  var import_json_map_transform = __toESM(require("json-map-transform"), 1);
271
292
 
272
- // src/i3s-converter/json-templates/metadata.ts
293
+ // dist/i3s-converter/json-templates/metadata.js
273
294
  var METADATA = () => ({
274
295
  folderPattern: {
275
296
  path: "folderPattern",
@@ -292,13 +313,13 @@ var METADATA = () => ({
292
313
  }
293
314
  });
294
315
 
295
- // src/lib/utils/file-utils.ts
316
+ // dist/lib/utils/file-utils.js
296
317
  var import_core = require("@loaders.gl/core");
297
318
  var import_loader_utils = require("@loaders.gl/loader-utils");
298
319
  var import_fs2 = require("fs");
299
320
  var import_path = require("path");
300
321
 
301
- // src/lib/utils/compress-util.ts
322
+ // dist/lib/utils/compress-util.js
302
323
  var import_zlib = require("zlib");
303
324
  var import_fs = require("fs");
304
325
  function compressFileWithGzip(pathFile) {
@@ -319,7 +340,7 @@ function compressFileWithGzip(pathFile) {
319
340
  });
320
341
  }
321
342
 
322
- // src/lib/utils/file-utils.ts
343
+ // dist/lib/utils/file-utils.js
323
344
  async function writeFile(path, data, fileName = "index.json") {
324
345
  let toWriteData;
325
346
  if (data instanceof Promise) {
@@ -346,14 +367,12 @@ async function writeFileForSlpk(path, data, fileName = "index.json", compress =
346
367
  if (!compressList.includes(pathFile)) {
347
368
  compressList.push(pathFile);
348
369
  return `${pathFile}.gz`;
349
- } else {
350
- return null;
351
370
  }
352
- } else {
353
- const pathGzFile = await compressFileWithGzip(pathFile);
354
- await removeFile(pathFile);
355
- return pathGzFile;
371
+ return null;
356
372
  }
373
+ const pathGzFile = await compressFileWithGzip(pathFile);
374
+ await removeFile(pathFile);
375
+ return pathGzFile;
357
376
  }
358
377
  return pathFile;
359
378
  }
@@ -401,8 +420,14 @@ async function renameFile(oldPath, newPath) {
401
420
  }
402
421
  }
403
422
 
404
- // src/i3s-converter/helpers/node-pages.ts
423
+ // dist/i3s-converter/helpers/node-pages.js
405
424
  var NodePages = class {
425
+ nodesPerPage;
426
+ nodesCounter;
427
+ writeFile;
428
+ converter;
429
+ nodePages;
430
+ length = 0;
406
431
  /**
407
432
  * @constructs
408
433
  * Create a nodePages instance.
@@ -410,7 +435,6 @@ var NodePages = class {
410
435
  * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
411
436
  */
412
437
  constructor(writeFileFunc, nodesPerPage, converter) {
413
- this.length = 0;
414
438
  this.nodesPerPage = nodesPerPage;
415
439
  this.nodesCounter = 0;
416
440
  this.nodePages = [{}];
@@ -454,9 +478,8 @@ var NodePages = class {
454
478
  if (await isFileExists(fullName)) {
455
479
  console.log(`load ${fullName}.`);
456
480
  return await openJson(filePath, fileName);
457
- } else {
458
- return { nodes: [] };
459
481
  }
482
+ return { nodes: [] };
460
483
  }
461
484
  /**
462
485
  * Get nodepage id by node id
@@ -530,33 +553,26 @@ var NodePages = class {
530
553
  async saveNode(node) {
531
554
  if (!this.converter.options.instantNodeWriting) {
532
555
  return;
556
+ }
557
+ const nodePageIndex = this.getPageIndexByNodeId(node.index);
558
+ const nodePage = await this.getPageByNodeId(node.index);
559
+ const { filePath, fileName } = this.getNodePageFileName(nodePageIndex);
560
+ const nodeToUpdate = await this.getNodeById(node.index, nodePage);
561
+ if (nodeToUpdate) {
562
+ NodePages.updateAll(nodeToUpdate, node);
533
563
  } else {
534
- const nodePageIndex = this.getPageIndexByNodeId(node.index);
535
- const nodePage = await this.getPageByNodeId(node.index);
536
- const { filePath, fileName } = this.getNodePageFileName(nodePageIndex);
537
- const nodeToUpdate = await this.getNodeById(node.index, nodePage);
538
- if (nodeToUpdate) {
539
- NodePages.updateAll(nodeToUpdate, node);
540
- } else {
541
- nodePage.nodes.push(node);
542
- }
543
- const nodePageStr = JSON.stringify(nodePage);
544
- if (this.converter.options.slpk) {
545
- await this.converter.writeQueue.enqueue(
546
- {
547
- archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
548
- writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
549
- },
550
- true
551
- );
552
- } else {
553
- await this.converter.writeQueue.enqueue(
554
- {
555
- writePromise: () => this.writeFile(filePath, nodePageStr)
556
- },
557
- true
558
- );
559
- }
564
+ nodePage.nodes.push(node);
565
+ }
566
+ const nodePageStr = JSON.stringify(nodePage);
567
+ if (this.converter.options.slpk) {
568
+ await this.converter.writeQueue.enqueue({
569
+ archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
570
+ writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
571
+ }, true);
572
+ } else {
573
+ await this.converter.writeQueue.enqueue({
574
+ writePromise: () => this.writeFile(filePath, nodePageStr)
575
+ }, true);
560
576
  }
561
577
  }
562
578
  /**
@@ -567,12 +583,7 @@ var NodePages = class {
567
583
  const compress = false;
568
584
  await this.converter.writeQueue.enqueue({
569
585
  archiveKey: "metadata.json",
570
- writePromise: () => this.writeFile(
571
- this.converter.layers0Path,
572
- JSON.stringify(metadata),
573
- "metadata.json",
574
- compress
575
- )
586
+ writePromise: () => this.writeFile(this.converter.layers0Path, JSON.stringify(metadata), "metadata.json", compress)
576
587
  });
577
588
  }
578
589
  /**
@@ -682,21 +693,20 @@ var NodePages = class {
682
693
  }
683
694
  };
684
695
 
685
- // src/lib/utils/statistic-utills.ts
696
+ // dist/lib/utils/statistic-utills.js
686
697
  var import_path3 = require("path");
687
698
  var import_fs3 = require("fs");
688
699
  function timeConverter(time) {
689
700
  if (typeof time === "number") {
690
701
  const milliSecondsInSecond = 1e3;
691
- const timeInSeconds = Math.floor(time / milliSecondsInSecond);
692
- const milliseconds = time - timeInSeconds * milliSecondsInSecond;
693
- return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
694
- } else {
695
- const nanoSecondsInMillisecond = 1e6;
696
- const timeInSeconds = time[0];
697
- const milliseconds = time[1] / nanoSecondsInMillisecond;
698
- return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
699
- }
702
+ const timeInSeconds2 = Math.floor(time / milliSecondsInSecond);
703
+ const milliseconds2 = time - timeInSeconds2 * milliSecondsInSecond;
704
+ return timeConverterFromSecondsAndMilliseconds(timeInSeconds2, milliseconds2);
705
+ }
706
+ const nanoSecondsInMillisecond = 1e6;
707
+ const timeInSeconds = time[0];
708
+ const milliseconds = time[1] / nanoSecondsInMillisecond;
709
+ return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
700
710
  }
701
711
  function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
702
712
  const hours = Math.floor(timeInSeconds / 3600);
@@ -750,7 +760,7 @@ async function getTotalFilesSize(dirPath) {
750
760
  return totalFileSize;
751
761
  }
752
762
 
753
- // src/i3s-converter/helpers/geometry-converter.ts
763
+ // dist/i3s-converter/helpers/geometry-converter.js
754
764
  var import_core4 = require("@math.gl/core");
755
765
  var import_geospatial3 = require("@math.gl/geospatial");
756
766
  var import_draco = require("@loaders.gl/draco");
@@ -759,7 +769,7 @@ var import_loader_utils3 = require("@loaders.gl/loader-utils");
759
769
  var import_md5 = __toESM(require("md5"), 1);
760
770
  var import_uuid = require("uuid");
761
771
 
762
- // src/i3s-converter/helpers/geometry-attributes.ts
772
+ // dist/i3s-converter/helpers/geometry-attributes.js
763
773
  var import_loader_utils2 = require("@loaders.gl/loader-utils");
764
774
  var VALUES_PER_VERTEX = 3;
765
775
  var POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
@@ -781,10 +791,7 @@ function generateAttributes(attributes) {
781
791
  const data = calculateFaceRangesAndFeaturesCount(featureIndices);
782
792
  const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
783
793
  const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
784
- const groupedAttributes = groupAttributesAndRangesByFeatureId(
785
- unifiedAttributeObjectsByFeatureIds,
786
- data.featureCount
787
- );
794
+ const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
788
795
  return groupedAttributes;
789
796
  }
790
797
  function calculateFaceRangesAndFeaturesCount(featureIndices) {
@@ -827,21 +834,13 @@ function getFrequentValue(values) {
827
834
  return mostFrequentValue;
828
835
  }
829
836
  function makeAttributeObjects(attributes) {
830
- const {
831
- featureIds,
832
- positions,
833
- normals,
834
- colors,
835
- uvRegions,
836
- texCoords,
837
- faceRange = new Uint32Array(0)
838
- } = attributes;
837
+ const { featureIds, positions, normals, colors, uvRegions, texCoords, faceRange = new Uint32Array(0) } = attributes;
839
838
  const groupedData = [];
840
- let positionsList = new Float32Array(positions);
841
- let normalsList = new Float32Array(normals);
842
- let colorsList = new Uint8Array(colors);
843
- let texCoordsList = new Float32Array(texCoords);
844
- let uvRegionsList = new Uint16Array(uvRegions);
839
+ const positionsList = new Float32Array(positions);
840
+ const normalsList = new Float32Array(normals);
841
+ const colorsList = new Uint8Array(colors);
842
+ const texCoordsList = new Float32Array(texCoords);
843
+ const uvRegionsList = new Uint16Array(uvRegions);
845
844
  let positionsOffset = 0;
846
845
  let normalsOffset = 0;
847
846
  let colorsOffset = 0;
@@ -952,7 +951,7 @@ function concatenateAttributes(attributes) {
952
951
  };
953
952
  }
954
953
 
955
- // src/i3s-converter/helpers/coordinate-converter.ts
954
+ // dist/i3s-converter/helpers/coordinate-converter.js
956
955
  var import_core2 = require("@math.gl/core");
957
956
  var import_geospatial = require("@math.gl/geospatial");
958
957
  var import_culling = require("@math.gl/culling");
@@ -960,10 +959,7 @@ function createBoundingVolumes(sourceBoundingVolume, geoidHeightModel) {
960
959
  let radius;
961
960
  let halfSize;
962
961
  let quaternion;
963
- const cartographicCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(
964
- sourceBoundingVolume.center,
965
- new import_core2.Vector3()
966
- );
962
+ const cartographicCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(sourceBoundingVolume.center, new import_core2.Vector3());
967
963
  cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
968
964
  if (sourceBoundingVolume instanceof import_culling.OrientedBoundingBox) {
969
965
  halfSize = sourceBoundingVolume.halfSize;
@@ -987,8 +983,8 @@ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel)
987
983
  const positionVectors = convertPositionsToVectors(cartesianPositions);
988
984
  const geometryObb = (0, import_culling.makeOrientedBoundingBoxFromPoints)(positionVectors);
989
985
  const geometryMbs = (0, import_culling.makeBoundingSphereFromPoints)(positionVectors);
990
- let mbsCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core2.Vector3());
991
- let obbCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core2.Vector3());
986
+ const mbsCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core2.Vector3());
987
+ const obbCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core2.Vector3());
992
988
  mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
993
989
  obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
994
990
  return {
@@ -1017,14 +1013,8 @@ function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
1017
1013
  }
1018
1014
  const center = sphere.center;
1019
1015
  const radius = sphere.radius;
1020
- const vertexMax = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(
1021
- new import_core2.Vector3(center[0] + radius, center[1] + radius, center[2] + radius),
1022
- new import_core2.Vector3()
1023
- );
1024
- const vertexMin = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(
1025
- new import_core2.Vector3(center[0] - radius, center[1] - radius, center[2] - radius),
1026
- new import_core2.Vector3()
1027
- );
1016
+ const vertexMax = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(new import_core2.Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new import_core2.Vector3());
1017
+ const vertexMin = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(new import_core2.Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new import_core2.Vector3());
1028
1018
  return {
1029
1019
  xmin: Math.min(vertexMin[0], vertexMax[0]),
1030
1020
  xmax: Math.max(vertexMin[0], vertexMax[0]),
@@ -1041,36 +1031,31 @@ function createObbFromMbs(mbs) {
1041
1031
  return new import_culling.OrientedBoundingBox(center, halfAxex);
1042
1032
  }
1043
1033
 
1044
- // src/i3s-converter/helpers/gltf-attributes.ts
1034
+ // dist/i3s-converter/helpers/gltf-attributes.js
1045
1035
  var import_core3 = require("@math.gl/core");
1046
1036
  var import_geospatial2 = require("@math.gl/geospatial");
1047
1037
  function prepareDataForAttributesConversion(tileContent, tileTransform, boundingVolume) {
1048
1038
  var _a2, _b, _c, _d, _e, _f, _g, _h;
1049
- let nodes = ((_b = (_a2 = tileContent.gltf) == null ? void 0 : _a2.scene) == null ? void 0 : _b.nodes) || ((_e = (_d = (_c = tileContent.gltf) == null ? void 0 : _c.scenes) == null ? void 0 : _d[0]) == null ? void 0 : _e.nodes) || ((_f = tileContent.gltf) == null ? void 0 : _f.nodes) || [];
1039
+ const nodes = ((_b = (_a2 = tileContent.gltf) == null ? void 0 : _a2.scene) == null ? void 0 : _b.nodes) || ((_e = (_d = (_c = tileContent.gltf) == null ? void 0 : _c.scenes) == null ? void 0 : _d[0]) == null ? void 0 : _e.nodes) || ((_f = tileContent.gltf) == null ? void 0 : _f.nodes) || [];
1050
1040
  const images = ((_h = (_g = tileContent.gltf) == null ? void 0 : _g.images) == null ? void 0 : _h.map((imageObject) => {
1051
1041
  var _a3, _b2;
1052
1042
  if ((_a3 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _a3.compressed) {
1053
1043
  return null;
1054
- } else {
1055
- const data = (_b2 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _b2.data;
1056
- const dataCopy = new Uint8Array(data.length);
1057
- dataCopy.set(data);
1058
- return {
1059
- data: dataCopy,
1060
- compressed: false,
1061
- height: imageObject.image.height,
1062
- width: imageObject.image.width,
1063
- components: imageObject.image.components,
1064
- mimeType: imageObject.mimeType
1065
- };
1066
1044
  }
1045
+ const data = (_b2 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _b2.data;
1046
+ const dataCopy = new Uint8Array(data.length);
1047
+ dataCopy.set(data);
1048
+ return {
1049
+ data: dataCopy,
1050
+ compressed: false,
1051
+ height: imageObject.image.height,
1052
+ width: imageObject.image.width,
1053
+ components: imageObject.image.components,
1054
+ mimeType: imageObject.mimeType
1055
+ };
1067
1056
  })) || [];
1068
1057
  prepareNodes(nodes);
1069
- const { cartographicOrigin, modelMatrix: cartesianModelMatrix } = calculateTransformProps(
1070
- tileContent,
1071
- tileTransform,
1072
- boundingVolume
1073
- );
1058
+ const { cartographicOrigin, modelMatrix: cartesianModelMatrix } = calculateTransformProps(tileContent, tileTransform, boundingVolume);
1074
1059
  return {
1075
1060
  nodes,
1076
1061
  images,
@@ -1109,10 +1094,7 @@ function calculateTransformProps(tileContent, tileTransform, boundingVolume) {
1109
1094
  break;
1110
1095
  }
1111
1096
  const cartesianOrigin = new import_core3.Vector3(center);
1112
- const cartographicOrigin = import_geospatial2.Ellipsoid.WGS84.cartesianToCartographic(
1113
- cartesianOrigin,
1114
- new import_core3.Vector3()
1115
- );
1097
+ const cartographicOrigin = import_geospatial2.Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new import_core3.Vector3());
1116
1098
  return { modelMatrix, cartographicOrigin };
1117
1099
  }
1118
1100
  function prepareNodes(nodes) {
@@ -1145,7 +1127,7 @@ function prepareNodes(nodes) {
1145
1127
  }
1146
1128
  }
1147
1129
 
1148
- // src/i3s-converter/helpers/batch-ids-extensions.ts
1130
+ // dist/i3s-converter/helpers/batch-ids-extensions.js
1149
1131
  var import_math = require("@loaders.gl/math");
1150
1132
  var import_gltf = require("@loaders.gl/gltf");
1151
1133
  function getTextureByMetadataClass(tileContent, metadataClass) {
@@ -1170,12 +1152,7 @@ function handleBatchIdsExtensions(attributes, primitive, images, featureTexture)
1170
1152
  for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
1171
1153
  switch (extensionName) {
1172
1154
  case import_gltf.EXT_FEATURE_METADATA:
1173
- return handleExtFeatureMetadataExtension(
1174
- attributes,
1175
- extensionData,
1176
- images,
1177
- featureTexture
1178
- );
1155
+ return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
1179
1156
  case import_gltf.EXT_MESH_FEATURES:
1180
1157
  return handleExtMeshFeaturesExtension(attributes, extensionData);
1181
1158
  default:
@@ -1185,7 +1162,7 @@ function handleBatchIdsExtensions(attributes, primitive, images, featureTexture)
1185
1162
  return [];
1186
1163
  }
1187
1164
  function handleExtMeshFeaturesExtension(attributes, extMeshFeatures) {
1188
- for (let ids of extMeshFeatures.featureIds) {
1165
+ for (const ids of extMeshFeatures.featureIds) {
1189
1166
  if (typeof ids.propertyTable !== "undefined") {
1190
1167
  return ids.data;
1191
1168
  }
@@ -1201,11 +1178,7 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
1201
1178
  }
1202
1179
  if (((_c = featureIdAttribute == null ? void 0 : featureIdAttribute.featureIds) == null ? void 0 : _c.hasOwnProperty("constant")) && ((_d = featureIdAttribute == null ? void 0 : featureIdAttribute.featureIds) == null ? void 0 : _d.hasOwnProperty("divisor"))) {
1203
1180
  const featuresCount = ((_e = attributes == null ? void 0 : attributes.POSITIONS) == null ? void 0 : _e.value.length) / 3 || 0;
1204
- return generateImplicitFeatureIds(
1205
- featuresCount,
1206
- featureIdAttribute.featureIds.constant,
1207
- featureIdAttribute.featureIds.divisor
1208
- );
1181
+ return generateImplicitFeatureIds(featuresCount, featureIdAttribute.featureIds.constant, featureIdAttribute.featureIds.divisor);
1209
1182
  }
1210
1183
  const featureIdTexture = (extFeatureMetadata == null ? void 0 : extFeatureMetadata.featureIdTextures) && (extFeatureMetadata == null ? void 0 : extFeatureMetadata.featureIdTextures[0]);
1211
1184
  if (featureIdTexture) {
@@ -1273,7 +1246,7 @@ function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, image
1273
1246
  return batchIds;
1274
1247
  }
1275
1248
 
1276
- // src/i3s-converter/helpers/feature-attributes.ts
1249
+ // dist/i3s-converter/helpers/feature-attributes.js
1277
1250
  var import_gltf2 = require("@loaders.gl/gltf");
1278
1251
  function flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable) {
1279
1252
  const resultPropertyTable = {};
@@ -1324,7 +1297,7 @@ var getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
1324
1297
  const attributeTypesMap = {};
1325
1298
  const extFeatureMetadataSchemaClass = (_d = (_c = (_b = (_a2 = gltfJson.extensions) == null ? void 0 : _a2[import_gltf2.EXT_FEATURE_METADATA]) == null ? void 0 : _b.schema) == null ? void 0 : _c.classes) == null ? void 0 : _d[metadataClass];
1326
1299
  if (extFeatureMetadataSchemaClass) {
1327
- for (let propertyName in extFeatureMetadataSchemaClass.properties) {
1300
+ for (const propertyName in extFeatureMetadataSchemaClass.properties) {
1328
1301
  const property = extFeatureMetadataSchemaClass.properties[propertyName];
1329
1302
  const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);
1330
1303
  attributeTypesMap[propertyName] = attributeProperty;
@@ -1333,7 +1306,7 @@ var getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
1333
1306
  }
1334
1307
  const extStructuralMetadataSchemaClass = (_h = (_g = (_f = (_e = gltfJson.extensions) == null ? void 0 : _e[import_gltf2.EXT_STRUCTURAL_METADATA]) == null ? void 0 : _f.schema) == null ? void 0 : _g.classes) == null ? void 0 : _h[metadataClass];
1335
1308
  if (extStructuralMetadataSchemaClass) {
1336
- for (let propertyName in extStructuralMetadataSchemaClass.properties) {
1309
+ for (const propertyName in extStructuralMetadataSchemaClass.properties) {
1337
1310
  const property = extStructuralMetadataSchemaClass.properties[propertyName];
1338
1311
  const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);
1339
1312
  attributeTypesMap[propertyName] = attributeProperty;
@@ -1401,10 +1374,10 @@ var getAttributeTypeFromExtStructuralMetadata = (property) => {
1401
1374
  return attributeType;
1402
1375
  };
1403
1376
 
1404
- // src/i3s-converter/helpers/geometry-converter.ts
1377
+ // dist/i3s-converter/helpers/geometry-converter.js
1405
1378
  var import_math2 = require("@loaders.gl/math");
1406
1379
 
1407
- // src/lib/utils/geometry-utils.ts
1380
+ // dist/lib/utils/geometry-utils.js
1408
1381
  var generateSyntheticIndices = (vertexCount) => {
1409
1382
  const result = new Uint32Array(vertexCount);
1410
1383
  for (let index = 0; index < vertexCount; index++) {
@@ -1413,7 +1386,7 @@ var generateSyntheticIndices = (vertexCount) => {
1413
1386
  return result;
1414
1387
  };
1415
1388
 
1416
- // src/i3s-converter/helpers/geometry-converter.ts
1389
+ // dist/i3s-converter/helpers/geometry-converter.js
1417
1390
  var import_gltf3 = require("@loaders.gl/gltf");
1418
1391
  var DEFAULT_ROUGHNESS_FACTOR = 1;
1419
1392
  var DEFAULT_METALLIC_FACTOR = 1;
@@ -1426,25 +1399,13 @@ var DOUBLE_TYPE = "Float64";
1426
1399
  var OBJECT_ID_TYPE = "Oid32";
1427
1400
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
1428
1401
  var scratchVector = new import_core4.Vector3();
1429
- async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
1402
+ async function convertB3dmToI3sGeometry({ tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass }) {
1430
1403
  var _a2;
1431
1404
  const useCartesianPositions = generateBoundingVolumes;
1432
- const materialAndTextureList = await convertMaterials(
1433
- (_a2 = tileContent.gltf) == null ? void 0 : _a2.materials,
1434
- shouldMergeMaterials
1435
- );
1436
- const dataForAttributesConversion = prepareDataForAttributesConversion(
1437
- tileContent,
1438
- tileTransform,
1439
- tileBoundingVolume
1440
- );
1405
+ const materialAndTextureList = await convertMaterials((_a2 = tileContent.gltf) == null ? void 0 : _a2.materials, shouldMergeMaterials);
1406
+ const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent, tileTransform, tileBoundingVolume);
1441
1407
  const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
1442
- const convertedAttributesMap = await convertAttributes(
1443
- dataForAttributesConversion,
1444
- materialAndTextureList,
1445
- useCartesianPositions,
1446
- featureTexture
1447
- );
1408
+ const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
1448
1409
  if (generateBoundingVolumes) {
1449
1410
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
1450
1411
  }
@@ -1460,20 +1421,18 @@ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBounding
1460
1421
  }
1461
1422
  const { material, texture } = materialAndTexture;
1462
1423
  const nodeId = await addNodeToNodePage();
1463
- result.push(
1464
- await _makeNodeResources({
1465
- convertedAttributes,
1466
- material,
1467
- texture,
1468
- tileContent,
1469
- nodeId,
1470
- featuresHashArray,
1471
- propertyTable,
1472
- attributeStorageInfo,
1473
- draco,
1474
- libraries
1475
- })
1476
- );
1424
+ result.push(await _makeNodeResources({
1425
+ convertedAttributes,
1426
+ material,
1427
+ texture,
1428
+ tileContent,
1429
+ nodeId,
1430
+ featuresHashArray,
1431
+ propertyTable,
1432
+ attributeStorageInfo,
1433
+ draco,
1434
+ libraries
1435
+ }));
1477
1436
  }
1478
1437
  if (!result.length) {
1479
1438
  return null;
@@ -1482,10 +1441,7 @@ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBounding
1482
1441
  }
1483
1442
  function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
1484
1443
  for (const attributes of convertedAttributesMap.values()) {
1485
- const boundingVolumes = createBoundingVolumesFromGeometry(
1486
- attributes.positions,
1487
- geoidHeightModel
1488
- );
1444
+ const boundingVolumes = createBoundingVolumesFromGeometry(attributes.positions, geoidHeightModel);
1489
1445
  attributes.boundingVolumes = boundingVolumes;
1490
1446
  const cartographicOrigin = boundingVolumes.obb.center;
1491
1447
  for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX2) {
@@ -1497,68 +1453,31 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
1497
1453
  }
1498
1454
  }
1499
1455
  }
1500
- async function _makeNodeResources({
1501
- convertedAttributes,
1502
- material,
1503
- texture,
1504
- tileContent,
1505
- nodeId,
1506
- featuresHashArray,
1507
- propertyTable,
1508
- attributeStorageInfo,
1509
- draco,
1510
- libraries
1511
- }) {
1456
+ async function _makeNodeResources({ convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, libraries }) {
1512
1457
  var _a2;
1513
1458
  const boundingVolumes = convertedAttributes.boundingVolumes;
1514
1459
  const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX2;
1515
1460
  const { faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount } = generateAttributes(convertedAttributes);
1516
1461
  let featureIdsMap = {};
1517
1462
  if (propertyTable) {
1518
- featureIdsMap = makeFeatureIdsUnique(
1519
- featureIds,
1520
- convertedAttributes.featureIndices,
1521
- featuresHashArray,
1522
- propertyTable
1523
- );
1463
+ featureIdsMap = makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, propertyTable);
1524
1464
  }
1525
1465
  const header = new Uint32Array(2);
1526
1466
  const typedFeatureIds = generateBigUint64Array(featureIds);
1527
1467
  header.set([vertexCount, featureCount], 0);
1528
- const fileBuffer = new Uint8Array(
1529
- (0, import_loader_utils3.concatenateArrayBuffers)(
1530
- header.buffer,
1531
- positions.buffer,
1532
- normals.buffer,
1533
- texture ? texCoords.buffer : new ArrayBuffer(0),
1534
- colors.buffer,
1535
- uvRegions,
1536
- typedFeatureIds.buffer,
1537
- faceRange.buffer
1538
- )
1539
- );
1540
- const compressedGeometry = draco ? generateCompressedGeometry(
1541
- vertexCount,
1542
- convertedAttributes,
1543
- {
1544
- positions,
1545
- normals,
1546
- texCoords: texture ? texCoords : new Float32Array(0),
1547
- colors,
1548
- uvRegions,
1549
- featureIds,
1550
- faceRange
1551
- },
1552
- libraries
1553
- ) : null;
1468
+ const fileBuffer = new Uint8Array((0, import_loader_utils3.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, uvRegions, typedFeatureIds.buffer, faceRange.buffer));
1469
+ const compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
1470
+ positions,
1471
+ normals,
1472
+ texCoords: texture ? texCoords : new Float32Array(0),
1473
+ colors,
1474
+ uvRegions,
1475
+ featureIds,
1476
+ faceRange
1477
+ }, libraries) : null;
1554
1478
  let attributes = [];
1555
1479
  if (attributeStorageInfo && propertyTable) {
1556
- attributes = convertPropertyTableToAttributeBuffers(
1557
- featureIds,
1558
- featureIdsMap,
1559
- propertyTable,
1560
- attributeStorageInfo
1561
- );
1480
+ attributes = convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo);
1562
1481
  }
1563
1482
  return {
1564
1483
  nodeId,
@@ -1593,16 +1512,15 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
1593
1512
  attributesMap.set(mergedMaterial.originalMaterialId, attributes);
1594
1513
  }
1595
1514
  }
1596
- convertNodes(
1515
+ convertNodes({
1597
1516
  nodes,
1598
1517
  images,
1599
1518
  cartographicOrigin,
1600
1519
  cartesianModelMatrix,
1601
1520
  attributesMap,
1602
1521
  useCartesianPositions,
1603
- void 0,
1604
1522
  featureTexture
1605
- );
1523
+ });
1606
1524
  for (const attrKey of attributesMap.keys()) {
1607
1525
  const attributes = attributesMap.get(attrKey);
1608
1526
  if (!attributes) {
@@ -1613,18 +1531,16 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
1613
1531
  continue;
1614
1532
  }
1615
1533
  if (attributes.featureIndicesGroups) {
1616
- attributes.featureIndices = attributes.featureIndicesGroups.reduce(
1617
- (acc, value) => acc.concat(value)
1618
- );
1534
+ attributes.featureIndices = attributes.featureIndicesGroups.reduce((acc, value) => acc.concat(value));
1619
1535
  delete attributes.featureIndicesGroups;
1620
1536
  }
1621
1537
  }
1622
1538
  return attributesMap;
1623
1539
  }
1624
- function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
1540
+ function convertNodes({ nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture }) {
1625
1541
  if (nodes) {
1626
1542
  for (const node of nodes) {
1627
- convertNode(
1543
+ convertNode({
1628
1544
  node,
1629
1545
  images,
1630
1546
  cartographicOrigin,
@@ -1633,7 +1549,7 @@ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, a
1633
1549
  useCartesianPositions,
1634
1550
  matrix,
1635
1551
  featureTexture
1636
- );
1552
+ });
1637
1553
  }
1638
1554
  }
1639
1555
  }
@@ -1654,100 +1570,78 @@ function getCompositeTransformationMatrix(node, matrix) {
1654
1570
  }
1655
1571
  return transformationMatrix;
1656
1572
  }
1657
- function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
1573
+ function convertNode({ node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture }) {
1658
1574
  const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
1659
1575
  const mesh = node.mesh;
1660
1576
  if (mesh) {
1661
- convertMesh(
1577
+ convertMesh({
1662
1578
  mesh,
1663
1579
  images,
1664
1580
  cartographicOrigin,
1665
1581
  cartesianModelMatrix,
1666
1582
  attributesMap,
1667
1583
  useCartesianPositions,
1668
- transformationMatrix,
1584
+ matrix: transformationMatrix,
1669
1585
  featureTexture
1670
- );
1586
+ });
1671
1587
  }
1672
- convertNodes(
1673
- node.children || [],
1588
+ convertNodes({
1589
+ nodes: node.children || [],
1674
1590
  images,
1675
1591
  cartographicOrigin,
1676
1592
  cartesianModelMatrix,
1677
1593
  attributesMap,
1678
1594
  useCartesianPositions,
1679
- transformationMatrix,
1595
+ matrix: transformationMatrix,
1680
1596
  featureTexture
1681
- );
1597
+ });
1682
1598
  }
1683
- function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
1599
+ function convertMesh({ mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix, featureTexture }) {
1684
1600
  var _a2;
1685
1601
  for (const primitive of mesh.primitives) {
1686
1602
  let outputAttributes = null;
1687
1603
  let materialUvRegion;
1688
1604
  if (primitive.material) {
1689
1605
  outputAttributes = attributesMap.get(primitive.material.id);
1690
- materialUvRegion = (_a2 = outputAttributes == null ? void 0 : outputAttributes.mergedMaterials.find(
1691
- ({ originalMaterialId }) => {
1692
- var _a3;
1693
- return originalMaterialId === ((_a3 = primitive.material) == null ? void 0 : _a3.id);
1694
- }
1695
- )) == null ? void 0 : _a2.uvRegion;
1606
+ materialUvRegion = (_a2 = outputAttributes == null ? void 0 : outputAttributes.mergedMaterials.find(({ originalMaterialId }) => {
1607
+ var _a3;
1608
+ return originalMaterialId === ((_a3 = primitive.material) == null ? void 0 : _a3.id);
1609
+ })) == null ? void 0 : _a2.uvRegion;
1696
1610
  } else if (attributesMap.has("default")) {
1697
1611
  outputAttributes = attributesMap.get("default");
1698
1612
  }
1699
1613
  (0, import_core5.assert)(outputAttributes !== null, "Primitive - material mapping failed");
1700
- (0, import_core5.assert)(
1701
- primitive.mode === void 0 || primitive.mode === import_math2.GL.TRIANGLES || primitive.mode === import_math2.GL.TRIANGLE_STRIP,
1702
- `Primitive - unsupported mode ${primitive.mode}`
1703
- );
1614
+ (0, import_core5.assert)(primitive.mode === void 0 || primitive.mode === import_math2.GL.TRIANGLES || primitive.mode === import_math2.GL.TRIANGLE_STRIP, `Primitive - unsupported mode ${primitive.mode}`);
1704
1615
  const attributes = primitive.attributes;
1705
1616
  if (!outputAttributes) {
1706
1617
  continue;
1707
1618
  }
1708
1619
  const indices = normalizeIndices(primitive);
1709
- outputAttributes.positions = (0, import_loader_utils3.concatenateTypedArrays)(
1710
- outputAttributes.positions,
1711
- transformVertexArray({
1712
- vertices: attributes.POSITION.value,
1713
- cartographicOrigin,
1714
- cartesianModelMatrix,
1715
- nodeMatrix: matrix,
1716
- indices,
1717
- attributeSpecificTransformation: transformVertexPositions,
1718
- useCartesianPositions
1719
- })
1720
- );
1721
- outputAttributes.normals = (0, import_loader_utils3.concatenateTypedArrays)(
1722
- outputAttributes.normals,
1723
- transformVertexArray({
1724
- vertices: attributes.NORMAL && attributes.NORMAL.value,
1725
- cartographicOrigin,
1726
- cartesianModelMatrix,
1727
- nodeMatrix: matrix,
1728
- indices,
1729
- attributeSpecificTransformation: transformVertexNormals,
1730
- useCartesianPositions: false
1731
- })
1732
- );
1733
- outputAttributes.texCoords = (0, import_loader_utils3.concatenateTypedArrays)(
1734
- outputAttributes.texCoords,
1735
- flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices)
1736
- );
1737
- outputAttributes.colors = (0, import_loader_utils3.concatenateTypedArrays)(
1738
- outputAttributes.colors,
1739
- flattenColors(attributes.COLOR_0, indices)
1740
- );
1620
+ outputAttributes.positions = (0, import_loader_utils3.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
1621
+ vertices: attributes.POSITION.value,
1622
+ cartographicOrigin,
1623
+ cartesianModelMatrix,
1624
+ nodeMatrix: matrix,
1625
+ indices,
1626
+ attributeSpecificTransformation: transformVertexPositions,
1627
+ useCartesianPositions
1628
+ }));
1629
+ outputAttributes.normals = (0, import_loader_utils3.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
1630
+ vertices: attributes.NORMAL && attributes.NORMAL.value,
1631
+ cartographicOrigin,
1632
+ cartesianModelMatrix,
1633
+ nodeMatrix: matrix,
1634
+ indices,
1635
+ attributeSpecificTransformation: transformVertexNormals,
1636
+ useCartesianPositions: false
1637
+ }));
1638
+ outputAttributes.texCoords = (0, import_loader_utils3.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
1639
+ outputAttributes.colors = (0, import_loader_utils3.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
1741
1640
  if (materialUvRegion) {
1742
- outputAttributes.uvRegions = (0, import_loader_utils3.concatenateTypedArrays)(
1743
- outputAttributes.uvRegions,
1744
- createUvRegion(materialUvRegion, indices)
1745
- );
1641
+ outputAttributes.uvRegions = (0, import_loader_utils3.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
1746
1642
  }
1747
1643
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
1748
- outputAttributes.featureIndicesGroups.push(
1749
- flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices)
1750
- );
1644
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
1751
1645
  }
1752
1646
  }
1753
1647
  function normalizeIndices(primitive) {
@@ -1802,10 +1696,7 @@ function transformVertexPositions(vertexVector, calleeArgs) {
1802
1696
  if (useCartesianPositions) {
1803
1697
  return vertexVector;
1804
1698
  }
1805
- import_geospatial3.Ellipsoid.WGS84.cartesianToCartographic(
1806
- [vertexVector[0], vertexVector[1], vertexVector[2]],
1807
- vertexVector
1808
- );
1699
+ import_geospatial3.Ellipsoid.WGS84.cartesianToCartographic([vertexVector[0], vertexVector[1], vertexVector[2]], vertexVector);
1809
1700
  vertexVector = vertexVector.subtract(cartographicOrigin);
1810
1701
  return vertexVector;
1811
1702
  }
@@ -1869,12 +1760,7 @@ function flattenBatchIds(batchedIds, indices) {
1869
1760
  return newBatchIds;
1870
1761
  }
1871
1762
  function getBatchIds(attributes, primitive, images, featureTexture) {
1872
- const batchIds = handleBatchIdsExtensions(
1873
- attributes,
1874
- primitive,
1875
- images,
1876
- featureTexture
1877
- );
1763
+ const batchIds = handleBatchIdsExtensions(attributes, primitive, images, featureTexture);
1878
1764
  if (batchIds.length) {
1879
1765
  return batchIds;
1880
1766
  }
@@ -1910,14 +1796,8 @@ async function mergeAllMaterials(materials) {
1910
1796
  }
1911
1797
  }
1912
1798
  if (newMaterial.texture && mergedIndices.length) {
1913
- const newWidth = (_a2 = newMaterial.mergedMaterials) == null ? void 0 : _a2.reduce(
1914
- (accum, { textureSize }) => accum + ((textureSize == null ? void 0 : textureSize.width) || 0),
1915
- 0
1916
- );
1917
- const newHeight = (_b = newMaterial.mergedMaterials) == null ? void 0 : _b.reduce(
1918
- (accum, { textureSize }) => Math.max(accum, (textureSize == null ? void 0 : textureSize.height) || 0),
1919
- 0
1920
- );
1799
+ const newWidth = (_a2 = newMaterial.mergedMaterials) == null ? void 0 : _a2.reduce((accum, { textureSize }) => accum + ((textureSize == null ? void 0 : textureSize.width) || 0), 0);
1800
+ const newHeight = (_b = newMaterial.mergedMaterials) == null ? void 0 : _b.reduce((accum, { textureSize }) => Math.max(accum, (textureSize == null ? void 0 : textureSize.height) || 0), 0);
1921
1801
  let currentX = -1;
1922
1802
  for (const aTextureMetadata of newMaterial.mergedMaterials) {
1923
1803
  if (aTextureMetadata.textureSize) {
@@ -1957,9 +1837,7 @@ async function mergeMaterials(material1, material2) {
1957
1837
  const sharpData = await joinImages([buffer1, buffer2], { direction: "horizontal" });
1958
1838
  material1.texture.bufferView.data = await sharpData.toFormat(material1.texture.mimeType === "image/png" ? "png" : "jpeg").toBuffer();
1959
1839
  } catch (error) {
1960
- console.log(
1961
- "Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)"
1962
- );
1840
+ console.log("Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)");
1963
1841
  throw error;
1964
1842
  }
1965
1843
  material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
@@ -1993,7 +1871,7 @@ function convertMaterial(sourceMaterial) {
1993
1871
  };
1994
1872
  }
1995
1873
  sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, import_uuid.v4)();
1996
- let mergedMaterials = [{ originalMaterialId: sourceMaterial.id }];
1874
+ const mergedMaterials = [{ originalMaterialId: sourceMaterial.id }];
1997
1875
  if (!texture) {
1998
1876
  const baseColorFactor = (_e = sourceMaterial == null ? void 0 : sourceMaterial.pbrMetallicRoughness) == null ? void 0 : _e.baseColorFactor;
1999
1877
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255)) || void 0;
@@ -2030,10 +1908,7 @@ function getSharedResources(gltfMaterials, nodeId) {
2030
1908
  }
2031
1909
  i3sResources.materialDefinitionInfos = [];
2032
1910
  for (const gltfMaterial of gltfMaterials) {
2033
- const { materialDefinitionInfo, textureDefinitionInfo } = convertGLTFMaterialToI3sSharedResources(
2034
- gltfMaterial,
2035
- nodeId
2036
- );
1911
+ const { materialDefinitionInfo, textureDefinitionInfo } = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId);
2037
1912
  i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
2038
1913
  if (textureDefinitionInfo) {
2039
1914
  i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
@@ -2056,10 +1931,7 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
2056
1931
  colorFactor[3] = colorFactor[3] || 1;
2057
1932
  }
2058
1933
  return {
2059
- materialDefinitionInfo: extractSharedResourcesMaterialInfo(
2060
- colorFactor || [1, 1, 1, 1],
2061
- metallicFactor
2062
- ),
1934
+ materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
2063
1935
  textureDefinitionInfo
2064
1936
  };
2065
1937
  }
@@ -2067,12 +1939,7 @@ function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 1)
2067
1939
  const matDielectricColorComponent = 0.04 / 255;
2068
1940
  const black = new import_core4.Vector4(0, 0, 0, 1);
2069
1941
  const unitVector = new import_core4.Vector4(1, 1, 1, 1);
2070
- const dielectricSpecular = new import_core4.Vector4(
2071
- matDielectricColorComponent,
2072
- matDielectricColorComponent,
2073
- matDielectricColorComponent,
2074
- 0
2075
- );
1942
+ const dielectricSpecular = new import_core4.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
2076
1943
  const baseColorVector = new import_core4.Vector4(baseColorFactor);
2077
1944
  const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
2078
1945
  const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
@@ -2196,13 +2063,7 @@ function generateAttributeBuffer(type, value) {
2196
2063
  function getAttributeType2(key, attributeStorageInfo) {
2197
2064
  const attribute = attributeStorageInfo.find((attr) => attr.name === key);
2198
2065
  if (!attribute) {
2199
- console.error(
2200
- `attribute is null, key=${key}, attributeStorageInfo=${JSON.stringify(
2201
- attributeStorageInfo,
2202
- null,
2203
- 2
2204
- )}`
2205
- );
2066
+ console.error(`attribute is null, key=${key}, attributeStorageInfo=${JSON.stringify(attributeStorageInfo, null, 2)}`);
2206
2067
  return "";
2207
2068
  }
2208
2069
  if (!attribute.attributeValues) {
@@ -2236,12 +2097,7 @@ function generateStringAttributeBuffer(batchAttributes) {
2236
2097
  stringBufferArray.push(currentStringBuffer);
2237
2098
  }
2238
2099
  const totalBytes = new Uint32Array([totalNumberOfBytes]);
2239
- return (0, import_loader_utils3.concatenateArrayBuffers)(
2240
- stringCountArray.buffer,
2241
- totalBytes.buffer,
2242
- stringSizesArray.buffer,
2243
- ...stringBufferArray
2244
- );
2100
+ return (0, import_loader_utils3.concatenateArrayBuffers)(stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer, ...stringBufferArray);
2245
2101
  }
2246
2102
  function generateBigUint64Array(featureIds) {
2247
2103
  const typedFeatureIds = new BigUint64Array(featureIds.length);
@@ -2256,9 +2112,7 @@ async function generateCompressedGeometry(vertexCount, convertedAttributes, attr
2256
2112
  for (let index = 0; index < indices.length; index++) {
2257
2113
  indices.set([index], index);
2258
2114
  }
2259
- const featureIndices = new Uint32Array(
2260
- convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount
2261
- );
2115
+ const featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
2262
2116
  const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
2263
2117
  const compressedAttributes = {
2264
2118
  positions,
@@ -2326,17 +2180,11 @@ function getPropertyTable(tileContent, metadataClass) {
2326
2180
  const { extensionName, extension } = getPropertyTableExtension(tileContent);
2327
2181
  switch (extensionName) {
2328
2182
  case import_gltf3.EXT_STRUCTURAL_METADATA: {
2329
- propertyTable = getPropertyTableFromExtStructuralMetadata(
2330
- extension,
2331
- metadataClass
2332
- );
2183
+ propertyTable = getPropertyTableFromExtStructuralMetadata(extension, metadataClass);
2333
2184
  return propertyTable;
2334
2185
  }
2335
2186
  case import_gltf3.EXT_FEATURE_METADATA: {
2336
- propertyTable = getPropertyTableFromExtFeatureMetadata(
2337
- extension,
2338
- metadataClass
2339
- );
2187
+ propertyTable = getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
2340
2188
  return propertyTable;
2341
2189
  }
2342
2190
  default:
@@ -2407,12 +2255,12 @@ function getPropertyTableExtension(tileContent) {
2407
2255
  return { extensionName, extension };
2408
2256
  }
2409
2257
 
2410
- // src/i3s-converter/helpers/create-scene-server-path.ts
2258
+ // dist/i3s-converter/helpers/create-scene-server-path.js
2411
2259
  var import_uuid2 = require("uuid");
2412
2260
  var import_json_map_transform2 = __toESM(require("json-map-transform"), 1);
2413
2261
  var import_path4 = require("path");
2414
2262
 
2415
- // src/i3s-converter/json-templates/scene-server.ts
2263
+ // dist/i3s-converter/json-templates/scene-server.js
2416
2264
  var SCENE_SERVER = () => ({
2417
2265
  serviceItemId: {
2418
2266
  path: "serviceItemId"
@@ -2441,7 +2289,7 @@ var SCENE_SERVER = () => ({
2441
2289
  }
2442
2290
  });
2443
2291
 
2444
- // src/i3s-converter/helpers/create-scene-server-path.ts
2292
+ // dist/i3s-converter/helpers/create-scene-server-path.js
2445
2293
  async function createSceneServerPath(layerName, layers0, rootPath) {
2446
2294
  const sceneServerData = {
2447
2295
  serviceItemId: (0, import_uuid2.v4)().replace(/-/gi, ""),
@@ -2453,7 +2301,7 @@ async function createSceneServerPath(layerName, layers0, rootPath) {
2453
2301
  await writeFile(nodePagePath, JSON.stringify(sceneServer));
2454
2302
  }
2455
2303
 
2456
- // src/lib/utils/lod-conversion-utils.ts
2304
+ // dist/lib/utils/lod-conversion-utils.js
2457
2305
  var DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
2458
2306
  function convertGeometricErrorToScreenThreshold(tile, coordinates) {
2459
2307
  const lodSelection = [];
@@ -2478,14 +2326,10 @@ function convertGeometricErrorToScreenThreshold(tile, coordinates) {
2478
2326
  }
2479
2327
  function convertScreenThresholdToGeometricError(node) {
2480
2328
  var _a2, _b;
2481
- const metricData = (_a2 = node.lodSelection) == null ? void 0 : _a2.find(
2482
- (metric) => metric.metricType === "maxScreenThreshold"
2483
- );
2329
+ const metricData = (_a2 = node.lodSelection) == null ? void 0 : _a2.find((metric) => metric.metricType === "maxScreenThreshold");
2484
2330
  let maxError = metricData == null ? void 0 : metricData.maxError;
2485
2331
  if (!maxError) {
2486
- const sqMetricData = (_b = node.lodSelection) == null ? void 0 : _b.find(
2487
- (metric) => metric.metricType === "maxScreenThresholdSQ"
2488
- );
2332
+ const sqMetricData = (_b = node.lodSelection) == null ? void 0 : _b.find((metric) => metric.metricType === "maxScreenThresholdSQ");
2489
2333
  if (sqMetricData) {
2490
2334
  maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
2491
2335
  }
@@ -2496,9 +2340,9 @@ function convertScreenThresholdToGeometricError(node) {
2496
2340
  return node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
2497
2341
  }
2498
2342
 
2499
- // src/pgm-loader.ts
2343
+ // dist/pgm-loader.js
2500
2344
  var import_geoid = require("@math.gl/geoid");
2501
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2345
+ var VERSION = true ? "4.2.0-alpha.5" : "latest";
2502
2346
  var PGMLoader = {
2503
2347
  name: "PGM - Netpbm grayscale image format",
2504
2348
  id: "pgm",
@@ -2514,10 +2358,10 @@ var PGMLoader = {
2514
2358
  }
2515
2359
  };
2516
2360
 
2517
- // src/i3s-converter/json-templates/layers.ts
2361
+ // dist/i3s-converter/json-templates/layers.js
2518
2362
  var import_json_map_transform3 = __toESM(require("json-map-transform"), 1);
2519
2363
 
2520
- // src/i3s-converter/json-templates/store.ts
2364
+ // dist/i3s-converter/json-templates/store.js
2521
2365
  var STORE = {
2522
2366
  id: {
2523
2367
  path: "id",
@@ -2619,7 +2463,7 @@ var STORE = {
2619
2463
  }
2620
2464
  };
2621
2465
 
2622
- // src/i3s-converter/json-templates/layers.ts
2466
+ // dist/i3s-converter/json-templates/layers.js
2623
2467
  var SPATIAL_REFERENCE = () => ({
2624
2468
  wkid: {
2625
2469
  path: "wkid",
@@ -2751,7 +2595,7 @@ var LAYERS = () => ({
2751
2595
  }
2752
2596
  });
2753
2597
 
2754
- // src/i3s-converter/json-templates/geometry-definitions.ts
2598
+ // dist/i3s-converter/json-templates/geometry-definitions.js
2755
2599
  var import_json_map_transform4 = __toESM(require("json-map-transform"), 1);
2756
2600
  var PLAIN_GEOMETRY_DEFINITION = () => ({
2757
2601
  offset: {
@@ -2833,7 +2677,7 @@ var GEOMETRY_DEFINITION = () => ({
2833
2677
  }
2834
2678
  });
2835
2679
 
2836
- // src/i3s-converter/json-templates/shared-resources.ts
2680
+ // dist/i3s-converter/json-templates/shared-resources.js
2837
2681
  var import_json_map_transform5 = __toESM(require("json-map-transform"), 1);
2838
2682
  var MATERIAL_DEFINITION_INFO_PARAMS = () => ({
2839
2683
  renderMode: {
@@ -2940,10 +2784,7 @@ var SHARED_RESOURCES = () => ({
2940
2784
  function transfromMaterialDefinitions(materialDefinitionInfos, thisObject, originalObject) {
2941
2785
  const result = {};
2942
2786
  for (const [index, materialDefinitionInfo] of materialDefinitionInfos.entries()) {
2943
- result[`Mat${originalObject.nodePath}${index}`] = (0, import_json_map_transform5.default)(
2944
- materialDefinitionInfo,
2945
- MATERIAL_DEFINITION_INFO()
2946
- );
2787
+ result[`Mat${originalObject.nodePath}${index}`] = (0, import_json_map_transform5.default)(materialDefinitionInfo, MATERIAL_DEFINITION_INFO());
2947
2788
  }
2948
2789
  return result;
2949
2790
  }
@@ -2960,7 +2801,7 @@ function transfromTextureDefinitions(textureDefinitionInfos, thisObject, origina
2960
2801
  return result;
2961
2802
  }
2962
2803
 
2963
- // src/i3s-converter/helpers/node-debug.ts
2804
+ // dist/i3s-converter/helpers/node-debug.js
2964
2805
  var import_culling2 = require("@math.gl/culling");
2965
2806
  var import_core6 = require("@math.gl/core");
2966
2807
  var import_geospatial4 = require("@math.gl/geospatial");
@@ -3082,11 +2923,7 @@ function getTileObbVertices(node) {
3082
2923
  const obbCenterCartesian = import_geospatial4.Ellipsoid.WGS84.cartographicToCartesian(node.obb.center);
3083
2924
  let vertices = [];
3084
2925
  for (let i = 0; i < positions.length; i += 3) {
3085
- const positionsVector = new import_core6.Vector3(
3086
- positions[i] *= halfSize[0],
3087
- positions[i + 1] *= halfSize[1],
3088
- positions[i + 2] *= halfSize[2]
3089
- );
2926
+ const positionsVector = new import_core6.Vector3(positions[i] *= halfSize[0], positions[i + 1] *= halfSize[1], positions[i + 2] *= halfSize[2]);
3090
2927
  const rotatedPositions = positionsVector.transformByQuaternion(node.obb.quaternion).add(obbCenterCartesian);
3091
2928
  vertices = vertices.concat(rotatedPositions);
3092
2929
  }
@@ -3106,12 +2943,12 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
3106
2943
  return isVerticesInsideObb;
3107
2944
  }
3108
2945
 
3109
- // src/i3s-converter/i3s-converter.ts
2946
+ // dist/i3s-converter/i3s-converter.js
3110
2947
  var import_textures = require("@loaders.gl/textures");
3111
2948
  var import_images = require("@loaders.gl/images");
3112
2949
  var import_worker_utils = require("@loaders.gl/worker-utils");
3113
2950
 
3114
- // src/lib/utils/queue.ts
2951
+ // dist/lib/utils/queue.js
3115
2952
  var Queue = class extends Array {
3116
2953
  enqueue(val) {
3117
2954
  this.push(val);
@@ -3127,14 +2964,19 @@ var Queue = class extends Array {
3127
2964
  }
3128
2965
  };
3129
2966
 
3130
- // src/lib/utils/write-queue.ts
2967
+ // dist/lib/utils/write-queue.js
3131
2968
  var import_process = __toESM(require("process"), 1);
3132
2969
  var MEMORY_LIMIT = 4 * 1024 * 1024 * 1024;
3133
2970
  var WriteQueue = class extends Queue {
2971
+ intervalId;
2972
+ // eslint-disable-line no-undef
2973
+ conversionDump;
2974
+ writePromise = null;
2975
+ fileMap = {};
2976
+ listeningInterval;
2977
+ writeConcurrency;
3134
2978
  constructor(conversionDump, listeningInterval = 2e3, writeConcurrency = 400) {
3135
2979
  super();
3136
- this.writePromise = null;
3137
- this.fileMap = {};
3138
2980
  this.conversionDump = conversionDump;
3139
2981
  this.listeningInterval = listeningInterval;
3140
2982
  this.writeConcurrency = writeConcurrency;
@@ -3154,7 +2996,7 @@ var WriteQueue = class extends Queue {
3154
2996
  }
3155
2997
  }
3156
2998
  startListening() {
3157
- this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
2999
+ this.intervalId = setInterval(() => this.startWrite.bind(this), this.listeningInterval);
3158
3000
  }
3159
3001
  stopListening() {
3160
3002
  if (this.intervalId) {
@@ -3203,16 +3045,16 @@ var WriteQueue = class extends Queue {
3203
3045
  }
3204
3046
  };
3205
3047
 
3206
- // src/constants.ts
3048
+ // dist/constants.js
3207
3049
  var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
3208
3050
  var DUMP_FILE_SUFFIX = ".dump.json";
3209
3051
 
3210
- // src/i3s-converter/helpers/node-index-document.ts
3052
+ // dist/i3s-converter/helpers/node-index-document.js
3211
3053
  var import_path5 = require("path");
3212
3054
  var import_json_map_transform7 = __toESM(require("json-map-transform"), 1);
3213
3055
  var import_uuid3 = require("uuid");
3214
3056
 
3215
- // src/i3s-converter/json-templates/node.ts
3057
+ // dist/i3s-converter/json-templates/node.js
3216
3058
  var import_json_map_transform6 = __toESM(require("json-map-transform"), 1);
3217
3059
  var COORDINATES = () => ({
3218
3060
  mbs: {
@@ -3296,30 +3138,36 @@ var NODE = () => ({
3296
3138
  }
3297
3139
  });
3298
3140
 
3299
- // src/i3s-converter/helpers/node-index-document.ts
3141
+ // dist/i3s-converter/helpers/node-index-document.js
3300
3142
  var NodeIndexDocument = class {
3143
+ /** Node id */
3144
+ id;
3145
+ /** Id in node pages */
3146
+ inPageId;
3147
+ /** 3DNodeIndexDocument data */
3148
+ data = null;
3149
+ /** children */
3150
+ children = [];
3151
+ /** converter instance */
3152
+ converter;
3153
+ /**
3154
+ * Finalized property. It means that all child nodes are saved and their data
3155
+ * is unloaded
3156
+ */
3157
+ _finalized = false;
3158
+ get finalized() {
3159
+ return this._finalized;
3160
+ }
3301
3161
  /**
3302
3162
  * Constructor
3303
3163
  * @param id - id of the node in node pages
3304
3164
  * @param converter - converter instance
3305
3165
  */
3306
3166
  constructor(id, converter) {
3307
- /** 3DNodeIndexDocument data */
3308
- this.data = null;
3309
- /** children */
3310
- this.children = [];
3311
- /**
3312
- * Finalized property. It means that all child nodes are saved and their data
3313
- * is unloaded
3314
- */
3315
- this._finalized = false;
3316
3167
  this.inPageId = id;
3317
3168
  this.id = id === 0 ? "root" : id.toString();
3318
3169
  this.converter = converter;
3319
3170
  }
3320
- get finalized() {
3321
- return this._finalized;
3322
- }
3323
3171
  /**
3324
3172
  * Add Node3DIndexDocument data to the node
3325
3173
  * @param data Node3DIndexDocument data
@@ -3381,9 +3229,7 @@ var NodeIndexDocument = class {
3381
3229
  childNodeData.neighbors.push({ ...neighbor });
3382
3230
  }
3383
3231
  } else {
3384
- console.warn(
3385
- `Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`
3386
- );
3232
+ console.warn(`Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`);
3387
3233
  delete childNodeData.neighbors;
3388
3234
  }
3389
3235
  if (this.converter.options.instantNodeWriting && childNodeData) {
@@ -3413,24 +3259,12 @@ var NodeIndexDocument = class {
3413
3259
  async write(node) {
3414
3260
  const path = (0, import_path5.join)(this.converter.layers0Path, "nodes", this.id);
3415
3261
  if (this.converter.options.slpk) {
3416
- await this.converter.writeQueue.enqueue(
3417
- {
3418
- archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
3419
- writePromise: () => writeFileForSlpk(
3420
- path,
3421
- JSON.stringify(node),
3422
- "3dNodeIndexDocument.json",
3423
- true,
3424
- this.converter.compressList
3425
- )
3426
- },
3427
- true
3428
- );
3262
+ await this.converter.writeQueue.enqueue({
3263
+ archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
3264
+ writePromise: () => writeFileForSlpk(path, JSON.stringify(node), "3dNodeIndexDocument.json", true, this.converter.compressList)
3265
+ }, true);
3429
3266
  } else {
3430
- await this.converter.writeQueue.enqueue(
3431
- { writePromise: () => writeFile(path, JSON.stringify(node)) },
3432
- true
3433
- );
3267
+ await this.converter.writeQueue.enqueue({ writePromise: () => writeFile(path, JSON.stringify(node)) }, true);
3434
3268
  }
3435
3269
  }
3436
3270
  /**
@@ -3476,14 +3310,8 @@ var NodeIndexDocument = class {
3476
3310
  * @param converter - I3SConverter instance
3477
3311
  * @returns NodeIndexDocument instance
3478
3312
  */
3479
- static async createNode(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
3480
- const data = await NodeIndexDocument.createNodeIndexDocument(
3481
- parentNode,
3482
- boundingVolumes,
3483
- lodSelection,
3484
- nodeInPage,
3485
- resources
3486
- );
3313
+ static async createNode({ parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter }) {
3314
+ const data = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
3487
3315
  const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);
3488
3316
  return node;
3489
3317
  }
@@ -3523,6 +3351,7 @@ var NodeIndexDocument = class {
3523
3351
  * @param resources.attributes - feature attributes
3524
3352
  * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
3525
3353
  */
3354
+ // eslint-disable-next-line complexity
3526
3355
  static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
3527
3356
  var _a2, _b, _c, _d, _e;
3528
3357
  const nodeId = nodeInPage.index;
@@ -3563,7 +3392,7 @@ var NodeIndexDocument = class {
3563
3392
  }
3564
3393
  };
3565
3394
 
3566
- // src/i3s-converter/helpers/load-3d-tiles.ts
3395
+ // dist/i3s-converter/helpers/load-3d-tiles.js
3567
3396
  var import_d_tiles = require("@loaders.gl/3d-tiles");
3568
3397
  var import_core7 = require("@loaders.gl/core");
3569
3398
  var import_loader_utils4 = require("@loaders.gl/loader-utils");
@@ -3580,11 +3409,7 @@ var loadNestedTileset = async (sourceTileset, sourceTile, tilesetLoadOptions) =>
3580
3409
  assetGltfUpAxis: sourceTileset.asset && sourceTileset.asset.gltfUpAxis || "Y"
3581
3410
  }
3582
3411
  };
3583
- const tileContent = await loadFromArchive(
3584
- sourceTile.contentUrl,
3585
- sourceTileset.loader,
3586
- loadOptions
3587
- );
3412
+ const tileContent = await loadFromArchive(sourceTile.contentUrl, sourceTileset.loader, loadOptions);
3588
3413
  if (tileContent.root) {
3589
3414
  sourceTile.children = [tileContent.root];
3590
3415
  }
@@ -3603,11 +3428,7 @@ var loadTile3DContent = async (sourceTileset, sourceTile, tilesetLoadOptions) =>
3603
3428
  assetGltfUpAxis: sourceTileset.asset && sourceTileset.asset.gltfUpAxis || "Y"
3604
3429
  }
3605
3430
  };
3606
- const tileContent = await loadFromArchive(
3607
- sourceTile.contentUrl,
3608
- sourceTileset.loader,
3609
- loadOptions
3610
- );
3431
+ const tileContent = await loadFromArchive(sourceTile.contentUrl, sourceTileset.loader, loadOptions);
3611
3432
  return tileContent;
3612
3433
  };
3613
3434
  async function loadFromArchive(url, loader, loadOptions) {
@@ -3646,29 +3467,23 @@ async function loadHashTable(fileProvider) {
3646
3467
  const hashCDOffset = await (0, import_zip.searchFromTheEnd)(fileProvider, import_zip.CD_HEADER_SIGNATURE);
3647
3468
  const cdFileHeader = await (0, import_zip.parseZipCDFileHeader)(hashCDOffset, fileProvider);
3648
3469
  if ((cdFileHeader == null ? void 0 : cdFileHeader.fileName) === "@3dtilesIndex1@") {
3649
- const localFileHeader = await (0, import_zip.parseZipLocalFileHeader)(
3650
- cdFileHeader.localHeaderOffset,
3651
- fileProvider
3652
- );
3470
+ const localFileHeader = await (0, import_zip.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
3653
3471
  if (!localFileHeader) {
3654
3472
  throw new Error("corrupted 3tz");
3655
3473
  }
3656
3474
  const fileDataOffset = localFileHeader.fileDataOffset;
3657
- const hashFile = await fileProvider.slice(
3658
- fileDataOffset,
3659
- fileDataOffset + localFileHeader.compressedSize
3660
- );
3475
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
3661
3476
  hashTable = (0, import_zip.parseHashTable)(hashFile);
3662
3477
  }
3663
3478
  return hashTable;
3664
3479
  }
3665
3480
 
3666
- // src/i3s-converter/i3s-converter.ts
3481
+ // dist/i3s-converter/i3s-converter.js
3667
3482
  var import_core10 = require("@math.gl/core");
3668
3483
  var import_tiles = require("@loaders.gl/tiles");
3669
3484
 
3670
- // src/i3s-converter/helpers/tileset-traversal.ts
3671
- var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0) => {
3485
+ // dist/i3s-converter/helpers/tileset-traversal.js
3486
+ var traverseDatasetWith = async ({ tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0 }) => {
3672
3487
  if (maxDepth && level > maxDepth) {
3673
3488
  return;
3674
3489
  }
@@ -3676,36 +3491,38 @@ var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessT
3676
3491
  const newTraversalProps = await processTile(tile, traversalProps);
3677
3492
  processResults.push(newTraversalProps);
3678
3493
  for (const childTile of tile.children) {
3679
- await traverseDatasetWith(
3680
- childTile,
3681
- newTraversalProps,
3494
+ await traverseDatasetWith({
3495
+ tile: childTile,
3496
+ traversalProps: newTraversalProps,
3682
3497
  processTile,
3683
3498
  postprocessTile,
3684
3499
  maxDepth,
3685
- level + 1
3686
- );
3500
+ level: level + 1
3501
+ });
3502
+ }
3503
+ if (postprocessTile) {
3504
+ await postprocessTile(processResults, traversalProps);
3687
3505
  }
3688
- postprocessTile && await postprocessTile(processResults, traversalProps);
3689
3506
  };
3690
3507
 
3691
- // src/i3s-converter/helpers/preprocess-3d-tiles.ts
3508
+ // dist/i3s-converter/helpers/preprocess-3d-tiles.js
3692
3509
  var import_gltf4 = require("@loaders.gl/gltf");
3693
3510
  var import_core8 = require("@loaders.gl/core");
3694
3511
  var import_gltf5 = require("@loaders.gl/gltf");
3695
3512
  var GLTF_PRIMITIVE_MODES = [
3696
- "POINTS" /* POINTS */,
3513
+ GLTFPrimitiveModeString.POINTS,
3697
3514
  // 0
3698
- "LINES" /* LINES */,
3515
+ GLTFPrimitiveModeString.LINES,
3699
3516
  // 1
3700
- "LINE_LOOP" /* LINE_LOOP */,
3517
+ GLTFPrimitiveModeString.LINE_LOOP,
3701
3518
  // 2
3702
- "LINE_STRIP" /* LINE_STRIP */,
3519
+ GLTFPrimitiveModeString.LINE_STRIP,
3703
3520
  // 3
3704
- "TRIANGLES" /* TRIANGLES */,
3521
+ GLTFPrimitiveModeString.TRIANGLES,
3705
3522
  // 4
3706
- "TRIANGLE_STRIP" /* TRIANGLE_STRIP */,
3523
+ GLTFPrimitiveModeString.TRIANGLE_STRIP,
3707
3524
  // 5
3708
- "TRIANGLE_FAN" /* TRIANGLE_FAN */
3525
+ GLTFPrimitiveModeString.TRIANGLE_FAN
3709
3526
  // 6
3710
3527
  ];
3711
3528
  var analyzeTileContent = async (tileContent) => {
@@ -3769,29 +3586,33 @@ var mergePreprocessData = (object1, object2) => {
3769
3586
  }
3770
3587
  };
3771
3588
 
3772
- // src/i3s-converter/helpers/progress.ts
3589
+ // dist/i3s-converter/helpers/progress.js
3773
3590
  var import_process2 = __toESM(require("process"), 1);
3774
3591
  var THRESHOLD_DEFAULT = 0.2;
3775
3592
  var Progress = class {
3593
+ /** Total amount of work, e.g. number of files to save or number of bytes to send */
3594
+ _stepsTotal = 0;
3595
+ /** Amount of work already done */
3596
+ _stepsDone = 0;
3597
+ /** Time in milli-seconds when the process started */
3598
+ startTime = 0;
3599
+ /** Time in milli-seconds when the process stopped */
3600
+ stopTime = 0;
3601
+ /** Time in milli-seconds when stepsDone was updated */
3602
+ timeOfUpdatingStepsDone = 0;
3603
+ /** Time in milli-seconds spent for performing one step*/
3604
+ milliSecForOneStep = 0;
3605
+ trust = false;
3606
+ /**
3607
+ * The number of digits to appear after decimal point in the string representation of the count of steps already done.
3608
+ * It's calculated based on the total count of steps.
3609
+ */
3610
+ numberOfDigitsInPercentage = 0;
3611
+ /** Defines a threshold that is used to check if the process velocity can be consifered trust. */
3612
+ threshold;
3613
+ /** Function that is used to get the time stamp */
3614
+ getTime;
3776
3615
  constructor(options = {}) {
3777
- /** Total amount of work, e.g. number of files to save or number of bytes to send */
3778
- this._stepsTotal = 0;
3779
- /** Amount of work already done */
3780
- this._stepsDone = 0;
3781
- /** Time in milli-seconds when the process started */
3782
- this.startTime = 0;
3783
- /** Time in milli-seconds when the process stopped */
3784
- this.stopTime = 0;
3785
- /** Time in milli-seconds when stepsDone was updated */
3786
- this.timeOfUpdatingStepsDone = 0;
3787
- /** Time in milli-seconds spent for performing one step*/
3788
- this.milliSecForOneStep = 0;
3789
- this.trust = false;
3790
- /**
3791
- * The number of digits to appear after decimal point in the string representation of the count of steps already done.
3792
- * It's calculated based on the total count of steps.
3793
- */
3794
- this.numberOfDigitsInPercentage = 0;
3795
3616
  this.getTime = options.getTime || import_process2.default.hrtime.bigint;
3796
3617
  this.threshold = options.threshold || THRESHOLD_DEFAULT;
3797
3618
  }
@@ -3907,16 +3728,16 @@ var Progress = class {
3907
3728
  }
3908
3729
  };
3909
3730
 
3910
- // src/i3s-converter/i3s-converter.ts
3731
+ // dist/i3s-converter/i3s-converter.js
3911
3732
  var import_zip2 = require("@loaders.gl/zip");
3912
3733
 
3913
- // src/lib/utils/conversion-dump.ts
3734
+ // dist/lib/utils/conversion-dump.js
3914
3735
  var import_util = require("util");
3915
3736
  var import_path6 = require("path");
3916
3737
  var import_process3 = __toESM(require("process"), 1);
3917
3738
  var import_ajv = __toESM(require("ajv"), 1);
3918
3739
 
3919
- // src/lib/json-schemas/conversion-dump-json-schema.ts
3740
+ // dist/lib/json-schemas/conversion-dump-json-schema.js
3920
3741
  var dumpJsonSchema = {
3921
3742
  type: "object",
3922
3743
  properties: {
@@ -4203,11 +4024,21 @@ var dumpJsonSchema = {
4203
4024
  }
4204
4025
  };
4205
4026
 
4206
- // src/lib/utils/conversion-dump.ts
4027
+ // dist/lib/utils/conversion-dump.js
4207
4028
  var ConversionDump = class {
4029
+ /** Restored/resumed dump indicator */
4030
+ restored = false;
4031
+ /** Conversion options */
4032
+ options;
4033
+ /** Tiles conversion progress status map */
4034
+ tilesConverted;
4035
+ /** Textures formats definitions */
4036
+ textureSetDefinitions;
4037
+ /** Attributes Metadata */
4038
+ attributeMetadataInfo;
4039
+ /** Array of materials definitions */
4040
+ materialDefinitions;
4208
4041
  constructor() {
4209
- /**Restored/resumed dump indicator */
4210
- this.restored = false;
4211
4042
  this.tilesConverted = {};
4212
4043
  }
4213
4044
  /**
@@ -4215,21 +4046,7 @@ var ConversionDump = class {
4215
4046
  * @param currentOptions - converter options
4216
4047
  */
4217
4048
  async createDump(currentOptions) {
4218
- const {
4219
- tilesetName,
4220
- slpk,
4221
- egmFilePath,
4222
- inputUrl,
4223
- outputPath,
4224
- draco = true,
4225
- maxDepth,
4226
- token,
4227
- generateTextures,
4228
- generateBoundingVolumes,
4229
- mergeMaterials: mergeMaterials2 = true,
4230
- metadataClass,
4231
- analyze = false
4232
- } = currentOptions;
4049
+ const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials: mergeMaterials2 = true, metadataClass, analyze = false } = currentOptions;
4233
4050
  this.options = {
4234
4051
  tilesetName,
4235
4052
  slpk,
@@ -4245,24 +4062,11 @@ var ConversionDump = class {
4245
4062
  metadataClass,
4246
4063
  analyze
4247
4064
  };
4248
- const dumpFilename = (0, import_path6.join)(
4249
- this.options.outputPath,
4250
- this.options.tilesetName,
4251
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
4252
- );
4065
+ const dumpFilename = (0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
4253
4066
  if (await isFileExists(dumpFilename)) {
4254
4067
  try {
4255
- const dump = await openJson(
4256
- (0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
4257
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
4258
- );
4259
- const {
4260
- options,
4261
- tilesConverted,
4262
- textureSetDefinitions,
4263
- attributeMetadataInfo,
4264
- materialDefinitions
4265
- } = dump;
4068
+ const dump = await openJson((0, import_path6.join)(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
4069
+ const { options, tilesConverted, textureSetDefinitions, attributeMetadataInfo, materialDefinitions } = dump;
4266
4070
  const ajv = new import_ajv.default();
4267
4071
  const dumpJsonValidate = ajv.compile(dumpJsonSchema);
4268
4072
  const isDumpValid = dumpJsonValidate(dump);
@@ -4304,29 +4108,14 @@ var ConversionDump = class {
4304
4108
  if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName) {
4305
4109
  try {
4306
4110
  const time = import_process3.default.hrtime();
4307
- await writeFile(
4308
- (0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
4309
- JSON.stringify({
4310
- options: this.options,
4311
- tilesConverted: this.tilesConverted,
4312
- textureSetDefinitions: this.textureSetDefinitions,
4313
- attributeMetadataInfo: this.attributeMetadataInfo,
4314
- materialDefinitions: this.materialDefinitions
4315
- }),
4316
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`
4317
- );
4318
- await renameFile(
4319
- (0, import_path6.join)(
4320
- this.options.outputPath,
4321
- this.options.tilesetName,
4322
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`
4323
- ),
4324
- (0, import_path6.join)(
4325
- this.options.outputPath,
4326
- this.options.tilesetName,
4327
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
4328
- )
4329
- );
4111
+ await writeFile((0, import_path6.join)(this.options.outputPath, this.options.tilesetName), JSON.stringify({
4112
+ options: this.options,
4113
+ tilesConverted: this.tilesConverted,
4114
+ textureSetDefinitions: this.textureSetDefinitions,
4115
+ attributeMetadataInfo: this.attributeMetadataInfo,
4116
+ materialDefinitions: this.materialDefinitions
4117
+ }), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`);
4118
+ await renameFile((0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`), (0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
4330
4119
  } catch (error) {
4331
4120
  console.log("Can't update dump file", error);
4332
4121
  }
@@ -4337,20 +4126,8 @@ var ConversionDump = class {
4337
4126
  */
4338
4127
  async deleteDumpFile() {
4339
4128
  var _a2;
4340
- if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName && await isFileExists(
4341
- (0, import_path6.join)(
4342
- this.options.outputPath,
4343
- this.options.tilesetName,
4344
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
4345
- )
4346
- )) {
4347
- await removeFile(
4348
- (0, import_path6.join)(
4349
- this.options.outputPath,
4350
- this.options.tilesetName,
4351
- `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
4352
- )
4353
- );
4129
+ if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName && await isFileExists((0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`))) {
4130
+ await removeFile((0, import_path6.join)(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
4354
4131
  }
4355
4132
  }
4356
4133
  /**
@@ -4405,9 +4182,7 @@ var ConversionDump = class {
4405
4182
  */
4406
4183
  updateDoneStatus(filename, nodeId, resourceType, value) {
4407
4184
  var _a2;
4408
- const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find(
4409
- (element) => element.nodeId === nodeId
4410
- );
4185
+ const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find((element) => element.nodeId === nodeId);
4411
4186
  if (nodeDump) {
4412
4187
  if (!nodeDump.progress) {
4413
4188
  nodeDump.progress = {};
@@ -4427,27 +4202,38 @@ var ConversionDump = class {
4427
4202
  for (let i = 0; i < changedRecords.length; i++) {
4428
4203
  if (changedRecords[i] && "value" in writeResults[i]) {
4429
4204
  const { sourceId, resourceType, outputId } = changedRecords[i];
4430
- if (!sourceId || !resourceType || !outputId)
4431
- continue;
4432
- for (const node of this.tilesConverted[sourceId].nodes) {
4433
- if (node.nodeId === outputId && node.progress) {
4434
- node.progress[resourceType] = true;
4435
- let done = false;
4436
- for (const key in node.progress) {
4437
- done = node.progress[key];
4438
- if (!done)
4439
- break;
4440
- }
4441
- node.done = done;
4442
- if (node.done) {
4443
- delete node.progress;
4444
- }
4205
+ this.updateNodes(sourceId, outputId, resourceType);
4206
+ }
4207
+ }
4208
+ await this.updateDumpFile();
4209
+ }
4210
+ /**
4211
+ * Update done status for a node
4212
+ * @param sourceId - source resource Id
4213
+ * @param outputId - output node/tile Id
4214
+ * @param resourceType - type of resource
4215
+ * @returns void
4216
+ */
4217
+ updateNodes(sourceId, outputId, resourceType) {
4218
+ if (!sourceId || !resourceType || !outputId) {
4219
+ return;
4220
+ }
4221
+ for (const node of this.tilesConverted[sourceId].nodes) {
4222
+ if (node.nodeId === outputId && node.progress) {
4223
+ node.progress[resourceType] = true;
4224
+ let done = false;
4225
+ for (const key in node.progress) {
4226
+ done = node.progress[key];
4227
+ if (!done)
4445
4228
  break;
4446
- }
4447
4229
  }
4230
+ node.done = done;
4231
+ if (node.done) {
4232
+ delete node.progress;
4233
+ }
4234
+ break;
4448
4235
  }
4449
4236
  }
4450
- await this.updateDumpFile();
4451
4237
  }
4452
4238
  /**
4453
4239
  * Update 3d-tiles-converter dump file
@@ -4457,9 +4243,7 @@ var ConversionDump = class {
4457
4243
  */
4458
4244
  async updateConvertedNodesDumpFile(filename, nodeId, done) {
4459
4245
  var _a2;
4460
- const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find(
4461
- (element) => element.nodeId === nodeId
4462
- );
4246
+ const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find((element) => element.nodeId === nodeId);
4463
4247
  if (nodeDump) {
4464
4248
  nodeDump.done = done;
4465
4249
  await this.updateDumpFile();
@@ -4490,7 +4274,7 @@ var ConversionDump = class {
4490
4274
  }
4491
4275
  };
4492
4276
 
4493
- // src/i3s-converter/i3s-converter.ts
4277
+ // dist/i3s-converter/i3s-converter.js
4494
4278
  var _a;
4495
4279
  var ION_DEFAULT_TOKEN = (_a = import_process4.default.env) == null ? void 0 : _a.IonToken;
4496
4280
  var HARDCODED_NODES_PER_PAGE = 64;
@@ -4500,35 +4284,52 @@ var REFRESH_TOKEN_TIMEOUT = 1800;
4500
4284
  var CESIUM_DATASET_PREFIX = "https://";
4501
4285
  var PROGRESS_PHASE1_COUNT = "phase1-count";
4502
4286
  var I3SConverter = class {
4503
- constructor() {
4504
- this.boundingVolumeWarnings = [];
4505
- this.conversionStartTime = [0, 0];
4506
- this.refreshTokenTime = [0, 0];
4507
- this.sourceTileset = null;
4508
- this.loadOptions = {
4509
- _nodeWorkers: true,
4510
- reuseWorkers: true,
4511
- useLocalLibraries: true,
4512
- basis: {
4513
- format: "rgba32",
4514
- // We need to load local fs workers because nodejs can't load workers from the Internet
4515
- workerUrl: "./modules/textures/dist/basis-worker-node.js"
4516
- },
4287
+ attributeMetadataInfo;
4288
+ nodePages;
4289
+ options;
4290
+ layers0Path;
4291
+ materialMap;
4292
+ materialDefinitions;
4293
+ geometryMap;
4294
+ geometryConfigs;
4295
+ vertexCounter;
4296
+ layers0;
4297
+ featuresHashArray;
4298
+ refinementCounter;
4299
+ validate;
4300
+ boundingVolumeWarnings = [];
4301
+ conversionStartTime = [0, 0];
4302
+ refreshTokenTime = [0, 0];
4303
+ sourceTileset = null;
4304
+ loadOptions = {
4305
+ _nodeWorkers: true,
4306
+ reuseWorkers: true,
4307
+ useLocalLibraries: true,
4308
+ basis: {
4309
+ format: "rgba32",
4517
4310
  // We need to load local fs workers because nodejs can't load workers from the Internet
4518
- draco: { workerUrl: "./modules/draco/dist/draco-worker-node.js" },
4519
- fetch: {},
4520
- modules: {}
4521
- };
4522
- this.geoidHeightModel = null;
4523
- this.Loader = import_d_tiles2.Tiles3DLoader;
4524
- this.workerSource = {};
4525
- this.writeQueue = new WriteQueue(new ConversionDump());
4526
- this.compressList = null;
4527
- this.preprocessData = {
4528
- meshTopologyTypes: /* @__PURE__ */ new Set(),
4529
- metadataClasses: /* @__PURE__ */ new Set()
4530
- };
4531
- this.progresses = {};
4311
+ workerUrl: "./modules/textures/dist/basis-worker-node.js"
4312
+ },
4313
+ // We need to load local fs workers because nodejs can't load workers from the Internet
4314
+ draco: { workerUrl: "./modules/draco/dist/draco-worker-node.js" },
4315
+ fetch: {},
4316
+ modules: {}
4317
+ };
4318
+ geoidHeightModel = null;
4319
+ Loader = import_d_tiles2.Tiles3DLoader;
4320
+ generateTextures;
4321
+ generateBoundingVolumes;
4322
+ layersHasTexture;
4323
+ workerSource = {};
4324
+ writeQueue = new WriteQueue(new ConversionDump());
4325
+ compressList = null;
4326
+ preprocessData = {
4327
+ meshTopologyTypes: /* @__PURE__ */ new Set(),
4328
+ metadataClasses: /* @__PURE__ */ new Set()
4329
+ };
4330
+ progresses = {};
4331
+ conversionDump;
4332
+ constructor() {
4532
4333
  this.attributeMetadataInfo = new AttributeMetadataInfo();
4533
4334
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
4534
4335
  this.options = {};
@@ -4568,31 +4369,14 @@ var I3SConverter = class {
4568
4369
  * @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes
4569
4370
  * @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed
4570
4371
  */
4372
+ // eslint-disable-next-line max-statements, complexity
4571
4373
  async convert(options) {
4572
4374
  if (import_core9.isBrowser) {
4573
4375
  console.log(BROWSER_ERROR_MESSAGE);
4574
4376
  return BROWSER_ERROR_MESSAGE;
4575
4377
  }
4576
4378
  this.conversionStartTime = import_process4.default.hrtime();
4577
- const {
4578
- tilesetName,
4579
- slpk,
4580
- egmFilePath,
4581
- inputUrl,
4582
- validate,
4583
- outputPath,
4584
- draco = true,
4585
- sevenZipExe,
4586
- maxDepth,
4587
- token,
4588
- generateTextures,
4589
- generateBoundingVolumes,
4590
- instantNodeWriting = false,
4591
- mergeMaterials: mergeMaterials2 = true,
4592
- inquirer,
4593
- metadataClass,
4594
- analyze = false
4595
- } = options;
4379
+ const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco = true, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes, instantNodeWriting = false, mergeMaterials: mergeMaterials2 = true, inquirer, metadataClass, analyze = false } = options;
4596
4380
  this.options = {
4597
4381
  outputPath,
4598
4382
  tilesetName,
@@ -4655,35 +4439,31 @@ var I3SConverter = class {
4655
4439
  * @returns true - the conversion is possible, false - the tileset's content is not supported
4656
4440
  */
4657
4441
  async preprocessConversion() {
4658
- console.log(`Analyze source tileset`);
4442
+ console.log("Analyze source tileset");
4659
4443
  const sourceRootTile = this.sourceTileset.root;
4660
- await traverseDatasetWith(
4661
- sourceRootTile,
4662
- null,
4663
- this.analyzeTile.bind(this),
4664
- void 0,
4665
- this.options.maxDepth
4666
- );
4444
+ await traverseDatasetWith({
4445
+ tile: sourceRootTile,
4446
+ traversalProps: null,
4447
+ processTile: this.analyzeTile.bind(this),
4448
+ postprocessTile: void 0,
4449
+ maxDepth: this.options.maxDepth
4450
+ });
4667
4451
  const { meshTopologyTypes, metadataClasses } = this.preprocessData;
4668
- console.log(`------------------------------------------------`);
4669
- console.log(`Preprocess results:`);
4452
+ console.log("------------------------------------------------");
4453
+ console.log("Preprocess results:");
4670
4454
  console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
4671
4455
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
4672
4456
  if (metadataClasses.size) {
4673
- console.log(
4674
- `Feature metadata classes have been found: ${Array.from(metadataClasses).join(", ")}`
4675
- );
4457
+ console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(", ")}`);
4676
4458
  } else {
4677
4459
  console.log("Feature metadata classes have not been found");
4678
4460
  }
4679
- if (!meshTopologyTypes.has("TRIANGLES" /* TRIANGLES */) && !meshTopologyTypes.has("TRIANGLE_STRIP" /* TRIANGLE_STRIP */)) {
4680
- console.log(
4681
- "The tileset is of unsupported mesh topology types. The conversion will be interrupted."
4682
- );
4683
- console.log(`------------------------------------------------`);
4461
+ if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
4462
+ console.log("The tileset is of unsupported mesh topology types. The conversion will be interrupted.");
4463
+ console.log("------------------------------------------------");
4684
4464
  return false;
4685
4465
  }
4686
- console.log(`------------------------------------------------`);
4466
+ console.log("------------------------------------------------");
4687
4467
  return true;
4688
4468
  }
4689
4469
  /**
@@ -4709,9 +4489,7 @@ var I3SConverter = class {
4709
4489
  "3d-tiles": { ...this.loadOptions["3d-tiles"], loadGLTF: false }
4710
4490
  });
4711
4491
  } catch (error) {
4712
- console.log(
4713
- `[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`
4714
- );
4492
+ console.log(`[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`);
4715
4493
  }
4716
4494
  const tilePreprocessData = await analyzeTileContent(tileContent);
4717
4495
  mergePreprocessData(this.preprocessData, tilePreprocessData);
@@ -4739,10 +4517,8 @@ var I3SConverter = class {
4739
4517
  this.options.metadataClass = result.metadataClass;
4740
4518
  console.log(`${result.metadataClass} has been selected`);
4741
4519
  } else {
4742
- console.log(
4743
- `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]}"`
4744
- );
4745
- console.log(`------------------------------------------------`);
4520
+ 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]}"`);
4521
+ console.log("------------------------------------------------");
4746
4522
  return false;
4747
4523
  }
4748
4524
  }
@@ -4753,6 +4529,7 @@ var I3SConverter = class {
4753
4529
  * @param outputPath - path to save output data
4754
4530
  * @param tilesetName - new tileset path
4755
4531
  */
4532
+ // eslint-disable-next-line max-statements, complexity
4756
4533
  async _createAndSaveTileset(outputPath, tilesetName) {
4757
4534
  var _a2, _b, _c;
4758
4535
  const tilesetPath = (0, import_path7.join)(`${outputPath}`, `${tilesetName}`);
@@ -4788,16 +4565,8 @@ var I3SConverter = class {
4788
4565
  this.materialDefinitions = this.conversionDump.materialDefinitions;
4789
4566
  }
4790
4567
  const sourceRootTile = this.sourceTileset.root;
4791
- const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(
4792
- sourceRootTile.boundingVolume,
4793
- new import_core10.Matrix4(sourceRootTile.transform),
4794
- null
4795
- );
4796
- this._formLayers0(
4797
- tilesetName,
4798
- sourceBoundingVolume,
4799
- (_c = (_b = (_a2 = this.sourceTileset) == null ? void 0 : _a2.root) == null ? void 0 : _b.boundingVolume) == null ? void 0 : _c.region
4800
- );
4568
+ const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(sourceRootTile.boundingVolume, new import_core10.Matrix4(sourceRootTile.transform), null);
4569
+ this._formLayers0(tilesetName, sourceBoundingVolume, (_c = (_b = (_a2 = this.sourceTileset) == null ? void 0 : _a2.root) == null ? void 0 : _b.boundingVolume) == null ? void 0 : _c.region);
4801
4570
  const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
4802
4571
  await this.nodePages.push({
4803
4572
  index: 0,
@@ -4807,16 +4576,16 @@ var I3SConverter = class {
4807
4576
  });
4808
4577
  this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
4809
4578
  const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
4810
- await traverseDatasetWith(
4811
- sourceRootTile,
4812
- {
4579
+ await traverseDatasetWith({
4580
+ tile: sourceRootTile,
4581
+ traversalProps: {
4813
4582
  transform: new import_core10.Matrix4(sourceRootTile.transform),
4814
4583
  parentNodes: [rootNode]
4815
4584
  },
4816
- this.convertTile.bind(this),
4817
- this.finalizeTile.bind(this),
4818
- this.options.maxDepth
4819
- );
4585
+ processTile: this.convertTile.bind(this),
4586
+ postprocessTile: this.finalizeTile.bind(this),
4587
+ maxDepth: this.options.maxDepth
4588
+ });
4820
4589
  this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
4821
4590
  console.log(`[finalizing conversion]`);
4822
4591
  this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
@@ -4829,16 +4598,11 @@ var I3SConverter = class {
4829
4598
  this.layers0.textureSetDefinitions = this.conversionDump.textureSetDefinitions;
4830
4599
  }
4831
4600
  this.layers0.materialDefinitions = this.materialDefinitions;
4832
- this.layers0.geometryDefinitions = (0, import_json_map_transform8.default)(
4833
- this.geometryConfigs.map((config) => ({
4834
- geometryConfig: { ...config, draco: this.options.draco }
4835
- })),
4836
- GEOMETRY_DEFINITION()
4837
- );
4601
+ this.layers0.geometryDefinitions = (0, import_json_map_transform8.default)(this.geometryConfigs.map((config) => ({
4602
+ geometryConfig: { ...config, draco: this.options.draco }
4603
+ })), GEOMETRY_DEFINITION());
4838
4604
  if (this.layersHasTexture === false) {
4839
- this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter(
4840
- (attribute) => attribute !== "uv0"
4841
- );
4605
+ this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter((attribute) => attribute !== "uv0");
4842
4606
  }
4843
4607
  await this._writeLayers0();
4844
4608
  createSceneServerPath(tilesetName, this.layers0, tilesetPath);
@@ -4925,6 +4689,7 @@ var I3SConverter = class {
4925
4689
  * @param traversalProps - traversal properties calculated recursively
4926
4690
  * @returns - traversal properties for the child tiles
4927
4691
  */
4692
+ // eslint-disable-next-line max-statements
4928
4693
  async convertTile(sourceTile, traversalProps) {
4929
4694
  const isTileset = isNestedTileset(sourceTile);
4930
4695
  if (isTileset || sourceTile.type === "empty") {
@@ -4995,16 +4760,12 @@ var I3SConverter = class {
4995
4760
  * @return NodeIndexDocument, nodeInPage and node data
4996
4761
  */
4997
4762
  async _generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, isDumped) {
4998
- this.layersHasTexture = this.layersHasTexture || Boolean(
4999
- "texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint
5000
- );
4763
+ this.layersHasTexture = this.layersHasTexture || Boolean("texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint);
5001
4764
  if (this.generateBoundingVolumes && resources.boundingVolumes) {
5002
4765
  boundingVolumes = resources.boundingVolumes;
5003
4766
  }
5004
4767
  const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
5005
- const maxScreenThresholdSQ = lodSelection.find(
5006
- (val) => val.metricType === "maxScreenThresholdSQ"
5007
- ) || { maxError: 0 };
4768
+ const maxScreenThresholdSQ = lodSelection.find((val) => val.metricType === "maxScreenThresholdSQ") || { maxError: 0 };
5008
4769
  if (isDumped) {
5009
4770
  const draftObb = {
5010
4771
  center: [],
@@ -5013,20 +4774,8 @@ var I3SConverter = class {
5013
4774
  };
5014
4775
  await this.nodePages.push({ index: 0, obb: draftObb }, parentNode.inPageId);
5015
4776
  }
5016
- const nodeInPage = await this._updateNodeInNodePages(
5017
- maxScreenThresholdSQ,
5018
- boundingVolumes,
5019
- sourceTile,
5020
- parentNode.inPageId,
5021
- resources
5022
- );
5023
- const nodeData = await NodeIndexDocument.createNodeIndexDocument(
5024
- parentNode,
5025
- boundingVolumes,
5026
- lodSelection,
5027
- nodeInPage,
5028
- resources
5029
- );
4777
+ const nodeInPage = await this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentNode.inPageId, resources);
4778
+ const nodeData = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
5030
4779
  const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
5031
4780
  return { node, nodeInPage, nodeData };
5032
4781
  }
@@ -5041,24 +4790,14 @@ var I3SConverter = class {
5041
4790
  this._checkAddRefinementTypeForTile(sourceTile);
5042
4791
  await this._updateTilesetOptions();
5043
4792
  if (this.conversionDump.restored && sourceTile.id && this.conversionDump.isFileConversionComplete(sourceTile.id)) {
5044
- const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(
5045
- sourceTile.boundingVolume,
5046
- transformationMatrix,
5047
- null
5048
- );
5049
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
4793
+ const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
4794
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
5050
4795
  const nodes = [];
5051
4796
  for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
5052
- const { node } = await this._generateNodeIndexDocument(
5053
- boundingVolumes,
5054
- {
5055
- ...convertedNode.dumpMetadata,
5056
- nodeId: convertedNode.nodeId
5057
- },
5058
- parentNode,
5059
- sourceTile,
5060
- true
5061
- );
4797
+ const { node } = await this._generateNodeIndexDocument(boundingVolumes, {
4798
+ ...convertedNode.dumpMetadata,
4799
+ nodeId: convertedNode.nodeId
4800
+ }, parentNode, sourceTile, true);
5062
4801
  nodes.push(node);
5063
4802
  }
5064
4803
  return nodes;
@@ -5075,6 +4814,7 @@ var I3SConverter = class {
5075
4814
  * transform of all parent tiles and transform of the current tile
5076
4815
  * @param level - tree level
5077
4816
  */
4817
+ // eslint-disable-next-line max-statements
5078
4818
  async _createNode(parentNode, sourceTile, transformationMatrix) {
5079
4819
  var _a2;
5080
4820
  this._checkAddRefinementTypeForTile(sourceTile);
@@ -5085,12 +4825,8 @@ var I3SConverter = class {
5085
4825
  } catch (error) {
5086
4826
  console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);
5087
4827
  }
5088
- const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(
5089
- sourceTile.boundingVolume,
5090
- transformationMatrix,
5091
- null
5092
- );
5093
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
4828
+ const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
4829
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
5094
4830
  const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
5095
4831
  this.createAttributeStorageInfo(tileContent, propertyTable);
5096
4832
  this.conversionDump.attributeMetadataInfo = {
@@ -5098,14 +4834,14 @@ var I3SConverter = class {
5098
4834
  fields: this.attributeMetadataInfo.fields,
5099
4835
  popupInfo: this.attributeMetadataInfo.popupInfo
5100
4836
  };
5101
- const resourcesData = await this._convertResources(
4837
+ const resourcesData = await this._convertResources({
5102
4838
  sourceTile,
5103
4839
  transformationMatrix,
5104
- sourceBoundingVolume,
4840
+ boundingVolume: sourceBoundingVolume,
5105
4841
  tileContent,
5106
- parentNode.inPageId,
4842
+ parentId: parentNode.inPageId,
5107
4843
  propertyTable
5108
- );
4844
+ });
5109
4845
  const nodes = [];
5110
4846
  const nodeIds = [];
5111
4847
  const nodesInPage = [];
@@ -5122,13 +4858,7 @@ var I3SConverter = class {
5122
4858
  boundingVolumes: null
5123
4859
  };
5124
4860
  for (const resources of resourcesData || [emptyResources]) {
5125
- const { node, nodeInPage, nodeData } = await this._generateNodeIndexDocument(
5126
- boundingVolumes,
5127
- resources,
5128
- parentNode,
5129
- sourceTile,
5130
- false
5131
- );
4861
+ const { node, nodeInPage, nodeData } = await this._generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, false);
5132
4862
  nodes.push(node);
5133
4863
  if (nodeInPage.mesh) {
5134
4864
  if (sourceTile.id) {
@@ -5169,7 +4899,7 @@ var I3SConverter = class {
5169
4899
  * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA
5170
4900
  * @returns - converted node resources
5171
4901
  */
5172
- async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
4902
+ async _convertResources({ sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable }) {
5173
4903
  if (!this.isContentSupported(sourceTile) || !tileContent) {
5174
4904
  return null;
5175
4905
  }
@@ -5178,21 +4908,21 @@ var I3SConverter = class {
5178
4908
  halfSize: [],
5179
4909
  quaternion: []
5180
4910
  };
5181
- const resourcesData = await convertB3dmToI3sGeometry(
4911
+ const resourcesData = await convertB3dmToI3sGeometry({
5182
4912
  tileContent,
5183
- transformationMatrix,
5184
- boundingVolume,
5185
- async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index,
4913
+ tileTransform: transformationMatrix,
4914
+ tileBoundingVolume: boundingVolume,
4915
+ addNodeToNodePage: async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index,
5186
4916
  propertyTable,
5187
- this.featuresHashArray,
5188
- this.attributeMetadataInfo.attributeStorageInfo,
5189
- this.options.draco,
5190
- this.generateBoundingVolumes,
5191
- this.options.mergeMaterials,
5192
- this.geoidHeightModel,
5193
- this.loadOptions.modules,
5194
- this.options.metadataClass
5195
- );
4917
+ featuresHashArray: this.featuresHashArray,
4918
+ attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
4919
+ draco: this.options.draco,
4920
+ generateBoundingVolumes: this.generateBoundingVolumes,
4921
+ shouldMergeMaterials: this.options.mergeMaterials,
4922
+ geoidHeightModel: this.geoidHeightModel,
4923
+ libraries: this.loadOptions.modules,
4924
+ metadataClass: this.options.metadataClass
4925
+ });
5196
4926
  return resourcesData;
5197
4927
  }
5198
4928
  /**
@@ -5210,6 +4940,7 @@ var I3SConverter = class {
5210
4940
  * @param resources.geometry - Uint8Array with geometry attributes
5211
4941
  * @return the node object in node pages
5212
4942
  */
4943
+ // eslint-disable-next-line max-statements, complexity
5213
4944
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
5214
4945
  const { vertexCount, featureCount, geometry, hasUvRegions } = resources;
5215
4946
  const nodeInPage = {
@@ -5221,12 +4952,7 @@ var I3SConverter = class {
5221
4952
  if (geometry && this.isContentSupported(sourceTile)) {
5222
4953
  nodeInPage.mesh = {
5223
4954
  geometry: {
5224
- definition: this.findOrCreateGeometryDefinition(
5225
- Boolean(
5226
- "texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint
5227
- ),
5228
- hasUvRegions
5229
- ),
4955
+ definition: this.findOrCreateGeometryDefinition(Boolean("texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint), hasUvRegions),
5230
4956
  resource: 0
5231
4957
  },
5232
4958
  attribute: {
@@ -5237,7 +4963,7 @@ var I3SConverter = class {
5237
4963
  }
5238
4964
  };
5239
4965
  }
5240
- let nodeId = "nodeId" in resources ? resources.nodeId : void 0;
4966
+ const nodeId = "nodeId" in resources ? resources.nodeId : void 0;
5241
4967
  let node;
5242
4968
  if (!nodeId) {
5243
4969
  node = await this.nodePages.push(nodeInPage, parentId);
@@ -5283,45 +5009,27 @@ var I3SConverter = class {
5283
5009
  * @return {Promise<void>}
5284
5010
  */
5285
5011
  async _writeResources(resources, nodePath, sourceTile) {
5286
- const {
5287
- geometry: geometryBuffer,
5288
- compressedGeometry,
5289
- texture,
5290
- sharedResources,
5291
- attributes
5292
- } = resources;
5012
+ const { geometry: geometryBuffer, compressedGeometry, texture, sharedResources, attributes } = resources;
5293
5013
  const childPath = (0, import_path7.join)(this.layers0Path, "nodes", nodePath);
5294
5014
  const slpkChildPath = (0, import_path7.join)("nodes", nodePath);
5295
- await this._writeGeometries(
5015
+ await this._writeGeometries({
5296
5016
  geometryBuffer,
5297
5017
  compressedGeometry,
5298
5018
  childPath,
5299
5019
  slpkChildPath,
5300
- sourceTile.id || "",
5301
- parseInt(nodePath)
5302
- );
5303
- await this._writeShared(
5020
+ sourceId: sourceTile.id || "",
5021
+ nodeId: parseInt(nodePath)
5022
+ });
5023
+ await this._writeShared({
5304
5024
  sharedResources,
5305
5025
  childPath,
5306
5026
  slpkChildPath,
5307
5027
  nodePath,
5308
- sourceTile.id || "",
5309
- parseInt(nodePath)
5310
- );
5311
- await this._writeTexture(
5312
- texture,
5313
- childPath,
5314
- slpkChildPath,
5315
- sourceTile.id || "",
5316
- parseInt(nodePath)
5317
- );
5318
- await this._writeAttributes(
5319
- attributes,
5320
- childPath,
5321
- slpkChildPath,
5322
- sourceTile.id || "",
5323
- parseInt(nodePath)
5324
- );
5028
+ sourceId: sourceTile.id || "",
5029
+ nodeId: parseInt(nodePath)
5030
+ });
5031
+ await this._writeTexture(texture, childPath, slpkChildPath, sourceTile.id || "", parseInt(nodePath));
5032
+ await this._writeAttributes(attributes, childPath, slpkChildPath, sourceTile.id || "", parseInt(nodePath));
5325
5033
  }
5326
5034
  /**
5327
5035
  * Write non-compressed and compressed geometries in files
@@ -5332,15 +5040,18 @@ var I3SConverter = class {
5332
5040
  * @param sourceId - source filename
5333
5041
  * @param nodeId - nodeId of a converted node for the writing
5334
5042
  */
5335
- async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
5336
- this.conversionDump.updateDoneStatus(sourceId, nodeId, "GEOMETRY" /* GEOMETRY */, false);
5043
+ async _writeGeometries({ geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId }) {
5044
+ if (!geometryBuffer) {
5045
+ return;
5046
+ }
5047
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
5337
5048
  if (this.options.slpk) {
5338
5049
  const slpkGeometryPath = (0, import_path7.join)(childPath, "geometries");
5339
5050
  await this.writeQueue.enqueue({
5340
5051
  archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
5341
5052
  sourceId,
5342
5053
  outputId: nodeId,
5343
- resourceType: "GEOMETRY" /* GEOMETRY */,
5054
+ resourceType: ResourceType.GEOMETRY,
5344
5055
  writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, "0.bin")
5345
5056
  });
5346
5057
  } else {
@@ -5348,19 +5059,19 @@ var I3SConverter = class {
5348
5059
  await this.writeQueue.enqueue({
5349
5060
  sourceId,
5350
5061
  outputId: nodeId,
5351
- resourceType: "GEOMETRY" /* GEOMETRY */,
5062
+ resourceType: ResourceType.GEOMETRY,
5352
5063
  writePromise: () => writeFile(geometryPath, geometryBuffer, "index.bin")
5353
5064
  });
5354
5065
  }
5355
- if (this.options.draco) {
5356
- this.conversionDump.updateDoneStatus(sourceId, nodeId, "DRACO_GEOMETRY" /* DRACO_GEOMETRY */, false);
5066
+ if (this.options.draco && compressedGeometry) {
5067
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
5357
5068
  if (this.options.slpk) {
5358
5069
  const slpkCompressedGeometryPath = (0, import_path7.join)(childPath, "geometries");
5359
5070
  await this.writeQueue.enqueue({
5360
5071
  archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
5361
5072
  sourceId,
5362
5073
  outputId: nodeId,
5363
- resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
5074
+ resourceType: ResourceType.DRACO_GEOMETRY,
5364
5075
  writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, "1.bin")
5365
5076
  });
5366
5077
  } else {
@@ -5368,7 +5079,7 @@ var I3SConverter = class {
5368
5079
  await this.writeQueue.enqueue({
5369
5080
  sourceId,
5370
5081
  outputId: nodeId,
5371
- resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
5082
+ resourceType: ResourceType.DRACO_GEOMETRY,
5372
5083
  writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, "index.bin")
5373
5084
  });
5374
5085
  }
@@ -5383,21 +5094,21 @@ var I3SConverter = class {
5383
5094
  * @param sourceId - source filename
5384
5095
  * @param nodeId - nodeId of a converted node for the writing
5385
5096
  */
5386
- async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
5097
+ async _writeShared({ sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId }) {
5387
5098
  if (!sharedResources) {
5388
5099
  return;
5389
5100
  }
5390
5101
  sharedResources.nodePath = nodePath;
5391
5102
  const sharedData = (0, import_json_map_transform8.default)(sharedResources, SHARED_RESOURCES());
5392
5103
  const sharedDataStr = JSON.stringify(sharedData);
5393
- this.conversionDump.updateDoneStatus(sourceId, nodeId, "SHARED" /* SHARED */, false);
5104
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.SHARED, false);
5394
5105
  if (this.options.slpk) {
5395
5106
  const slpkSharedPath = (0, import_path7.join)(childPath, "shared");
5396
5107
  await this.writeQueue.enqueue({
5397
5108
  archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
5398
5109
  sourceId,
5399
5110
  outputId: nodeId,
5400
- resourceType: "SHARED" /* SHARED */,
5111
+ resourceType: ResourceType.SHARED,
5401
5112
  writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, "sharedResource.json")
5402
5113
  });
5403
5114
  } else {
@@ -5405,7 +5116,7 @@ var I3SConverter = class {
5405
5116
  await this.writeQueue.enqueue({
5406
5117
  sourceId,
5407
5118
  outputId: nodeId,
5408
- resourceType: "SHARED" /* SHARED */,
5119
+ resourceType: ResourceType.SHARED,
5409
5120
  writePromise: () => writeFile(sharedPath, sharedDataStr)
5410
5121
  });
5411
5122
  }
@@ -5418,6 +5129,7 @@ var I3SConverter = class {
5418
5129
  * @param sourceId - source filename
5419
5130
  * @param nodeId - nodeId of a converted node for the writing
5420
5131
  */
5132
+ // eslint-disable-next-line max-statements
5421
5133
  async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
5422
5134
  if (texture) {
5423
5135
  const format = this._getFormatByMimeType(texture == null ? void 0 : texture.mimeType);
@@ -5427,21 +5139,16 @@ var I3SConverter = class {
5427
5139
  case "jpg":
5428
5140
  case "png": {
5429
5141
  formats.push({ name: "0", format });
5430
- this.conversionDump.updateDoneStatus(
5431
- sourceId,
5432
- nodeId,
5433
- `${"TEXTURE" /* TEXTURE */}/${format}`,
5434
- false
5435
- );
5436
- await this.writeTextureFile(
5142
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
5143
+ await this.writeTextureFile({
5437
5144
  textureData,
5438
- "0",
5145
+ name: "0",
5439
5146
  format,
5440
5147
  childPath,
5441
5148
  slpkChildPath,
5442
5149
  sourceId,
5443
5150
  nodeId
5444
- );
5151
+ });
5445
5152
  if (this.generateTextures) {
5446
5153
  formats.push({ name: "1", format: "ktx2" });
5447
5154
  const copyArrayBuffer = texture.image.data.subarray();
@@ -5461,61 +5168,48 @@ var I3SConverter = class {
5461
5168
  useLocalLibraries: true
5462
5169
  }
5463
5170
  );
5464
- this.conversionDump.updateDoneStatus(
5465
- sourceId,
5466
- nodeId,
5467
- `${"TEXTURE" /* TEXTURE */}/ktx2`,
5468
- false
5469
- );
5470
- await this.writeTextureFile(
5471
- ktx2TextureData,
5472
- "1",
5473
- "ktx2",
5171
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/ktx2`, false);
5172
+ await this.writeTextureFile({
5173
+ textureData: ktx2TextureData,
5174
+ name: "1",
5175
+ format: "ktx2",
5474
5176
  childPath,
5475
5177
  slpkChildPath,
5476
5178
  sourceId,
5477
5179
  nodeId
5478
- );
5180
+ });
5479
5181
  }
5480
5182
  break;
5481
5183
  }
5482
5184
  case "ktx2": {
5483
5185
  formats.push({ name: "1", format });
5484
- this.conversionDump.updateDoneStatus(
5485
- sourceId,
5486
- nodeId,
5487
- `${"TEXTURE" /* TEXTURE */}/${format}`,
5488
- false
5489
- );
5490
- await this.writeTextureFile(
5186
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
5187
+ await this.writeTextureFile({
5491
5188
  textureData,
5492
- "1",
5189
+ name: "1",
5493
5190
  format,
5494
5191
  childPath,
5495
5192
  slpkChildPath,
5496
5193
  sourceId,
5497
5194
  nodeId
5498
- );
5195
+ });
5499
5196
  if (this.generateTextures) {
5500
5197
  formats.push({ name: "0", format: "jpg" });
5501
5198
  const decodedFromKTX2TextureData = (0, import_core9.encode)(texture.image.data[0], import_images.ImageWriter);
5502
- this.conversionDump.updateDoneStatus(
5503
- sourceId,
5504
- nodeId,
5505
- `${"TEXTURE" /* TEXTURE */}/jpg`,
5506
- false
5507
- );
5508
- await this.writeTextureFile(
5509
- decodedFromKTX2TextureData,
5510
- "0",
5511
- "jpg",
5199
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/jpg`, false);
5200
+ await this.writeTextureFile({
5201
+ textureData: decodedFromKTX2TextureData,
5202
+ name: "0",
5203
+ format: "jpg",
5512
5204
  childPath,
5513
5205
  slpkChildPath,
5514
5206
  sourceId,
5515
5207
  nodeId
5516
- );
5208
+ });
5517
5209
  }
5210
+ break;
5518
5211
  }
5212
+ default:
5519
5213
  }
5520
5214
  if (!this.layers0.textureSetDefinitions.length) {
5521
5215
  this.layers0.textureSetDefinitions.push({ formats });
@@ -5536,7 +5230,7 @@ var I3SConverter = class {
5536
5230
  * @param sourceId
5537
5231
  * @param nodeId
5538
5232
  */
5539
- async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
5233
+ async writeTextureFile({ textureData, name, format, childPath, slpkChildPath, sourceId, nodeId }) {
5540
5234
  if (this.options.slpk) {
5541
5235
  const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
5542
5236
  const compress = false;
@@ -5544,7 +5238,7 @@ var I3SConverter = class {
5544
5238
  archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
5545
5239
  sourceId,
5546
5240
  outputId: nodeId,
5547
- resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
5241
+ resourceType: `${ResourceType.TEXTURE}/${format}`,
5548
5242
  writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
5549
5243
  });
5550
5244
  } else {
@@ -5552,7 +5246,7 @@ var I3SConverter = class {
5552
5246
  await this.writeQueue.enqueue({
5553
5247
  sourceId,
5554
5248
  outputId: nodeId,
5555
- resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
5249
+ resourceType: `${ResourceType.TEXTURE}/${format}`,
5556
5250
  writePromise: () => writeFile(texturePath, textureData, `index.${format}`)
5557
5251
  });
5558
5252
  }
@@ -5571,19 +5265,14 @@ var I3SConverter = class {
5571
5265
  for (let index = 0; index < minimumLength; index++) {
5572
5266
  const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
5573
5267
  const fileBuffer = new Uint8Array(attributes[index]);
5574
- this.conversionDump.updateDoneStatus(
5575
- sourceId,
5576
- nodeId,
5577
- `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
5578
- false
5579
- );
5268
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.ATTRIBUTES}/${folderName}`, false);
5580
5269
  if (this.options.slpk) {
5581
5270
  const slpkAttributesPath = (0, import_path7.join)(childPath, "attributes", folderName);
5582
5271
  await this.writeQueue.enqueue({
5583
5272
  archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
5584
5273
  sourceId,
5585
5274
  outputId: nodeId,
5586
- resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
5275
+ resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
5587
5276
  writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, "0.bin")
5588
5277
  });
5589
5278
  } else {
@@ -5591,7 +5280,7 @@ var I3SConverter = class {
5591
5280
  await this.writeQueue.enqueue({
5592
5281
  sourceId,
5593
5282
  outputId: nodeId,
5594
- resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
5283
+ resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
5595
5284
  writePromise: () => writeFile(attributesPath, fileBuffer, "index.bin")
5596
5285
  });
5597
5286
  }
@@ -5654,10 +5343,7 @@ var I3SConverter = class {
5654
5343
  let attributeTypesMap = null;
5655
5344
  if (this.options.metadataClass) {
5656
5345
  if (!this.attributeMetadataInfo.attributeStorageInfo.length && (tileContent == null ? void 0 : tileContent.gltf)) {
5657
- attributeTypesMap = getAttributeTypesMapFromSchema(
5658
- tileContent.gltf,
5659
- this.options.metadataClass
5660
- );
5346
+ attributeTypesMap = getAttributeTypesMapFromSchema(tileContent.gltf, this.options.metadataClass);
5661
5347
  }
5662
5348
  } else if (propertyTable) {
5663
5349
  attributeTypesMap = getAttributeTypesMapFromPropertyTable(propertyTable);
@@ -5676,13 +5362,13 @@ var I3SConverter = class {
5676
5362
  const filesSize = await calculateFilesSize(params);
5677
5363
  const diff = import_process4.default.hrtime(this.conversionStartTime);
5678
5364
  const conversionTime = timeConverter(diff);
5679
- console.log(`------------------------------------------------`);
5365
+ console.log("------------------------------------------------");
5680
5366
  console.log(`Finishing conversion of ${_3D_TILES}`);
5681
5367
  console.log(`Total conversion time: ${conversionTime}`);
5682
- console.log(`Vertex count: `, this.vertexCounter);
5683
- console.log(`File(s) size: `, filesSize, " bytes");
5684
- console.log(`Percentage of tiles with "ADD" refinement type:`, addRefinementPercentage, "%");
5685
- console.log(`------------------------------------------------`);
5368
+ console.log("Vertex count: ", this.vertexCounter);
5369
+ console.log("File(s) size: ", filesSize, " bytes");
5370
+ console.log('Percentage of tiles with "ADD" refinement type:', addRefinementPercentage, "%");
5371
+ console.log("------------------------------------------------");
5686
5372
  }
5687
5373
  /**
5688
5374
  * Fetch preload options for ION tileset
@@ -5720,7 +5406,7 @@ var I3SConverter = class {
5720
5406
  * @param tile
5721
5407
  */
5722
5408
  _checkAddRefinementTypeForTile(tile) {
5723
- const ADD_TILE_REFINEMENT = 1;
5409
+ const ADD_TILE_REFINEMENT = import_tiles.TILE_REFINEMENT.ADD;
5724
5410
  if (tile.refine === ADD_TILE_REFINEMENT) {
5725
5411
  this.refinementCounter.tilesWithAddRefineCount += 1;
5726
5412
  console.warn('This tile uses "ADD" type of refinement');
@@ -5737,14 +5423,14 @@ var I3SConverter = class {
5737
5423
  }
5738
5424
  };
5739
5425
 
5740
- // src/3d-tiles-converter/3d-tiles-converter.ts
5426
+ // dist/3d-tiles-converter/3d-tiles-converter.js
5741
5427
  var import_path8 = require("path");
5742
5428
  var import_process5 = __toESM(require("process"), 1);
5743
5429
  var import_json_map_transform10 = __toESM(require("json-map-transform"), 1);
5744
5430
  var import_core15 = require("@loaders.gl/core");
5745
5431
  var import_i3s2 = require("@loaders.gl/i3s");
5746
5432
 
5747
- // src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts
5433
+ // dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js
5748
5434
  var import_core11 = require("@math.gl/core");
5749
5435
  var import_geospatial5 = require("@math.gl/geospatial");
5750
5436
  var import_culling3 = require("@math.gl/culling");
@@ -5755,15 +5441,11 @@ function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
5755
5441
  i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])
5756
5442
  ];
5757
5443
  const cartesianCenter = import_geospatial5.Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new import_core11.Vector3());
5758
- const tiles3DObb = new import_culling3.OrientedBoundingBox().fromCenterHalfSizeQuaternion(
5759
- cartesianCenter,
5760
- i3SObb.halfSize,
5761
- i3SObb.quaternion
5762
- );
5444
+ const tiles3DObb = new import_culling3.OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
5763
5445
  return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
5764
5446
  }
5765
5447
 
5766
- // src/3d-tiles-converter/json-templates/tileset.ts
5448
+ // dist/3d-tiles-converter/json-templates/tileset.js
5767
5449
  var import_json_map_transform9 = __toESM(require("json-map-transform"), 1);
5768
5450
  var ASSET = () => ({
5769
5451
  version: {
@@ -5804,17 +5486,17 @@ var TILESET = () => ({
5804
5486
  }
5805
5487
  });
5806
5488
 
5807
- // src/3d-tiles-converter/3d-tiles-converter.ts
5489
+ // dist/3d-tiles-converter/3d-tiles-converter.js
5808
5490
  var import_worker_utils2 = require("@loaders.gl/worker-utils");
5809
5491
 
5810
- // src/3d-tiles-converter/helpers/b3dm-converter.ts
5492
+ // dist/3d-tiles-converter/helpers/b3dm-converter.js
5811
5493
  var import_core12 = require("@loaders.gl/core");
5812
5494
  var import_gltf6 = require("@loaders.gl/gltf");
5813
5495
  var import_d_tiles3 = require("@loaders.gl/3d-tiles");
5814
5496
  var import_core13 = require("@math.gl/core");
5815
5497
  var import_geospatial6 = require("@math.gl/geospatial");
5816
5498
 
5817
- // src/3d-tiles-converter/helpers/texture-atlas.ts
5499
+ // dist/3d-tiles-converter/helpers/texture-atlas.js
5818
5500
  function convertTextureAtlas(texCoords, uvRegions) {
5819
5501
  const convertedTexCoords = new Float32Array(texCoords.length);
5820
5502
  const normalisedRegions = normalizeRegions(uvRegions);
@@ -5845,13 +5527,16 @@ function normalizeRegions(regions) {
5845
5527
  return normalizedRegions;
5846
5528
  }
5847
5529
 
5848
- // src/3d-tiles-converter/helpers/b3dm-converter.ts
5530
+ // dist/3d-tiles-converter/helpers/b3dm-converter.js
5849
5531
  var Z_UP_TO_Y_UP_MATRIX = new import_core13.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
5850
5532
  var scratchVector2 = new import_core13.Vector3();
5851
5533
  var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
5852
5534
  var METALLIC_FACTOR_DEFAULT = 1;
5853
5535
  var ROUGHNESS_FACTOR_DEFAULT = 1;
5854
5536
  var B3dmConverter = class {
5537
+ // @ts-expect-error
5538
+ rtcCenter;
5539
+ i3sTile;
5855
5540
  /**
5856
5541
  * The starter of content conversion
5857
5542
  * @param i3sTile - Tile3D instance for I3S node
@@ -5859,15 +5544,12 @@ var B3dmConverter = class {
5859
5544
  */
5860
5545
  async convert(i3sAttributesData, featureAttributes = null) {
5861
5546
  const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);
5862
- const b3dm = (0, import_core12.encodeSync)(
5863
- {
5864
- gltfEncoded: new Uint8Array(gltf),
5865
- type: "b3dm",
5866
- featuresLength: this._getFeaturesLength(featureAttributes),
5867
- batchTable: featureAttributes
5868
- },
5869
- import_d_tiles3.Tile3DWriter
5870
- );
5547
+ const b3dm = (0, import_core12.encodeSync)({
5548
+ gltfEncoded: new Uint8Array(gltf),
5549
+ type: "b3dm",
5550
+ featuresLength: this._getFeaturesLength(featureAttributes),
5551
+ batchTable: featureAttributes
5552
+ }, import_d_tiles3.Tile3DWriter);
5871
5553
  return b3dm;
5872
5554
  }
5873
5555
  /**
@@ -5875,6 +5557,7 @@ var B3dmConverter = class {
5875
5557
  * @param i3sTile - Tile3D instance for I3S node
5876
5558
  * @returns - encoded glb content
5877
5559
  */
5560
+ // eslint-disable-next-line max-statements
5878
5561
  async buildGLTF(i3sAttributesData, featureAttributes) {
5879
5562
  const { tileContent, textureFormat, box } = i3sAttributesData;
5880
5563
  const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
@@ -5890,22 +5573,11 @@ var B3dmConverter = class {
5890
5573
  const positions = attributes.positions;
5891
5574
  const positionsValue = positions.value;
5892
5575
  if (attributes.uvRegions && attributes.texCoords) {
5893
- attributes.texCoords.value = convertTextureAtlas(
5894
- attributes.texCoords.value,
5895
- attributes.uvRegions.value
5896
- );
5576
+ attributes.texCoords.value = convertTextureAtlas(attributes.texCoords.value, attributes.uvRegions.value);
5897
5577
  }
5898
5578
  const cartesianOrigin = new import_core13.Vector3(box);
5899
- const cartographicOrigin = import_geospatial6.Ellipsoid.WGS84.cartesianToCartographic(
5900
- cartesianOrigin,
5901
- new import_core13.Vector3()
5902
- );
5903
- attributes.positions.value = this._normalizePositions(
5904
- positionsValue,
5905
- cartesianOrigin,
5906
- cartographicOrigin,
5907
- modelMatrix
5908
- );
5579
+ const cartographicOrigin = import_geospatial6.Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new import_core13.Vector3());
5580
+ attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
5909
5581
  this._createBatchIds(tileContent, featureAttributes);
5910
5582
  if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
5911
5583
  delete attributes.normals;
@@ -6112,7 +5784,7 @@ var B3dmConverter = class {
6112
5784
  }
6113
5785
  };
6114
5786
 
6115
- // src/3d-tiles-converter/helpers/load-i3s.ts
5787
+ // dist/3d-tiles-converter/helpers/load-i3s.js
6116
5788
  var import_core14 = require("@loaders.gl/core");
6117
5789
  var import_i3s = require("@loaders.gl/i3s");
6118
5790
  var import_loader_utils5 = require("@loaders.gl/loader-utils");
@@ -6147,31 +5819,23 @@ var loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions, slpkF
6147
5819
  }
6148
5820
  }
6149
5821
  };
6150
- const tileContent = await loadFromArchive2(
6151
- sourceTile.contentUrl,
6152
- import_i3s.I3SLoader,
6153
- loadOptions,
6154
- slpkFilesystem
6155
- );
5822
+ const tileContent = await loadFromArchive2(sourceTile.contentUrl, import_i3s.I3SLoader, loadOptions, slpkFilesystem);
6156
5823
  return tileContent;
6157
5824
  };
6158
5825
  async function openSLPK(url) {
6159
5826
  const slpkUrlParts = url.split(".slpk");
6160
- const { slpkFileName } = getSlpkUrlParts(url) || {};
6161
- if (slpkFileName) {
6162
- const slpkFileName2 = `${slpkUrlParts[0]}.slpk`;
6163
- const fileProvider = new import_loader_utils5.FileHandleFile(slpkFileName2);
6164
- const archive = await (0, import_i3s.parseSLPKArchive)(fileProvider, void 0, slpkFileName2);
5827
+ if (slpkUrlParts.length === 2) {
5828
+ const slpkFileName = `${slpkUrlParts[0]}.slpk`;
5829
+ const fileProvider = new import_loader_utils5.FileHandleFile(slpkFileName);
5830
+ const archive = await (0, import_i3s.parseSLPKArchive)(fileProvider, void 0, slpkFileName);
6165
5831
  const fileSystem = new import_zip3.ZipFileSystem(archive);
6166
5832
  return fileSystem;
6167
5833
  }
6168
5834
  return null;
6169
5835
  }
6170
5836
  async function loadFromArchive2(url, loader, loadOptions, fileSystem) {
6171
- const slpkUrlParts = getSlpkUrlParts(url);
6172
- if (fileSystem !== null && slpkUrlParts !== null) {
6173
- const { internalFileName } = slpkUrlParts;
6174
- const content = await (0, import_core14.load)(internalFileName, loader, {
5837
+ if (fileSystem !== null) {
5838
+ const content = await (0, import_core14.load)(url, loader, {
6175
5839
  ...loadOptions,
6176
5840
  fetch: fileSystem.fetch.bind(fileSystem)
6177
5841
  });
@@ -6179,18 +5843,6 @@ async function loadFromArchive2(url, loader, loadOptions, fileSystem) {
6179
5843
  }
6180
5844
  return await (0, import_core14.load)(url, loader, loadOptions);
6181
5845
  }
6182
- function getSlpkUrlParts(url) {
6183
- const slpkUrlParts = url.split(".slpk");
6184
- let result;
6185
- if (slpkUrlParts.length === 1) {
6186
- result = null;
6187
- } else if (slpkUrlParts.length === 2) {
6188
- result = { slpkFileName: `${slpkUrlParts[0]}.slpk`, internalFileName: slpkUrlParts[1].slice(1) };
6189
- } else {
6190
- throw new Error("Unexpected URL format");
6191
- }
6192
- return result;
6193
- }
6194
5846
  async function getNodeCount(fileSystem) {
6195
5847
  if (!(fileSystem == null ? void 0 : fileSystem.fileProvider)) {
6196
5848
  return 0;
@@ -6206,23 +5858,32 @@ async function getNodeCount(fileSystem) {
6206
5858
  return count;
6207
5859
  }
6208
5860
 
6209
- // src/3d-tiles-converter/3d-tiles-converter.ts
5861
+ // dist/3d-tiles-converter/3d-tiles-converter.js
6210
5862
  var I3S = "I3S";
6211
5863
  var Tiles3DConverter = class {
5864
+ options;
5865
+ tilesetPath;
5866
+ vertexCounter;
5867
+ conversionStartTime;
5868
+ geoidHeightModel;
5869
+ sourceTileset;
5870
+ attributeStorageInfo;
5871
+ workerSource = {};
5872
+ slpkFilesystem = null;
5873
+ loaderOptions = {
5874
+ _nodeWorkers: true,
5875
+ reuseWorkers: true,
5876
+ // TODO: converter freezes in the end because of i3s-content-worker
5877
+ worker: false,
5878
+ i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
5879
+ // We need to load local fs workers because nodejs can't load workers from the Internet
5880
+ "i3s-content": {
5881
+ workerUrl: "./modules/i3s/dist/i3s-content-worker-node.js"
5882
+ }
5883
+ };
5884
+ conversionDump;
5885
+ progress;
6212
5886
  constructor() {
6213
- this.workerSource = {};
6214
- this.slpkFilesystem = null;
6215
- this.loaderOptions = {
6216
- _nodeWorkers: true,
6217
- reuseWorkers: true,
6218
- // TODO: converter freezes in the end because of i3s-content-worker
6219
- worker: false,
6220
- i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
6221
- // We need to load local fs workers because nodejs can't load workers from the Internet
6222
- "i3s-content": {
6223
- workerUrl: "./modules/i3s/dist/i3s-content-worker-node.js"
6224
- }
6225
- };
6226
5887
  this.options = {};
6227
5888
  this.tilesetPath = "";
6228
5889
  this.vertexCounter = 0;
@@ -6243,6 +5904,7 @@ var Tiles3DConverter = class {
6243
5904
  * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
6244
5905
  * @param options.maxDepth The max tree depth of conversion
6245
5906
  */
5907
+ // eslint-disable-next-line complexity, max-statements
6246
5908
  async convert(options) {
6247
5909
  var _a2;
6248
5910
  if (import_core15.isBrowser) {
@@ -6260,22 +5922,17 @@ var Tiles3DConverter = class {
6260
5922
  if (analyze || this.slpkFilesystem) {
6261
5923
  preprocessResult = await this.preprocessConversion();
6262
5924
  if (!preprocessResult || analyze) {
6263
- return;
5925
+ return void 0;
6264
5926
  }
6265
5927
  }
6266
5928
  this.progress.startMonitoring();
6267
- this.sourceTileset = await loadFromArchive2(
6268
- inputUrl,
6269
- import_i3s2.I3SLoader,
6270
- {
6271
- ...this.loaderOptions,
6272
- // @ts-expect-error `isTileset` can be boolean of 'auto' but TS expects a string
6273
- i3s: { ...this.loaderOptions.i3s, isTileset: true }
6274
- },
6275
- this.slpkFilesystem
6276
- );
5929
+ this.sourceTileset = await loadFromArchive2(inputUrl, import_i3s2.I3SLoader, {
5930
+ ...this.loaderOptions,
5931
+ // @ts-expect-error `isTileset` can be boolean of 'auto' but TS expects a string
5932
+ i3s: { ...this.loaderOptions.i3s, isTileset: true }
5933
+ }, this.slpkFilesystem);
6277
5934
  if (!this.sourceTileset) {
6278
- return;
5935
+ return void 0;
6279
5936
  }
6280
5937
  const rootNode = (_a2 = this.sourceTileset) == null ? void 0 : _a2.root;
6281
5938
  if (!rootNode.obb) {
@@ -6321,28 +5978,29 @@ var Tiles3DConverter = class {
6321
5978
  }
6322
5979
  const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
6323
5980
  workerFarm.destroy();
5981
+ return void 0;
6324
5982
  }
6325
5983
  /**
6326
5984
  * Preprocess stage of the tile converter. Calculate number of nodes
6327
5985
  * @returns true - the conversion is possible, false - the tileset's content is not supported
6328
5986
  */
6329
5987
  async preprocessConversion() {
6330
- console.log(`Analyze source layer`);
5988
+ console.log("Analyze source layer");
6331
5989
  const nodesCount = await getNodeCount(this.slpkFilesystem);
6332
5990
  this.progress.stepsTotal = nodesCount;
6333
- console.log(`------------------------------------------------`);
6334
- console.log(`Preprocess results:`);
5991
+ console.log("------------------------------------------------");
5992
+ console.log("Preprocess results:");
6335
5993
  if (this.slpkFilesystem) {
6336
5994
  console.log(`Node count: ${nodesCount}`);
6337
5995
  if (nodesCount === 0) {
6338
5996
  console.log("Node count is 0. The conversion will be interrupted.");
6339
- console.log(`------------------------------------------------`);
5997
+ console.log("------------------------------------------------");
6340
5998
  return false;
6341
5999
  }
6342
6000
  } else {
6343
- console.log(`Node count cannot be calculated for the remote dataset`);
6001
+ console.log("Node count cannot be calculated for the remote dataset");
6344
6002
  }
6345
- console.log(`------------------------------------------------`);
6003
+ console.log("------------------------------------------------");
6346
6004
  return true;
6347
6005
  }
6348
6006
  /**
@@ -6352,6 +6010,7 @@ var Tiles3DConverter = class {
6352
6010
  * @param level a current level of a tree depth
6353
6011
  * @param childNodeInfo child node to convert
6354
6012
  */
6013
+ // eslint-disable-next-line complexity, max-statements
6355
6014
  async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
6356
6015
  let nextParentNode = parentNode;
6357
6016
  const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
@@ -6362,12 +6021,7 @@ var Tiles3DConverter = class {
6362
6021
  await this._addChildren(sourceChild, child2, level + 1);
6363
6022
  return;
6364
6023
  }
6365
- const content = await loadI3SContent(
6366
- this.sourceTileset,
6367
- sourceChild,
6368
- this.loaderOptions,
6369
- this.slpkFilesystem
6370
- );
6024
+ const content = await loadI3SContent(this.sourceTileset, sourceChild, this.loaderOptions, this.slpkFilesystem);
6371
6025
  if (!content) {
6372
6026
  await this._addChildren(sourceChild, parentNode, level + 1);
6373
6027
  return;
@@ -6387,11 +6041,7 @@ var Tiles3DConverter = class {
6387
6041
  const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);
6388
6042
  await this.conversionDump.addNode(`${sourceChild.id}.b3dm`, sourceChild.id);
6389
6043
  await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
6390
- await this.conversionDump.updateConvertedNodesDumpFile(
6391
- `${sourceChild.id}.b3dm`,
6392
- sourceChild.id,
6393
- true
6394
- );
6044
+ await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.b3dm`, sourceChild.id, true);
6395
6045
  parentNode.children.push(child);
6396
6046
  nextParentNode = child;
6397
6047
  }
@@ -6431,9 +6081,7 @@ var Tiles3DConverter = class {
6431
6081
  let header;
6432
6082
  if ((_a2 = this.sourceTileset) == null ? void 0 : _a2.nodePagesTile) {
6433
6083
  console.log(`Node conversion: ${childNodeInfo.id}`);
6434
- header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(
6435
- parseInt(childNodeInfo.id)
6436
- );
6084
+ header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(parseInt(childNodeInfo.id));
6437
6085
  } else {
6438
6086
  const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
6439
6087
  const options = {
@@ -6558,3 +6206,4 @@ var Tiles3DConverter = class {
6558
6206
  console.log(`------------------------------------------------`);
6559
6207
  }
6560
6208
  };
6209
+ //# sourceMappingURL=index.cjs.map