@loaders.gl/tile-converter 3.1.7 → 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 (224) 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 +82 -0
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +268 -0
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +84 -0
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
  11. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
  12. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  13. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
  14. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  15. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
  17. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  18. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  19. package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
  20. package/dist/bundle.d.ts +2 -0
  21. package/dist/bundle.d.ts.map +1 -0
  22. package/dist/bundle.js +5 -0
  23. package/dist/converter.min.js +20 -20
  24. package/dist/deps-installer/deps-installer.d.ts +4 -0
  25. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  26. package/dist/deps-installer/deps-installer.js +21 -0
  27. package/dist/dist.min.js +1082 -1131
  28. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  29. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  30. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +104 -44
  31. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  32. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +34 -43
  33. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  34. package/dist/es5/i3s-attributes-worker.js +29 -0
  35. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  36. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  37. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  39. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/geometry-converter.js +267 -178
  41. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  43. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  44. package/dist/es5/i3s-converter/helpers/node-pages.js +43 -52
  45. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  46. package/dist/es5/i3s-converter/i3s-converter.js +264 -219
  47. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  48. package/dist/es5/index.js +8 -0
  49. package/dist/es5/index.js.map +1 -1
  50. package/dist/es5/lib/utils/compress-util.js +14 -17
  51. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  52. package/dist/es5/lib/utils/file-utils.js +39 -14
  53. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  54. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  55. package/dist/es5/lib/utils/queue.js +61 -0
  56. package/dist/es5/lib/utils/queue.js.map +1 -0
  57. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  58. package/dist/es5/lib/utils/write-queue.js +225 -0
  59. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  60. package/dist/es5/pgm-loader.js +1 -1
  61. package/dist/es5/pgm-loader.js.map +1 -1
  62. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  63. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  64. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  65. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  66. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  67. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  68. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +32 -5
  69. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  70. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +23 -23
  71. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  72. package/dist/esm/i3s-attributes-worker.js +16 -0
  73. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  74. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  75. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  76. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  77. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  78. package/dist/esm/i3s-converter/helpers/geometry-converter.js +117 -58
  79. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  80. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  81. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  82. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -9
  83. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  84. package/dist/esm/i3s-converter/i3s-converter.js +115 -28
  85. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  86. package/dist/esm/index.js +1 -0
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/lib/utils/compress-util.js +6 -8
  89. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  90. package/dist/esm/lib/utils/file-utils.js +11 -1
  91. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  92. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  93. package/dist/esm/lib/utils/queue.js +19 -0
  94. package/dist/esm/lib/utils/queue.js.map +1 -0
  95. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  96. package/dist/esm/lib/utils/write-queue.js +88 -0
  97. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  98. package/dist/esm/pgm-loader.js +1 -1
  99. package/dist/esm/pgm-loader.js.map +1 -1
  100. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  101. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  102. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  103. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  104. package/dist/i3s-attributes-worker.d.ts +33 -0
  105. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  106. package/dist/i3s-attributes-worker.js +10 -0
  107. package/dist/i3s-attributes-worker.js.map +7 -0
  108. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  109. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  110. package/dist/i3s-converter/helpers/coordinate-converter.js +122 -0
  111. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  112. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  113. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  114. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  115. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  116. package/dist/i3s-converter/helpers/geometry-attributes.js +177 -0
  117. package/dist/i3s-converter/helpers/geometry-converter.d.ts +29 -0
  118. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  119. package/dist/i3s-converter/helpers/geometry-converter.js +901 -0
  120. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  121. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  122. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  123. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  124. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  126. package/dist/i3s-converter/helpers/node-pages.d.ts +117 -0
  127. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  128. package/dist/i3s-converter/helpers/node-pages.js +208 -0
  129. package/dist/i3s-converter/i3s-converter.d.ts +325 -0
  130. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  131. package/dist/i3s-converter/i3s-converter.js +1056 -0
  132. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  133. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  134. package/dist/i3s-converter/json-templates/layers.js +199 -0
  135. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  136. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  137. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  138. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  139. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  140. package/dist/i3s-converter/json-templates/node.js +89 -0
  141. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  142. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  143. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  144. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  145. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  146. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  147. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  148. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  149. package/dist/i3s-converter/json-templates/store.js +103 -0
  150. package/dist/i3s-converter/types.d.ts +114 -0
  151. package/dist/i3s-converter/types.d.ts.map +1 -0
  152. package/dist/i3s-converter/types.js +2 -0
  153. package/dist/i3s-server/app.d.ts +3 -0
  154. package/dist/i3s-server/app.d.ts.map +1 -0
  155. package/dist/i3s-server/app.js +14 -0
  156. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  157. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  158. package/dist/i3s-server/controllers/index-controller.js +23 -0
  159. package/dist/i3s-server/routes/index.d.ts +3 -0
  160. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  161. package/dist/i3s-server/routes/index.js +16 -0
  162. package/dist/index.d.ts +6 -0
  163. package/dist/index.d.ts.map +1 -0
  164. package/dist/index.js +16 -0
  165. package/dist/lib/utils/compress-util.d.ts +45 -0
  166. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  167. package/dist/lib/utils/compress-util.js +257 -0
  168. package/{src → dist}/lib/utils/file-utils.d.ts +6 -14
  169. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  170. package/dist/lib/utils/file-utils.js +81 -0
  171. package/dist/lib/utils/lod-conversion-utils.d.ts +41 -0
  172. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  173. package/dist/lib/utils/lod-conversion-utils.js +76 -0
  174. package/dist/lib/utils/queue.d.ts +7 -0
  175. package/dist/lib/utils/queue.d.ts.map +1 -0
  176. package/dist/lib/utils/queue.js +18 -0
  177. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  178. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  179. package/dist/lib/utils/statistic-utills.js +64 -0
  180. package/dist/lib/utils/write-queue.d.ts +22 -0
  181. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  182. package/dist/lib/utils/write-queue.js +62 -0
  183. package/dist/pgm-loader.d.ts +6 -0
  184. package/dist/pgm-loader.d.ts.map +1 -0
  185. package/dist/pgm-loader.js +23 -0
  186. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  187. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  188. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  189. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  190. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  191. package/dist/workers/i3s-attributes-worker.js +5 -0
  192. package/package.json +20 -18
  193. package/src/3d-tiles-attributes-worker.ts +43 -0
  194. package/src/3d-tiles-converter/3d-tiles-converter.ts +48 -5
  195. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +21 -18
  196. package/src/i3s-attributes-worker.ts +46 -0
  197. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  198. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  199. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +421 -175
  200. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  201. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  202. package/src/i3s-converter/i3s-converter.ts +124 -69
  203. package/src/i3s-converter/types.ts +90 -8
  204. package/src/index.ts +1 -0
  205. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  206. package/src/lib/utils/file-utils.ts +84 -0
  207. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  208. package/src/lib/utils/queue.ts +17 -0
  209. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  210. package/src/lib/utils/write-queue.ts +75 -0
  211. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  212. package/src/workers/i3s-attributes-worker.ts +6 -0
  213. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  214. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  215. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  216. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  217. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  218. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  219. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  220. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  221. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  222. package/src/lib/utils/compress-util.d.ts +0 -53
  223. package/src/lib/utils/file-utils.js +0 -38
  224. 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);
