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

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 (203) 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 +5 -1
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +34 -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/constants.d.ts +2 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +4 -0
  14. package/dist/converter-cli.d.ts +2 -0
  15. package/dist/converter-cli.d.ts.map +1 -0
  16. package/dist/converter-cli.js +232 -0
  17. package/dist/converter.min.js +68 -68
  18. package/dist/deps-installer/deps-installer.d.ts +11 -1
  19. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  20. package/dist/deps-installer/deps-installer.js +10 -0
  21. package/dist/dist.min.js +910 -790
  22. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  23. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  24. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +116 -46
  25. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  26. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
  27. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  28. package/dist/es5/constants.js +9 -0
  29. package/dist/es5/constants.js.map +1 -0
  30. package/dist/es5/converter-cli.js +306 -0
  31. package/dist/es5/converter-cli.js.map +1 -0
  32. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  33. package/dist/es5/i3s-attributes-worker.js +29 -0
  34. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  35. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  36. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  37. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  38. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  39. package/dist/es5/i3s-converter/helpers/geometry-converter.js +271 -182
  40. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  41. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  42. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  43. package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
  44. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  45. package/dist/es5/i3s-converter/i3s-converter.js +293 -223
  46. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  47. package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
  48. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  49. package/dist/es5/index.js +0 -16
  50. package/dist/es5/index.js.map +1 -1
  51. package/dist/es5/lib/utils/compress-util.js +14 -17
  52. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  53. package/dist/es5/lib/utils/file-utils.js +39 -14
  54. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  55. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  56. package/dist/es5/lib/utils/queue.js +61 -0
  57. package/dist/es5/lib/utils/queue.js.map +1 -0
  58. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  59. package/dist/es5/lib/utils/write-queue.js +225 -0
  60. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  61. package/dist/es5/pgm-loader.js +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 +36 -4
  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 +16 -18
  71. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  72. package/dist/esm/constants.js +2 -0
  73. package/dist/esm/constants.js.map +1 -0
  74. package/dist/esm/converter-cli.js +230 -0
  75. package/dist/esm/converter-cli.js.map +1 -0
  76. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  77. package/dist/esm/i3s-attributes-worker.js +16 -0
  78. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  79. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  80. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  81. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  82. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  83. package/dist/esm/i3s-converter/helpers/geometry-converter.js +121 -62
  84. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  85. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  86. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  87. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
  88. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  89. package/dist/esm/i3s-converter/i3s-converter.js +157 -52
  90. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  91. package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
  92. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  93. package/dist/esm/index.js +0 -2
  94. package/dist/esm/index.js.map +1 -1
  95. package/dist/esm/lib/utils/compress-util.js +6 -8
  96. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  97. package/dist/esm/lib/utils/file-utils.js +11 -1
  98. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  99. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  100. package/dist/esm/lib/utils/queue.js +19 -0
  101. package/dist/esm/lib/utils/queue.js.map +1 -0
  102. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  103. package/dist/esm/lib/utils/write-queue.js +88 -0
  104. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  105. package/dist/esm/pgm-loader.js +1 -1
  106. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  107. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  108. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  109. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  110. package/dist/i3s-attributes-worker.d.ts +33 -0
  111. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  112. package/dist/i3s-attributes-worker.js +10 -0
  113. package/dist/i3s-attributes-worker.js.map +7 -0
  114. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
  115. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  116. package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
  117. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
  118. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  119. package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
  120. package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
  121. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  122. package/dist/i3s-converter/helpers/geometry-converter.js +223 -113
  123. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  124. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  126. package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
  127. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  128. package/dist/i3s-converter/helpers/node-pages.js +13 -8
  129. package/dist/i3s-converter/i3s-converter.d.ts +7 -5
  130. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  131. package/dist/i3s-converter/i3s-converter.js +126 -40
  132. package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
  133. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  134. package/dist/i3s-converter/json-templates/layers.js +24 -0
  135. package/dist/i3s-converter/types.d.ts +83 -8
  136. package/dist/i3s-converter/types.d.ts.map +1 -1
  137. package/dist/index.d.ts +0 -2
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +1 -5
  140. package/dist/lib/utils/compress-util.d.ts +44 -5
  141. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  142. package/dist/lib/utils/compress-util.js +73 -6
  143. package/dist/lib/utils/file-utils.d.ts +34 -5
  144. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  145. package/dist/lib/utils/file-utils.js +40 -1
  146. package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
  147. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  148. package/dist/lib/utils/lod-conversion-utils.js +21 -2
  149. package/dist/lib/utils/queue.d.ts +7 -0
  150. package/dist/lib/utils/queue.d.ts.map +1 -0
  151. package/dist/lib/utils/queue.js +18 -0
  152. package/dist/lib/utils/statistic-utills.d.ts +2 -2
  153. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  154. package/dist/lib/utils/write-queue.d.ts +22 -0
  155. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  156. package/dist/lib/utils/write-queue.js +62 -0
  157. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  158. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  159. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  160. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  161. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  162. package/dist/workers/i3s-attributes-worker.js +5 -0
  163. package/package.json +23 -18
  164. package/src/3d-tiles-attributes-worker.ts +43 -0
  165. package/src/3d-tiles-converter/3d-tiles-converter.ts +50 -5
  166. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
  167. package/src/constants.ts +2 -0
  168. package/src/converter-cli.ts +310 -0
  169. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  170. package/src/i3s-attributes-worker.ts +46 -0
  171. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  172. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  173. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +425 -179
  174. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  175. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  176. package/src/i3s-converter/i3s-converter.ts +150 -90
  177. package/src/i3s-converter/json-templates/layers.ts +25 -0
  178. package/src/i3s-converter/types.ts +90 -8
  179. package/src/index.ts +0 -4
  180. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  181. package/src/lib/utils/file-utils.ts +84 -0
  182. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  183. package/src/lib/utils/queue.ts +17 -0
  184. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  185. package/src/lib/utils/write-queue.ts +75 -0
  186. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  187. package/src/workers/i3s-attributes-worker.ts +6 -0
  188. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  189. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  190. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  191. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  192. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  193. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  194. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  195. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  196. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  197. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  198. package/src/deps-installer/deps-installer.d.ts +0 -10
  199. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  200. package/src/lib/utils/compress-util.d.ts +0 -53
  201. package/src/lib/utils/file-utils.d.ts +0 -43
  202. package/src/lib/utils/file-utils.js +0 -38
  203. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
