@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.0-alpha.2

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 (170) hide show
  1. package/dist/3d-tiles-attributes-worker.d.ts +28 -0
  2. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
  3. package/dist/3d-tiles-attributes-worker.js +4 -0
  4. package/dist/3d-tiles-attributes-worker.js.map +7 -0
  5. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -0
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +29 -3
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -4
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +10 -10
  11. package/dist/converter.min.js +20 -20
  12. package/dist/dist.min.js +789 -645
  13. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  14. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  15. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +102 -43
  16. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  17. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
  18. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  19. package/dist/es5/i3s-attributes-worker.js +29 -0
  20. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  21. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  22. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  24. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/geometry-converter.js +267 -178
  26. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  27. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  28. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  29. package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
  30. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  31. package/dist/es5/i3s-converter/i3s-converter.js +230 -195
  32. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  33. package/dist/es5/index.js +8 -0
  34. package/dist/es5/index.js.map +1 -1
  35. package/dist/es5/lib/utils/compress-util.js +14 -17
  36. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  37. package/dist/es5/lib/utils/file-utils.js +39 -14
  38. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  39. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  40. package/dist/es5/lib/utils/queue.js +61 -0
  41. package/dist/es5/lib/utils/queue.js.map +1 -0
  42. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  43. package/dist/es5/lib/utils/write-queue.js +225 -0
  44. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  45. package/dist/es5/pgm-loader.js +1 -1
  46. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  47. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  48. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  49. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  50. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  51. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  52. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +30 -4
  53. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  54. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +16 -18
  55. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  56. package/dist/esm/i3s-attributes-worker.js +16 -0
  57. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  58. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  59. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  60. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  61. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  62. package/dist/esm/i3s-converter/helpers/geometry-converter.js +117 -58
  63. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  64. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  65. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  66. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
  67. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  68. package/dist/esm/i3s-converter/i3s-converter.js +105 -28
  69. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  70. package/dist/esm/index.js +1 -0
  71. package/dist/esm/index.js.map +1 -1
  72. package/dist/esm/lib/utils/compress-util.js +6 -8
  73. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  74. package/dist/esm/lib/utils/file-utils.js +11 -1
  75. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  76. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  77. package/dist/esm/lib/utils/queue.js +19 -0
  78. package/dist/esm/lib/utils/queue.js.map +1 -0
  79. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  80. package/dist/esm/lib/utils/write-queue.js +88 -0
  81. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  82. package/dist/esm/pgm-loader.js +1 -1
  83. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  84. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  85. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  86. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  87. package/dist/i3s-attributes-worker.d.ts +33 -0
  88. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  89. package/dist/i3s-attributes-worker.js +10 -0
  90. package/dist/i3s-attributes-worker.js.map +7 -0
  91. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
  92. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  93. package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
  94. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
  95. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  96. package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
  97. package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
  98. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  99. package/dist/i3s-converter/helpers/geometry-converter.js +220 -110
  100. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  101. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  102. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  103. package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
  104. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  105. package/dist/i3s-converter/helpers/node-pages.js +13 -8
  106. package/dist/i3s-converter/i3s-converter.d.ts +7 -3
  107. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  108. package/dist/i3s-converter/i3s-converter.js +88 -26
  109. package/dist/i3s-converter/types.d.ts +83 -8
  110. package/dist/i3s-converter/types.d.ts.map +1 -1
  111. package/dist/index.d.ts +1 -0
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +3 -1
  114. package/dist/lib/utils/compress-util.d.ts +44 -5
  115. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  116. package/dist/lib/utils/compress-util.js +73 -6
  117. package/dist/lib/utils/file-utils.d.ts +34 -5
  118. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  119. package/dist/lib/utils/file-utils.js +40 -1
  120. package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
  121. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  122. package/dist/lib/utils/lod-conversion-utils.js +21 -2
  123. package/dist/lib/utils/queue.d.ts +7 -0
  124. package/dist/lib/utils/queue.d.ts.map +1 -0
  125. package/dist/lib/utils/queue.js +18 -0
  126. package/dist/lib/utils/statistic-utills.d.ts +2 -2
  127. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  128. package/dist/lib/utils/write-queue.d.ts +22 -0
  129. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  130. package/dist/lib/utils/write-queue.js +62 -0
  131. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  132. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  133. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  134. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  135. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  136. package/dist/workers/i3s-attributes-worker.js +5 -0
  137. package/package.json +20 -17
  138. package/src/3d-tiles-attributes-worker.ts +43 -0
  139. package/src/3d-tiles-converter/3d-tiles-converter.ts +44 -4
  140. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
  141. package/src/i3s-attributes-worker.ts +46 -0
  142. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  143. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  144. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +421 -175
  145. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  146. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  147. package/src/i3s-converter/i3s-converter.ts +112 -69
  148. package/src/i3s-converter/types.ts +90 -8
  149. package/src/index.ts +1 -0
  150. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  151. package/src/lib/utils/file-utils.ts +84 -0
  152. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  153. package/src/lib/utils/queue.ts +17 -0
  154. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  155. package/src/lib/utils/write-queue.ts +75 -0
  156. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  157. package/src/workers/i3s-attributes-worker.ts +6 -0
  158. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  159. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  160. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  161. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  162. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  163. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  164. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  165. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  166. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  167. package/src/lib/utils/compress-util.d.ts +0 -53
  168. package/src/lib/utils/file-utils.d.ts +0 -43
  169. package/src/lib/utils/file-utils.js +0 -38
  170. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { load, encode } from '@loaders.gl/core';