@@ -72,8 +74,13 @@ export default class I3SConverter {
72
74
 
73
75
  _defineProperty(this, "generateBoundingVolumes", void 0);
74
76
 
77
+ _defineProperty(this, "layersHasTexture", void 0);
78
+
79
+ _defineProperty(this, "workerSource", {});
80
+
81
+ _defineProperty(this, "writeQueue", new WriteQueue());
82
+
75
83
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
76
- this.fileMap = {};
77
84
  this.options = {};
78
85
  this.layers0Path = '';
79
86
  this.materialMap = new Map();
@@ -88,6 +95,7 @@ export default class I3SConverter {
88
95
  this.validate = false;
89
96
  this.generateTextures = false;
90
97
  this.generateBoundingVolumes = false;
98
+ this.layersHasTexture = false;
91
99
  }
92
100
 
93
101
  async convert(options) {
@@ -119,6 +127,8 @@ export default class I3SConverter {
119
127
  this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
120
128
  this.generateTextures = Boolean(generateTextures);
121
129
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
130
+ this.writeQueue = new WriteQueue();
131
+ this.writeQueue.startListening();
122
132
  console.log('Loading egm file...');
123
133
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
124
134
  console.log('Loading egm file completed!');
@@ -127,6 +137,7 @@ export default class I3SConverter {
127
137
  this.nodePages.useWriteFunction(writeFileForSlpk);
128
138
  }
129
139
 
140
+ await this.loadWorkers();
130
141
  const preloadOptions = await this._fetchPreloadOptions();
131
142
  const tilesetOptions = {
132
143
  loadOptions: {
@@ -151,6 +162,8 @@ export default class I3SConverter {
151
162
  outputPath,
152
163
  tilesetName
153
164
  });
165
+ const workerFarm = WorkerFarm.getWorkerFarm({});
166
+ workerFarm.destroy();
154
167
  return sourceTilesetJson;
155
168
  }
156
169
 
@@ -181,15 +194,24 @@ export default class I3SConverter {
181
194
 
182
195
  await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
183
196
  this.layers0.materialDefinitions = this.materialDefinitions;
197
+
198
+ if (this.layersHasTexture === false) {
199
+ this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter(attribute => attribute !== 'uv0');
200
+ }
201
+
184
202
  await this._writeLayers0();
185
203
  createSceneServerPath(tilesetName, this.layers0, tilesetPath);
186
204
  await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
187
- await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
205
+ await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
206
+ await this.writeQueue.finalize();
188
207
  await this._createSlpk(tilesetPath);
189
208
  }
190
209
 
191
210
  _formLayers0(tilesetName) {
192
- 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];
193
215
  const layers0data = {
194
216
  version: "{".concat(uuidv4().toUpperCase(), "}"),
195
217
  id: 0,
@@ -239,9 +261,14 @@ export default class I3SConverter {
239
261
  const childPath = join(this.layers0Path, 'nodes', child.path);
240
262
 
241
263
  if (this.options.slpk) {
242
- 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
+ });
243
268
  } else {
244
- await writeFile(childPath, JSON.stringify(child));
269
+ this.writeQueue.enqueue({
270
+ writePromise: writeFile(childPath, JSON.stringify(child))
271
+ });
245
272
  }
246
273
  } else {
247
274
  await this._addChildrenWithNeighborsAndWriteFile({
@@ -257,17 +284,27 @@ export default class I3SConverter {
257
284
 
258
285
  async _writeLayers0() {
259
286
  if (this.options.slpk) {
260
- 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
+ });
261
291
  } else {
262
- await writeFile(this.layers0Path, JSON.stringify(this.layers0));
292
+ this.writeQueue.enqueue({
293
+ writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
294
+ });
263
295
  }
264
296
  }
265
297
 
266
298
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
267
299
  if (this.options.slpk) {
268
- 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
+ });
269
304
  } else {
270
- await writeFile(rootPath, JSON.stringify(root0));
305
+ this.writeQueue.enqueue({
306
+ writePromise: writeFile(rootPath, JSON.stringify(root0))
307
+ });
271
308
  }
272
309
  }
273
310
 
@@ -397,6 +434,8 @@ export default class I3SConverter {
397
434
  };
398
435
 
399
436
  for (const resources of resourcesData || [emptyResources]) {
437
+ this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
438
+
400
439
  if (this.generateBoundingVolumes && resources.boundingVolumes) {
401
440
  boundingVolumes = resources.boundingVolumes;
402
441
  }
@@ -453,7 +492,7 @@ export default class I3SConverter {
453
492
  return null;
454
493
  }
455
494
 
456
- 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);
457
496
  return resourcesData;
458
497
  }