@@ -1,5 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { load, encode } from '@loaders.gl/core';
2
+
3
+ var _process$env;
4
+
5
+ import { load, encode, fetchFile, getLoaderOptions, isBrowser } from '@loaders.gl/core';
3
6
  import { Tileset3D } from '@loaders.gl/tiles';
4
7
  import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
5
8
  import { join } from 'path';
@@ -12,7 +15,7 @@ import { writeFile, removeDir, writeFileForSlpk } from '../lib/utils/file-utils'
12
15
  import { compressWithChildProcess } from '../lib/utils/compress-util';
13
16
  import { calculateFilesSize, timeConverter } from '../lib/utils/statistic-utills';
14
17
  import convertB3dmToI3sGeometry from './helpers/geometry-converter';
15
- import { createBoundingVolumes, convertCommonToI3SExtentCoordinate } from './helpers/coordinate-converter';
18
+ import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from './helpers/coordinate-converter';
16
19
  import { createSceneServerPath } from './helpers/create-scene-server-path';
17
20
  import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-conversion-utils';
18
21
  import { PGMLoader } from '../pgm-loader';
@@ -20,9 +23,14 @@ import { LAYERS as layersTemplate } from './json-templates/layers';
20
23
  import { NODE as nodeTemplate } from './json-templates/node';
21
24
  import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
22
25
  import { validateNodeBoundingVolumes } from './helpers/node-debug';
23
- import { KTX2BasisUniversalTextureWriter } from '@loaders.gl/textures';
26
+ import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
24
27
  import { ImageWriter } from '@loaders.gl/images';
25
- const ION_DEFAULT_TOKEN = process.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
28
+ import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
29
+ import { DracoWriterWorker } from '@loaders.gl/draco';
30
+ import WriteQueue from '../lib/utils/write-queue';
31
+ import { I3SAttributesWorker } from '../i3s-attributes-worker';
32
+ import { BROWSER_ERROR_MESSAGE } from '../constants';
33
+ const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
26
34
  const HARDCODED_NODES_PER_PAGE = 64;