2
+ import { load, encode, fetchFile, getLoaderOptions } from '@loaders.gl/core';
3
3
  import { Tileset3D } from '@loaders.gl/tiles';
4
4
  import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
5
5
  import { join } from 'path';
@@ -12,7 +12,7 @@ import { writeFile, removeDir, writeFileForSlpk } from '../lib/utils/file-utils'
12
12
  import { compressWithChildProcess } from '../lib/utils/compress-util';
13
13
  import { calculateFilesSize, timeConverter } from '../lib/utils/statistic-utills';
14
14
  import convertB3dmToI3sGeometry from './helpers/geometry-converter';
15
- import { createBoundingVolumes, convertCommonToI3SExtentCoordinate } from './helpers/coordinate-converter';
15
+ import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from './helpers/coordinate-converter';
16
16
  import { createSceneServerPath } from './helpers/create-scene-server-path';
17
17
  import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-conversion-utils';
18
18
  import { PGMLoader } from '../pgm-loader';
@@ -20,8 +20,12 @@ import { LAYERS as layersTemplate } from './json-templates/layers';
20
20
  import { NODE as nodeTemplate } from './json-templates/node';
21
21
  import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
22
22
  import { validateNodeBoundingVolumes } from './helpers/node-debug';
23
- import { KTX2BasisUniversalTextureWriter } from '@loaders.gl/textures';
23
+ import { KTX2BasisWriter } from '@loaders.gl/textures';
24
24
  import { ImageWriter } from '@loaders.gl/images';
25
+ import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
26
+ import { DracoWriterWorker } from '@loaders.gl/draco';
27
+ import WriteQueue from '../lib/utils/write-queue';
28
+ import { I3SAttributesWorker } from '../i3s-attributes-worker';
25
29
  const ION_DEFAULT_TOKEN = process.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
26
30
  const HARDCODED_NODES_PER_PAGE = 64;
27
31
  const _3D_TILES = '3DTILES';
