@loaders.gl/tile-converter 4.2.0-alpha.5 → 4.2.0-beta.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 (102) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +42 -22
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +4 -0
  6. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/helpers/load-i3s.js +3 -28
  8. package/dist/converter-cli.js +4 -2
  9. package/dist/converter.min.cjs +95 -95
  10. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  11. package/dist/deps-installer/deps-installer.js +9 -1
  12. package/dist/i3s-converter/helpers/attribute-metadata-info.js +4 -1
  13. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  14. package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -1
  15. package/dist/i3s-converter/helpers/coordinate-converter.js +2 -2
  16. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  17. package/dist/i3s-converter/helpers/feature-attributes.js +4 -2
  18. package/dist/i3s-converter/helpers/geometry-attributes.js +6 -5
  19. package/dist/i3s-converter/helpers/geometry-converter.d.ts +15 -1
  20. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  21. package/dist/i3s-converter/helpers/geometry-converter.js +52 -12
  22. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  23. package/dist/i3s-converter/helpers/gltf-attributes.js +12 -14
  24. package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -1
  25. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  26. package/dist/i3s-converter/helpers/node-index-document.js +18 -11
  27. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  28. package/dist/i3s-converter/helpers/node-pages.js +27 -26
  29. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  30. package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
  31. package/dist/i3s-converter/helpers/progress.js +23 -18
  32. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +8 -1
  33. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  34. package/dist/i3s-converter/helpers/tileset-traversal.js +12 -3
  35. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  36. package/dist/i3s-converter/i3s-converter.js +190 -66
  37. package/dist/i3s-converter/json-templates/node.js +1 -1
  38. package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
  39. package/dist/i3s-server/bin/www.js +6 -4
  40. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  41. package/dist/i3s-server/controllers/slpk-controller.js +3 -1
  42. package/dist/i3s-server/routes/index.js +11 -8
  43. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  44. package/dist/i3s-server/routes/slpk-router.js +24 -18
  45. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
  46. package/dist/i3s-server/utils/server-utils.js +8 -5
  47. package/dist/index.cjs +421 -211
  48. package/dist/index.cjs.map +3 -3
  49. package/dist/lib/utils/cli-utils.d.ts.map +1 -1
  50. package/dist/lib/utils/cli-utils.js +2 -0
  51. package/dist/lib/utils/conversion-dump.d.ts +9 -1
  52. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  53. package/dist/lib/utils/conversion-dump.js +44 -21
  54. package/dist/lib/utils/file-utils.d.ts +1 -1
  55. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  56. package/dist/lib/utils/file-utils.js +10 -12
  57. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  58. package/dist/lib/utils/statistic-utills.js +5 -7
  59. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  60. package/dist/lib/utils/write-queue.js +7 -3
  61. package/dist/pgm-loader.d.ts +17 -2
  62. package/dist/pgm-loader.d.ts.map +1 -1
  63. package/dist/pgm-loader.js +3 -1
  64. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  65. package/dist/slpk-extractor/slpk-extractor.js +2 -1
  66. package/dist/slpk-extractor-cli.d.ts.map +1 -1
  67. package/dist/slpk-extractor-cli.js +16 -8
  68. package/dist/slpk-extractor.min.cjs +36 -36
  69. package/package.json +23 -22
  70. package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
  71. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
  72. package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
  73. package/src/converter-cli.ts +4 -2
  74. package/src/deps-installer/deps-installer.ts +11 -0
  75. package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
  76. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
  77. package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
  78. package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
  79. package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
  80. package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
  81. package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
  82. package/src/i3s-converter/helpers/node-index-document.ts +18 -10
  83. package/src/i3s-converter/helpers/node-pages.ts +27 -29
  84. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
  85. package/src/i3s-converter/helpers/progress.ts +1 -0
  86. package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
  87. package/src/i3s-converter/i3s-converter.ts +173 -114
  88. package/src/i3s-converter/json-templates/node.ts +1 -1
  89. package/src/i3s-server/bin/www.ts +6 -4
  90. package/src/i3s-server/controllers/slpk-controller.ts +4 -2
  91. package/src/i3s-server/routes/index.ts +10 -7
  92. package/src/i3s-server/routes/slpk-router.ts +22 -16
  93. package/src/i3s-server/utils/server-utils.ts +6 -4
  94. package/src/lib/utils/cli-utils.ts +2 -0
  95. package/src/lib/utils/conversion-dump.ts +35 -20
  96. package/src/lib/utils/file-utils.ts +11 -11
  97. package/src/lib/utils/statistic-utills.ts +5 -6
  98. package/src/lib/utils/write-queue.ts +2 -2
  99. package/src/pgm-loader.ts +5 -2
  100. package/src/slpk-extractor/slpk-extractor.ts +2 -1
  101. package/src/slpk-extractor-cli.ts +16 -8
  102. package/src/lib/utils/statistic-utills.d.ts +0 -25
