@loaders.gl/tile-converter 3.1.8 → 3.2.0-alpha.3

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 (238) 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-cli.d.ts +2 -0
  24. package/dist/converter-cli.d.ts.map +1 -0
  25. package/dist/converter-cli.js +232 -0
  26. package/dist/converter.min.js +68 -68
  27. package/dist/deps-installer/deps-installer.d.ts +14 -0
  28. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  29. package/dist/deps-installer/deps-installer.js +31 -0
  30. package/dist/dist.min.js +1151 -1264
  31. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  32. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  33. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +104 -44
  34. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  35. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +34 -43
  36. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  37. package/dist/es5/converter-cli.js +306 -0
  38. package/dist/es5/converter-cli.js.map +1 -0
  39. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  40. package/dist/es5/i3s-attributes-worker.js +29 -0
  41. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  42. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  43. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  44. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  45. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  46. package/dist/es5/i3s-converter/helpers/geometry-converter.js +271 -182
  47. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  48. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  49. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  50. package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
  51. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  52. package/dist/es5/i3s-converter/i3s-converter.js +311 -245
  53. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  54. package/dist/es5/index.js +0 -16
  55. package/dist/es5/index.js.map +1 -1
  56. package/dist/es5/lib/utils/compress-util.js +14 -17
  57. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  58. package/dist/es5/lib/utils/file-utils.js +39 -14
  59. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  60. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  61. package/dist/es5/lib/utils/queue.js +61 -0
  62. package/dist/es5/lib/utils/queue.js.map +1 -0
  63. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  64. package/dist/es5/lib/utils/write-queue.js +225 -0
  65. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  66. package/dist/es5/pgm-loader.js +1 -1
  67. package/dist/es5/pgm-loader.js.map +1 -1
  68. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  69. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  70. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  71. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  72. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  73. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  74. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +32 -5
  75. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  76. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +23 -23
  77. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  78. package/dist/esm/converter-cli.js +230 -0
  79. package/dist/esm/converter-cli.js.map +1 -0
  80. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  81. package/dist/esm/i3s-attributes-worker.js +16 -0
  82. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  83. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  84. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  85. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  86. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  87. package/dist/esm/i3s-converter/helpers/geometry-converter.js +121 -62
  88. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  89. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  90. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  91. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
  92. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  93. package/dist/esm/i3s-converter/i3s-converter.js +155 -50
  94. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  95. package/dist/esm/index.js +0 -2
  96. package/dist/esm/index.js.map +1 -1
  97. package/dist/esm/lib/utils/compress-util.js +6 -8
  98. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  99. package/dist/esm/lib/utils/file-utils.js +11 -1
  100. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  101. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  102. package/dist/esm/lib/utils/queue.js +19 -0
  103. package/dist/esm/lib/utils/queue.js.map +1 -0
  104. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  105. package/dist/esm/lib/utils/write-queue.js +88 -0
  106. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  107. package/dist/esm/pgm-loader.js +1 -1
  108. package/dist/esm/pgm-loader.js.map +1 -1
  109. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  110. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  111. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  112. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  113. package/dist/i3s-attributes-worker.d.ts +33 -0
  114. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  115. package/dist/i3s-attributes-worker.js +10 -0
  116. package/dist/i3s-attributes-worker.js.map +7 -0
  117. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  118. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  119. package/dist/i3s-converter/helpers/coordinate-converter.js +122 -0
  120. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  121. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  122. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  123. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  124. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/geometry-attributes.js +177 -0
  126. package/dist/i3s-converter/helpers/geometry-converter.d.ts +29 -0
  127. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  128. package/dist/i3s-converter/helpers/geometry-converter.js +901 -0
  129. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  130. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  131. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  132. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  133. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  134. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  135. package/dist/i3s-converter/helpers/node-pages.d.ts +117 -0
  136. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  137. package/dist/i3s-converter/helpers/node-pages.js +208 -0
  138. package/dist/i3s-converter/i3s-converter.d.ts +323 -0
  139. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  140. package/dist/i3s-converter/i3s-converter.js +1074 -0
  141. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  142. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  143. package/dist/i3s-converter/json-templates/layers.js +199 -0
  144. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  145. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  146. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  147. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  148. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  149. package/dist/i3s-converter/json-templates/node.js +89 -0
  150. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  151. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  152. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  153. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  154. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  155. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  156. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  157. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  158. package/dist/i3s-converter/json-templates/store.js +103 -0
  159. package/dist/i3s-converter/types.d.ts +114 -0
  160. package/dist/i3s-converter/types.d.ts.map +1 -0
  161. package/dist/i3s-converter/types.js +2 -0
  162. package/dist/i3s-server/app.d.ts +3 -0
  163. package/dist/i3s-server/app.d.ts.map +1 -0
  164. package/dist/i3s-server/app.js +14 -0
  165. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  166. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  167. package/dist/i3s-server/controllers/index-controller.js +23 -0
  168. package/dist/i3s-server/routes/index.d.ts +3 -0
  169. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  170. package/dist/i3s-server/routes/index.js +16 -0
  171. package/dist/index.d.ts +3 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +10 -0
  174. package/dist/lib/utils/compress-util.d.ts +45 -0
  175. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  176. package/dist/lib/utils/compress-util.js +257 -0
  177. package/dist/{esm/lib → lib}/utils/file-utils.d.ts +6 -14
  178. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  179. package/dist/lib/utils/file-utils.js +81 -0
  180. package/dist/lib/utils/lod-conversion-utils.d.ts +41 -0
  181. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  182. package/dist/lib/utils/lod-conversion-utils.js +76 -0
  183. package/dist/lib/utils/queue.d.ts +7 -0
  184. package/dist/lib/utils/queue.d.ts.map +1 -0
  185. package/dist/lib/utils/queue.js +18 -0
  186. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  187. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  188. package/dist/lib/utils/statistic-utills.js +64 -0
  189. package/dist/lib/utils/write-queue.d.ts +22 -0
  190. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  191. package/dist/lib/utils/write-queue.js +62 -0
  192. package/dist/pgm-loader.d.ts +6 -0
  193. package/dist/pgm-loader.d.ts.map +1 -0
  194. package/dist/pgm-loader.js +23 -0
  195. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  196. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  197. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  198. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  199. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  200. package/dist/workers/i3s-attributes-worker.js +5 -0
  201. package/package.json +19 -18
  202. package/src/3d-tiles-attributes-worker.ts +43 -0
  203. package/src/3d-tiles-converter/3d-tiles-converter.ts +49 -6
  204. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +21 -18
  205. package/src/converter-cli.ts +310 -0
  206. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  207. package/src/i3s-attributes-worker.ts +46 -0
  208. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  209. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  210. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +425 -179
  211. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  212. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  213. package/src/i3s-converter/i3s-converter.ts +154 -87
  214. package/src/i3s-converter/types.ts +90 -8
  215. package/src/index.ts +0 -4
  216. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  217. package/src/lib/utils/file-utils.ts +84 -0
  218. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  219. package/src/lib/utils/queue.ts +17 -0
  220. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  221. package/src/lib/utils/write-queue.ts +75 -0
  222. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  223. package/src/workers/i3s-attributes-worker.ts +6 -0
  224. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  225. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  226. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  227. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  228. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  229. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  230. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  231. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  232. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  233. package/src/deps-installer/deps-installer.d.ts +0 -10
  234. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  235. package/src/lib/utils/compress-util.d.ts +0 -53
  236. package/src/lib/utils/file-utils.d.ts +0 -43
  237. package/src/lib/utils/file-utils.js +0 -38
  238. 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 { KTX2BasisWriterWorker } 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,31 +137,40 @@ export default class I3SConverter {
127
137
  this.nodePages.useWriteFunction(writeFileForSlpk);
128
138
  }
