@loaders.gl/tile-converter 4.1.0-alpha.9 → 4.1.1

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 (60) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -4
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  7. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/json-templates/tileset.js +3 -0
  9. package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  10. package/dist/constants.d.ts +1 -0
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/constants.js +1 -0
  13. package/dist/constants.js.map +1 -1
  14. package/dist/converter-cli.js +3 -3
  15. package/dist/converter-cli.js.map +1 -1
  16. package/dist/converter.min.cjs +131 -220
  17. package/dist/deps-installer/deps-installer.js +1 -1
  18. package/dist/deps-installer/deps-installer.js.map +1 -1
  19. package/dist/i3s-converter/helpers/progress.js +1 -1
  20. package/dist/i3s-converter/helpers/progress.js.map +1 -1
  21. package/dist/i3s-converter/i3s-converter.d.ts +14 -0
  22. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  23. package/dist/i3s-converter/i3s-converter.js +76 -25
  24. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  25. package/dist/i3s-converter/types.d.ts +7 -0
  26. package/dist/i3s-converter/types.d.ts.map +1 -1
  27. package/dist/i3s-converter/types.js +8 -0
  28. package/dist/i3s-converter/types.js.map +1 -1
  29. package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
  30. package/dist/index.cjs +376 -104
  31. package/dist/lib/utils/compress-util.d.ts +0 -37
  32. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  33. package/dist/lib/utils/compress-util.js +1 -149
  34. package/dist/lib/utils/compress-util.js.map +1 -1
  35. package/dist/lib/utils/conversion-dump.d.ts +81 -0
  36. package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
  37. package/dist/lib/utils/conversion-dump.js +131 -0
  38. package/dist/lib/utils/conversion-dump.js.map +1 -0
  39. package/dist/lib/utils/statistic-utills.js +1 -1
  40. package/dist/lib/utils/statistic-utills.js.map +1 -1
  41. package/dist/lib/utils/write-queue.d.ts +6 -1
  42. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  43. package/dist/lib/utils/write-queue.js +15 -3
  44. package/dist/lib/utils/write-queue.js.map +1 -1
  45. package/dist/pgm-loader.js +1 -1
  46. package/dist/pgm-loader.js.map +1 -1
  47. package/dist/slpk-extractor.min.cjs +31 -31
  48. package/package.json +16 -16
  49. package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -4
  50. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
  51. package/src/3d-tiles-converter/json-templates/tileset.ts +3 -0
  52. package/src/constants.ts +1 -0
  53. package/src/converter-cli.ts +3 -3
  54. package/src/i3s-converter/helpers/progress.ts +1 -1
  55. package/src/i3s-converter/i3s-converter.ts +192 -57
  56. package/src/i3s-converter/types.ts +8 -0
  57. package/src/lib/utils/compress-util.ts +1 -264
  58. package/src/lib/utils/conversion-dump.ts +203 -0
  59. package/src/lib/utils/statistic-utills.ts +1 -1
  60. package/src/lib/utils/write-queue.ts +15 -2
package/dist/index.cjs CHANGED
@@ -257,7 +257,7 @@ var import_json_map_transform8 = __toESM(require("json-map-transform"), 1);
257
257
  var import_md52 = __toESM(require("md5"), 1);
258
258
 
259
259
  // src/i3s-converter/helpers/node-pages.ts
260
- var import_path3 = require("path");
260
+ var import_path2 = require("path");
261
261
  var import_json_map_transform = __toESM(require("json-map-transform"), 1);
262
262
 
263
263
  // src/i3s-converter/json-templates/metadata.ts
@@ -287,17 +287,11 @@ var METADATA = () => ({
287
287
  var import_core = require("@loaders.gl/core");
288
288
  var import_loader_utils = require("@loaders.gl/loader-utils");
289
289
  var import_fs2 = require("fs");
290
- var import_path2 = require("path");
290
+ var import_path = require("path");
291
291
 
292
292
  // src/lib/utils/compress-util.ts
293
293
  var import_zlib = require("zlib");
294
- var import_path = require("path");
295
294
  var import_fs = require("fs");
296
- var import_archiver = __toESM(require("archiver"), 1);
297
- var import_worker_utils = require("@loaders.gl/worker-utils");
298
- var import_jszip = __toESM(require("jszip"), 1);
299
- var import_crypto = require("@loaders.gl/crypto");
300
- var import_crypt = __toESM(require("crypt"), 1);
301
295
  function compressFileWithGzip(pathFile) {
302
296
  const compressedPathFile = `${pathFile}.gz`;
303
297
  const gzip = (0, import_zlib.createGzip)();
@@ -315,42 +309,6 @@ function compressFileWithGzip(pathFile) {
315
309
  input.pipe(gzip).pipe(output);
316
310
  });
317
311
  }
318
- async function compressWithChildProcess(inputFolder, outputFile, level, inputFiles, sevenZipExe) {
319
- if (process.platform === "win32") {
320
- await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);
321
- } else {
322
- await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);
323
- }
324
- }
325
- async function compressWithChildProcessUnix(inputFolder, outputFile, level = 0, inputFiles = ".") {
326
- const fullOutputFile = getAbsoluteFilePath(outputFile);
327
- const args = [`-${level}`, "-r", fullOutputFile, inputFiles];
328
- const childProcess = new import_worker_utils.ChildProcessProxy();
329
- await childProcess.start({
330
- command: "zip",
331
- arguments: args,
332
- spawn: {
333
- cwd: inputFolder
334
- },
335
- wait: 0
336
- });
337
- }
338
- async function compressWithChildProcessWindows(inputFolder, outputFile, level = 0, inputFiles = (0, import_path.join)(".", "*"), sevenZipExe) {
339
- if (inputFiles[0] === "@") {
340
- inputFiles = `*${inputFiles.substr(1)}`;
341
- }
342
- const fullOutputFile = getAbsoluteFilePath(outputFile);
343
- const args = ["a", "-tzip", `-mx=${level}`, fullOutputFile, inputFiles];
344
- const childProcess = new import_worker_utils.ChildProcessProxy();
345
- await childProcess.start({
346
- command: sevenZipExe,
347
- arguments: args,
348
- spawn: {
349
- cwd: `${inputFolder}`
350
- },
351
- wait: 0
352
- });
353
- }
354
312
 
