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