@@ -74,7 +74,7 @@ import {
74
74
  } from './helpers/load-3d-tiles';
75
75
  import {Matrix4} from '@math.gl/core';
76
76
  import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
77
- import {createBoundingVolume} from '@loaders.gl/tiles';
77
+ import {TILE_REFINEMENT, createBoundingVolume} from '@loaders.gl/tiles';
78
78
  import {TraversalConversionProps, traverseDatasetWith} from './helpers/tileset-traversal';
79
79
  import {analyzeTileContent, mergePreprocessData} from './helpers/preprocess-3d-tiles';
80
80
  import {Progress} from './helpers/progress';
@@ -184,6 +184,7 @@ export default class I3SConverter {
184
184
  * @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes
185
185
  * @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed
186
186
  */
187
+ // eslint-disable-next-line max-statements, complexity
187
188
  async convert(options: {
188
189
  inputUrl: string;
189
190
  outputPath: string;
@@ -204,7 +205,7 @@ export default class I3SConverter {
204
205
  analyze?: boolean;
205
206
  }): Promise<string> {
206
207
  if (isBrowser) {
207
- console.log(BROWSER_ERROR_MESSAGE);
208
+ console.log(BROWSER_ERROR_MESSAGE); // eslint-disable-line no-console
208
209
  return BROWSER_ERROR_MESSAGE;
209
210
  }
210
211
  this.conversionStartTime = process.hrtime();
@@ -298,27 +299,34 @@ export default class I3SConverter {
298
299
  * @returns true - the conversion is possible, false - the tileset's content is not supported
299
300
  */
300
301
  private async preprocessConversion(): Promise<boolean> {
301
- console.log(`Analyze source tileset`);
302
- const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;
303
- await traverseDatasetWith<null>(
304
- sourceRootTile,
305
- null,
306
- this.analyzeTile.bind(this),
307
- undefined,
308
- this.options.maxDepth
309
- );
302
+ // eslint-disable-next-line no-console
303
+ console.log('Analyze source tileset');
304
+ const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root;
305
+ await traverseDatasetWith<null>({
306
+ tile: sourceRootTile,
307
+ traversalProps: null,
308
+ processTile: this.analyzeTile.bind(this),
309
+ postprocessTile: undefined,
310
+ maxDepth: this.options.maxDepth
311
+ });
310
312
  const {meshTopologyTypes, metadataClasses} = this.preprocessData;
311
313
 
312
- console.log(`------------------------------------------------`);
313
- console.log(`Preprocess results:`);
314
+ // eslint-disable-next-line no-console
315
+ console.log('------------------------------------------------');
316
+ // eslint-disable-next-line no-console
317
+ console.log('Preprocess results:');
318
+ // eslint-disable-next-line no-console
314
319
  console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
320
+ // eslint-disable-next-line no-console
315
321
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);
316
322
 
317
323
  if (metadataClasses.size) {
324
+ // eslint-disable-next-line no-console
318
325
  console.log(
319
326
  `Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`
320
327
  );
321
328
  } else {
329
+ // eslint-disable-next-line no-console
322
330
  console.log('Feature metadata classes have not been found');
323
331
  }
324
332
 
@@ -326,14 +334,17 @@ export default class I3SConverter {
326
334
  !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) &&
327
335
  !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)
328
336
  ) {
337
+ // eslint-disable-next-line no-console
329
338
  console.log(
330
339
  'The tileset is of unsupported mesh topology types. The conversion will be interrupted.'
331
340
  );
332
- console.log(`------------------------------------------------`);
341
+ // eslint-disable-next-line no-console
342
+ console.log('------------------------------------------------');
333
343
  return false;
334
344
  }
335
345
 
336
- console.log(`------------------------------------------------`);
346
+ // eslint-disable-next-line no-console
347
+ console.log('------------------------------------------------');
337
348
  return true;
338
349
  }
339
350
 
@@ -364,6 +375,7 @@ export default class I3SConverter {
364
375
  '3d-tiles': {...this.loadOptions['3d-tiles'], loadGLTF: false}
365
376
  });