129
139
 
130
- const preloadOptions = await this._fetchPreloadOptions();
131
- const tilesetOptions = {
132
- loadOptions: {
133
- basis: {
134
- format: 'rgba32'
140
+ await this.loadWorkers();
141
+
142
+ try {
143
+ const preloadOptions = await this._fetchPreloadOptions();
144
+ const tilesetOptions = {
145
+ loadOptions: {
146
+ basis: {
147
+ format: 'rgba32'
148
+ }
135
149
  }
150
+ };
151
+
152
+ if (preloadOptions.headers) {
153
+ tilesetOptions.loadOptions.fetch = {
154
+ headers: preloadOptions.headers
155
+ };
136
156
  }
137
- };
138
157
 
139
- if (preloadOptions.headers) {
140
- tilesetOptions.loadOptions.fetch = {
141
- headers: preloadOptions.headers
142
- };
158
+ Object.assign(tilesetOptions, preloadOptions);
159
+ const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
160
+ this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
161
+ await this._createAndSaveTileset(outputPath, tilesetName);
162
+ await this._finishConversion({
163
+ slpk: Boolean(slpk),
164
+ outputPath,
165
+ tilesetName
166
+ });
167
+ return sourceTilesetJson;
168
+ } catch (error) {
169
+ throw error;
170
+ } finally {
171
+ const workerFarm = WorkerFarm.getWorkerFarm({});
172
+ workerFarm.destroy();
143
173
  }
144
-
145
- Object.assign(tilesetOptions, preloadOptions);
146
- const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
147
- this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
148
- await this._createAndSaveTileset(outputPath, tilesetName);
149
- await this._finishConversion({
150
- slpk: Boolean(slpk),
151
- outputPath,
152
- tilesetName
153
- });
154
- return sourceTilesetJson;
155
174
  }
156
175
 
157
176
  async _createAndSaveTileset(outputPath, tilesetName) {
@@ -181,15 +200,24 @@ export default class I3SConverter {
181
200
 
182
201
  await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
183
202
  this.layers0.materialDefinitions = this.materialDefinitions;
203
+
204
+ if (this.layersHasTexture === false) {
205
+ this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter(attribute => attribute !== 'uv0');
206
+ }
207
+
184
208
  await this._writeLayers0();
185
209
  createSceneServerPath(tilesetName, this.layers0, tilesetPath);
186
210
  await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
187
- await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
211
+ await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
212
+ await this.writeQueue.finalize();
188
213
  await this._createSlpk(tilesetPath);
189
214
  }
190
215
 
191
216
  _formLayers0(tilesetName) {
192
- const extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);
217
+ var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
218
+
219
+ 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));
220
+ const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
193
221
  const layers0data = {
194
222
  version: "{".concat(uuidv4().toUpperCase(), "}"),
195
223
  id: 0,
@@ -239,9 +267,14 @@ export default class I3SConverter {
239
267
  const childPath = join(this.layers0Path, 'nodes', child.path);
240
268
 
241
269
  if (this.options.slpk) {
242
- this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json');
270
+ this.writeQueue.enqueue({
271
+ archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
272
+ writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
273
+ });
243
274
  } else {
244
- await writeFile(childPath, JSON.stringify(child));
275
+ this.writeQueue.enqueue({
276
+ writePromise: writeFile(childPath, JSON.stringify(child))
277
+ });
245
278
  }
246
279
  } else {
247
280
  await this._addChildrenWithNeighborsAndWriteFile({
@@ -257,17 +290,27 @@ export default class I3SConverter {
257
290
 
258
291
  async _writeLayers0() {
259
292
  if (this.options.slpk) {
260
- this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json');
293
+ this.writeQueue.enqueue({
294
+ archiveKey: '3dSceneLayer.json.gz',
295
+ writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
296
+ });
261
297
  } else {
262
- await writeFile(this.layers0Path, JSON.stringify(this.layers0));
298
+ this.writeQueue.enqueue({
299
+ writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
300
+ });
263
301
  }
264
302
  }
265
303
 
266
304
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
267
305
  if (this.options.slpk) {
268
- this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = await writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
306
+ this.writeQueue.enqueue({
307
+ archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
308
+ writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
309
+ });
269
310
  } else {
270
- await writeFile(rootPath, JSON.stringify(root0));
311
+ this.writeQueue.enqueue({
312
+ writePromise: writeFile(rootPath, JSON.stringify(root0))
313
+ });
271
314
  }
272
315
  }
273
316
 
@@ -397,6 +440,8 @@ export default class I3SConverter {
397
440
  };
398
441
 
399
442
  for (const resources of resourcesData || [emptyResources]) {
443
+ this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
444
+
400
445
  if (this.generateBoundingVolumes && resources.boundingVolumes) {
401
446
  boundingVolumes = resources.boundingVolumes;
402
447
  }
@@ -453,7 +498,7 @@ export default class I3SConverter {
453
498
  return null;
454
499
  }
455
500
 
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);
501
+ 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
502
  return resourcesData;
458
503
  }
459
504
 
@@ -588,34 +633,53 @@ export default class I3SConverter {
588
633
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
589
634
  if (this.options.slpk) {
590
635
  const slpkGeometryPath = join(childPath, 'geometries');
591
- this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = await writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin');
636
+ this.writeQueue.enqueue({
637
+ archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
638
+ writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
639
+ });
592
640
  } else {
593
641
  const geometryPath = join(childPath, 'geometries/0/');
594
- await writeFile(geometryPath, geometryBuffer, 'index.bin');
642
+ this.writeQueue.enqueue({
643
+ writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
644
+ });
595
645
  }
596
646
 
597
647
  if (this.options.draco) {
598
648
  if (this.options.slpk) {
599
649
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
600
- this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = await writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
650
+ this.writeQueue.enqueue({
651
+ archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
652
+ writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
653
+ });
601
654
  } else {
602
655
  const compressedGeometryPath = join(childPath, 'geometries/1/');
603
- await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');
656
+ this.writeQueue.enqueue({
657
+ writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
658
+ });
604
659
  }
605
660
  }
606
661
  }
607
662
 
608
663
  async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
664
+ if (!sharedResources) {
665
+ return;
666
+ }
667
+
609
668
  sharedResources.nodePath = nodePath;
610
669
  const sharedData = transform(sharedResources, sharedResourcesTemplate());
611
670
  const sharedDataStr = JSON.stringify(sharedData);
612
671
 
613
672
  if (this.options.slpk) {
614
673
  const slpkSharedPath = join(childPath, 'shared');
615
- this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = await writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json');
674
+ this.writeQueue.enqueue({
675
+ archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
676
+ writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
677
+ });
616
678
  } else {
617
679
  const sharedPath = join(childPath, 'shared/');
618
- await writeFile(sharedPath, sharedDataStr);
680
+ this.writeQueue.enqueue({
681
+ writePromise: writeFile(sharedPath, sharedDataStr)
682
+ });
619
683
  }
620
684
  }
621
685
 
@@ -641,7 +705,11 @@ export default class I3SConverter {
641
705
  name: '1',
642
706
  format: 'ktx2'
643
707
  });
644
- const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
708
+ const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, { ...KTX2BasisWriterWorker.options,
709
+ source: this.workerSource.ktx2,
710
+ reuseWorkers: true,
711
+ _nodeWorkers: true
712
+ });
645
713
  await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
646
714
  }