459
498
 
@@ -588,34 +627,53 @@ export default class I3SConverter {
588
627
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
589
628
  if (this.options.slpk) {
590
629
  const slpkGeometryPath = join(childPath, 'geometries');
591
- 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
+ });
592
634
  } else {
593
635
  const geometryPath = join(childPath, 'geometries/0/');
594
- await writeFile(geometryPath, geometryBuffer, 'index.bin');
636
+ this.writeQueue.enqueue({
637
+ writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
638
+ });
595
639
  }
596
640
 
597
641
  if (this.options.draco) {
598
642
  if (this.options.slpk) {
599
643
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
600
- 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
+ });
601
648
  } else {
602
649
  const compressedGeometryPath = join(childPath, 'geometries/1/');
603
- await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');
650
+ this.writeQueue.enqueue({
651
+ writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
652
+ });
604
653
  }
605
654
  }
606
655
  }
607
656
 
608
657
  async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
658
+ if (!sharedResources) {
659
+ return;
660
+ }
661
+
609
662
  sharedResources.nodePath = nodePath;
610
663
  const sharedData = transform(sharedResources, sharedResourcesTemplate());
611
664
  const sharedDataStr = JSON.stringify(sharedData);
612
665
 
613
666
  if (this.options.slpk) {
614
667
  const slpkSharedPath = join(childPath, 'shared');
615
- 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
+ });
616
672
  } else {
617
673
  const sharedPath = join(childPath, 'shared/');
618
- await writeFile(sharedPath, sharedDataStr);
674
+ this.writeQueue.enqueue({
675
+ writePromise: writeFile(sharedPath, sharedDataStr)
676
+ });
619
677
  }