366
377
  } catch (error) {
378
+ // eslint-disable-next-line no-console
367
379
  console.log(
368
380
  `[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`
369
381
  );
@@ -381,6 +393,7 @@ export default class I3SConverter {
381
393
  const {metadataClasses} = this.preprocessData;
382
394
  if (metadataClasses.size > 1) {
383
395
  if (this.options.metadataClass?.length) {
396
+ // eslint-disable-next-line no-console
384
397
  console.log(`${this.options.metadataClass} has been selected`);
385
398
  } else if (this.options.inquirer) {
386
399
  const result = await this.options.inquirer.prompt([
@@ -392,14 +405,17 @@ export default class I3SConverter {
392
405
  }
393
406
  ]);
394
407
  this.options.metadataClass = result.metadataClass;
408
+ // eslint-disable-next-line no-console
395
409
  console.log(`${result.metadataClass} has been selected`);
396
410
  } else {
411
+ // eslint-disable-next-line no-console
397
412
  console.log(
398
413
  `A feature metadata class has not been selected. Start the converter with option "--metadata-class". For example, "npx tile-converter ... --metadata-class ${
399
414
  Array.from(metadataClasses)[0]
400
415
  }"`
401
416
  );
402
- console.log(`------------------------------------------------`);
417
+ // eslint-disable-next-line no-console
418
+ console.log('------------------------------------------------');
403
419
  return false;
404
420
  }
405
421
  }
@@ -411,6 +427,7 @@ export default class I3SConverter {
411
427
  * @param outputPath - path to save output data
412
428
  * @param tilesetName - new tileset path
413
429
  */
430
+ // eslint-disable-next-line max-statements, complexity
414
431
  private async _createAndSaveTileset(outputPath: string, tilesetName: string): Promise<void> {
415
432
  const tilesetPath = join(`${outputPath}`, `${tilesetName}`);
416
433
 
@@ -456,7 +473,7 @@ export default class I3SConverter {
456
473
  this.materialDefinitions = this.conversionDump.materialDefinitions;
457
474
  }
458
475
 
459
- const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;
476
+ const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root;
460
477
  const sourceBoundingVolume = createBoundingVolume(
461
478
  sourceRootTile.boundingVolume,
462
479
  new Matrix4(sourceRootTile.transform),
@@ -479,16 +496,16 @@ export default class I3SConverter {
479
496
  });
480
497
  this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
481
498
  const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
482
- await traverseDatasetWith<TraversalConversionProps>(
483
- sourceRootTile,
484
- {
499
+ await traverseDatasetWith<TraversalConversionProps>({
500
+ tile: sourceRootTile,
501
+ traversalProps: {
485
502
  transform: new Matrix4(sourceRootTile.transform),
486
503
  parentNodes: [rootNode]
487
504
  },
488
- this.convertTile.bind(this),
489
- this.finalizeTile.bind(this),
490
- this.options.maxDepth
491
- );
505
+ processTile: this.convertTile.bind(this),
506
+ postprocessTile: this.finalizeTile.bind(this),
507
+ maxDepth: this.options.maxDepth
508
+ });
492
509
  this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
493
510
  console.log(`[finalizing conversion]`); // eslint-disable-line
494
511
 
@@ -616,6 +633,7 @@ export default class I3SConverter {
616
633
  * @param traversalProps - traversal properties calculated recursively
617
634
  * @returns - traversal properties for the child tiles
618
635
  */
636
+ // eslint-disable-next-line max-statements
619
637
  private async convertTile(
620
638
  sourceTile: Tiles3DTileJSONPostprocessed,
621
639
  traversalProps: TraversalConversionProps
@@ -775,7 +793,7 @@ export default class I3SConverter {
775
793
  transformationMatrix,
776
794
  null
777
795
  );
778
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);
796
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);
779
797
  const nodes: NodeIndexDocument[] = [];
780
798
  for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
781
799
  const {node} = await this._generateNodeIndexDocument(
@@ -792,7 +810,7 @@ export default class I3SConverter {
792
810
  }
793
811
  return nodes;
794
812
  } else if (this.conversionDump.restored && sourceTile.id) {
795
- //clear existing record in a dump
813
+ // clear existing record in a dump
796
814
  this.conversionDump.clearDumpRecord(sourceTile.id);
797
815
  }
798
816
  return null;
@@ -806,6 +824,7 @@ export default class I3SConverter {
806
824
  * transform of all parent tiles and transform of the current tile
807
825
  * @param level - tree level
808
826
  */
827
+ // eslint-disable-next-line max-statements
809
828
  private async _createNode(
810
829
  parentNode: NodeIndexDocument,
811
830
  sourceTile: Tiles3DTileJSONPostprocessed,
@@ -819,6 +838,7 @@ export default class I3SConverter {
819
838
  try {
820
839
  tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, this.loadOptions);
821
840
  } catch (error) {
841
+ // eslint-disable-next-line no-console
822
842
  console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);
823
843
  }
824
844
  const sourceBoundingVolume = createBoundingVolume(
@@ -826,7 +846,7 @@ export default class I3SConverter {
826
846
  transformationMatrix,
827
847
  null
828
848
  );
829
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);
849
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);
830
850
 
831
851
  const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
832
852
  this.createAttributeStorageInfo(tileContent, propertyTable);
@@ -837,14 +857,14 @@ export default class I3SConverter {
837
857
  popupInfo: this.attributeMetadataInfo.popupInfo
838
858
  };
839
859
 
840
- const resourcesData = await this._convertResources(
860
+ const resourcesData = await this._convertResources({
841
861
  sourceTile,
842
862
  transformationMatrix,
843
- sourceBoundingVolume,
863
+ boundingVolume: sourceBoundingVolume,
844
864
  tileContent,
845
- parentNode.inPageId,
865
+ parentId: parentNode.inPageId,
846
866
  propertyTable
847
- );
867
+ });
848
868
 
849
869
  const nodes: NodeIndexDocument[] = [];
850
870
  const nodeIds: number[] = [];
@@ -873,7 +893,7 @@ export default class I3SConverter {
873
893
  nodes.push(node);
874
894
 
875
895
  if (nodeInPage.mesh) {
876
- //update a record in a dump file
896
+ // update a record in a dump file
877
897
  if (sourceTile.id) {
878
898
  const dumpMetadata = {
879
899
  boundingVolumes: resources.boundingVolumes,
@@ -889,7 +909,7 @@ export default class I3SConverter {
889
909
  await this.conversionDump.addNode(sourceTile.id, nodeInPage.index, dumpMetadata);
890
910
  }
891
911
 
892
- //write resources
912
+ // write resources
893
913
  await this._writeResources(resources, node.id, sourceTile);
894
914
  }
895
915
 
@@ -919,14 +939,21 @@ export default class I3SConverter {
919
939
  * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA
920
940
  * @returns - converted node resources
921
941
  */
922
- private async _convertResources(
923
- sourceTile: Tiles3DTileJSONPostprocessed,
924
- transformationMatrix: Matrix4,
925
- boundingVolume: OrientedBoundingBox | BoundingSphere,
926
- tileContent: Tiles3DTileContent | null,
927
- parentId: number,
928
- propertyTable: FeatureTableJson | null
929
- ): Promise<I3SConvertedResources[] | null> {
942
+ private async _convertResources({
943
+ sourceTile,
944
+ transformationMatrix,
945
+ boundingVolume,
946
+ tileContent,
947
+ parentId,
948
+ propertyTable
949
+ }: {
950
+ sourceTile: Tiles3DTileJSONPostprocessed;
951
+ transformationMatrix: Matrix4;
952
+ boundingVolume: OrientedBoundingBox | BoundingSphere;
953
+ tileContent: Tiles3DTileContent | null;
954
+ parentId: number;
955
+ propertyTable: FeatureTableJson | null;
956
+ }): Promise<I3SConvertedResources[] | null> {
930
957
  if (!this.isContentSupported(sourceTile) || !tileContent) {
931
958
  return null;
932
959
  }
@@ -935,21 +962,22 @@ export default class I3SConverter {
935
962
  halfSize: [],
936
963
  quaternion: []
937
964
  };
938
- const resourcesData = await convertB3dmToI3sGeometry(
965
+ const resourcesData = await convertB3dmToI3sGeometry({
939
966
  tileContent,
940
- transformationMatrix,
941
- boundingVolume,
942
- async () => (await this.nodePages.push({index: 0, obb: draftObb}, parentId)).index,
967
+ tileTransform: transformationMatrix,
968
+ tileBoundingVolume: boundingVolume,
969
+ addNodeToNodePage: async () =>
970
+ (await this.nodePages.push({index: 0, obb: draftObb}, parentId)).index,
943
971
  propertyTable,
944
- this.featuresHashArray,
945
- this.attributeMetadataInfo.attributeStorageInfo,
946
- this.options.draco,
947
- this.generateBoundingVolumes,
948
- this.options.mergeMaterials,
949
- this.geoidHeightModel!,
950
- this.loadOptions.modules as Record<string, string>,
951
- this.options.metadataClass
952
- );
972
+ featuresHashArray: this.featuresHashArray,
973
+ attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
974
+ draco: this.options.draco,
975
+ generateBoundingVolumes: this.generateBoundingVolumes,
976
+ shouldMergeMaterials: this.options.mergeMaterials,
977
+ geoidHeightModel: this.geoidHeightModel!,
978
+ libraries: this.loadOptions.modules as Record<string, string>,
979
+ metadataClass: this.options.metadataClass
980
+ });
953
981
  return resourcesData;
954
982
  }
955
983
 
@@ -968,6 +996,7 @@ export default class I3SConverter {
968
996
  * @param resources.geometry - Uint8Array with geometry attributes
969
997
  * @return the node object in node pages
970
998
  */
999
+ // eslint-disable-next-line max-statements, complexity
971
1000
  private async _updateNodeInNodePages(
972
1001
  maxScreenThresholdSQ: MaxScreenThresholdSQ,
973
1002
  boundingVolumes: BoundingVolumes,
@@ -1003,7 +1032,7 @@ export default class I3SConverter {
1003
1032
  };
1004
1033
  }
1005
1034
 
1006
- let nodeId = 'nodeId' in resources ? resources.nodeId : undefined;
1035
+ const nodeId = 'nodeId' in resources ? resources.nodeId : undefined;
1007
1036
  let node: NodeInPage;
1008
1037
  if (!nodeId) {
1009
1038
  node = await this.nodePages.push(nodeInPage, parentId);
@@ -1012,6 +1041,7 @@ export default class I3SConverter {
1012
1041
  }
1013
1042
 
1014
1043
  if (!nodeInPage.mesh) {
1044
+ // eslint-disable-next-line no-console
1015
1045
  console.log(`[warning]: node ${node.index} is created with empty content`);
1016
1046
  }
1017
1047
 
@@ -1068,22 +1098,22 @@ export default class I3SConverter {
1068
1098
  const childPath = join(this.layers0Path, 'nodes', nodePath);
1069
1099
  const slpkChildPath = join('nodes', nodePath);
1070
1100
 
1071
- await this._writeGeometries(
1072
- geometryBuffer!,
1073
- compressedGeometry!,
1101
+ await this._writeGeometries({
1102
+ geometryBuffer,
1103
+ compressedGeometry,
1074
1104
  childPath,
1075
1105
  slpkChildPath,
1076
- sourceTile.id || '',
1077
- parseInt(nodePath)
1078
- );
1079
- await this._writeShared(
1106
+ sourceId: sourceTile.id || '',
1107
+ nodeId: parseInt(nodePath)
1108
+ });
1109
+ await this._writeShared({
1080
1110
  sharedResources,
1081
1111
  childPath,
1082
1112
  slpkChildPath,
1083
1113
  nodePath,
1084
- sourceTile.id || '',
1085
- parseInt(nodePath)
1086
- );
1114
+ sourceId: sourceTile.id || '',
1115
+ nodeId: parseInt(nodePath)
1116
+ });
1087
1117
  await this._writeTexture(
1088
1118
  texture,
1089
1119
  childPath,
@@ -1109,14 +1139,25 @@ export default class I3SConverter {
1109
1139
  * @param sourceId - source filename
1110
1140
  * @param nodeId - nodeId of a converted node for the writing
1111
1141
  */
1112
- private async _writeGeometries(
1113
- geometryBuffer: ArrayBuffer,
1114
- compressedGeometry: Promise<ArrayBuffer>,
1115
- childPath: string,
1116
- slpkChildPath: string,
1117
- sourceId: string,
1118
- nodeId: number
1119
- ): Promise<void> {
1142
+ private async _writeGeometries({
1143
+ geometryBuffer,
1144
+ compressedGeometry,
1145
+ childPath,
1146
+ slpkChildPath,
1147
+ sourceId,
1148
+ nodeId
1149
+ }: {
1150
+ geometryBuffer: ArrayBuffer | null;
1151
+ compressedGeometry?: Promise<ArrayBuffer> | null;
1152
+ childPath: string;
1153
+ slpkChildPath: string;
1154
+ sourceId: string;
1155
+ nodeId: number;
1156
+ }): Promise<void> {
1157
+ if (!geometryBuffer) {
1158
+ return;
1159
+ }
1160
+
1120
1161
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
1121
1162
 
1122
1163
  if (this.options.slpk) {
@@ -1138,7 +1179,7 @@ export default class I3SConverter {
1138
1179
  });
1139
1180
  }
1140
1181
 
1141
- if (this.options.draco) {
1182
+ if (this.options.draco && compressedGeometry) {
1142
1183
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
1143
1184
 
1144
1185
  if (this.options.slpk) {
@@ -1172,14 +1213,21 @@ export default class I3SConverter {
1172
1213
  * @param sourceId - source filename
1173
1214
  * @param nodeId - nodeId of a converted node for the writing
1174
1215
  */
1175
- private async _writeShared(
1176
- sharedResources: SharedResourcesArrays | null,
1177
- childPath: string,
1178
- slpkChildPath: string,
1179
- nodePath: string,
1180
- sourceId: string,
1181
- nodeId: number
1182
- ): Promise<void> {
1216
+ private async _writeShared({
1217
+ sharedResources,
1218
+ childPath,
1219
+ slpkChildPath,
1220
+ nodePath,
1221
+ sourceId,
1222
+ nodeId
1223
+ }: {
1224
+ sharedResources: SharedResourcesArrays | null;
1225
+ childPath: string;
1226
+ slpkChildPath: string;
1227
+ nodePath: string;
1228
+ sourceId: string;
1229
+ nodeId: number;
1230
+ }): Promise<void> {
1183
1231
  if (!sharedResources) {
1184
1232
  return;
1185
1233
  }
@@ -1215,6 +1263,7 @@ export default class I3SConverter {
1215
1263
  * @param sourceId - source filename
1216
1264
  * @param nodeId - nodeId of a converted node for the writing
1217
1265
  */
1266
+ // eslint-disable-next-line max-statements
1218
1267
  private async _writeTexture(
1219
1268
  texture: GLTFImagePostprocessed,
1220
1269
  childPath: string,
@@ -1237,15 +1286,15 @@ export default class I3SConverter {
1237
1286
  `${ResourceType.TEXTURE}/${format}`,
1238
1287
  false
1239
1288
  );
1240
- await this.writeTextureFile(
1289
+ await this.writeTextureFile({
1241
1290
  textureData,
1242
- '0',
1291
+ name: '0',
1243
1292
  format,
1244
1293
  childPath,
1245
1294
  slpkChildPath,
1246
1295
  sourceId,
1247
1296
  nodeId
1248
- );
1297
+ });
1249
1298
 
1250
1299
  if (this.generateTextures) {
1251
1300
  formats.push({name: '1', format: 'ktx2'});
@@ -1275,15 +1324,15 @@ export default class I3SConverter {
1275
1324
  false
1276
1325
  );
1277
1326
 
1278
- await this.writeTextureFile(
1279
- ktx2TextureData,
1280
- '1',
1281
- 'ktx2',
1327
+ await this.writeTextureFile({
1328
+ textureData: ktx2TextureData,
1329
+ name: '1',
1330
+ format: 'ktx2',
1282
1331
  childPath,
1283
1332
  slpkChildPath,
1284
1333
  sourceId,
1285
1334
  nodeId
1286
- );
1335
+ });
1287
1336
  }
1288
1337
 
1289
1338
  break;
@@ -1297,36 +1346,38 @@ export default class I3SConverter {
1297
1346
  `${ResourceType.TEXTURE}/${format}`,
1298
1347
  false
1299
1348
  );
1300
- await this.writeTextureFile(
1349
+ await this.writeTextureFile({
1301
1350
  textureData,
1302
- '1',
1351
+ name: '1',
1303
1352
  format,
1304
1353
  childPath,
1305
1354
  slpkChildPath,
1306
1355
  sourceId,
1307
1356
  nodeId
1308
- );
1357
+ });
1309
1358
 
1310
1359
  if (this.generateTextures) {
1311
1360
  formats.push({name: '0', format: 'jpg'});
1312
- const decodedFromKTX2TextureData = encode(texture.image!.data[0], ImageWriter);
1361
+ const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
1313
1362
  this.conversionDump.updateDoneStatus(
1314
1363
  sourceId,
1315
1364
  nodeId,
1316
1365
  `${ResourceType.TEXTURE}/jpg`,
1317
1366
  false
1318
1367
  );
1319
- await this.writeTextureFile(
1320
- decodedFromKTX2TextureData,
1321
- '0',
1322
- 'jpg',
1368
+ await this.writeTextureFile({
1369
+ textureData: decodedFromKTX2TextureData,
1370
+ name: '0',
1371
+ format: 'jpg',
1323
1372
  childPath,
1324
1373
  slpkChildPath,
1325
1374
  sourceId,
1326
1375
  nodeId
1327
- );
1376
+ });
1328
1377
  }
1378
+ break;
1329
1379
  }
1380
+ default:
1330
1381
  }
1331
1382
 
1332
1383
  if (!this.layers0!.textureSetDefinitions!.length) {
@@ -1349,15 +1400,23 @@ export default class I3SConverter {
1349
1400
  * @param sourceId
1350
1401
  * @param nodeId
1351
1402
  */
1352
- private async writeTextureFile(
1353
- textureData: Uint8Array | Promise<ArrayBuffer>,
1354
- name: string,
1355
- format: 'jpg' | 'png' | 'ktx2',
1356
- childPath: string,
1357
- slpkChildPath: string,
1358
- sourceId: string,
1359
- nodeId: number
1360
- ): Promise<void> {
1403
+ private async writeTextureFile({
1404
+ textureData,
1405
+ name,
1406
+ format,
1407
+ childPath,
1408
+ slpkChildPath,
1409
+ sourceId,
1410
+ nodeId
1411
+ }: {
1412
+ textureData: Uint8Array | Promise<ArrayBuffer>;
1413
+ name: string;
1414
+ format: 'jpg' | 'png' | 'ktx2';
1415
+ childPath: string;
1416
+ slpkChildPath: string;
1417
+ sourceId: string;
1418
+ nodeId: number;
1419
+ }): Promise<void> {
1361
1420
  if (this.options.slpk) {
1362
1421
  const slpkTexturePath = join(childPath, 'textures');
1363
1422
  const compress = false;
@@ -1532,13 +1591,13 @@ export default class I3SConverter {
1532
1591
  const filesSize = await calculateFilesSize(params);
1533
1592
  const diff = process.hrtime(this.conversionStartTime);
1534
1593
  const conversionTime = timeConverter(diff);
1535
- console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console
1594
+ console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
1536
1595
  console.log(`Finishing conversion of ${_3D_TILES}`); // eslint-disable-line no-undef, no-console
1537
1596
  console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line no-undef, no-console
1538
- console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line no-undef, no-console
1539
- console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line no-undef, no-console
1540
- console.log(`Percentage of tiles with "ADD" refinement type:`, addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console
1541
- console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console
1597
+ console.log('Vertex count: ', this.vertexCounter); // eslint-disable-line no-undef, no-console
1598
+ console.log('File(s) size: ', filesSize, ' bytes'); // eslint-disable-line no-undef, no-console
1599
+ console.log('Percentage of tiles with "ADD" refinement type:', addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console
1600
+ console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
1542
1601
  }
1543
1602
 
1544
1603
  /**
@@ -1580,7 +1639,7 @@ export default class I3SConverter {
1580
1639
  * @param tile
1581
1640
  */
1582
1641
  private _checkAddRefinementTypeForTile(tile: Tiles3DTileJSONPostprocessed): void {
1583
- const ADD_TILE_REFINEMENT = 1;
1642
+ const ADD_TILE_REFINEMENT = TILE_REFINEMENT.ADD;
1584
1643
 
1585
1644
  if (tile.refine === ADD_TILE_REFINEMENT) {
1586
1645
  this.refinementCounter.tilesWithAddRefineCount += 1;
@@ -46,7 +46,7 @@ export const NODE = () => ({
46
46
  },
47
47
  {
48
48
  metricType: 'maxScreenThreshold',
49
- maxError: 999.99999999999994
49
+ maxError: 999.9999999999999
50
50
  }
51
51
  ]
52
52
  },
@@ -16,13 +16,15 @@ import {formErrorHandler, formListeningHandler, normalizePort} from '../utils/se
16
16
  /** Get port from environment and store in Express. */
17
17
  const httpPort = normalizePort(process.env.PORT || '80');
18
18
  if (httpPort === false) {
19
- console.error(`Incorrect HTTP port`);
20
- process.exit(1);
19
+ // eslint-disable-next-line no-console
20
+ console.error('Incorrect HTTP port');
21
+ process.exit(1); // eslint-disable-line no-process-exit
21
22
  }
22
23
  const httpsPort = normalizePort(process.env.HTTPS_PORT || '443');
23
24
  if (httpsPort === false) {
24
- console.error(`Incorrect HTTPs port`);
25
- process.exit(1);
25
+ // eslint-disable-next-line no-console
26
+ console.error('Incorrect HTTPs port');
27
+ process.exit(1); // eslint-disable-line no-process-exit
26
28
  }
27
29
 
28
30
  /** Create HTTP server. */
@@ -9,9 +9,11 @@ let slpkArchive: SLPKArchive;
9
9
  * @param fullLayerPath - full path to SLPK file
10
10
  */
11
11
  export async function loadArchive(fullLayerPath: string): Promise<void> {
12
- slpkArchive = await parseSLPKArchive(new FileHandleFile(fullLayerPath), (msg) =>
13
- console.log(msg)
12
+ slpkArchive = await parseSLPKArchive(
13
+ new FileHandleFile(fullLayerPath),
14
+ (msg) => console.log(msg) // eslint-disable-line no-console
14
15
  );
16
+ // eslint-disable-next-line no-console
15
17
  console.log('The server is ready to use');
16
18
  }
17
19
 
@@ -4,12 +4,15 @@ import {getFileNameByUrl} from '../controllers/index-controller';
4
4
  export const router = express.Router();
5
5
 
6
6
  /* GET home page. */
7
- router.get('*', async function (req, res, next) {
8
- const fileName = await getFileNameByUrl(req.path);
9
- if (fileName) {
10
- res.sendFile(fileName);
11
- } else {
12
- res.status(404);
13
- res.send('File not found');
7
+ router.get('*', (req, res, next) => {
8
+ async function routerCallback(req, res, next) {
9
+ const fileName = await getFileNameByUrl(req.path);
10
+ if (fileName) {
11
+ res.sendFile(fileName);
12
+ } else {
13
+ res.status(404);
14
+ res.send('File not found');
15
+ }
14
16
  }
17
+ routerCallback(req, res, next);
15
18
  });