647
715
 
@@ -661,7 +729,7 @@ export default class I3SConverter {
661
729
  name: '0',
662
730
  format: 'jpg'
663
731
  });
664
- const decodedFromKTX2TextureData = new Uint8Array(await encode(texture.image.data[0], ImageWriter));
732
+ const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
665
733
  await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
666
734
  }
667
735
  }
@@ -679,27 +747,37 @@ export default class I3SConverter {
679
747
  if (this.options.slpk) {
680
748
  const slpkTexturePath = join(childPath, 'textures');
681
749
  const compress = false;
682
- this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
750
+ this.writeQueue.enqueue({
751
+ archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
752
+ writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
753
+ });
683
754
  } else {
684
755
  const texturePath = join(childPath, "textures/".concat(name, "/"));
685
- await writeFile(texturePath, textureData, "index.".concat(format));
756
+ this.writeQueue.enqueue({
757
+ writePromise: writeFile(texturePath, textureData, "index.".concat(format))
758
+ });
686
759
  }
687
760
  }
688
761
 
689
- async _writeAttributes(attributes, childPath, slpkChildPath) {
762
+ async _writeAttributes(attributes = [], childPath, slpkChildPath) {
690
763
  var _this$layers4, _this$layers4$attribu;
691
764
 
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) {
765
+ 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
766
  for (let index = 0; index < attributes.length; index++) {
694
767
  const folderName = this.layers0.attributeStorageInfo[index].key;
695
768
  const fileBuffer = new Uint8Array(attributes[index]);
696
769
 
697
770
  if (this.options.slpk) {
698
771
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
699
- this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = await writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin');
772
+ this.writeQueue.enqueue({
773
+ archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
774
+ writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
775
+ });
700
776
  } else {
701
777
  const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
702
- await writeFile(attributesPath, fileBuffer, 'index.bin');
778
+ this.writeQueue.enqueue({
779
+ writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
780
+ });
703
781
  }
704
782
  }
705
783
  }
@@ -976,5 +1054,32 @@ export default class I3SConverter {
976
1054
  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
1055
  }
978
1056
 
1057
+ async loadWorkers() {
1058
+ console.log("Loading workers source...");
1059
+
1060
+ if (this.options.draco) {
1061
+ const url = getWorkerURL(DracoWriterWorker, { ...getLoaderOptions()
1062
+ });
1063
+ const sourceResponse = await fetchFile(url);
1064
+ const source = await sourceResponse.text();
1065
+ this.workerSource.draco = source;
1066
+ }
1067
+
1068
+ if (this.generateTextures) {
1069
+ const url = getWorkerURL(KTX2BasisWriterWorker, { ...getLoaderOptions()
1070
+ });
1071
+ const sourceResponse = await fetchFile(url);
1072
+ const source = await sourceResponse.text();
1073
+ this.workerSource.ktx2 = source;
1074
+ }
1075
+
1076
+ const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getLoaderOptions()
1077
+ });
1078
+ const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
1079
+ const source = await sourceResponse.text();
1080
+ this.workerSource.I3SAttributes = source;
1081
+ console.log("Loading workers source completed!");
1082
+ }
1083
+
979
1084
  }
980
1085
  //# sourceMappingURL=i3s-converter.js.map