620
678
  }
621
679
 
@@ -641,7 +699,7 @@ export default class I3SConverter {
641
699
  name: '1',
642
700
  format: 'ktx2'
643
701
  });
644
- const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
702
+ const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisWriter));
645
703
  await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
646
704
  }
647
705
 
@@ -679,27 +737,37 @@ export default class I3SConverter {
679
737
  if (this.options.slpk) {
680
738
  const slpkTexturePath = join(childPath, 'textures');
681
739
  const compress = false;
682
- 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
+ });
683
744
  } else {
684
745
  const texturePath = join(childPath, "textures/".concat(name, "/"));
685
- await writeFile(texturePath, textureData, "index.".concat(format));
746
+ this.writeQueue.enqueue({
747
+ writePromise: writeFile(texturePath, textureData, "index.".concat(format))
748
+ });
686
749
  }
687
750
  }
688
751
 
689
- async _writeAttributes(attributes, childPath, slpkChildPath) {
752
+ async _writeAttributes(attributes = [], childPath, slpkChildPath) {
690
753
  var _this$layers4, _this$layers4$attribu;
691
754
 
692
- 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) {
693
756
  for (let index = 0; index < attributes.length; index++) {
694
757
  const folderName = this.layers0.attributeStorageInfo[index].key;
695
758
  const fileBuffer = new Uint8Array(attributes[index]);
696
759
 
697
760
  if (this.options.slpk) {
698
761
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
699
- 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
+ });
700
766
  } else {
701
767
  const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
702
- await writeFile(attributesPath, fileBuffer, 'index.bin');
768
+ this.writeQueue.enqueue({
769
+ writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
770
+ });
703
771
  }
704
772
  }
705
773
  }
@@ -976,5 +1044,24 @@ export default class I3SConverter {
976
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);
977
1045
  }
978
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
+
979
1066
  }
980
1067
  //# sourceMappingURL=i3s-converter.js.map