@loaders.gl/tile-converter 4.2.0-alpha.5 → 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 (99) 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 +6 -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 +69 -69
  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 +419 -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.js +1 -1
  62. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  63. package/dist/slpk-extractor/slpk-extractor.js +2 -1
  64. package/dist/slpk-extractor-cli.d.ts.map +1 -1
  65. package/dist/slpk-extractor-cli.js +16 -8
  66. package/dist/slpk-extractor.min.cjs +1 -1
  67. package/package.json +23 -22
  68. package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
  69. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
  70. package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
  71. package/src/converter-cli.ts +4 -2
  72. package/src/deps-installer/deps-installer.ts +7 -0
  73. package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
  74. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
  75. package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
  76. package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
  77. package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
  78. package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
  79. package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
  80. package/src/i3s-converter/helpers/node-index-document.ts +18 -10
  81. package/src/i3s-converter/helpers/node-pages.ts +27 -29
  82. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
  83. package/src/i3s-converter/helpers/progress.ts +1 -0
  84. package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
  85. package/src/i3s-converter/i3s-converter.ts +173 -114
  86. package/src/i3s-converter/json-templates/node.ts +1 -1
  87. package/src/i3s-server/bin/www.ts +6 -4
  88. package/src/i3s-server/controllers/slpk-controller.ts +4 -2
  89. package/src/i3s-server/routes/index.ts +10 -7
  90. package/src/i3s-server/routes/slpk-router.ts +22 -16
  91. package/src/i3s-server/utils/server-utils.ts +6 -4
  92. package/src/lib/utils/cli-utils.ts +2 -0
  93. package/src/lib/utils/conversion-dump.ts +35 -20
  94. package/src/lib/utils/file-utils.ts +11 -11
  95. package/src/lib/utils/statistic-utills.ts +5 -6
  96. package/src/lib/utils/write-queue.ts +2 -2
  97. package/src/slpk-extractor/slpk-extractor.ts +2 -1
  98. package/src/slpk-extractor-cli.ts +16 -8
  99. package/src/lib/utils/statistic-utills.d.ts +0 -25
@@ -6,25 +6,30 @@ const THRESHOLD_DEFAULT = 0.2;
6
6
  * Implements methods to keep track on the progress of a long process.
7
7
  */