@@ -36,8 +40,6 @@ export default class I3SConverter {
36
40
  constructor() {
37
41
  _defineProperty(this, "nodePages", void 0);
38
42
 
39
- _defineProperty(this, "fileMap", void 0);
40
-
41
43
  _defineProperty(this, "options", void 0);
42
44
 
43
45
  _defineProperty(this, "layers0Path", void 0);
@@ -74,8 +76,11 @@ export default class I3SConverter {
74
76
 
75
77
  _defineProperty(this, "layersHasTexture", void 0);
76
78
 
79
+ _defineProperty(this, "workerSource", {});
80
+
81
+ _defineProperty(this, "writeQueue", new WriteQueue());
82
+
77
83
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
78
- this.fileMap = {};
79
84
  this.options = {};
80
85
  this.layers0Path = '';
81
86
  this.materialMap = new Map();
@@ -122,6 +127,8 @@ export default class I3SConverter {
122
127
  this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
123
128
  this.generateTextures = Boolean(generateTextures);
124
129
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
130
+ this.writeQueue = new WriteQueue();
131
+ this.writeQueue.startListening();
125
132
  console.log('Loading egm file...');
126
133
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
127
134
  console.log('Loading egm file completed!');
@@ -130,6 +137,7 @@ export default class I3SConverter {
130
137
  this.nodePages.useWriteFunction(writeFileForSlpk);
131
138
  }
132
139
 
140
+ await this.loadWorkers();
133
141
  const preloadOptions = await this._fetchPreloadOptions();
134
142
  const tilesetOptions = {
135
143
  loadOptions: {
@@ -154,6 +162,8 @@ export default class I3SConverter {
154
162
  outputPath,
155
163
  tilesetName
156
164
  });
165
+ const workerFarm = WorkerFarm.getWorkerFarm({});
166
+ workerFarm.destroy();
157
167
  return sourceTilesetJson;
158
168
  }
159
169
 
@@ -192,12 +202,16 @@ export default class I3SConverter {
192
202
  await this._writeLayers0();
193
203
  createSceneServerPath(tilesetName, this.layers0, tilesetPath);
194
204
  await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
195
- await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
205
+ await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
206
+ await this.writeQueue.finalize();
196
207
  await this._createSlpk(tilesetPath);
197
208
  }
198
209
 
199
210
  _formLayers0(tilesetName) {
200
- const extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);
211
+ var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
212
+
213
+ const fullExtent = convertBoundingVolumeToI3SFullExtent(((_this$sourceTileset = this.sourceTileset) === null || _this$sourceTileset === void 0 ? void 0 : _this$sourceTileset.boundingVolume) || ((_this$sourceTileset2 = this.sourceTileset) === null || _this$sourceTileset2 === void 0 ? void 0 : (_this$sourceTileset2$ = _this$sourceTileset2.root) === null || _this$sourceTileset2$ === void 0 ? void 0 : _this$sourceTileset2$.boundingVolume));
214
+ const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
201
215
  const layers0data = {
202
216
  version: "{".concat(uuidv4().toUpperCase(), "}"),
203
217
  id: 0,
@@ -247,9 +261,14 @@ export default class I3SConverter {
247
261
  const childPath = join(this.layers0Path, 'nodes', child.path);
248
262
 
249
263
  if (this.options.slpk) {
250
- this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json');
264
+ this.writeQueue.enqueue({
265
+ archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
266
+ writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
267
+ });
251
268
  } else {
252
- await writeFile(childPath, JSON.stringify(child));
269
+ this.writeQueue.enqueue({
270
+ writePromise: writeFile(childPath, JSON.stringify(child))
271
+ });
253
272
  }
254
273
  } else {
255
274
  await this._addChildrenWithNeighborsAndWriteFile({
@@ -265,17 +284,27 @@ export default class I3SConverter {
265
284
 
266
285
  async _writeLayers0() {
267
286
  if (this.options.slpk) {
268
- this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json');
287
+ this.writeQueue.enqueue({
288
+ archiveKey: '3dSceneLayer.json.gz',
289
+ writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
290
+ });
269
291
  } else {
270
- await writeFile(this.layers0Path, JSON.stringify(this.layers0));
292
+ this.writeQueue.enqueue({
293
+ writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
294
+ });
271
295
  }
272
296
  }
273
297
 
274
298
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
275
299
  if (this.options.slpk) {
276
- this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = await writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
300
+ this.writeQueue.enqueue({
301
+ archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
302
+ writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
303
+ });
277
304
  } else {
278
- await writeFile(rootPath, JSON.stringify(root0));
305
+ this.writeQueue.enqueue({
306
+ writePromise: writeFile(rootPath, JSON.stringify(root0))
307
+ });
279
308
  }
280
309
  }
281
310
 
@@ -463,7 +492,7 @@ export default class I3SConverter {
463
492
  return null;
464
493
  }
465
494
 
466
- const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel);
495
+ const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
467
496
  return resourcesData;
468
497
  }
469
498
 
@@ -598,34 +627,53 @@ export default class I3SConverter {
598
627
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
599
628
  if (this.options.slpk) {
600
629
  const slpkGeometryPath = join(childPath, 'geometries');
601
- this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = await writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin');
630
+ this.writeQueue.enqueue({
631
+ archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
632
+ writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
633
+ });
602
634
  } else {
603
635
  const geometryPath = join(childPath, 'geometries/0/');
604
- await writeFile(geometryPath, geometryBuffer, 'index.bin');
636
+ this.writeQueue.enqueue({
637
+ writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
638
+ });
605
639
  }
606
640
 
607
641
  if (this.options.draco) {
608
642
  if (this.options.slpk) {
609
643
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
610
- this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = await writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
644
+ this.writeQueue.enqueue({
645
+ archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
646
+ writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
647
+ });
611
648
  } else {
612
649
  const compressedGeometryPath = join(childPath, 'geometries/1/');
613
- await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');
650
+ this.writeQueue.enqueue({
651
+ writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
652
+ });
614
653
  }
615
654
  }
616
655
  }
617
656
 
618
657
  async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
658
+ if (!sharedResources) {
659
+ return;
660
+ }
661
+
619
662
  sharedResources.nodePath = nodePath;
620
663
  const sharedData = transform(sharedResources, sharedResourcesTemplate());
621
664
  const sharedDataStr = JSON.stringify(sharedData);
622
665
 
623
666
  if (this.options.slpk) {
624
667
  const slpkSharedPath = join(childPath, 'shared');
625
- this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = await writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json');
668
+ this.writeQueue.enqueue({
669
+ archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
670
+ writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
671
+ });
626
672
  } else {
627
673
  const sharedPath = join(childPath, 'shared/');
628
- await writeFile(sharedPath, sharedDataStr);
674
+ this.writeQueue.enqueue({
675
+ writePromise: writeFile(sharedPath, sharedDataStr)
676
+ });
629
677
  }
630
678
  }
631
679
 
@@ -651,7 +699,7 @@ export default class I3SConverter {
651
699
  name: '1',
652
700
  format: 'ktx2'
653
701
  });
654
- const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
702
+ const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisWriter));
655
703
  await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
656
704
  }
657
705
 
@@ -689,27 +737,37 @@ export default class I3SConverter {
689
737
  if (this.options.slpk) {
690
738
  const slpkTexturePath = join(childPath, 'textures');
691
739
  const compress = false;
692
- this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
740
+ this.writeQueue.enqueue({
741
+ archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
742
+ writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
743
+ });
693
744
  } else {
694
745
  const texturePath = join(childPath, "textures/".concat(name, "/"));
695
- await writeFile(texturePath, textureData, "index.".concat(format));
746
+ this.writeQueue.enqueue({
747
+ writePromise: writeFile(texturePath, textureData, "index.".concat(format))
748
+ });
696
749
  }
697
750
  }
698
751
 
699
- async _writeAttributes(attributes, childPath, slpkChildPath) {
752
+ async _writeAttributes(attributes = [], childPath, slpkChildPath) {
700
753
  var _this$layers4, _this$layers4$attribu;
701
754
 
702
- if (attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
755
+ if (attributes !== null && attributes !== void 0 && attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
703
756
  for (let index = 0; index < attributes.length; index++) {
704
757
  const folderName = this.layers0.attributeStorageInfo[index].key;
705
758
  const fileBuffer = new Uint8Array(attributes[index]);
706
759
 
707
760
  if (this.options.slpk) {
708
761
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
709
- this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = await writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin');
762
+ this.writeQueue.enqueue({
763
+ archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
764
+ writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
765
+ });
710
766
  } else {
711
767
  const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
712
- await writeFile(attributesPath, fileBuffer, 'index.bin');
768
+ this.writeQueue.enqueue({
769
+ writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
770
+ });
713
771
  }
714
772
  }
715
773
  }
@@ -986,5 +1044,24 @@ export default class I3SConverter {
986
1044
  return ['b3dm', 'glTF'].includes(sourceRootTile === null || sourceRootTile === void 0 ? void 0 : (_sourceRootTile$conte = sourceRootTile.content) === null || _sourceRootTile$conte === void 0 ? void 0 : _sourceRootTile$conte.type);
987
1045
  }
988
1046
 
1047
+ async loadWorkers() {
1048
+ console.log("Loading workers source...");
1049
+
1050
+ if (this.options.draco) {
1051
+ const url = getWorkerURL(DracoWriterWorker, { ...getLoaderOptions()
1052
+ });
1053
+ const sourceResponse = await fetchFile(url);
1054
+ const source = await sourceResponse.text();
1055
+ this.workerSource.draco = source;
1056
+ }
1057
+
1058
+ const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getLoaderOptions()
1059
+ });
1060
+ const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
1061
+ const source = await sourceResponse.text();
1062
+ this.workerSource.I3SAttributes = source;
1063
+ console.log("Loading workers source completed!");
1064
+ }
1065
+
989
1066
  }
990
1067
  //# sourceMappingURL=i3s-converter.js.map