27
35
  const _3D_TILES = '3DTILES';
28
36
  const _3D_OBJECT_LAYER_TYPE = '3DObject';
@@ -36,8 +44,6 @@ export default class I3SConverter {
36
44
  constructor() {
37
45
  _defineProperty(this, "nodePages", void 0);
38
46
 
39
- _defineProperty(this, "fileMap", void 0);
40
-
41
47
  _defineProperty(this, "options", void 0);
42
48
 
43
49
  _defineProperty(this, "layers0Path", void 0);
@@ -74,8 +80,11 @@ export default class I3SConverter {
74
80
 
75
81
  _defineProperty(this, "layersHasTexture", void 0);
76
82
 
83
+ _defineProperty(this, "workerSource", {});
84
+
85
+ _defineProperty(this, "writeQueue", new WriteQueue());
86
+
77
87
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
78
- this.fileMap = {};
79
88
  this.options = {};
80
89
  this.layers0Path = '';
81
90
  this.materialMap = new Map();
@@ -94,6 +103,11 @@ export default class I3SConverter {
94
103
  }
95
104
 
96
105
  async convert(options) {
106
+ if (isBrowser) {
107
+ console.log(BROWSER_ERROR_MESSAGE);
108
+ return BROWSER_ERROR_MESSAGE;
109
+ }
110
+
97
111
  this.conversionStartTime = process.hrtime();
98
112
  const {
99
113
  tilesetName,
@@ -122,6 +136,8 @@ export default class I3SConverter {
122
136
  this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
123
137
  this.generateTextures = Boolean(generateTextures);
124
138
  this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
139
+ this.writeQueue = new WriteQueue();
140
+ this.writeQueue.startListening();
125
141
  console.log('Loading egm file...');
126
142
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
127
143
  console.log('Loading egm file completed!');
@@ -130,31 +146,40 @@ export default class I3SConverter {
130
146
  this.nodePages.useWriteFunction(writeFileForSlpk);
131
147
  }
132
148
 
133
- const preloadOptions = await this._fetchPreloadOptions();
134
- const tilesetOptions = {
135
- loadOptions: {
136
- basis: {
137
- format: 'rgba32'
149
+ await this.loadWorkers();
150
+
151
+ try {
152
+ const preloadOptions = await this._fetchPreloadOptions();
153
+ const tilesetOptions = {
154
+ loadOptions: {
155
+ basis: {
156
+ format: 'rgba32'
157
+ }
138
158
  }
159
+ };
160
+
161
+ if (preloadOptions.headers) {
162
+ tilesetOptions.loadOptions.fetch = {
163
+ headers: preloadOptions.headers
164
+ };
139
165
  }
140
- };
141
166
 
142
- if (preloadOptions.headers) {
143
- tilesetOptions.loadOptions.fetch = {
144
- headers: preloadOptions.headers
145
- };
167
+ Object.assign(tilesetOptions, preloadOptions);
168
+ const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
169
+ this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
170
+ await this._createAndSaveTileset(outputPath, tilesetName);
171
+ await this._finishConversion({
172
+ slpk: Boolean(slpk),
173
+ outputPath,
174
+ tilesetName
175
+ });
176
+ return sourceTilesetJson;
177
+ } catch (error) {
178
+ throw error;
179
+ } finally {
180
+ const workerFarm = WorkerFarm.getWorkerFarm({});
181
+ workerFarm.destroy();
146
182
  }
147
-
148
- Object.assign(tilesetOptions, preloadOptions);
149
- const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
150
- this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
151
- await this._createAndSaveTileset(outputPath, tilesetName);
152
- await this._finishConversion({
153
- slpk: Boolean(slpk),
154
- outputPath,
155
- tilesetName
156
- });
157
- return sourceTilesetJson;
158
183
  }
159
184
 
160
185
  async _createAndSaveTileset(outputPath, tilesetName) {
@@ -192,12 +217,16 @@ export default class I3SConverter {
192
217
  await this._writeLayers0();
193
218
  createSceneServerPath(tilesetName, this.layers0, tilesetPath);
194
219
  await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
195
- await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
220
+ await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
221
+ await this.writeQueue.finalize();
196
222
  await this._createSlpk(tilesetPath);
197
223
  }
198
224
 
199
225
  _formLayers0(tilesetName) {
200
- const extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);
226
+ var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
227
+
228
+ 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));
229
+ const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
201
230
  const layers0data = {
202
231
  version: "{".concat(uuidv4().toUpperCase(), "}"),
203
232
  id: 0,
@@ -210,7 +239,8 @@ export default class I3SConverter {
210
239
  nodePages: {
211
240
  nodesPerPage: HARDCODED_NODES_PER_PAGE
212
241
  },
213
- compressGeometry: this.options.draco
242
+ compressGeometry: this.options.draco,
243
+ fullExtent
214
244
  };
215
245
  this.layers0 = transform(layers0data, layersTemplate());
216
246
  }
@@ -247,9 +277,14 @@ export default class I3SConverter {
247
277
  const childPath = join(this.layers0Path, 'nodes', child.path);
248
278
 
249
279
  if (this.options.slpk) {
250
- this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json');
280
+ this.writeQueue.enqueue({
281
+ archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
282
+ writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
283
+ });
251
284
  } else {
252
- await writeFile(childPath, JSON.stringify(child));
285
+ this.writeQueue.enqueue({
286
+ writePromise: writeFile(childPath, JSON.stringify(child))
287
+ });
253
288
  }
254
289
  } else {
255
290
  await this._addChildrenWithNeighborsAndWriteFile({
@@ -265,17 +300,27 @@ export default class I3SConverter {
265
300
 
266
301
  async _writeLayers0() {
267
302
  if (this.options.slpk) {
268
- this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json');
303
+ this.writeQueue.enqueue({
304
+ archiveKey: '3dSceneLayer.json.gz',
305
+ writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
306
+ });
269
307
  } else {
270
- await writeFile(this.layers0Path, JSON.stringify(this.layers0));
308
+ this.writeQueue.enqueue({
309
+ writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
310
+ });
271
311
  }
272
312
  }
273
313
 
274
314
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
275
315
  if (this.options.slpk) {
276
- this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = await writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
316
+ this.writeQueue.enqueue({
317
+ archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
318
+ writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
319
+ });
277
320
  } else {
278
- await writeFile(rootPath, JSON.stringify(root0));
321
+ this.writeQueue.enqueue({
322
+ writePromise: writeFile(rootPath, JSON.stringify(root0))
323
+ });
279
324
  }
280
325
  }
281
326
 
@@ -463,7 +508,7 @@ export default class I3SConverter {
463
508
  return null;
464
509
  }
465
510
 
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);
511
+ 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
512
  return resourcesData;
468
513
  }
469
514
 
@@ -598,34 +643,53 @@ export default class I3SConverter {
598
643
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
599
644
  if (this.options.slpk) {
600
645
  const slpkGeometryPath = join(childPath, 'geometries');
601
- this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = await writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin');
646
+ this.writeQueue.enqueue({
647
+ archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
648
+ writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
649
+ });
602
650
  } else {
603
651
  const geometryPath = join(childPath, 'geometries/0/');
604
- await writeFile(geometryPath, geometryBuffer, 'index.bin');
652
+ this.writeQueue.enqueue({
653
+ writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
654
+ });
605
655
  }
606
656
 
607
657
  if (this.options.draco) {
608
658
  if (this.options.slpk) {
609
659
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
610
- this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = await writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
660
+ this.writeQueue.enqueue({
661
+ archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
662
+ writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
663
+ });
611
664
  } else {
612
665
  const compressedGeometryPath = join(childPath, 'geometries/1/');
613
- await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');
666
+ this.writeQueue.enqueue({
667
+ writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
668
+ });
614
669
  }
615
670
  }
616
671
  }
617
672
 
618
673
  async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
674
+ if (!sharedResources) {
675
+ return;
676
+ }
677
+
619
678
  sharedResources.nodePath = nodePath;
620
679
  const sharedData = transform(sharedResources, sharedResourcesTemplate());
621
680
  const sharedDataStr = JSON.stringify(sharedData);
622
681
 
623
682
  if (this.options.slpk) {
624
683
  const slpkSharedPath = join(childPath, 'shared');
625
- this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = await writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json');
684
+ this.writeQueue.enqueue({
685
+ archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
686
+ writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
687
+ });
626
688
  } else {
627
689
  const sharedPath = join(childPath, 'shared/');
628
- await writeFile(sharedPath, sharedDataStr);
690
+ this.writeQueue.enqueue({
691
+ writePromise: writeFile(sharedPath, sharedDataStr)
692
+ });
629
693
  }
630
694
  }
631
695
 
@@ -651,7 +715,11 @@ export default class I3SConverter {
651
715
  name: '1',
652
716
  format: 'ktx2'
653
717
  });
654
- const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
718
+ const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, { ...KTX2BasisWriterWorker.options,
719
+ source: this.workerSource.ktx2,
720
+ reuseWorkers: true,
721
+ _nodeWorkers: true
722
+ });
655
723
  await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
656
724
  }
657
725
 
@@ -671,7 +739,7 @@ export default class I3SConverter {
671
739
  name: '0',
672
740
  format: 'jpg'
673
741
  });
674
- const decodedFromKTX2TextureData = new Uint8Array(await encode(texture.image.data[0], ImageWriter));
742
+ const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
675
743
  await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
676
744
  }
677
745
  }
@@ -689,27 +757,37 @@ export default class I3SConverter {
689
757
  if (this.options.slpk) {
690
758
  const slpkTexturePath = join(childPath, 'textures');
691
759
  const compress = false;
692
- this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
760
+ this.writeQueue.enqueue({
761
+ archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
762
+ writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
763
+ });
693
764
  } else {
694
765
  const texturePath = join(childPath, "textures/".concat(name, "/"));
695
- await writeFile(texturePath, textureData, "index.".concat(format));
766
+ this.writeQueue.enqueue({
767
+ writePromise: writeFile(texturePath, textureData, "index.".concat(format))
768
+ });
696
769
  }
697
770
  }
698
771
 
699
- async _writeAttributes(attributes, childPath, slpkChildPath) {
772
+ async _writeAttributes(attributes = [], childPath, slpkChildPath) {
700
773
  var _this$layers4, _this$layers4$attribu;
701
774
 
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) {
775
+ 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
776
  for (let index = 0; index < attributes.length; index++) {
704
777
  const folderName = this.layers0.attributeStorageInfo[index].key;
705
778
  const fileBuffer = new Uint8Array(attributes[index]);
706
779
 
707
780
  if (this.options.slpk) {
708
781
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
709
- this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = await writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin');
782
+ this.writeQueue.enqueue({
783
+ archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
784
+ writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
785
+ });
710
786
  } else {
711
787
  const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
712
- await writeFile(attributesPath, fileBuffer, 'index.bin');
788
+ this.writeQueue.enqueue({
789
+ writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
790
+ });
713
791
  }
714
792
  }
715
793
  }
@@ -986,5 +1064,32 @@ export default class I3SConverter {
986
1064
  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
1065
  }
988
1066
 
1067
+ async loadWorkers() {
1068
+ console.log("Loading workers source...");
1069
+
1070
+ if (this.options.draco) {
1071
+ const url = getWorkerURL(DracoWriterWorker, { ...getLoaderOptions()
1072
+ });
1073
+ const sourceResponse = await fetchFile(url);
1074
+ const source = await sourceResponse.text();
1075
+ this.workerSource.draco = source;
1076
+ }
1077
+
1078
+ if (this.generateTextures) {
1079
+ const url = getWorkerURL(KTX2BasisWriterWorker, { ...getLoaderOptions()
1080
+ });
1081
+ const sourceResponse = await fetchFile(url);
1082
+ const source = await sourceResponse.text();
1083
+ this.workerSource.ktx2 = source;
1084
+ }
1085
+
1086
+ const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getLoaderOptions()
1087
+ });
1088
+ const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
1089
+ const source = await sourceResponse.text();
1090
+ this.workerSource.I3SAttributes = source;
1091
+ console.log("Loading workers source completed!");
1092
+ }
1093
+
989
1094
  }
990
1095
  //# sourceMappingURL=i3s-converter.js.map