8
8
  export class Progress {
9
+ /** Total amount of work, e.g. number of files to save or number of bytes to send */
10
+ _stepsTotal = 0;
11
+ /** Amount of work already done */
12
+ _stepsDone = 0;
13
+ /** Time in milli-seconds when the process started */
14
+ startTime = 0;
15
+ /** Time in milli-seconds when the process stopped */
16
+ stopTime = 0;
17
+ /** Time in milli-seconds when stepsDone was updated */
18
+ timeOfUpdatingStepsDone = 0;
19
+ /** Time in milli-seconds spent for performing one step*/
20
+ milliSecForOneStep = 0;
21
+ trust = false;
22
+ /**
23
+ * The number of digits to appear after decimal point in the string representation of the count of steps already done.
24
+ * It's calculated based on the total count of steps.
25
+ */
26
+ numberOfDigitsInPercentage = 0;
27
+ /** Defines a threshold that is used to check if the process velocity can be consifered trust. */
28
+ threshold;
29
+ /** Function that is used to get the time stamp */
30
+ getTime;
9
31
  constructor(options = {}) {
10
- /** Total amount of work, e.g. number of files to save or number of bytes to send */
11
- this._stepsTotal = 0;
12
- /** Amount of work already done */
13
- this._stepsDone = 0;
14
- /** Time in milli-seconds when the process started */
15
- this.startTime = 0;
16
- /** Time in milli-seconds when the process stopped */
17
- this.stopTime = 0;
18
- /** Time in milli-seconds when stepsDone was updated */
19
- this.timeOfUpdatingStepsDone = 0;
20
- /** Time in milli-seconds spent for performing one step*/
21
- this.milliSecForOneStep = 0;
22
- this.trust = false;
23
- /**
24
- * The number of digits to appear after decimal point in the string representation of the count of steps already done.
25
- * It's calculated based on the total count of steps.
26
- */
27
- this.numberOfDigitsInPercentage = 0;
32
+ // eslint-disable-next-line @typescript-eslint/unbound-method
28
33
  this.getTime = options.getTime || process.hrtime.bigint;
29
34
  this.threshold = options.threshold || THRESHOLD_DEFAULT;
30
35
  }
@@ -21,5 +21,12 @@ export type TraversalConversionProps = {
21
21
  * traversal at the some level of the tree
22
22
  * @returns void
23
23
  */
24
- export declare const traverseDatasetWith: <TProps>(tile: Tiles3DTileJSONPostprocessed, traversalProps: TProps, processTile: (tile: Tiles3DTileJSONPostprocessed, traversalProps: TProps) => Promise<TProps>, postprocessTile?: ((processResults: TProps[], currentTraversalProps: TProps) => Promise<void>) | undefined, maxDepth?: number, level?: number) => Promise<void>;
24
+ export declare const traverseDatasetWith: <TProps>({ tile, traversalProps, processTile, postprocessTile, maxDepth, level }: {
25
+ tile: Tiles3DTileJSONPostprocessed;
26
+ traversalProps: TProps;
27
+ processTile: (tile: Tiles3DTileJSONPostprocessed, traversalProps: TProps) => Promise<TProps>;
28
+ postprocessTile?: ((processResults: TProps[], currentTraversalProps: TProps) => Promise<void>) | undefined;
29
+ maxDepth?: number | undefined;
30
+ level?: number | undefined;
31
+ }) => Promise<void>;
25
32
  //# sourceMappingURL=tileset-traversal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tileset-traversal.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/tileset-traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,+CAA+C;AAC/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,iBACxB,4BAA4B,8CAEd,4BAA4B,8HAC+B,QAAQ,IAAI,CAAC,0BACjF,MAAM,qBAEhB,QAAQ,IAAI,CAkBd,CAAC"}
1
+ {"version":3,"file":"tileset-traversal.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/tileset-traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,+CAA+C;AAC/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB;UAQxB,4BAA4B;oBAClB,MAAM;wBACF,4BAA4B,kBAAkB,MAAM,KAAK,QAAQ,MAAM,CAAC;wCACzD,MAAM,EAAE,yBAAyB,MAAM,KAAK,QAAQ,IAAI,CAAC;;;MAG1F,QAAQ,IAAI,CAoBf,CAAC"}
@@ -11,7 +11,7 @@
11
11
  * traversal at the some level of the tree
12
12
  * @returns void
13
13
  */
14
- export const traverseDatasetWith = async (tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0) => {
14
+ export const traverseDatasetWith = async ({ tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0 }) => {
15
15
  if (maxDepth && level > maxDepth) {
16
16
  return;
17
17
  }
@@ -19,7 +19,16 @@ export const traverseDatasetWith = async (tile, traversalProps, processTile, pos
19
19
  const newTraversalProps = await processTile(tile, traversalProps);
20
20
  processResults.push(newTraversalProps);
21
21
  for (const childTile of tile.children) {
22
- await traverseDatasetWith(childTile, newTraversalProps, processTile, postprocessTile, maxDepth, level + 1);
22
+ await traverseDatasetWith({
23
+ tile: childTile,
24
+ traversalProps: newTraversalProps,
25
+ processTile,
26
+ postprocessTile,
27
+ maxDepth,
28
+ level: level + 1
29
+ });
30
+ }
31
+ if (postprocessTile) {
32
+ await postprocessTile(processResults, traversalProps);
23
33
  }
24
- postprocessTile && (await postprocessTile(processResults, traversalProps));
25
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAC,6CAA0C;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,oCAAiC;AAC7D,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,gCAA6B;AAkB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAGf,mBAAgB;AAEjB,OAAO,UAAU,oCAAiC;AAkBlD,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAE5C,OAAO,EAAC,cAAc,EAAsC,wCAAqC;AAWjG;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;IAC7C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,EAAE;QAAC,UAAU,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAC,EAAE,CAAC;IAChE,aAAa,EAAE,MAAM,CAAC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,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -32,7 +32,7 @@ import { getAttributeTypesMapFromPropertyTable, getAttributeTypesMapFromSchema }
32
32
  import { NodeIndexDocument } from "./helpers/node-index-document.js";
33
33
  import { isNestedTileset, loadNestedTileset, loadTile3DContent, loadFromArchive } from "./helpers/load-3d-tiles.js";
34
34
  import { Matrix4 } from '@math.gl/core';
35
- import { createBoundingVolume } from '@loaders.gl/tiles';
35
+ import { TILE_REFINEMENT, createBoundingVolume } from '@loaders.gl/tiles';
36
36
  import { traverseDatasetWith } from "./helpers/tileset-traversal.js";
37
37
  import { analyzeTileContent, mergePreprocessData } from "./helpers/preprocess-3d-tiles.js";
38
38
  import { Progress } from "./helpers/progress.js";
@@ -50,35 +50,52 @@ const PROGRESS_PHASE1_COUNT = 'phase1-count';
50
50
  * Converter from 3d-tiles tileset to i3s layer
51
51
  */
52
52
  export default class I3SConverter {
53
- constructor() {
54
- this.boundingVolumeWarnings = [];
55
- this.conversionStartTime = [0, 0];
56
- this.refreshTokenTime = [0, 0];
57
- this.sourceTileset = null;
58
- this.loadOptions = {
59
- _nodeWorkers: true,
60
- reuseWorkers: true,
61
- useLocalLibraries: true,
62
- basis: {
63
- format: 'rgba32',
64
- // We need to load local fs workers because nodejs can't load workers from the Internet
65
- workerUrl: './modules/textures/dist/basis-worker-node.js'
66
- },
53
+ attributeMetadataInfo;
54
+ nodePages;
55
+ options;
56
+ layers0Path;
57
+ materialMap;
58
+ materialDefinitions;
59
+ geometryMap;
60
+ geometryConfigs;
61
+ vertexCounter;
62
+ layers0;
63
+ featuresHashArray;
64
+ refinementCounter;
65
+ validate;
66
+ boundingVolumeWarnings = [];
67
+ conversionStartTime = [0, 0];
68
+ refreshTokenTime = [0, 0];
69
+ sourceTileset = null;
70
+ loadOptions = {
71
+ _nodeWorkers: true,
72
+ reuseWorkers: true,
73
+ useLocalLibraries: true,
74
+ basis: {
75
+ format: 'rgba32',
67
76
  // We need to load local fs workers because nodejs can't load workers from the Internet
68
- draco: { workerUrl: './modules/draco/dist/draco-worker-node.js' },
69
- fetch: {},
70
- modules: {}
71
- };
72
- this.geoidHeightModel = null;
73
- this.Loader = Tiles3DLoader;
74
- this.workerSource = {};
75
- this.writeQueue = new WriteQueue(new ConversionDump());
76
- this.compressList = null;
77
- this.preprocessData = {
78
- meshTopologyTypes: new Set(),
79
- metadataClasses: new Set()
80
- };
81
- this.progresses = {};
77
+ workerUrl: './modules/textures/dist/basis-worker-node.js'
78
+ },
79
+ // We need to load local fs workers because nodejs can't load workers from the Internet
80
+ draco: { workerUrl: './modules/draco/dist/draco-worker-node.js' },
81
+ fetch: {},
82
+ modules: {}
83
+ };
84
+ geoidHeightModel = null;
85
+ Loader = Tiles3DLoader;
86
+ generateTextures;
87
+ generateBoundingVolumes;
88
+ layersHasTexture;
89
+ workerSource = {};
90
+ writeQueue = new WriteQueue(new ConversionDump());
91
+ compressList = null;
92
+ preprocessData = {
93
+ meshTopologyTypes: new Set(),
94
+ metadataClasses: new Set()
95
+ };
96
+ progresses = {};
97
+ conversionDump;
98
+ constructor() {
82
99
  this.attributeMetadataInfo = new AttributeMetadataInfo();
83
100
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
84
101
  this.options = {};
@@ -118,9 +135,10 @@ export default class I3SConverter {
118
135
  * @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes
119
136
  * @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed
120
137
  */
138
+ // eslint-disable-next-line max-statements, complexity
121
139
  async convert(options) {
122
140
  if (isBrowser) {
123
- console.log(BROWSER_ERROR_MESSAGE);
141
+ console.log(BROWSER_ERROR_MESSAGE); // eslint-disable-line no-console
124
142
  return BROWSER_ERROR_MESSAGE;
125
143
  }
126
144
  this.conversionStartTime = process.hrtime();
@@ -190,27 +208,43 @@ export default class I3SConverter {
190
208
  * @returns true - the conversion is possible, false - the tileset's content is not supported
191
209
  */
192
210
  async preprocessConversion() {
193
- console.log(`Analyze source tileset`);
211
+ // eslint-disable-next-line no-console
212
+ console.log('Analyze source tileset');
194
213
  const sourceRootTile = this.sourceTileset.root;
195
- await traverseDatasetWith(sourceRootTile, null, this.analyzeTile.bind(this), undefined, this.options.maxDepth);
214
+ await traverseDatasetWith({
215
+ tile: sourceRootTile,
216
+ traversalProps: null,
217
+ processTile: this.analyzeTile.bind(this),
218
+ postprocessTile: undefined,
219
+ maxDepth: this.options.maxDepth
220
+ });
196
221
  const { meshTopologyTypes, metadataClasses } = this.preprocessData;
197
- console.log(`------------------------------------------------`);
198
- console.log(`Preprocess results:`);
222
+ // eslint-disable-next-line no-console
223
+ console.log('------------------------------------------------');
224
+ // eslint-disable-next-line no-console
225
+ console.log('Preprocess results:');
226
+ // eslint-disable-next-line no-console
199
227
  console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
228
+ // eslint-disable-next-line no-console
200
229
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);
201
230
  if (metadataClasses.size) {
231
+ // eslint-disable-next-line no-console
202
232
  console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`);
203
233
  }
204
234
  else {
235
+ // eslint-disable-next-line no-console
205
236
  console.log('Feature metadata classes have not been found');
206
237
  }
207
238
  if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) &&
208
239
  !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
240
+ // eslint-disable-next-line no-console
209
241
  console.log('The tileset is of unsupported mesh topology types. The conversion will be interrupted.');
210
- console.log(`------------------------------------------------`);
242
+ // eslint-disable-next-line no-console
243
+ console.log('------------------------------------------------');
211
244
  return false;
212
245
  }
213
- console.log(`------------------------------------------------`);
246
+ // eslint-disable-next-line no-console
247
+ console.log('------------------------------------------------');
214
248
  return true;
215
249
  }
216
250
  /**
@@ -237,6 +271,7 @@ export default class I3SConverter {
237
271
  });
238
272
  }
239
273
  catch (error) {
274
+ // eslint-disable-next-line no-console
240
275
  console.log(`[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`);
241
276
  }
242
277
  const tilePreprocessData = await analyzeTileContent(tileContent);
@@ -251,6 +286,7 @@ export default class I3SConverter {
251
286
  const { metadataClasses } = this.preprocessData;
252
287
  if (metadataClasses.size > 1) {
253
288
  if (this.options.metadataClass?.length) {
289
+ // eslint-disable-next-line no-console
254
290
  console.log(`${this.options.metadataClass} has been selected`);
255
291
  }
256
292
  else if (this.options.inquirer) {
@@ -263,11 +299,14 @@ export default class I3SConverter {
263
299
  }
264
300
  ]);
265
301
  this.options.metadataClass = result.metadataClass;
302
+ // eslint-disable-next-line no-console
266
303
  console.log(`${result.metadataClass} has been selected`);
267
304
  }
268
305
  else {
306
+ // eslint-disable-next-line no-console
269
307
  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]}"`);
270
- console.log(`------------------------------------------------`);
308
+ // eslint-disable-next-line no-console
309
+ console.log('------------------------------------------------');
271
310
  return false;
272
311
  }
273
312
  }
@@ -278,6 +317,7 @@ export default class I3SConverter {
278
317
  * @param outputPath - path to save output data
279
318
  * @param tilesetName - new tileset path
280
319
  */
320
+ // eslint-disable-next-line max-statements, complexity
281
321
  async _createAndSaveTileset(outputPath, tilesetName) {
282
322
  const tilesetPath = join(`${outputPath}`, `${tilesetName}`);
283
323
  await this.conversionDump.createDump(this.options);
@@ -328,10 +368,16 @@ export default class I3SConverter {
328
368
  });
329
369
  this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
330
370
  const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
331
- await traverseDatasetWith(sourceRootTile, {
332
- transform: new Matrix4(sourceRootTile.transform),
333
- parentNodes: [rootNode]
334
- }, this.convertTile.bind(this), this.finalizeTile.bind(this), this.options.maxDepth);
371
+ await traverseDatasetWith({
372
+ tile: sourceRootTile,
373
+ traversalProps: {
374
+ transform: new Matrix4(sourceRootTile.transform),
375
+ parentNodes: [rootNode]
376
+ },
377
+ processTile: this.convertTile.bind(this),
378
+ postprocessTile: this.finalizeTile.bind(this),
379
+ maxDepth: this.options.maxDepth
380
+ });
335
381
  this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
336
382
  console.log(`[finalizing conversion]`); // eslint-disable-line
337
383
  this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
@@ -439,6 +485,7 @@ export default class I3SConverter {
439
485
  * @param traversalProps - traversal properties calculated recursively
440
486
  * @returns - traversal properties for the child tiles
441
487
  */
488
+ // eslint-disable-next-line max-statements
442
489
  async convertTile(sourceTile, traversalProps) {
443
490
  const isTileset = isNestedTileset(sourceTile);
444
491
  if (isTileset || sourceTile.type === 'empty') {
@@ -546,7 +593,7 @@ export default class I3SConverter {
546
593
  sourceTile.id &&
547
594
  this.conversionDump.isFileConversionComplete(sourceTile.id)) {
548
595
  const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
549
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
596
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
550
597
  const nodes = [];
551
598
  for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
552
599
  const { node } = await this._generateNodeIndexDocument(boundingVolumes, {
@@ -558,7 +605,7 @@ export default class I3SConverter {
558
605
  return nodes;
559
606
  }
560
607
  else if (this.conversionDump.restored && sourceTile.id) {
561
- //clear existing record in a dump
608
+ // clear existing record in a dump
562
609
  this.conversionDump.clearDumpRecord(sourceTile.id);
563
610
  }
564
611
  return null;
@@ -571,6 +618,7 @@ export default class I3SConverter {
571
618
  * transform of all parent tiles and transform of the current tile
572
619
  * @param level - tree level
573
620
  */
621
+ // eslint-disable-next-line max-statements
574
622
  async _createNode(parentNode, sourceTile, transformationMatrix) {
575
623
  this._checkAddRefinementTypeForTile(sourceTile);
576
624
  await this._updateTilesetOptions();
@@ -579,10 +627,11 @@ export default class I3SConverter {
579
627
  tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, this.loadOptions);
580
628
  }
581
629
  catch (error) {
630
+ // eslint-disable-next-line no-console
582
631
  console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);
583
632
  }
584
633
  const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
585
- let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
634
+ const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
586
635
  const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
587
636
  this.createAttributeStorageInfo(tileContent, propertyTable);
588
637
  this.conversionDump.attributeMetadataInfo = {
@@ -590,7 +639,14 @@ export default class I3SConverter {
590
639
  fields: this.attributeMetadataInfo.fields,
591
640
  popupInfo: this.attributeMetadataInfo.popupInfo
592
641
  };
593
- const resourcesData = await this._convertResources(sourceTile, transformationMatrix, sourceBoundingVolume, tileContent, parentNode.inPageId, propertyTable);
642
+ const resourcesData = await this._convertResources({
643
+ sourceTile,
644
+ transformationMatrix,
645
+ boundingVolume: sourceBoundingVolume,
646
+ tileContent,
647
+ parentId: parentNode.inPageId,
648
+ propertyTable
649
+ });
594
650
  const nodes = [];
595
651
  const nodeIds = [];
596
652
  const nodesInPage = [];
@@ -610,7 +666,7 @@ export default class I3SConverter {
610
666
  const { node, nodeInPage, nodeData } = await this._generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, false);
611
667
  nodes.push(node);
612
668
  if (nodeInPage.mesh) {
613
- //update a record in a dump file
669
+ // update a record in a dump file
614
670
  if (sourceTile.id) {
615
671
  const dumpMetadata = {
616
672
  boundingVolumes: resources.boundingVolumes,
@@ -625,7 +681,7 @@ export default class I3SConverter {
625
681
  this.conversionDump.setMaterialsDefinitions(this.materialDefinitions);
626
682
  await this.conversionDump.addNode(sourceTile.id, nodeInPage.index, dumpMetadata);
627
683
  }
628
- //write resources
684
+ // write resources
629
685
  await this._writeResources(resources, node.id, sourceTile);
630
686
  }
631
687
  if (this.validate) {
@@ -650,7 +706,7 @@ export default class I3SConverter {
650
706
  * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA
651
707
  * @returns - converted node resources
652
708
  */
653
- async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
709
+ async _convertResources({ sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable }) {
654
710
  if (!this.isContentSupported(sourceTile) || !tileContent) {
655
711
  return null;
656
712
  }
@@ -659,7 +715,21 @@ export default class I3SConverter {
659
715
  halfSize: [],
660
716
  quaternion: []
661
717
  };
662
- const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.attributeMetadataInfo.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
718
+ const resourcesData = await convertB3dmToI3sGeometry({
719
+ tileContent,
720
+ tileTransform: transformationMatrix,
721
+ tileBoundingVolume: boundingVolume,
722
+ addNodeToNodePage: async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index,
723
+ propertyTable,
724
+ featuresHashArray: this.featuresHashArray,
725
+ attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
726
+ draco: this.options.draco,
727
+ generateBoundingVolumes: this.generateBoundingVolumes,
728
+ shouldMergeMaterials: this.options.mergeMaterials,
729
+ geoidHeightModel: this.geoidHeightModel,
730
+ libraries: this.loadOptions.modules,
731
+ metadataClass: this.options.metadataClass
732
+ });
663
733
  return resourcesData;
664
734
  }
665
735
  /**
@@ -677,6 +747,7 @@ export default class I3SConverter {
677
747
  * @param resources.geometry - Uint8Array with geometry attributes
678
748
  * @return the node object in node pages
679
749
  */
750
+ // eslint-disable-next-line max-statements, complexity
680
751
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
681
752
  const { vertexCount, featureCount, geometry, hasUvRegions } = resources;
682
753
  const nodeInPage = {
@@ -700,7 +771,7 @@ export default class I3SConverter {
700
771
  }
701
772
  };
702
773
  }
703
- let nodeId = 'nodeId' in resources ? resources.nodeId : undefined;
774
+ const nodeId = 'nodeId' in resources ? resources.nodeId : undefined;
704
775
  let node;
705
776
  if (!nodeId) {
706
777
  node = await this.nodePages.push(nodeInPage, parentId);
@@ -709,6 +780,7 @@ export default class I3SConverter {
709
780
  node = await this.nodePages.getNodeById(nodeId);
710
781
  }
711
782
  if (!nodeInPage.mesh) {
783
+ // eslint-disable-next-line no-console
712
784
  console.log(`[warning]: node ${node.index} is created with empty content`);
713
785
  }
714
786
  NodePages.updateAll(node, nodeInPage);
@@ -752,8 +824,22 @@ export default class I3SConverter {
752
824
  const { geometry: geometryBuffer, compressedGeometry, texture, sharedResources, attributes } = resources;
753
825
  const childPath = join(this.layers0Path, 'nodes', nodePath);
754
826
  const slpkChildPath = join('nodes', nodePath);
755
- await this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
756
- await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceTile.id || '', parseInt(nodePath));
827
+ await this._writeGeometries({
828
+ geometryBuffer,
829
+ compressedGeometry,
830
+ childPath,
831
+ slpkChildPath,
832
+ sourceId: sourceTile.id || '',
833
+ nodeId: parseInt(nodePath)
834
+ });
835
+ await this._writeShared({
836
+ sharedResources,
837
+ childPath,
838
+ slpkChildPath,
839
+ nodePath,
840
+ sourceId: sourceTile.id || '',
841
+ nodeId: parseInt(nodePath)
842
+ });
757
843
  await this._writeTexture(texture, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
758
844
  await this._writeAttributes(attributes, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
759
845
  }
@@ -766,7 +852,10 @@ export default class I3SConverter {
766
852
  * @param sourceId - source filename
767
853
  * @param nodeId - nodeId of a converted node for the writing
768
854
  */
769
- async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
855
+ async _writeGeometries({ geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId }) {
856
+ if (!geometryBuffer) {
857
+ return;
858
+ }
770
859
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
771
860
  if (this.options.slpk) {
772
861
  const slpkGeometryPath = join(childPath, 'geometries');
@@ -787,7 +876,7 @@ export default class I3SConverter {
787
876
  writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')
788
877
  });
789
878
  }
790
- if (this.options.draco) {
879
+ if (this.options.draco && compressedGeometry) {
791
880
  this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
792
881
  if (this.options.slpk) {
793
882
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
@@ -819,7 +908,7 @@ export default class I3SConverter {
819
908
  * @param sourceId - source filename
820
909
  * @param nodeId - nodeId of a converted node for the writing
821
910
  */
822
- async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
911
+ async _writeShared({ sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId }) {
823
912
  if (!sharedResources) {
824
913
  return;
825
914
  }
@@ -855,6 +944,7 @@ export default class I3SConverter {
855
944
  * @param sourceId - source filename
856
945
  * @param nodeId - nodeId of a converted node for the writing
857
946
  */
947
+ // eslint-disable-next-line max-statements
858
948
  async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
859
949
  if (texture) {
860
950
  const format = this._getFormatByMimeType(texture?.mimeType);
@@ -865,7 +955,15 @@ export default class I3SConverter {
865
955
  case 'png': {
866
956
  formats.push({ name: '0', format });
867
957
  this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
868
- await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath, sourceId, nodeId);
958
+ await this.writeTextureFile({
959
+ textureData,
960
+ name: '0',
961
+ format,
962
+ childPath,
963
+ slpkChildPath,
964
+ sourceId,
965
+ nodeId
966
+ });
869
967
  if (this.generateTextures) {
870
968
  formats.push({ name: '1', format: 'ktx2' });
871
969
  // For Node.js texture.image.data is type of Buffer
@@ -884,21 +982,47 @@ export default class I3SConverter {
884
982
  useLocalLibraries: true
885
983
  });
886
984
  this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/ktx2`, false);
887
- await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath, sourceId, nodeId);
985
+ await this.writeTextureFile({
986
+ textureData: ktx2TextureData,
987
+ name: '1',
988
+ format: 'ktx2',
989
+ childPath,
990
+ slpkChildPath,
991
+ sourceId,
992
+ nodeId
993
+ });
888
994
  }
889
995
  break;
890
996
  }
891
997
  case 'ktx2': {
892
998
  formats.push({ name: '1', format });
893
999
  this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
894
- await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath, sourceId, nodeId);
1000
+ await this.writeTextureFile({
1001
+ textureData,
1002
+ name: '1',
1003
+ format,
1004
+ childPath,
1005
+ slpkChildPath,
1006
+ sourceId,
1007
+ nodeId
1008
+ });
895
1009
  if (this.generateTextures) {
896
1010
  formats.push({ name: '0', format: 'jpg' });
897
1011
  const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
898
1012
  this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/jpg`, false);
899
- await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath, sourceId, nodeId);
1013
+ await this.writeTextureFile({
1014
+ textureData: decodedFromKTX2TextureData,
1015
+ name: '0',
1016
+ format: 'jpg',
1017
+ childPath,
1018
+ slpkChildPath,
1019
+ sourceId,
1020
+ nodeId
1021
+ });
900
1022
  }
1023
+ break;
901
1024
  }
1025
+ default:
902
1026
  }
903
1027
  if (!this.layers0.textureSetDefinitions.length) {
904
1028
  this.layers0.textureSetDefinitions.push({ formats });
@@ -919,7 +1043,7 @@ export default class I3SConverter {
919
1043
  * @param sourceId
920
1044
  * @param nodeId
921
1045
  */
922
- async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
1046
+ async writeTextureFile({ textureData, name, format, childPath, slpkChildPath, sourceId, nodeId }) {
923
1047
  if (this.options.slpk) {
924
1048
  const slpkTexturePath = join(childPath, 'textures');
925
1049
  const compress = false;
@@ -1065,13 +1189,13 @@ export default class I3SConverter {
1065
1189
  const filesSize = await calculateFilesSize(params);
1066
1190
  const diff = process.hrtime(this.conversionStartTime);
1067
1191
  const conversionTime = timeConverter(diff);
1068
- console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console
1192
+ console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
1069
1193
  console.log(`Finishing conversion of ${_3D_TILES}`); // eslint-disable-line no-undef, no-console
1070
1194
  console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line no-undef, no-console
1071
- console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line no-undef, no-console
1072
- console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line no-undef, no-console
1073
- console.log(`Percentage of tiles with "ADD" refinement type:`, addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console
1074
- console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console
1195
+ console.log('Vertex count: ', this.vertexCounter); // eslint-disable-line no-undef, no-console
1196
+ console.log('File(s) size: ', filesSize, ' bytes'); // eslint-disable-line no-undef, no-console
1197
+ console.log('Percentage of tiles with "ADD" refinement type:', addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console
1198
+ console.log('------------------------------------------------'); // eslint-disable-line no-undef, no-console
1075
1199
  }
1076
1200
  /**
1077
1201
  * Fetch preload options for ION tileset
@@ -1109,7 +1233,7 @@ export default class I3SConverter {
1109
1233
  * @param tile
1110
1234
  */
1111
1235
  _checkAddRefinementTypeForTile(tile) {
1112
- const ADD_TILE_REFINEMENT = 1;
1236
+ const ADD_TILE_REFINEMENT = TILE_REFINEMENT.ADD;
1113
1237
  if (tile.refine === ADD_TILE_REFINEMENT) {
1114
1238
  this.refinementCounter.tilesWithAddRefineCount += 1;
1115
1239
  console.warn('This tile uses "ADD" type of refinement'); // eslint-disable-line
@@ -42,7 +42,7 @@ export const NODE = () => ({
42
42
  },
43
43
  {
44
44
  metricType: 'maxScreenThreshold',
45
- maxError: 999.99999999999994
45
+ maxError: 999.9999999999999
46
46
  }
47
47
  ]
48
48
  },