355
313
  // src/lib/utils/file-utils.ts
356
314
  async function writeFile(path, data, fileName = "index.json") {
@@ -363,7 +321,7 @@ async function writeFile(path, data, fileName = "index.json") {
363
321
  toWriteData = data;
364
322
  }
365
323
  await import_fs2.promises.mkdir(path, { recursive: true });
366
- const pathFile = (0, import_path2.join)(path, fileName);
324
+ const pathFile = (0, import_path.join)(path, fileName);
367
325
  try {
368
326
  await import_fs2.promises.writeFile(pathFile, toWriteData);
369
327
  } catch (err) {
@@ -395,7 +353,7 @@ async function openJson(path, fileName) {
395
353
  let count = 0;
396
354
  console.log(`load ${path}/${fileName}.`);
397
355
  const intervalId = setInterval(() => {
398
- const pathFile = (0, import_path2.join)(path, fileName);
356
+ const pathFile = (0, import_path.join)(path, fileName);
399
357
  (0, import_core.load)(pathFile, import_loader_utils.JSONLoader).then((result) => {
400
358
  clearInterval(intervalId);
401
359
  resolve(result);
@@ -424,7 +382,7 @@ function removeFile(path) {
424
382
  return import_fs2.promises.unlink(path);
425
383
  }
426
384
  function getAbsoluteFilePath(filePath) {
427
- return (0, import_path2.isAbsolute)(filePath) ? filePath : (0, import_path2.join)(process.cwd(), filePath);
385
+ return (0, import_path.isAbsolute)(filePath) ? filePath : (0, import_path.join)(process.cwd(), filePath);
428
386
  }
429
387
 
430
388
  // src/i3s-converter/helpers/node-pages.ts
@@ -461,10 +419,10 @@ var NodePages = class {
461
419
  let filePath;
462
420
  let fileName;
463
421
  if (this.converter.options.slpk) {
464
- filePath = (0, import_path3.join)(this.converter.layers0Path, "nodepages");
422
+ filePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages");
465
423
  fileName = `${nodePageId.toString()}.json`;
466
424
  } else {
467
- filePath = (0, import_path3.join)(this.converter.layers0Path, "nodepages", nodePageId.toString());
425
+ filePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages", nodePageId.toString());
468
426
  fileName = "index.json";
469
427
  }
470
428
  return { filePath, fileName };
@@ -476,7 +434,7 @@ var NodePages = class {
476
434
  */
477
435
  async loadNodePage(nodePageId) {
478
436
  const { filePath, fileName } = this.getNodePageFileName(nodePageId);
479
- const fullName = (0, import_path3.join)(filePath, fileName);
437
+ const fullName = (0, import_path2.join)(filePath, fileName);
480
438
  if (await isFileExists(fullName)) {
481
439
  console.log(`load ${fullName}.`);
482
440
  return await openJson(filePath, fileName);
@@ -613,7 +571,7 @@ var NodePages = class {
613
571
  if (this.converter.options.slpk) {
614
572
  for (const [index, nodePage] of this.nodePages.entries()) {
615
573
  const nodePageStr = JSON.stringify(nodePage);
616
- const slpkPath = (0, import_path3.join)(this.converter.layers0Path, "nodepages");
574
+ const slpkPath = (0, import_path2.join)(this.converter.layers0Path, "nodepages");
617
575
  await this.converter.writeQueue.enqueue({
618
576
  archiveKey: `nodePages/${index.toString()}.json.gz`,
619
577
  writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
@@ -623,7 +581,7 @@ var NodePages = class {
623
581
  } else {
624
582
  for (const [index, nodePage] of this.nodePages.entries()) {
625
583
  const nodePageStr = JSON.stringify(nodePage);
626
- const nodePagePath = (0, import_path3.join)(this.converter.layers0Path, "nodepages", index.toString());
584
+ const nodePagePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages", index.toString());
627
585
  await this.converter.writeQueue.enqueue({
628
586
  writePromise: () => this.writeFile(nodePagePath, nodePageStr)
629
587
  });
@@ -709,7 +667,7 @@ var NodePages = class {
709
667
  };
710
668
 
711
669
  // src/lib/utils/statistic-utills.ts
712
- var import_path4 = require("path");
670
+ var import_path3 = require("path");
713
671
  var import_fs3 = require("fs");
714
672
  function timeConverter(time) {
715
673
  if (typeof time === "number") {
@@ -741,7 +699,7 @@ function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
741
699
  result += `${seconds}s`;
742
700
  }
743
701
  if (!result) {
744
- result += `${milliseconds}ms`;
702
+ result += `${Math.floor(milliseconds)}ms`;
745
703
  }
746
704
  return result;
747
705
  }
@@ -750,11 +708,11 @@ async function calculateFilesSize(params) {
750
708
  const fullOutputPath = getAbsoluteFilePath(outputPath);
751
709
  try {
752
710
  if (slpk) {
753
- const slpkPath = (0, import_path4.join)(fullOutputPath, `${tilesetName}.slpk`);
711
+ const slpkPath = (0, import_path3.join)(fullOutputPath, `${tilesetName}.slpk`);
754
712
  const stat = await import_fs3.promises.stat(slpkPath);
755
713
  return stat.size;
756
714
  }
757
- const directoryPath = (0, import_path4.join)(fullOutputPath, tilesetName);
715
+ const directoryPath = (0, import_path3.join)(fullOutputPath, tilesetName);
758
716
  const totalSize = await getTotalFilesSize(directoryPath);
759
717
  return totalSize;
760
718
  } catch (error) {
@@ -766,9 +724,9 @@ async function getTotalFilesSize(dirPath) {
766
724
  let totalFileSize = 0;
767
725
  const files = await import_fs3.promises.readdir(dirPath);
768
726
  for (const file of files) {
769
- const fileStat = await import_fs3.promises.stat((0, import_path4.join)(dirPath, file));
727
+ const fileStat = await import_fs3.promises.stat((0, import_path3.join)(dirPath, file));
770
728
  if (fileStat.isDirectory()) {
771
- totalFileSize += await getTotalFilesSize((0, import_path4.join)(dirPath, file));
729
+ totalFileSize += await getTotalFilesSize((0, import_path3.join)(dirPath, file));
772
730
  } else {
773
731
  totalFileSize += fileStat.size;
774
732
  }
@@ -2436,7 +2394,7 @@ function getPropertyTableExtension(tileContent) {
2436
2394
  // src/i3s-converter/helpers/create-scene-server-path.ts
2437
2395
  var import_uuid2 = require("uuid");
2438
2396
  var import_json_map_transform2 = __toESM(require("json-map-transform"), 1);
2439
- var import_path5 = require("path");
2397
+ var import_path4 = require("path");
2440
2398
 
2441
2399
  // src/i3s-converter/json-templates/scene-server.ts
2442
2400
  var SCENE_SERVER = () => ({
@@ -2475,7 +2433,7 @@ async function createSceneServerPath(layerName, layers0, rootPath) {
2475
2433
  layers0
2476
2434
  };
2477
2435
  const sceneServer = (0, import_json_map_transform2.default)(sceneServerData, SCENE_SERVER());
2478
- const nodePagePath = (0, import_path5.join)(rootPath, "SceneServer");
2436
+ const nodePagePath = (0, import_path4.join)(rootPath, "SceneServer");
2479
2437
  await writeFile(nodePagePath, JSON.stringify(sceneServer));
2480
2438
  }
2481
2439
 
@@ -3134,9 +3092,8 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
3134
3092
 
3135
3093
  // src/i3s-converter/i3s-converter.ts
3136
3094
  var import_textures = require("@loaders.gl/textures");
3137
- var import_loader_utils4 = require("@loaders.gl/loader-utils");
3138
3095
  var import_images = require("@loaders.gl/images");
3139
- var import_worker_utils2 = require("@loaders.gl/worker-utils");
3096
+ var import_worker_utils = require("@loaders.gl/worker-utils");
3140
3097
 
3141
3098
  // src/lib/utils/queue.ts
3142
3099
  var Queue = class extends Array {
@@ -3158,10 +3115,11 @@ var Queue = class extends Array {
3158
3115
  var import_process = __toESM(require("process"), 1);
3159
3116
  var MEMORY_LIMIT = 4 * 1024 * 1024 * 1024;
3160
3117
  var WriteQueue = class extends Queue {
3161
- constructor(listeningInterval = 2e3, writeConcurrency = 400) {
3118
+ constructor(conversionDump, listeningInterval = 2e3, writeConcurrency = 400) {
3162
3119
  super();
3163
3120
  this.writePromise = null;
3164
3121
  this.fileMap = {};
3122
+ this.conversionDump = conversionDump;
3165
3123
  this.listeningInterval = listeningInterval;
3166
3124
  this.writeConcurrency = writeConcurrency;
3167
3125
  }
@@ -3202,18 +3160,21 @@ var WriteQueue = class extends Queue {
3202
3160
  while (this.length) {
3203
3161
  const promises = [];
3204
3162
  const archiveKeys = [];
3163
+ const changedRecords = [];
3205
3164
  for (let i = 0; i < this.writeConcurrency; i++) {
3206
3165
  const item = this.dequeue();
3207
3166
  if (!item) {
3208
3167
  break;
3209
3168
  }
3210
- const { archiveKey, writePromise } = item;
3169
+ const { archiveKey, sourceId, outputId, resourceType, writePromise } = item;
3211
3170
  archiveKeys.push(archiveKey);
3171
+ changedRecords.push({ sourceId, outputId, resourceType });
3212
3172
  const promise = writePromise();
3213
3173
  promises.push(promise);
3214
3174
  }
3215
3175
  const writeResults = await Promise.allSettled(promises);
3216
3176
  this.updateFileMap(archiveKeys, writeResults);
3177
+ await this.conversionDump.updateConvertedTilesDump(changedRecords, writeResults);
3217
3178
  }
3218
3179
  }
3219
3180
  updateFileMap(archiveKeys, writeResults) {
@@ -3228,9 +3189,10 @@ var WriteQueue = class extends Queue {
3228
3189
 
3229
3190
  // src/constants.ts
3230
3191
  var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
3192
+ var DUMP_FILE_SUFFIX = ".dump.json";
3231
3193
 
3232
3194
  // src/i3s-converter/helpers/node-index-document.ts
3233
- var import_path6 = require("path");
3195
+ var import_path5 = require("path");
3234
3196
  var import_json_map_transform7 = __toESM(require("json-map-transform"), 1);
3235
3197
  var import_uuid3 = require("uuid");
3236
3198
 
@@ -3433,7 +3395,7 @@ var NodeIndexDocument = class {
3433
3395
  * @param node - Node3DIndexDocument object
3434
3396
  */
3435
3397
  async write(node) {
3436
- const path = (0, import_path6.join)(this.converter.layers0Path, "nodes", this.id);
3398
+ const path = (0, import_path5.join)(this.converter.layers0Path, "nodes", this.id);
3437
3399
  if (this.converter.options.slpk) {
3438
3400
  await this.converter.writeQueue.enqueue(
3439
3401
  {
@@ -3464,7 +3426,7 @@ var NodeIndexDocument = class {
3464
3426
  return this.data;
3465
3427
  }
3466
3428
  const path = this.id;
3467
- const parentNodePath = (0, import_path6.join)(this.converter.layers0Path, "nodes", path);
3429
+ const parentNodePath = (0, import_path5.join)(this.converter.layers0Path, "nodes", path);
3468
3430
  let parentNodeFileName = "index.json";
3469
3431
  if (this.converter.options.slpk) {
3470
3432
  parentNodeFileName = "3dNodeIndexDocument.json";
@@ -3863,7 +3825,7 @@ var Progress = class {
3863
3825
  * @returns Number of milliseconds remaining
3864
3826
  */
3865
3827
  getTimeRemaining() {
3866
- if (!this._stepsDone || !this.startTime) {
3828
+ if (!this._stepsTotal || !this._stepsDone || !this.startTime) {
3867
3829
  return null;
3868
3830
  }
3869
3831
  const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
@@ -3905,6 +3867,171 @@ var Progress = class {
3905
3867
 
3906
3868
  // src/i3s-converter/i3s-converter.ts
3907
3869
  var import_zip = require("@loaders.gl/zip");
3870
+
3871
+ // src/lib/utils/conversion-dump.ts
3872
+ var import_path6 = require("path");
3873
+ var ConversionDump = class {
3874
+ constructor() {
3875
+ this.tilesConverted = {};
3876
+ }
3877
+ /**
3878
+ * Create a dump file with convertion options
3879
+ * @param options - converter options
3880
+ */
3881
+ async createDumpFile(options) {
3882
+ const {
3883
+ tilesetName,
3884
+ slpk,
3885
+ egmFilePath,
3886
+ inputUrl,
3887
+ outputPath,
3888
+ draco = true,
3889
+ maxDepth,
3890
+ token,
3891
+ generateTextures,
3892
+ generateBoundingVolumes,
3893
+ mergeMaterials: mergeMaterials2 = true,
3894
+ metadataClass,
3895
+ analyze = false
3896
+ } = options;
3897
+ this.options = {
3898
+ tilesetName,
3899
+ slpk,
3900
+ egmFilePath,
3901
+ inputUrl,
3902
+ outputPath,
3903
+ draco,
3904
+ maxDepth,
3905
+ token,
3906
+ generateTextures,
3907
+ generateBoundingVolumes,
3908
+ mergeMaterials: mergeMaterials2,
3909
+ metadataClass,
3910
+ analyze
3911
+ };
3912
+ try {
3913
+ await writeFile(
3914
+ options.outputPath,
3915
+ JSON.stringify({ options: this.options }),
3916
+ `${options.tilesetName}${DUMP_FILE_SUFFIX}`
3917
+ );
3918
+ } catch (error) {
3919
+ console.log("Can't create dump file", error);
3920
+ }
3921
+ }
3922
+ /**
3923
+ * Update conversion status in the dump file
3924
+ */
3925
+ async updateDumpFile() {
3926
+ var _a2;
3927
+ if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName) {
3928
+ try {
3929
+ await writeFile(
3930
+ this.options.outputPath,
3931
+ JSON.stringify({
3932
+ options: this.options,
3933
+ tilesConverted: this.tilesConverted
3934
+ }),
3935
+ `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
3936
+ );
3937
+ } catch (error) {
3938
+ console.log("Can't update dump file", error);
3939
+ }
3940
+ }
3941
+ }
3942
+ /**
3943
+ * Delete a dump file
3944
+ */
3945
+ async deleteDumpFile() {
3946
+ var _a2;
3947
+ if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName) {
3948
+ await removeFile(
3949
+ (0, import_path6.join)(this.options.outputPath, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)
3950
+ );
3951
+ }
3952
+ }
3953
+ /**
3954
+ * Get record from the tilesConverted Map
3955
+ * @param fileName - source filename
3956
+ * @returns existing object from the tilesConverted Map
3957
+ */
3958
+ getRecord(fileName) {
3959
+ return this.tilesConverted[fileName];
3960
+ }
3961
+ /**
3962
+ * Set a record for the dump file
3963
+ * @param fileName - key - source filename
3964
+ * @param object - value
3965
+ */
3966
+ setRecord(fileName, object) {
3967
+ this.tilesConverted[fileName] = object;
3968
+ }
3969
+ /**
3970
+ * Add a node into the dump file for the source file record
3971
+ * @param fileName - source filename
3972
+ * @param nodeId - nodeId of the node
3973
+ */
3974
+ async addNode(filename, nodeId) {
3975
+ const { nodes } = this.getRecord(filename) || { nodes: [] };
3976
+ nodes.push({ nodeId, done: false, progress: {} });
3977
+ if (nodes.length === 1) {
3978
+ this.setRecord(filename, { nodes });
3979
+ }
3980
+ await this.updateDumpFile();
3981
+ }
3982
+ /**
3983
+ * Update done status object for the writing resources
3984
+ * @param fileName - key - source filename
3985
+ * @param nodeId - nodeId for the source filename
3986
+ * @param resourceType - resource type to update status
3987
+ * @param value - value
3988
+ */
3989
+ updateDoneStatus(filename, nodeId, resourceType, value) {
3990
+ var _a2;
3991
+ const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find(
3992
+ (element) => element.nodeId === nodeId
3993
+ );
3994
+ if (nodeDump) {
3995
+ nodeDump.progress[resourceType] = value;
3996
+ if (!value) {
3997
+ nodeDump.done = false;
3998
+ }
3999
+ }
4000
+ }
4001
+ /**
4002
+ * Update dump file according to writing results
4003
+ * @param changedRecords - array of parameters ids for the written resources
4004
+ * @param writeResults - array of writing resource files results
4005
+ */
4006
+ async updateConvertedTilesDump(changedRecords, writeResults) {
4007
+ for (let i = 0; i < changedRecords.length; i++) {
4008
+ if (changedRecords[i] && "value" in writeResults[i]) {
4009
+ const { sourceId, resourceType, outputId } = changedRecords[i];
4010
+ if (!sourceId || !resourceType || !outputId)
4011
+ continue;
4012
+ for (const node of this.tilesConverted[sourceId].nodes) {
4013
+ if (node.nodeId === outputId) {
4014
+ node.progress[resourceType] = true;
4015
+ let done = false;
4016
+ for (const key in node.progress) {
4017
+ done = node.progress[key];
4018
+ if (!done)
4019
+ break;
4020
+ }
4021
+ node.done = done;
4022
+ if (node.done) {
4023
+ node.progress = {};
4024
+ }
4025
+ break;
4026
+ }
4027
+ }
4028
+ }
4029
+ }
4030
+ await this.updateDumpFile();
4031
+ }
4032
+ };
4033
+
4034
+ // src/i3s-converter/i3s-converter.ts
3908
4035
  var _a;
3909
4036
  var ION_DEFAULT_TOKEN = (_a = import_process3.default.env) == null ? void 0 : _a.IonToken;
3910
4037
  var HARDCODED_NODES_PER_PAGE = 64;
@@ -3936,7 +4063,7 @@ var I3SConverter = class {
3936
4063
  this.geoidHeightModel = null;
3937
4064
  this.Loader = import_d_tiles2.Tiles3DLoader;
3938
4065
  this.workerSource = {};
3939
- this.writeQueue = new WriteQueue();
4066
+ this.writeQueue = new WriteQueue(new ConversionDump());
3940
4067
  this.compressList = null;
3941
4068
  this.preprocessData = {
3942
4069
  meshTopologyTypes: /* @__PURE__ */ new Set(),
@@ -3963,6 +4090,7 @@ var I3SConverter = class {
3963
4090
  this.generateBoundingVolumes = false;
3964
4091
  this.layersHasTexture = false;
3965
4092
  this.compressList = null;
4093
+ this.conversionDump = new ConversionDump();
3966
4094
  }
3967
4095
  /**
3968
4096
  * Convert a 3d tileset
@@ -4007,6 +4135,8 @@ var I3SConverter = class {
4007
4135
  analyze = false
4008
4136
  } = options;
4009
4137
  this.options = {
4138
+ outputPath,
4139
+ tilesetName,
4010
4140
  maxDepth,
4011
4141
  slpk,
4012
4142
  sevenZipExe,
@@ -4025,7 +4155,7 @@ var I3SConverter = class {
4025
4155
  this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? import_d_tiles2.CesiumIonLoader : import_d_tiles2.Tiles3DLoader;
4026
4156
  this.generateTextures = Boolean(generateTextures);
4027
4157
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
4028
- this.writeQueue = new WriteQueue();
4158
+ this.writeQueue = new WriteQueue(this.conversionDump);
4029
4159
  this.writeQueue.startListening();
4030
4160
  console.log("Loading egm file...");
4031
4161
  this.geoidHeightModel = await (0, import_core9.load)(egmFilePath, PGMLoader);
@@ -4033,6 +4163,7 @@ var I3SConverter = class {
4033
4163
  if (slpk) {
4034
4164
  this.nodePages.useWriteFunction(writeFileForSlpk);
4035
4165
  }
4166
+ await this.conversionDump.createDumpFile(options);
4036
4167
  try {
4037
4168
  const preloadOptions = await this._fetchPreloadOptions();
4038
4169
  let tilesetUrl = inputUrl;
@@ -4055,7 +4186,7 @@ var I3SConverter = class {
4055
4186
  throw error;
4056
4187
  } finally {
4057
4188
  await this.writeQueue.finalize();
4058
- const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
4189
+ const workerFarm = import_worker_utils.WorkerFarm.getWorkerFarm({});
4059
4190
  workerFarm.destroy();
4060
4191
  }
4061
4192
  return "success";
@@ -4288,18 +4419,14 @@ var I3SConverter = class {
4288
4419
  * @param tilesetPath - Path to save file
4289
4420
  */
4290
4421
  async _createSlpk(tilesetPath) {
4422
+ await this.conversionDump.deleteDumpFile();
4291
4423
  if (this.options.slpk) {
4292
4424
  const slpkTilesetPath = (0, import_path7.join)(tilesetPath, "SceneServer", "layers", "0");
4293
4425
  const slpkFileName = `${tilesetPath}.slpk`;
4294
- await compressWithChildProcess(
4295
- slpkTilesetPath,
4296
- slpkFileName,
4297
- 0,
4298
- ".",
4299
- this.options.sevenZipExe
4300
- );
4301
- const hashTable = await (0, import_zip.composeHashFile)(new import_loader_utils4.FileHandleFile(slpkFileName));
4302
- await (0, import_zip.addOneFile)(slpkFileName, hashTable, "@specialIndexFileHASH128@");
4426
+ await (0, import_zip.createZip)(slpkTilesetPath, slpkFileName, async (fileList) => ({
4427
+ path: "@specialIndexFileHASH128@",
4428
+ file: await (0, import_zip.composeHashFile)(fileList)
4429
+ }));
4303
4430
  try {
4304
4431
  await removeDir(tilesetPath);
4305
4432
  } catch (e) {
@@ -4346,8 +4473,9 @@ var I3SConverter = class {
4346
4473
  if (timeRemainingStringBasedOnCount) {
4347
4474
  timeRemainingString = `${timeRemainingStringBasedOnCount} left`;
4348
4475
  }
4349
- let percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
4350
- console.log(`[converted ${percentString}%, ${timeRemainingString}]: ${sourceTile.id}`);
4476
+ const percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
4477
+ const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : "";
4478
+ console.log(`[converted${progressString}]: ${sourceTile.id}`);
4351
4479
  }
4352
4480
  return newTraversalProps;
4353
4481
  }
@@ -4440,7 +4568,10 @@ var I3SConverter = class {
4440
4568
  const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
4441
4569
  nodes.push(node);
4442
4570
  if (nodeInPage.mesh) {
4443
- await this._writeResources(resources, node.id);
4571
+ if (sourceTile.id) {
4572
+ await this.conversionDump.addNode(sourceTile.id, nodeInPage.index);
4573
+ }
4574
+ await this._writeResources(resources, node.id, sourceTile);
4444
4575
  }
4445
4576
  if (this.validate) {
4446
4577
  this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);
@@ -4564,9 +4695,11 @@ var I3SConverter = class {
4564
4695
  * @param resources.texture - texture image
4565
4696
  * @param resources.sharedResources - shared resource data object
4566
4697
  * @param resources.attributes - feature attributes
4698
+ * @param nodePath - node path
4699
+ * @param sourceTile - source tile (3DTile)
4567
4700
  * @return {Promise<void>}
4568
4701
  */
4569
- async _writeResources(resources, nodePath) {
4702
+ async _writeResources(resources, nodePath, sourceTile) {
4570
4703
  const {
4571
4704
  geometry: geometryBuffer,
4572
4705
  compressedGeometry,
@@ -4576,10 +4709,36 @@ var I3SConverter = class {
4576
4709
  } = resources;
4577
4710
  const childPath = (0, import_path7.join)(this.layers0Path, "nodes", nodePath);
4578
4711
  const slpkChildPath = (0, import_path7.join)("nodes", nodePath);
4579
- await this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath);
4580
- await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);
4581
- await this._writeTexture(texture, childPath, slpkChildPath);
4582
- await this._writeAttributes(attributes, childPath, slpkChildPath);
4712
+ await this._writeGeometries(
4713
+ geometryBuffer,
4714
+ compressedGeometry,
4715
+ childPath,
4716
+ slpkChildPath,
4717
+ sourceTile.id || "",
4718
+ parseInt(nodePath)
4719
+ );
4720
+ await this._writeShared(
4721
+ sharedResources,
4722
+ childPath,
4723
+ slpkChildPath,
4724
+ nodePath,
4725
+ sourceTile.id || "",
4726
+ parseInt(nodePath)
4727
+ );
4728
+ await this._writeTexture(
4729
+ texture,
4730
+ childPath,
4731
+ slpkChildPath,
4732
+ sourceTile.id || "",
4733
+ parseInt(nodePath)
4734
+ );
4735
+ await this._writeAttributes(
4736
+ attributes,
4737
+ childPath,
4738
+ slpkChildPath,
4739
+ sourceTile.id || "",
4740
+ parseInt(nodePath)
4741
+ );
4583
4742
  }
4584
4743
  /**
4585
4744
  * Write non-compressed and compressed geometries in files
@@ -4587,30 +4746,46 @@ var I3SConverter = class {
4587
4746
  * @param compressedGeometry - Uint8Array with compressed (draco) geometry
4588
4747
  * @param childPath - a child path to write resources
4589
4748
  * @param slpkChildPath - resource path inside *slpk file
4749
+ * @param sourceId - source filename
4750
+ * @param nodeId - nodeId of a converted node for the writing
4590
4751
  */
4591
- async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
4752
+ async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
4753
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, "GEOMETRY" /* GEOMETRY */, false);
4592
4754
  if (this.options.slpk) {
4593
4755
  const slpkGeometryPath = (0, import_path7.join)(childPath, "geometries");
4594
4756
  await this.writeQueue.enqueue({
4595
4757
  archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
4758
+ sourceId,
4759
+ outputId: nodeId,
4760
+ resourceType: "GEOMETRY" /* GEOMETRY */,
4596
4761
  writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, "0.bin")
4597
4762
  });
4598
4763
  } else {
4599
4764
  const geometryPath = (0, import_path7.join)(childPath, "geometries/0/");
4600
4765
  await this.writeQueue.enqueue({
4766
+ sourceId,
4767
+ outputId: nodeId,
4768
+ resourceType: "GEOMETRY" /* GEOMETRY */,
4601
4769
  writePromise: () => writeFile(geometryPath, geometryBuffer, "index.bin")
4602
4770
  });
4603
4771
  }
4604
4772
  if (this.options.draco) {
4773
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, "DRACO_GEOMETRY" /* DRACO_GEOMETRY */, false);
4605
4774
  if (this.options.slpk) {
4606
4775
  const slpkCompressedGeometryPath = (0, import_path7.join)(childPath, "geometries");
4607
4776
  await this.writeQueue.enqueue({
4608
4777
  archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
4778
+ sourceId,
4779
+ outputId: nodeId,
4780
+ resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
4609
4781
  writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, "1.bin")
4610
4782
  });
4611
4783
  } else {
4612
4784
  const compressedGeometryPath = (0, import_path7.join)(childPath, "geometries/1/");
4613
4785
  await this.writeQueue.enqueue({
4786
+ sourceId,
4787
+ outputId: nodeId,
4788
+ resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
4614
4789
  writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, "index.bin")
4615
4790
  });
4616
4791
  }
@@ -4622,23 +4797,34 @@ var I3SConverter = class {
4622
4797
  * @param childPath - a child path to write resources
4623
4798
  * @param slpkChildPath - resource path inside *slpk file
4624
4799
  * @param nodePath - a node path
4800
+ * @param sourceId - source filename
4801
+ * @param nodeId - nodeId of a converted node for the writing
4625
4802
  */
4626
- async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
4803
+ async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
4627
4804
  if (!sharedResources) {
4628
4805
  return;
4629
4806
  }
4630
4807
  sharedResources.nodePath = nodePath;
4631
4808
  const sharedData = (0, import_json_map_transform8.default)(sharedResources, SHARED_RESOURCES());
4632
4809
  const sharedDataStr = JSON.stringify(sharedData);
4810
+ this.conversionDump.updateDoneStatus(sourceId, nodeId, "SHARED" /* SHARED */, false);
4633
4811
  if (this.options.slpk) {
4634
4812
  const slpkSharedPath = (0, import_path7.join)(childPath, "shared");
4635
4813
  await this.writeQueue.enqueue({
4636
4814
  archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
4815
+ sourceId,
4816
+ outputId: nodeId,
4817
+ resourceType: "SHARED" /* SHARED */,
4637
4818
  writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, "sharedResource.json")
4638
4819
  });
4639
4820
  } else {
4640
4821
  const sharedPath = (0, import_path7.join)(childPath, "shared/");
4641
- await this.writeQueue.enqueue({ writePromise: () => writeFile(sharedPath, sharedDataStr) });
4822
+ await this.writeQueue.enqueue({
4823
+ sourceId,
4824
+ outputId: nodeId,
4825
+ resourceType: "SHARED" /* SHARED */,
4826
+ writePromise: () => writeFile(sharedPath, sharedDataStr)
4827
+ });
4642
4828
  }
4643
4829
  }
4644
4830
  /**
@@ -4646,8 +4832,10 @@ var I3SConverter = class {
4646
4832
  * @param texture - the texture image
4647
4833
  * @param childPath - a child path to write resources
4648
4834
  * @param slpkChildPath - the resource path inside *slpk file
4835
+ * @param sourceId - source filename
4836
+ * @param nodeId - nodeId of a converted node for the writing
4649
4837
  */
4650
- async _writeTexture(texture, childPath, slpkChildPath) {
4838
+ async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
4651
4839
  if (texture) {
4652
4840
  const format = this._getFormatByMimeType(texture == null ? void 0 : texture.mimeType);
4653
4841
  const formats = [];
@@ -4656,7 +4844,21 @@ var I3SConverter = class {
4656
4844
  case "jpg":
4657
4845
  case "png": {
4658
4846
  formats.push({ name: "0", format });
4659
- await this.writeTextureFile(textureData, "0", format, childPath, slpkChildPath);
4847
+ this.conversionDump.updateDoneStatus(
4848
+ sourceId,
4849
+ nodeId,
4850
+ `${"TEXTURE" /* TEXTURE */}/${format}`,
4851
+ false
4852
+ );
4853
+ await this.writeTextureFile(
4854
+ textureData,
4855
+ "0",
4856
+ format,
4857
+ childPath,
4858
+ slpkChildPath,
4859
+ sourceId,
4860
+ nodeId
4861
+ );
4660
4862
  if (this.generateTextures) {
4661
4863
  formats.push({ name: "1", format: "ktx2" });
4662
4864
  const copyArrayBuffer = texture.image.data.subarray();
@@ -4676,22 +4878,58 @@ var I3SConverter = class {
4676
4878
  useLocalLibraries: true
4677
4879
  }
4678
4880
  );
4679
- await this.writeTextureFile(ktx2TextureData, "1", "ktx2", childPath, slpkChildPath);
4881
+ this.conversionDump.updateDoneStatus(
4882
+ sourceId,
4883
+ nodeId,
4884
+ `${"TEXTURE" /* TEXTURE */}/ktx2`,
4885
+ false
4886
+ );
4887
+ await this.writeTextureFile(
4888
+ ktx2TextureData,
4889
+ "1",
4890
+ "ktx2",
4891
+ childPath,
4892
+ slpkChildPath,
4893
+ sourceId,
4894
+ nodeId
4895
+ );
4680
4896
  }
4681
4897
  break;
4682
4898
  }
4683
4899
  case "ktx2": {
4684
4900
  formats.push({ name: "1", format });
4685
- await this.writeTextureFile(textureData, "1", format, childPath, slpkChildPath);
4901
+ this.conversionDump.updateDoneStatus(
4902
+ sourceId,
4903
+ nodeId,
4904
+ `${"TEXTURE" /* TEXTURE */}/${format}`,
4905
+ false
4906
+ );
4907
+ await this.writeTextureFile(
4908
+ textureData,
4909
+ "1",
4910
+ format,
4911
+ childPath,
4912
+ slpkChildPath,
4913
+ sourceId,
4914
+ nodeId
4915
+ );
4686
4916
  if (this.generateTextures) {
4687
4917
  formats.push({ name: "0", format: "jpg" });
4688
4918
  const decodedFromKTX2TextureData = (0, import_core9.encode)(texture.image.data[0], import_images.ImageWriter);
4919
+ this.conversionDump.updateDoneStatus(
4920
+ sourceId,
4921
+ nodeId,
4922
+ `${"TEXTURE" /* TEXTURE */}/jpg`,
4923
+ false
4924
+ );
4689
4925
  await this.writeTextureFile(
4690
4926
  decodedFromKTX2TextureData,
4691
4927
  "0",
4692
4928
  "jpg",
4693
4929
  childPath,
4694
- slpkChildPath
4930
+ slpkChildPath,
4931
+ sourceId,
4932
+ nodeId
4695
4933
  );
4696
4934
  }
4697
4935
  }
@@ -4709,18 +4947,26 @@ var I3SConverter = class {
4709
4947
  * @param format
4710
4948
  * @param childPath
4711
4949
  * @param slpkChildPath
4950
+ * @param sourceId
4951
+ * @param nodeId
4712
4952
  */
4713
- async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
4953
+ async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
4714
4954
  if (this.options.slpk) {
4715
4955
  const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
4716
4956
  const compress = false;
4717
4957
  await this.writeQueue.enqueue({
4718
4958
  archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
4959
+ sourceId,
4960
+ outputId: nodeId,
4961
+ resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
4719
4962
  writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
4720
4963
  });
4721
4964
  } else {
4722
4965
  const texturePath = (0, import_path7.join)(childPath, `textures/${name}/`);
4723
4966
  await this.writeQueue.enqueue({
4967
+ sourceId,
4968
+ outputId: nodeId,
4969
+ resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
4724
4970
  writePromise: () => writeFile(texturePath, textureData, `index.${format}`)
4725
4971
  });
4726
4972
  }
@@ -4730,22 +4976,36 @@ var I3SConverter = class {
4730
4976
  * @param attributes - feature attributes
4731
4977
  * @param childPath - a child path to write resources
4732
4978
  * @param slpkChildPath - the resource path inside *slpk file
4979
+ * @param sourceId - source filename
4980
+ * @param nodeId - nodeId of a converted node for the writing
4733
4981
  */
4734
- async _writeAttributes(attributes = [], childPath, slpkChildPath) {
4982
+ async _writeAttributes(attributes = [], childPath, slpkChildPath, sourceId, nodeId) {
4735
4983
  if ((attributes == null ? void 0 : attributes.length) && this.attributeMetadataInfo.attributeStorageInfo.length) {
4736
4984
  const minimumLength = attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length ? attributes.length : this.attributeMetadataInfo.attributeStorageInfo.length;
4737
4985
  for (let index = 0; index < minimumLength; index++) {
4738
4986
  const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
4739
4987
  const fileBuffer = new Uint8Array(attributes[index]);
4988
+ this.conversionDump.updateDoneStatus(
4989
+ sourceId,
4990
+ nodeId,
4991
+ `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
4992
+ false
4993
+ );
4740
4994
  if (this.options.slpk) {
4741
4995
  const slpkAttributesPath = (0, import_path7.join)(childPath, "attributes", folderName);
4742
4996
  await this.writeQueue.enqueue({
4743
4997
  archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
4998
+ sourceId,
4999
+ outputId: nodeId,
5000
+ resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
4744
5001
  writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, "0.bin")
4745
5002
  });
4746
5003
  } else {
4747
5004
  const attributesPath = (0, import_path7.join)(childPath, `attributes/${folderName}/0`);
4748
5005
  await this.writeQueue.enqueue({
5006
+ sourceId,
5007
+ outputId: nodeId,
5008
+ resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
4749
5009
  writePromise: () => writeFile(attributesPath, fileBuffer, "index.bin")
4750
5010
  });
4751
5011
  }
@@ -4932,6 +5192,9 @@ var TILE = () => ({
4932
5192
  geometricError: {
4933
5193
  path: "geometricError"
4934
5194
  },
5195
+ refine: {
5196
+ path: "refine"
5197
+ },
4935
5198
  content: {
4936
5199
  path: "content"
4937
5200
  },
@@ -4956,7 +5219,7 @@ var TILESET = () => ({
4956
5219
  });
4957
5220
 
4958
5221
  // src/3d-tiles-converter/3d-tiles-converter.ts
4959
- var import_worker_utils3 = require("@loaders.gl/worker-utils");
5222
+ var import_worker_utils2 = require("@loaders.gl/worker-utils");
4960
5223
 
4961
5224
  // src/3d-tiles-converter/helpers/b3dm-converter.ts
4962
5225
  var import_core12 = require("@loaders.gl/core");
@@ -4999,6 +5262,9 @@ function normalizeRegions(regions) {
4999
5262
  // src/3d-tiles-converter/helpers/b3dm-converter.ts
5000
5263
  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]);
5001
5264
  var scratchVector2 = new import_core13.Vector3();
5265
+ var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
5266
+ var METALLIC_FACTOR_DEFAULT = 1;
5267
+ var ROUGHNESS_FACTOR_DEFAULT = 1;
5002
5268
  var B3dmConverter = class {
5003
5269
  /**
5004
5270
  * The starter of content conversion
@@ -5028,6 +5294,11 @@ var B3dmConverter = class {
5028
5294
  const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
5029
5295
  const gltfBuilder = new import_gltf6.GLTFScenegraph();
5030
5296
  const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);
5297
+ const pbrMetallicRoughness = material == null ? void 0 : material.pbrMetallicRoughness;
5298
+ if (pbrMetallicRoughness && (pbrMetallicRoughness.metallicFactor === void 0 || pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) && (pbrMetallicRoughness.roughnessFactor === void 0 || pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)) {
5299
+ gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
5300
+ gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);
5301
+ }
5031
5302
  const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);
5032
5303
  const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
5033
5304
  const positions = attributes.positions;
@@ -5296,6 +5567,8 @@ var Tiles3DConverter = class {
5296
5567
  this.loaderOptions = {
5297
5568
  _nodeWorkers: true,
5298
5569
  reuseWorkers: true,
5570
+ // TODO: converter freezes in the end because of i3s-content-worker
5571
+ worker: false,
5299
5572
  i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
5300
5573
  // We need to load local fs workers because nodejs can't load workers from the Internet
5301
5574
  "i3s-content": {
@@ -5351,13 +5624,14 @@ var Tiles3DConverter = class {
5351
5624
  box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)
5352
5625
  },
5353
5626
  geometricError: convertScreenThresholdToGeometricError(rootNode),
5354
- children: []
5627
+ children: [],
5628
+ refine: "REPLACE"
5355
5629
  };
5356
5630
  await this._addChildren(rootNode, rootTile, 1);
5357
5631
  const tileset = (0, import_json_map_transform10.default)({ root: rootTile }, TILESET());
5358
5632
  await writeFile(this.tilesetPath, JSON.stringify(tileset), "tileset.json");
5359
5633
  this._finishConversion({ slpk: false, outputPath, tilesetName });
5360
- const workerFarm = import_worker_utils3.WorkerFarm.getWorkerFarm({});
5634
+ const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
5361
5635
  workerFarm.destroy();
5362
5636
  }
5363
5637
  /**
@@ -5419,11 +5693,9 @@ var Tiles3DConverter = class {
5419
5693
  if (this.options.maxDepth && level > this.options.maxDepth) {
5420
5694
  return;
5421
5695
  }
5422
- const promises = [];
5423
5696
  for (const childNodeInfo of parentSourceNode.children || []) {
5424
- promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
5697
+ await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);
5425
5698
  }
5426
- await Promise.all(promises);
5427
5699
  }
5428
5700
  /**
5429
5701
  * Load a child node having information from the node header