@loaders.gl/tile-converter 4.1.0-alpha.9 → 4.2.0-alpha.1
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-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -4
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +3 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/converter-cli.js +3 -3
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +131 -220
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +10 -0
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +5 -0
- package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts +2 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +6 -8
- package/dist/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/i3s-converter/helpers/progress.js +1 -1
- package/dist/i3s-converter/helpers/progress.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +32 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +195 -47
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +8 -0
- package/dist/i3s-converter/types.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
- package/dist/index.cjs +638 -139
- package/dist/lib/utils/compress-util.d.ts +0 -37
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +1 -149
- package/dist/lib/utils/compress-util.js.map +1 -1
- package/dist/lib/utils/conversion-dump.d.ts +131 -0
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
- package/dist/lib/utils/conversion-dump.js +191 -0
- package/dist/lib/utils/conversion-dump.js.map +1 -0
- package/dist/lib/utils/statistic-utills.js +1 -1
- package/dist/lib/utils/statistic-utills.js.map +1 -1
- package/dist/lib/utils/write-queue.d.ts +6 -1
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +15 -3
- package/dist/lib/utils/write-queue.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/dist/slpk-extractor.min.cjs +31 -31
- package/package.json +16 -16
- package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -4
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
- package/src/3d-tiles-converter/json-templates/tileset.ts +3 -0
- package/src/constants.ts +1 -0
- package/src/converter-cli.ts +3 -3
- package/src/i3s-converter/helpers/attribute-metadata-info.ts +16 -0
- package/src/i3s-converter/helpers/node-index-document.ts +18 -8
- package/src/i3s-converter/helpers/progress.ts +1 -1
- package/src/i3s-converter/i3s-converter.ts +385 -93
- package/src/i3s-converter/types.ts +8 -0
- package/src/lib/utils/compress-util.ts +1 -264
- package/src/lib/utils/conversion-dump.ts +325 -0
- package/src/lib/utils/statistic-utills.ts +1 -1
- package/src/lib/utils/write-queue.ts +15 -2
package/dist/index.cjs
CHANGED
|
@@ -115,6 +115,15 @@ var AttributeMetadataInfo = class {
|
|
|
115
115
|
this._popupInfo = this.createPopupInfo(attributeNames);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Set AttributeMetadataInfo from object
|
|
120
|
+
* @param object - object with AttributeMetadataInfo props
|
|
121
|
+
*/
|
|
122
|
+
fromObject(object) {
|
|
123
|
+
this._attributeStorageInfo = object.attributeStorageInfo;
|
|
124
|
+
this._fields = object.fields;
|
|
125
|
+
this._popupInfo = object.popupInfo;
|
|
126
|
+
}
|
|
118
127
|
/**
|
|
119
128
|
* Generates storage attribute for map segmentation.
|
|
120
129
|
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
@@ -257,7 +266,7 @@ var import_json_map_transform8 = __toESM(require("json-map-transform"), 1);
|
|
|
257
266
|
var import_md52 = __toESM(require("md5"), 1);
|
|
258
267
|
|
|
259
268
|
// src/i3s-converter/helpers/node-pages.ts
|
|
260
|
-
var
|
|
269
|
+
var import_path2 = require("path");
|
|
261
270
|
var import_json_map_transform = __toESM(require("json-map-transform"), 1);
|
|
262
271
|
|
|
263
272
|
// src/i3s-converter/json-templates/metadata.ts
|
|
@@ -287,17 +296,11 @@ var METADATA = () => ({
|
|
|
287
296
|
var import_core = require("@loaders.gl/core");
|
|
288
297
|
var import_loader_utils = require("@loaders.gl/loader-utils");
|
|
289
298
|
var import_fs2 = require("fs");
|
|
290
|
-
var
|
|
299
|
+
var import_path = require("path");
|
|
291
300
|
|
|
292
301
|
// src/lib/utils/compress-util.ts
|
|
293
302
|
var import_zlib = require("zlib");
|
|
294
|
-
var import_path = require("path");
|
|
295
303
|
var import_fs = require("fs");
|
|
296
|
-
var import_archiver = __toESM(require("archiver"), 1);
|
|
297
|
-
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
298
|
-
var import_jszip = __toESM(require("jszip"), 1);
|
|
299
|
-
var import_crypto = require("@loaders.gl/crypto");
|
|
300
|
-
var import_crypt = __toESM(require("crypt"), 1);
|
|
301
304
|
function compressFileWithGzip(pathFile) {
|
|
302
305
|
const compressedPathFile = `${pathFile}.gz`;
|
|
303
306
|
const gzip = (0, import_zlib.createGzip)();
|
|
@@ -315,42 +318,6 @@ function compressFileWithGzip(pathFile) {
|
|
|
315
318
|
input.pipe(gzip).pipe(output);
|
|
316
319
|
});
|
|
317
320
|
}
|
|
318
|
-
async function compressWithChildProcess(inputFolder, outputFile, level, inputFiles, sevenZipExe) {
|
|
319
|
-
if (process.platform === "win32") {
|
|
320
|
-
await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);
|
|
321
|
-
} else {
|
|
322
|
-
await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
async function compressWithChildProcessUnix(inputFolder, outputFile, level = 0, inputFiles = ".") {
|
|
326
|
-
const fullOutputFile = getAbsoluteFilePath(outputFile);
|
|
327
|
-
const args = [`-${level}`, "-r", fullOutputFile, inputFiles];
|
|
328
|
-
const childProcess = new import_worker_utils.ChildProcessProxy();
|
|
329
|
-
await childProcess.start({
|
|
330
|
-
command: "zip",
|
|
331
|
-
arguments: args,
|
|
332
|
-
spawn: {
|
|
333
|
-
cwd: inputFolder
|
|
334
|
-
},
|
|
335
|
-
wait: 0
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
async function compressWithChildProcessWindows(inputFolder, outputFile, level = 0, inputFiles = (0, import_path.join)(".", "*"), sevenZipExe) {
|
|
339
|
-
if (inputFiles[0] === "@") {
|
|
340
|
-
inputFiles = `*${inputFiles.substr(1)}`;
|
|
341
|
-
}
|
|
342
|
-
const fullOutputFile = getAbsoluteFilePath(outputFile);
|
|
343
|
-
const args = ["a", "-tzip", `-mx=${level}`, fullOutputFile, inputFiles];
|
|
344
|
-
const childProcess = new import_worker_utils.ChildProcessProxy();
|
|
345
|
-
await childProcess.start({
|
|
346
|
-
command: sevenZipExe,
|
|
347
|
-
arguments: args,
|
|
348
|
-
spawn: {
|
|
349
|
-
cwd: `${inputFolder}`
|
|
350
|
-
},
|
|
351
|
-
wait: 0
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
321
|
|
|
355
322
|
// src/lib/utils/file-utils.ts
|
|
356
323
|
async function writeFile(path, data, fileName = "index.json") {
|
|
@@ -363,7 +330,7 @@ async function writeFile(path, data, fileName = "index.json") {
|
|
|
363
330
|
toWriteData = data;
|
|
364
331
|
}
|
|
365
332
|
await import_fs2.promises.mkdir(path, { recursive: true });
|
|
366
|
-
const pathFile = (0,
|
|
333
|
+
const pathFile = (0, import_path.join)(path, fileName);
|
|
367
334
|
try {
|
|
368
335
|
await import_fs2.promises.writeFile(pathFile, toWriteData);
|
|
369
336
|
} catch (err) {
|
|
@@ -395,7 +362,7 @@ async function openJson(path, fileName) {
|
|
|
395
362
|
let count = 0;
|
|
396
363
|
console.log(`load ${path}/${fileName}.`);
|
|
397
364
|
const intervalId = setInterval(() => {
|
|
398
|
-
const pathFile = (0,
|
|
365
|
+
const pathFile = (0, import_path.join)(path, fileName);
|
|
399
366
|
(0, import_core.load)(pathFile, import_loader_utils.JSONLoader).then((result) => {
|
|
400
367
|
clearInterval(intervalId);
|
|
401
368
|
resolve(result);
|
|
@@ -424,7 +391,7 @@ function removeFile(path) {
|
|
|
424
391
|
return import_fs2.promises.unlink(path);
|
|
425
392
|
}
|
|
426
393
|
function getAbsoluteFilePath(filePath) {
|
|
427
|
-
return (0,
|
|
394
|
+
return (0, import_path.isAbsolute)(filePath) ? filePath : (0, import_path.join)(process.cwd(), filePath);
|
|
428
395
|
}
|
|
429
396
|
|
|
430
397
|
// src/i3s-converter/helpers/node-pages.ts
|
|
@@ -461,10 +428,10 @@ var NodePages = class {
|
|
|
461
428
|
let filePath;
|
|
462
429
|
let fileName;
|
|
463
430
|
if (this.converter.options.slpk) {
|
|
464
|
-
filePath = (0,
|
|
431
|
+
filePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages");
|
|
465
432
|
fileName = `${nodePageId.toString()}.json`;
|
|
466
433
|
} else {
|
|
467
|
-
filePath = (0,
|
|
434
|
+
filePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages", nodePageId.toString());
|
|
468
435
|
fileName = "index.json";
|
|
469
436
|
}
|
|
470
437
|
return { filePath, fileName };
|
|
@@ -476,7 +443,7 @@ var NodePages = class {
|
|
|
476
443
|
*/
|
|
477
444
|
async loadNodePage(nodePageId) {
|
|
478
445
|
const { filePath, fileName } = this.getNodePageFileName(nodePageId);
|
|
479
|
-
const fullName = (0,
|
|
446
|
+
const fullName = (0, import_path2.join)(filePath, fileName);
|
|
480
447
|
if (await isFileExists(fullName)) {
|
|
481
448
|
console.log(`load ${fullName}.`);
|
|
482
449
|
return await openJson(filePath, fileName);
|
|
@@ -613,7 +580,7 @@ var NodePages = class {
|
|
|
613
580
|
if (this.converter.options.slpk) {
|
|
614
581
|
for (const [index, nodePage] of this.nodePages.entries()) {
|
|
615
582
|
const nodePageStr = JSON.stringify(nodePage);
|
|
616
|
-
const slpkPath = (0,
|
|
583
|
+
const slpkPath = (0, import_path2.join)(this.converter.layers0Path, "nodepages");
|
|
617
584
|
await this.converter.writeQueue.enqueue({
|
|
618
585
|
archiveKey: `nodePages/${index.toString()}.json.gz`,
|
|
619
586
|
writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
|
|
@@ -623,7 +590,7 @@ var NodePages = class {
|
|
|
623
590
|
} else {
|
|
624
591
|
for (const [index, nodePage] of this.nodePages.entries()) {
|
|
625
592
|
const nodePageStr = JSON.stringify(nodePage);
|
|
626
|
-
const nodePagePath = (0,
|
|
593
|
+
const nodePagePath = (0, import_path2.join)(this.converter.layers0Path, "nodepages", index.toString());
|
|
627
594
|
await this.converter.writeQueue.enqueue({
|
|
628
595
|
writePromise: () => this.writeFile(nodePagePath, nodePageStr)
|
|
629
596
|
});
|
|
@@ -709,7 +676,7 @@ var NodePages = class {
|
|
|
709
676
|
};
|
|
710
677
|
|
|
711
678
|
// src/lib/utils/statistic-utills.ts
|
|
712
|
-
var
|
|
679
|
+
var import_path3 = require("path");
|
|
713
680
|
var import_fs3 = require("fs");
|
|
714
681
|
function timeConverter(time) {
|
|
715
682
|
if (typeof time === "number") {
|
|
@@ -741,7 +708,7 @@ function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
|
|
|
741
708
|
result += `${seconds}s`;
|
|
742
709
|
}
|
|
743
710
|
if (!result) {
|
|
744
|
-
result += `${milliseconds}ms`;
|
|
711
|
+
result += `${Math.floor(milliseconds)}ms`;
|
|
745
712
|
}
|
|
746
713
|
return result;
|
|
747
714
|
}
|
|
@@ -750,11 +717,11 @@ async function calculateFilesSize(params) {
|
|
|
750
717
|
const fullOutputPath = getAbsoluteFilePath(outputPath);
|
|
751
718
|
try {
|
|
752
719
|
if (slpk) {
|
|
753
|
-
const slpkPath = (0,
|
|
720
|
+
const slpkPath = (0, import_path3.join)(fullOutputPath, `${tilesetName}.slpk`);
|
|
754
721
|
const stat = await import_fs3.promises.stat(slpkPath);
|
|
755
722
|
return stat.size;
|
|
756
723
|
}
|
|
757
|
-
const directoryPath = (0,
|
|
724
|
+
const directoryPath = (0, import_path3.join)(fullOutputPath, tilesetName);
|
|
758
725
|
const totalSize = await getTotalFilesSize(directoryPath);
|
|
759
726
|
return totalSize;
|
|
760
727
|
} catch (error) {
|
|
@@ -766,9 +733,9 @@ async function getTotalFilesSize(dirPath) {
|
|
|
766
733
|
let totalFileSize = 0;
|
|
767
734
|
const files = await import_fs3.promises.readdir(dirPath);
|
|
768
735
|
for (const file of files) {
|
|
769
|
-
const fileStat = await import_fs3.promises.stat((0,
|
|
736
|
+
const fileStat = await import_fs3.promises.stat((0, import_path3.join)(dirPath, file));
|
|
770
737
|
if (fileStat.isDirectory()) {
|
|
771
|
-
totalFileSize += await getTotalFilesSize((0,
|
|
738
|
+
totalFileSize += await getTotalFilesSize((0, import_path3.join)(dirPath, file));
|
|
772
739
|
} else {
|
|
773
740
|
totalFileSize += fileStat.size;
|
|
774
741
|
}
|
|
@@ -2436,7 +2403,7 @@ function getPropertyTableExtension(tileContent) {
|
|
|
2436
2403
|
// src/i3s-converter/helpers/create-scene-server-path.ts
|
|
2437
2404
|
var import_uuid2 = require("uuid");
|
|
2438
2405
|
var import_json_map_transform2 = __toESM(require("json-map-transform"), 1);
|
|
2439
|
-
var
|
|
2406
|
+
var import_path4 = require("path");
|
|
2440
2407
|
|
|
2441
2408
|
// src/i3s-converter/json-templates/scene-server.ts
|
|
2442
2409
|
var SCENE_SERVER = () => ({
|
|
@@ -2475,7 +2442,7 @@ async function createSceneServerPath(layerName, layers0, rootPath) {
|
|
|
2475
2442
|
layers0
|
|
2476
2443
|
};
|
|
2477
2444
|
const sceneServer = (0, import_json_map_transform2.default)(sceneServerData, SCENE_SERVER());
|
|
2478
|
-
const nodePagePath = (0,
|
|
2445
|
+
const nodePagePath = (0, import_path4.join)(rootPath, "SceneServer");
|
|
2479
2446
|
await writeFile(nodePagePath, JSON.stringify(sceneServer));
|
|
2480
2447
|
}
|
|
2481
2448
|
|
|
@@ -3134,9 +3101,8 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
|
|
|
3134
3101
|
|
|
3135
3102
|
// src/i3s-converter/i3s-converter.ts
|
|
3136
3103
|
var import_textures = require("@loaders.gl/textures");
|
|
3137
|
-
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
3138
3104
|
var import_images = require("@loaders.gl/images");
|
|
3139
|
-
var
|
|
3105
|
+
var import_worker_utils = require("@loaders.gl/worker-utils");
|
|
3140
3106
|
|
|
3141
3107
|
// src/lib/utils/queue.ts
|
|
3142
3108
|
var Queue = class extends Array {
|
|
@@ -3158,10 +3124,11 @@ var Queue = class extends Array {
|
|
|
3158
3124
|
var import_process = __toESM(require("process"), 1);
|
|
3159
3125
|
var MEMORY_LIMIT = 4 * 1024 * 1024 * 1024;
|
|
3160
3126
|
var WriteQueue = class extends Queue {
|
|
3161
|
-
constructor(listeningInterval = 2e3, writeConcurrency = 400) {
|
|
3127
|
+
constructor(conversionDump, listeningInterval = 2e3, writeConcurrency = 400) {
|
|
3162
3128
|
super();
|
|
3163
3129
|
this.writePromise = null;
|
|
3164
3130
|
this.fileMap = {};
|
|
3131
|
+
this.conversionDump = conversionDump;
|
|
3165
3132
|
this.listeningInterval = listeningInterval;
|
|
3166
3133
|
this.writeConcurrency = writeConcurrency;
|
|
3167
3134
|
}
|
|
@@ -3202,18 +3169,21 @@ var WriteQueue = class extends Queue {
|
|
|
3202
3169
|
while (this.length) {
|
|
3203
3170
|
const promises = [];
|
|
3204
3171
|
const archiveKeys = [];
|
|
3172
|
+
const changedRecords = [];
|
|
3205
3173
|
for (let i = 0; i < this.writeConcurrency; i++) {
|
|
3206
3174
|
const item = this.dequeue();
|
|
3207
3175
|
if (!item) {
|
|
3208
3176
|
break;
|
|
3209
3177
|
}
|
|
3210
|
-
const { archiveKey, writePromise } = item;
|
|
3178
|
+
const { archiveKey, sourceId, outputId, resourceType, writePromise } = item;
|
|
3211
3179
|
archiveKeys.push(archiveKey);
|
|
3180
|
+
changedRecords.push({ sourceId, outputId, resourceType });
|
|
3212
3181
|
const promise = writePromise();
|
|
3213
3182
|
promises.push(promise);
|
|
3214
3183
|
}
|
|
3215
3184
|
const writeResults = await Promise.allSettled(promises);
|
|
3216
3185
|
this.updateFileMap(archiveKeys, writeResults);
|
|
3186
|
+
await this.conversionDump.updateConvertedTilesDump(changedRecords, writeResults);
|
|
3217
3187
|
}
|
|
3218
3188
|
}
|
|
3219
3189
|
updateFileMap(archiveKeys, writeResults) {
|
|
@@ -3228,9 +3198,10 @@ var WriteQueue = class extends Queue {
|
|
|
3228
3198
|
|
|
3229
3199
|
// src/constants.ts
|
|
3230
3200
|
var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
|
|
3201
|
+
var DUMP_FILE_SUFFIX = ".dump.json";
|
|
3231
3202
|
|
|
3232
3203
|
// src/i3s-converter/helpers/node-index-document.ts
|
|
3233
|
-
var
|
|
3204
|
+
var import_path5 = require("path");
|
|
3234
3205
|
var import_json_map_transform7 = __toESM(require("json-map-transform"), 1);
|
|
3235
3206
|
var import_uuid3 = require("uuid");
|
|
3236
3207
|
|
|
@@ -3433,7 +3404,7 @@ var NodeIndexDocument = class {
|
|
|
3433
3404
|
* @param node - Node3DIndexDocument object
|
|
3434
3405
|
*/
|
|
3435
3406
|
async write(node) {
|
|
3436
|
-
const path = (0,
|
|
3407
|
+
const path = (0, import_path5.join)(this.converter.layers0Path, "nodes", this.id);
|
|
3437
3408
|
if (this.converter.options.slpk) {
|
|
3438
3409
|
await this.converter.writeQueue.enqueue(
|
|
3439
3410
|
{
|
|
@@ -3464,7 +3435,7 @@ var NodeIndexDocument = class {
|
|
|
3464
3435
|
return this.data;
|
|
3465
3436
|
}
|
|
3466
3437
|
const path = this.id;
|
|
3467
|
-
const parentNodePath = (0,
|
|
3438
|
+
const parentNodePath = (0, import_path5.join)(this.converter.layers0Path, "nodes", path);
|
|
3468
3439
|
let parentNodeFileName = "index.json";
|
|
3469
3440
|
if (this.converter.options.slpk) {
|
|
3470
3441
|
parentNodeFileName = "3dNodeIndexDocument.json";
|
|
@@ -3546,8 +3517,7 @@ var NodeIndexDocument = class {
|
|
|
3546
3517
|
* @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
|
|
3547
3518
|
*/
|
|
3548
3519
|
static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
3549
|
-
var _a2, _b;
|
|
3550
|
-
const { texture, attributes } = resources;
|
|
3520
|
+
var _a2, _b, _c, _d, _e;
|
|
3551
3521
|
const nodeId = nodeInPage.index;
|
|
3552
3522
|
const parentNodeData = await parentNode.load();
|
|
3553
3523
|
const nodeData = {
|
|
@@ -3569,12 +3539,13 @@ var NodeIndexDocument = class {
|
|
|
3569
3539
|
if (nodeInPage.mesh) {
|
|
3570
3540
|
node.geometryData = [{ href: "./geometries/0" }];
|
|
3571
3541
|
node.sharedResource = { href: "./shared" };
|
|
3572
|
-
if (texture) {
|
|
3542
|
+
if ("texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint) {
|
|
3573
3543
|
node.textureData = [{ href: "./textures/0" }, { href: "./textures/1" }];
|
|
3574
3544
|
}
|
|
3575
|
-
if (attributes && attributes.length && ((_b = (_a2 = parentNode.converter.layers0) == null ? void 0 : _a2.attributeStorageInfo) == null ? void 0 : _b.length)) {
|
|
3545
|
+
if ("attributes" in resources && resources.attributes && resources.attributes.length && ((_b = (_a2 = parentNode.converter.layers0) == null ? void 0 : _a2.attributeStorageInfo) == null ? void 0 : _b.length) || "attributesCount" in resources && resources.attributesCount && ((_d = (_c = parentNode.converter.layers0) == null ? void 0 : _c.attributeStorageInfo) == null ? void 0 : _d.length)) {
|
|
3546
|
+
const attributesLength = ("attributes" in resources ? (_e = resources.attributes) == null ? void 0 : _e.length : resources.attributesCount) || 0;
|
|
3576
3547
|
node.attributeData = [];
|
|
3577
|
-
const minimumLength =
|
|
3548
|
+
const minimumLength = attributesLength < parentNode.converter.layers0.attributeStorageInfo.length ? attributesLength : parentNode.converter.layers0.attributeStorageInfo.length;
|
|
3578
3549
|
for (let index = 0; index < minimumLength; index++) {
|
|
3579
3550
|
const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
|
|
3580
3551
|
node.attributeData.push({ href: `./attributes/${folderName}/0` });
|
|
@@ -3863,7 +3834,7 @@ var Progress = class {
|
|
|
3863
3834
|
* @returns Number of milliseconds remaining
|
|
3864
3835
|
*/
|
|
3865
3836
|
getTimeRemaining() {
|
|
3866
|
-
if (!this._stepsDone || !this.startTime) {
|
|
3837
|
+
if (!this._stepsTotal || !this._stepsDone || !this.startTime) {
|
|
3867
3838
|
return null;
|
|
3868
3839
|
}
|
|
3869
3840
|
const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
|
|
@@ -3905,6 +3876,262 @@ var Progress = class {
|
|
|
3905
3876
|
|
|
3906
3877
|
// src/i3s-converter/i3s-converter.ts
|
|
3907
3878
|
var import_zip = require("@loaders.gl/zip");
|
|
3879
|
+
|
|
3880
|
+
// src/lib/utils/conversion-dump.ts
|
|
3881
|
+
var import_util = require("util");
|
|
3882
|
+
var import_path6 = require("path");
|
|
3883
|
+
var ConversionDump = class {
|
|
3884
|
+
constructor() {
|
|
3885
|
+
/**Restored/resumed dump indicator */
|
|
3886
|
+
this.restored = false;
|
|
3887
|
+
/** Array of materials definitions */
|
|
3888
|
+
this.materialDefinitions = [];
|
|
3889
|
+
this.tilesConverted = {};
|
|
3890
|
+
}
|
|
3891
|
+
/**
|
|
3892
|
+
* Create a dump with convertion options
|
|
3893
|
+
* @param currentOptions - converter options
|
|
3894
|
+
*/
|
|
3895
|
+
async createDump(currentOptions) {
|
|
3896
|
+
const {
|
|
3897
|
+
tilesetName,
|
|
3898
|
+
slpk,
|
|
3899
|
+
egmFilePath,
|
|
3900
|
+
inputUrl,
|
|
3901
|
+
outputPath,
|
|
3902
|
+
draco = true,
|
|
3903
|
+
maxDepth,
|
|
3904
|
+
token,
|
|
3905
|
+
generateTextures,
|
|
3906
|
+
generateBoundingVolumes,
|
|
3907
|
+
mergeMaterials: mergeMaterials2 = true,
|
|
3908
|
+
metadataClass,
|
|
3909
|
+
analyze = false
|
|
3910
|
+
} = currentOptions;
|
|
3911
|
+
this.options = {
|
|
3912
|
+
tilesetName,
|
|
3913
|
+
slpk,
|
|
3914
|
+
egmFilePath,
|
|
3915
|
+
inputUrl,
|
|
3916
|
+
outputPath,
|
|
3917
|
+
draco,
|
|
3918
|
+
maxDepth,
|
|
3919
|
+
token,
|
|
3920
|
+
generateTextures,
|
|
3921
|
+
generateBoundingVolumes,
|
|
3922
|
+
mergeMaterials: mergeMaterials2,
|
|
3923
|
+
metadataClass,
|
|
3924
|
+
analyze
|
|
3925
|
+
};
|
|
3926
|
+
const dumpFilename = (0, import_path6.join)(
|
|
3927
|
+
this.options.outputPath,
|
|
3928
|
+
this.options.tilesetName,
|
|
3929
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
3930
|
+
);
|
|
3931
|
+
if (await isFileExists(dumpFilename)) {
|
|
3932
|
+
const {
|
|
3933
|
+
options,
|
|
3934
|
+
tilesConverted,
|
|
3935
|
+
textureSetDefinitions,
|
|
3936
|
+
attributeMetadataInfo,
|
|
3937
|
+
materialDefinitions
|
|
3938
|
+
} = await openJson(
|
|
3939
|
+
(0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
|
|
3940
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
3941
|
+
);
|
|
3942
|
+
if ((0, import_util.isDeepStrictEqual)(options, JSON.parse(JSON.stringify(this.options)))) {
|
|
3943
|
+
this.tilesConverted = tilesConverted;
|
|
3944
|
+
this.textureSetDefinitions = textureSetDefinitions;
|
|
3945
|
+
this.attributeMetadataInfo = attributeMetadataInfo;
|
|
3946
|
+
this.materialDefinitions = materialDefinitions;
|
|
3947
|
+
this.restored = true;
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
await this.deleteDumpFile();
|
|
3952
|
+
}
|
|
3953
|
+
/**
|
|
3954
|
+
* Reset a dump
|
|
3955
|
+
*/
|
|
3956
|
+
reset() {
|
|
3957
|
+
this.restored = false;
|
|
3958
|
+
this.tilesConverted = {};
|
|
3959
|
+
if (this.textureSetDefinitions) {
|
|
3960
|
+
delete this.textureSetDefinitions;
|
|
3961
|
+
}
|
|
3962
|
+
if (this.attributeMetadataInfo) {
|
|
3963
|
+
delete this.attributeMetadataInfo;
|
|
3964
|
+
}
|
|
3965
|
+
if (this.materialDefinitions.length > 0) {
|
|
3966
|
+
this.materialDefinitions = [];
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
/**
|
|
3970
|
+
* Update conversion status in the dump file
|
|
3971
|
+
*/
|
|
3972
|
+
async updateDumpFile() {
|
|
3973
|
+
var _a2;
|
|
3974
|
+
if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName) {
|
|
3975
|
+
try {
|
|
3976
|
+
await writeFile(
|
|
3977
|
+
(0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
|
|
3978
|
+
JSON.stringify({
|
|
3979
|
+
options: this.options,
|
|
3980
|
+
tilesConverted: this.tilesConverted,
|
|
3981
|
+
textureSetDefinitions: this.textureSetDefinitions,
|
|
3982
|
+
attributeMetadataInfo: this.attributeMetadataInfo,
|
|
3983
|
+
materialDefinitions: this.materialDefinitions
|
|
3984
|
+
}),
|
|
3985
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
3986
|
+
);
|
|
3987
|
+
} catch (error) {
|
|
3988
|
+
console.log("Can't update dump file", error);
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
/**
|
|
3993
|
+
* Delete a dump file
|
|
3994
|
+
*/
|
|
3995
|
+
async deleteDumpFile() {
|
|
3996
|
+
var _a2;
|
|
3997
|
+
if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName && await isFileExists(
|
|
3998
|
+
(0, import_path6.join)(
|
|
3999
|
+
this.options.outputPath,
|
|
4000
|
+
this.options.tilesetName,
|
|
4001
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
4002
|
+
)
|
|
4003
|
+
)) {
|
|
4004
|
+
await removeFile(
|
|
4005
|
+
(0, import_path6.join)(
|
|
4006
|
+
this.options.outputPath,
|
|
4007
|
+
this.options.tilesetName,
|
|
4008
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
4009
|
+
)
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
/**
|
|
4014
|
+
* Get record from the tilesConverted Map
|
|
4015
|
+
* @param fileName - source filename
|
|
4016
|
+
* @returns existing object from the tilesConverted Map
|
|
4017
|
+
*/
|
|
4018
|
+
getRecord(fileName) {
|
|
4019
|
+
return this.tilesConverted[fileName];
|
|
4020
|
+
}
|
|
4021
|
+
/**
|
|
4022
|
+
* Set a record for the dump file
|
|
4023
|
+
* @param fileName - key - source filename
|
|
4024
|
+
* @param object - value
|
|
4025
|
+
*/
|
|
4026
|
+
setRecord(fileName, object) {
|
|
4027
|
+
this.tilesConverted[fileName] = object;
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* Add a node into the dump file for the source file record
|
|
4031
|
+
* @param fileName - source filename
|
|
4032
|
+
* @param nodeId - nodeId of the node
|
|
4033
|
+
*/
|
|
4034
|
+
async addNode(filename, nodeId, dumpMetadata) {
|
|
4035
|
+
const { nodes } = this.getRecord(filename) || { nodes: [] };
|
|
4036
|
+
nodes.push({ nodeId, done: false, progress: {}, dumpMetadata });
|
|
4037
|
+
if (nodes.length === 1) {
|
|
4038
|
+
this.setRecord(filename, { nodes });
|
|
4039
|
+
}
|
|
4040
|
+
await this.updateDumpFile();
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Clear dump record got the source filename
|
|
4044
|
+
* @param fileName - source filename
|
|
4045
|
+
*/
|
|
4046
|
+
clearDumpRecord(filename) {
|
|
4047
|
+
this.setRecord(filename, { nodes: [] });
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
4050
|
+
* Add textures definitions into the dump file
|
|
4051
|
+
* @param textureDefinitions - textures definitions array
|
|
4052
|
+
*/
|
|
4053
|
+
addTexturesDefinitions(textureDefinitions) {
|
|
4054
|
+
this.textureSetDefinitions = textureDefinitions;
|
|
4055
|
+
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Update done status object for the writing resources
|
|
4058
|
+
* @param fileName - key - source filename
|
|
4059
|
+
* @param nodeId - nodeId for the source filename
|
|
4060
|
+
* @param resourceType - resource type to update status
|
|
4061
|
+
* @param value - value
|
|
4062
|
+
*/
|
|
4063
|
+
updateDoneStatus(filename, nodeId, resourceType, value) {
|
|
4064
|
+
var _a2;
|
|
4065
|
+
const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find(
|
|
4066
|
+
(element) => element.nodeId === nodeId
|
|
4067
|
+
);
|
|
4068
|
+
if (nodeDump) {
|
|
4069
|
+
if (!nodeDump.progress) {
|
|
4070
|
+
nodeDump.progress = {};
|
|
4071
|
+
}
|
|
4072
|
+
nodeDump.progress[resourceType] = value;
|
|
4073
|
+
if (!value) {
|
|
4074
|
+
nodeDump.done = false;
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Update dump file according to writing results
|
|
4080
|
+
* @param changedRecords - array of parameters ids for the written resources
|
|
4081
|
+
* @param writeResults - array of writing resource files results
|
|
4082
|
+
*/
|
|
4083
|
+
async updateConvertedTilesDump(changedRecords, writeResults) {
|
|
4084
|
+
for (let i = 0; i < changedRecords.length; i++) {
|
|
4085
|
+
if (changedRecords[i] && "value" in writeResults[i]) {
|
|
4086
|
+
const { sourceId, resourceType, outputId } = changedRecords[i];
|
|
4087
|
+
if (!sourceId || !resourceType || !outputId)
|
|
4088
|
+
continue;
|
|
4089
|
+
for (const node of this.tilesConverted[sourceId].nodes) {
|
|
4090
|
+
if (node.nodeId === outputId && node.progress) {
|
|
4091
|
+
node.progress[resourceType] = true;
|
|
4092
|
+
let done = false;
|
|
4093
|
+
for (const key in node.progress) {
|
|
4094
|
+
done = node.progress[key];
|
|
4095
|
+
if (!done)
|
|
4096
|
+
break;
|
|
4097
|
+
}
|
|
4098
|
+
node.done = done;
|
|
4099
|
+
if (node.done) {
|
|
4100
|
+
delete node.progress;
|
|
4101
|
+
}
|
|
4102
|
+
break;
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
await this.updateDumpFile();
|
|
4108
|
+
}
|
|
4109
|
+
/**
|
|
4110
|
+
* Check is source file conversion complete
|
|
4111
|
+
* @param filename - source filename
|
|
4112
|
+
* @returns true if source file conversion complete
|
|
4113
|
+
*/
|
|
4114
|
+
isFileConversionComplete(filename) {
|
|
4115
|
+
var _a2, _b, _c;
|
|
4116
|
+
let result = true;
|
|
4117
|
+
for (const node of ((_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes) || []) {
|
|
4118
|
+
if (!node.done) {
|
|
4119
|
+
result = false;
|
|
4120
|
+
break;
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
return result && ((_c = (_b = this.tilesConverted[filename]) == null ? void 0 : _b.nodes) == null ? void 0 : _c.length) > 0;
|
|
4124
|
+
}
|
|
4125
|
+
/**
|
|
4126
|
+
* Set materialDefinitions into a dump
|
|
4127
|
+
* @param materialDefinitions - Array materialDefinitions
|
|
4128
|
+
*/
|
|
4129
|
+
setMaterialsDefinitions(materialDefinitions) {
|
|
4130
|
+
this.materialDefinitions = materialDefinitions;
|
|
4131
|
+
}
|
|
4132
|
+
};
|
|
4133
|
+
|
|
4134
|
+
// src/i3s-converter/i3s-converter.ts
|
|
3908
4135
|
var _a;
|
|
3909
4136
|
var ION_DEFAULT_TOKEN = (_a = import_process3.default.env) == null ? void 0 : _a.IonToken;
|
|
3910
4137
|
var HARDCODED_NODES_PER_PAGE = 64;
|
|
@@ -3936,7 +4163,7 @@ var I3SConverter = class {
|
|
|
3936
4163
|
this.geoidHeightModel = null;
|
|
3937
4164
|
this.Loader = import_d_tiles2.Tiles3DLoader;
|
|
3938
4165
|
this.workerSource = {};
|
|
3939
|
-
this.writeQueue = new WriteQueue();
|
|
4166
|
+
this.writeQueue = new WriteQueue(new ConversionDump());
|
|
3940
4167
|
this.compressList = null;
|
|
3941
4168
|
this.preprocessData = {
|
|
3942
4169
|
meshTopologyTypes: /* @__PURE__ */ new Set(),
|
|
@@ -3963,6 +4190,7 @@ var I3SConverter = class {
|
|
|
3963
4190
|
this.generateBoundingVolumes = false;
|
|
3964
4191
|
this.layersHasTexture = false;
|
|
3965
4192
|
this.compressList = null;
|
|
4193
|
+
this.conversionDump = new ConversionDump();
|
|
3966
4194
|
}
|
|
3967
4195
|
/**
|
|
3968
4196
|
* Convert a 3d tileset
|
|
@@ -4007,6 +4235,8 @@ var I3SConverter = class {
|
|
|
4007
4235
|
analyze = false
|
|
4008
4236
|
} = options;
|
|
4009
4237
|
this.options = {
|
|
4238
|
+
outputPath,
|
|
4239
|
+
tilesetName,
|
|
4010
4240
|
maxDepth,
|
|
4011
4241
|
slpk,
|
|
4012
4242
|
sevenZipExe,
|
|
@@ -4025,7 +4255,7 @@ var I3SConverter = class {
|
|
|
4025
4255
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? import_d_tiles2.CesiumIonLoader : import_d_tiles2.Tiles3DLoader;
|
|
4026
4256
|
this.generateTextures = Boolean(generateTextures);
|
|
4027
4257
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
4028
|
-
this.writeQueue = new WriteQueue();
|
|
4258
|
+
this.writeQueue = new WriteQueue(this.conversionDump);
|
|
4029
4259
|
this.writeQueue.startListening();
|
|
4030
4260
|
console.log("Loading egm file...");
|
|
4031
4261
|
this.geoidHeightModel = await (0, import_core9.load)(egmFilePath, PGMLoader);
|
|
@@ -4055,7 +4285,7 @@ var I3SConverter = class {
|
|
|
4055
4285
|
throw error;
|
|
4056
4286
|
} finally {
|
|
4057
4287
|
await this.writeQueue.finalize();
|
|
4058
|
-
const workerFarm =
|
|
4288
|
+
const workerFarm = import_worker_utils.WorkerFarm.getWorkerFarm({});
|
|
4059
4289
|
workerFarm.destroy();
|
|
4060
4290
|
}
|
|
4061
4291
|
return "success";
|
|
@@ -4167,13 +4397,37 @@ var I3SConverter = class {
|
|
|
4167
4397
|
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
4168
4398
|
var _a2, _b, _c;
|
|
4169
4399
|
const tilesetPath = (0, import_path7.join)(`${outputPath}`, `${tilesetName}`);
|
|
4400
|
+
await this.conversionDump.createDump(this.options);
|
|
4401
|
+
if (this.conversionDump.restored && this.options.inquirer) {
|
|
4402
|
+
const result = await this.options.inquirer.prompt([
|
|
4403
|
+
{
|
|
4404
|
+
name: "resumeConversion",
|
|
4405
|
+
type: "confirm",
|
|
4406
|
+
message: "Dump file of the previous conversion exists, do you want to resume that conversion?"
|
|
4407
|
+
}
|
|
4408
|
+
]);
|
|
4409
|
+
if (!result.resumeConversion) {
|
|
4410
|
+
this.conversionDump.reset();
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
this.layers0Path = (0, import_path7.join)(tilesetPath, "SceneServer", "layers", "0");
|
|
4414
|
+
const removePath = this.conversionDump.restored ? (0, import_path7.join)(this.layers0Path, "nodepages") : tilesetPath;
|
|
4170
4415
|
try {
|
|
4171
|
-
await removeDir(
|
|
4416
|
+
await removeDir(removePath);
|
|
4172
4417
|
} catch (e) {
|
|
4173
4418
|
}
|
|
4174
|
-
this.
|
|
4419
|
+
if (this.conversionDump.restored && this.conversionDump.attributeMetadataInfo) {
|
|
4420
|
+
this.attributeMetadataInfo.fromObject(this.conversionDump.attributeMetadataInfo);
|
|
4421
|
+
}
|
|
4175
4422
|
this.materialDefinitions = [];
|
|
4176
4423
|
this.materialMap = /* @__PURE__ */ new Map();
|
|
4424
|
+
if (this.conversionDump.restored && this.conversionDump.materialDefinitions) {
|
|
4425
|
+
for (let i = 0; i < this.conversionDump.materialDefinitions.length; i++) {
|
|
4426
|
+
const hash = (0, import_md52.default)(JSON.stringify(this.conversionDump.materialDefinitions[i]));
|
|
4427
|
+
this.materialMap.set(hash, i);
|
|
4428
|
+
}
|
|
4429
|
+
this.materialDefinitions = this.conversionDump.materialDefinitions;
|
|
4430
|
+
}
|
|
4177
4431
|
const sourceRootTile = this.sourceTileset.root;
|
|
4178
4432
|
const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(
|
|
4179
4433
|
sourceRootTile.boundingVolume,
|
|
@@ -4212,6 +4466,9 @@ var I3SConverter = class {
|
|
|
4212
4466
|
if (this.attributeMetadataInfo.attributeStorageInfo.length) {
|
|
4213
4467
|
this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
|
|
4214
4468
|
}
|
|
4469
|
+
if (this.conversionDump.restored && this.conversionDump.textureSetDefinitions) {
|
|
4470
|
+
this.layers0.textureSetDefinitions = this.conversionDump.textureSetDefinitions;
|
|
4471
|
+
}
|
|
4215
4472
|
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
4216
4473
|
this.layers0.geometryDefinitions = (0, import_json_map_transform8.default)(
|
|
4217
4474
|
this.geometryConfigs.map((config) => ({
|
|
@@ -4288,18 +4545,14 @@ var I3SConverter = class {
|
|
|
4288
4545
|
* @param tilesetPath - Path to save file
|
|
4289
4546
|
*/
|
|
4290
4547
|
async _createSlpk(tilesetPath) {
|
|
4548
|
+
await this.conversionDump.deleteDumpFile();
|
|
4291
4549
|
if (this.options.slpk) {
|
|
4292
4550
|
const slpkTilesetPath = (0, import_path7.join)(tilesetPath, "SceneServer", "layers", "0");
|
|
4293
4551
|
const slpkFileName = `${tilesetPath}.slpk`;
|
|
4294
|
-
await
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
".",
|
|
4299
|
-
this.options.sevenZipExe
|
|
4300
|
-
);
|
|
4301
|
-
const hashTable = await (0, import_zip.composeHashFile)(new import_loader_utils4.FileHandleFile(slpkFileName));
|
|
4302
|
-
await (0, import_zip.addOneFile)(slpkFileName, hashTable, "@specialIndexFileHASH128@");
|
|
4552
|
+
await (0, import_zip.createZip)(slpkTilesetPath, slpkFileName, async (fileList) => ({
|
|
4553
|
+
path: "@specialIndexFileHASH128@",
|
|
4554
|
+
file: await (0, import_zip.composeHashFile)(fileList)
|
|
4555
|
+
}));
|
|
4303
4556
|
try {
|
|
4304
4557
|
await removeDir(tilesetPath);
|
|
4305
4558
|
} catch (e) {
|
|
@@ -4333,7 +4586,13 @@ var I3SConverter = class {
|
|
|
4333
4586
|
transformationMatrix = transformationMatrix.multiplyRight(sourceTile.transform);
|
|
4334
4587
|
}
|
|
4335
4588
|
const parentNode = parentNodes[0];
|
|
4336
|
-
const
|
|
4589
|
+
const restoreResult = await this._restoreNode(parentNode, sourceTile, transformationMatrix);
|
|
4590
|
+
let childNodes;
|
|
4591
|
+
if (restoreResult === null) {
|
|
4592
|
+
childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);
|
|
4593
|
+
} else {
|
|
4594
|
+
childNodes = restoreResult;
|
|
4595
|
+
}
|
|
4337
4596
|
await parentNode.addChildren(childNodes);
|
|
4338
4597
|
const newTraversalProps = {
|
|
4339
4598
|
transform: transformationMatrix,
|
|
@@ -4346,8 +4605,9 @@ var I3SConverter = class {
|
|
|
4346
4605
|
if (timeRemainingStringBasedOnCount) {
|
|
4347
4606
|
timeRemainingString = `${timeRemainingStringBasedOnCount} left`;
|
|
4348
4607
|
}
|
|
4349
|
-
|
|
4350
|
-
|
|
4608
|
+
const percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
|
|
4609
|
+
const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : "";
|
|
4610
|
+
console.log(`[converted${progressString}]: ${sourceTile.id}`);
|
|
4351
4611
|
}
|
|
4352
4612
|
return newTraversalProps;
|
|
4353
4613
|
}
|
|
@@ -4366,6 +4626,88 @@ var I3SConverter = class {
|
|
|
4366
4626
|
await node.save();
|
|
4367
4627
|
}
|
|
4368
4628
|
}
|
|
4629
|
+
/**
|
|
4630
|
+
* Generate NodeIndexDocument
|
|
4631
|
+
* @param boundingVolumes - Bounding volumes
|
|
4632
|
+
* @param resources - converted or dumped node resources data
|
|
4633
|
+
* @param parentNode - 3DNodeIndexDocument of parent node
|
|
4634
|
+
* @param sourceTile - source 3DTile data
|
|
4635
|
+
* @param isDumped - indicator if the node is dumped
|
|
4636
|
+
* @return NodeIndexDocument, nodeInPage and node data
|
|
4637
|
+
*/
|
|
4638
|
+
async _generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, isDumped) {
|
|
4639
|
+
this.layersHasTexture = this.layersHasTexture || Boolean(
|
|
4640
|
+
"texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint
|
|
4641
|
+
);
|
|
4642
|
+
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
4643
|
+
boundingVolumes = resources.boundingVolumes;
|
|
4644
|
+
}
|
|
4645
|
+
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
4646
|
+
const maxScreenThresholdSQ = lodSelection.find(
|
|
4647
|
+
(val) => val.metricType === "maxScreenThresholdSQ"
|
|
4648
|
+
) || { maxError: 0 };
|
|
4649
|
+
if (isDumped) {
|
|
4650
|
+
const draftObb = {
|
|
4651
|
+
center: [],
|
|
4652
|
+
halfSize: [],
|
|
4653
|
+
quaternion: []
|
|
4654
|
+
};
|
|
4655
|
+
await this.nodePages.push({ index: 0, obb: draftObb }, parentNode.inPageId);
|
|
4656
|
+
}
|
|
4657
|
+
const nodeInPage = await this._updateNodeInNodePages(
|
|
4658
|
+
maxScreenThresholdSQ,
|
|
4659
|
+
boundingVolumes,
|
|
4660
|
+
sourceTile,
|
|
4661
|
+
parentNode.inPageId,
|
|
4662
|
+
resources
|
|
4663
|
+
);
|
|
4664
|
+
const nodeData = await NodeIndexDocument.createNodeIndexDocument(
|
|
4665
|
+
parentNode,
|
|
4666
|
+
boundingVolumes,
|
|
4667
|
+
lodSelection,
|
|
4668
|
+
nodeInPage,
|
|
4669
|
+
resources
|
|
4670
|
+
);
|
|
4671
|
+
const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
|
|
4672
|
+
return { node, nodeInPage, nodeData };
|
|
4673
|
+
}
|
|
4674
|
+
/**
|
|
4675
|
+
* Restore 3DNodeIndexDocument from a comversion dump file
|
|
4676
|
+
* @param parentNode - 3DNodeIndexDocument of parent node
|
|
4677
|
+
* @param sourceTile - source 3DTile data
|
|
4678
|
+
* @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying
|
|
4679
|
+
* transform of all parent tiles and transform of the current tile
|
|
4680
|
+
*/
|
|
4681
|
+
async _restoreNode(parentNode, sourceTile, transformationMatrix) {
|
|
4682
|
+
this._checkAddRefinementTypeForTile(sourceTile);
|
|
4683
|
+
await this._updateTilesetOptions();
|
|
4684
|
+
if (this.conversionDump.restored && sourceTile.id && this.conversionDump.isFileConversionComplete(sourceTile.id)) {
|
|
4685
|
+
const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(
|
|
4686
|
+
sourceTile.boundingVolume,
|
|
4687
|
+
transformationMatrix,
|
|
4688
|
+
null
|
|
4689
|
+
);
|
|
4690
|
+
let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
4691
|
+
const nodes = [];
|
|
4692
|
+
for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
|
|
4693
|
+
const { node } = await this._generateNodeIndexDocument(
|
|
4694
|
+
boundingVolumes,
|
|
4695
|
+
{
|
|
4696
|
+
...convertedNode.dumpMetadata,
|
|
4697
|
+
nodeId: convertedNode.nodeId
|
|
4698
|
+
},
|
|
4699
|
+
parentNode,
|
|
4700
|
+
sourceTile,
|
|
4701
|
+
true
|
|
4702
|
+
);
|
|
4703
|
+
nodes.push(node);
|
|
4704
|
+
}
|
|
4705
|
+
return nodes;
|
|
4706
|
+
} else if (this.conversionDump.restored && sourceTile.id) {
|
|
4707
|
+
this.conversionDump.clearDumpRecord(sourceTile.id);
|
|
4708
|
+
}
|
|
4709
|
+
return null;
|
|
4710
|
+
}
|
|
4369
4711
|
/**
|
|
4370
4712
|
* Convert tile to one or more I3S nodes
|
|
4371
4713
|
* @param parentNode - 3DNodeIndexDocument of parent node
|
|
@@ -4375,6 +4717,7 @@ var I3SConverter = class {
|
|
|
4375
4717
|
* @param level - tree level
|
|
4376
4718
|
*/
|
|
4377
4719
|
async _createNode(parentNode, sourceTile, transformationMatrix) {
|
|
4720
|
+
var _a2;
|
|
4378
4721
|
this._checkAddRefinementTypeForTile(sourceTile);
|
|
4379
4722
|
await this._updateTilesetOptions();
|
|
4380
4723
|
let tileContent = null;
|
|
@@ -4391,6 +4734,11 @@ var I3SConverter = class {
|
|
|
4391
4734
|
let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
4392
4735
|
const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
|
|
4393
4736
|
this.createAttributeStorageInfo(tileContent, propertyTable);
|
|
4737
|
+
this.conversionDump.attributeMetadataInfo = {
|
|
4738
|
+
attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
|
|
4739
|
+
fields: this.attributeMetadataInfo.fields,
|
|
4740
|
+
popupInfo: this.attributeMetadataInfo.popupInfo
|
|
4741
|
+
};
|
|
4394
4742
|
const resourcesData = await this._convertResources(
|
|
4395
4743
|
sourceTile,
|
|
4396
4744
|
transformationMatrix,
|
|
@@ -4415,32 +4763,30 @@ var I3SConverter = class {
|
|
|
4415
4763
|
boundingVolumes: null
|
|
4416
4764
|
};
|
|
4417
4765
|
for (const resources of resourcesData || [emptyResources]) {
|
|
4418
|
-
|
|
4419
|
-
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
4420
|
-
boundingVolumes = resources.boundingVolumes;
|
|
4421
|
-
}
|
|
4422
|
-
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
4423
|
-
const maxScreenThresholdSQ = lodSelection.find(
|
|
4424
|
-
(val) => val.metricType === "maxScreenThresholdSQ"
|
|
4425
|
-
) || { maxError: 0 };
|
|
4426
|
-
const nodeInPage = await this._updateNodeInNodePages(
|
|
4427
|
-
maxScreenThresholdSQ,
|
|
4766
|
+
const { node, nodeInPage, nodeData } = await this._generateNodeIndexDocument(
|
|
4428
4767
|
boundingVolumes,
|
|
4429
|
-
|
|
4430
|
-
parentNode.inPageId,
|
|
4431
|
-
resources
|
|
4432
|
-
);
|
|
4433
|
-
const nodeData = await NodeIndexDocument.createNodeIndexDocument(
|
|
4768
|
+
resources,
|
|
4434
4769
|
parentNode,
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
nodeInPage,
|
|
4438
|
-
resources
|
|
4770
|
+
sourceTile,
|
|
4771
|
+
false
|
|
4439
4772
|
);
|
|
4440
|
-
const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
|
|
4441
4773
|
nodes.push(node);
|
|
4442
4774
|
if (nodeInPage.mesh) {
|
|
4443
|
-
|
|
4775
|
+
if (sourceTile.id) {
|
|
4776
|
+
const dumpMetadata = {
|
|
4777
|
+
boundingVolumes: resources.boundingVolumes,
|
|
4778
|
+
attributesCount: (_a2 = resources.attributes) == null ? void 0 : _a2.length,
|
|
4779
|
+
featureCount: resources.featureCount,
|
|
4780
|
+
geometry: Boolean(resources.geometry),
|
|
4781
|
+
hasUvRegions: resources.hasUvRegions,
|
|
4782
|
+
materialId: nodeInPage.mesh.material.definition,
|
|
4783
|
+
texelCountHint: nodeInPage.mesh.material.texelCountHint,
|
|
4784
|
+
vertexCount: resources.vertexCount
|
|
4785
|
+
};
|
|
4786
|
+
this.conversionDump.setMaterialsDefinitions(this.materialDefinitions);
|
|
4787
|
+
await this.conversionDump.addNode(sourceTile.id, nodeInPage.index, dumpMetadata);
|
|
4788
|
+
}
|
|
4789
|
+
await this._writeResources(resources, node.id, sourceTile);
|
|
4444
4790
|
}
|
|
4445
4791
|
if (this.validate) {
|
|
4446
4792
|
this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);
|
|
@@ -4506,7 +4852,7 @@ var I3SConverter = class {
|
|
|
4506
4852
|
* @return the node object in node pages
|
|
4507
4853
|
*/
|
|
4508
4854
|
async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
4509
|
-
const {
|
|
4855
|
+
const { vertexCount, featureCount, geometry, hasUvRegions } = resources;
|
|
4510
4856
|
const nodeInPage = {
|
|
4511
4857
|
index: 0,
|
|
4512
4858
|
lodThreshold: maxScreenThresholdSQ.maxError,
|
|
@@ -4516,7 +4862,12 @@ var I3SConverter = class {
|
|
|
4516
4862
|
if (geometry && this.isContentSupported(sourceTile)) {
|
|
4517
4863
|
nodeInPage.mesh = {
|
|
4518
4864
|
geometry: {
|
|
4519
|
-
definition: this.findOrCreateGeometryDefinition(
|
|
4865
|
+
definition: this.findOrCreateGeometryDefinition(
|
|
4866
|
+
Boolean(
|
|
4867
|
+
"texture" in resources && resources.texture || "texelCountHint" in resources && resources.texelCountHint
|
|
4868
|
+
),
|
|
4869
|
+
hasUvRegions
|
|
4870
|
+
),
|
|
4520
4871
|
resource: 0
|
|
4521
4872
|
},
|
|
4522
4873
|
attribute: {
|
|
@@ -4527,7 +4878,7 @@ var I3SConverter = class {
|
|
|
4527
4878
|
}
|
|
4528
4879
|
};
|
|
4529
4880
|
}
|
|
4530
|
-
let nodeId = resources.nodeId;
|
|
4881
|
+
let nodeId = "nodeId" in resources ? resources.nodeId : void 0;
|
|
4531
4882
|
let node;
|
|
4532
4883
|
if (!nodeId) {
|
|
4533
4884
|
node = await this.nodePages.push(nodeInPage, parentId);
|
|
@@ -4538,12 +4889,16 @@ var I3SConverter = class {
|
|
|
4538
4889
|
console.log(`[warning]: node ${node.index} is created with empty content`);
|
|
4539
4890
|
}
|
|
4540
4891
|
NodePages.updateAll(node, nodeInPage);
|
|
4541
|
-
if (meshMaterial) {
|
|
4542
|
-
NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));
|
|
4892
|
+
if ("meshMaterial" in resources && resources.meshMaterial) {
|
|
4893
|
+
NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(resources.meshMaterial));
|
|
4894
|
+
} else if ("materialId" in resources && resources.materialId !== null) {
|
|
4895
|
+
NodePages.updateMaterialByNodeId(node, resources.materialId);
|
|
4543
4896
|
}
|
|
4544
|
-
if (texture) {
|
|
4545
|
-
const texelCountHint = texture.image.height * texture.image.width;
|
|
4897
|
+
if ("texture" in resources && resources.texture) {
|
|
4898
|
+
const texelCountHint = resources.texture.image.height * resources.texture.image.width;
|
|
4546
4899
|
NodePages.updateTexelCountHintByNodeId(node, texelCountHint);
|
|
4900
|
+
} else if ("texelCountHint" in resources && resources.texelCountHint) {
|
|
4901
|
+
NodePages.updateTexelCountHintByNodeId(node, resources.texelCountHint);
|
|
4547
4902
|
}
|
|
4548
4903
|
if (vertexCount) {
|
|
4549
4904
|
this.vertexCounter += vertexCount;
|
|
@@ -4564,9 +4919,11 @@ var I3SConverter = class {
|
|
|
4564
4919
|
* @param resources.texture - texture image
|
|
4565
4920
|
* @param resources.sharedResources - shared resource data object
|
|
4566
4921
|
* @param resources.attributes - feature attributes
|
|
4922
|
+
* @param nodePath - node path
|
|
4923
|
+
* @param sourceTile - source tile (3DTile)
|
|
4567
4924
|
* @return {Promise<void>}
|
|
4568
4925
|
*/
|
|
4569
|
-
async _writeResources(resources, nodePath) {
|
|
4926
|
+
async _writeResources(resources, nodePath, sourceTile) {
|
|
4570
4927
|
const {
|
|
4571
4928
|
geometry: geometryBuffer,
|
|
4572
4929
|
compressedGeometry,
|
|
@@ -4576,10 +4933,36 @@ var I3SConverter = class {
|
|
|
4576
4933
|
} = resources;
|
|
4577
4934
|
const childPath = (0, import_path7.join)(this.layers0Path, "nodes", nodePath);
|
|
4578
4935
|
const slpkChildPath = (0, import_path7.join)("nodes", nodePath);
|
|
4579
|
-
await this._writeGeometries(
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4936
|
+
await this._writeGeometries(
|
|
4937
|
+
geometryBuffer,
|
|
4938
|
+
compressedGeometry,
|
|
4939
|
+
childPath,
|
|
4940
|
+
slpkChildPath,
|
|
4941
|
+
sourceTile.id || "",
|
|
4942
|
+
parseInt(nodePath)
|
|
4943
|
+
);
|
|
4944
|
+
await this._writeShared(
|
|
4945
|
+
sharedResources,
|
|
4946
|
+
childPath,
|
|
4947
|
+
slpkChildPath,
|
|
4948
|
+
nodePath,
|
|
4949
|
+
sourceTile.id || "",
|
|
4950
|
+
parseInt(nodePath)
|
|
4951
|
+
);
|
|
4952
|
+
await this._writeTexture(
|
|
4953
|
+
texture,
|
|
4954
|
+
childPath,
|
|
4955
|
+
slpkChildPath,
|
|
4956
|
+
sourceTile.id || "",
|
|
4957
|
+
parseInt(nodePath)
|
|
4958
|
+
);
|
|
4959
|
+
await this._writeAttributes(
|
|
4960
|
+
attributes,
|
|
4961
|
+
childPath,
|
|
4962
|
+
slpkChildPath,
|
|
4963
|
+
sourceTile.id || "",
|
|
4964
|
+
parseInt(nodePath)
|
|
4965
|
+
);
|
|
4583
4966
|
}
|
|
4584
4967
|
/**
|
|
4585
4968
|
* Write non-compressed and compressed geometries in files
|
|
@@ -4587,30 +4970,46 @@ var I3SConverter = class {
|
|
|
4587
4970
|
* @param compressedGeometry - Uint8Array with compressed (draco) geometry
|
|
4588
4971
|
* @param childPath - a child path to write resources
|
|
4589
4972
|
* @param slpkChildPath - resource path inside *slpk file
|
|
4973
|
+
* @param sourceId - source filename
|
|
4974
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
4590
4975
|
*/
|
|
4591
|
-
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
4976
|
+
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
|
|
4977
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, "GEOMETRY" /* GEOMETRY */, false);
|
|
4592
4978
|
if (this.options.slpk) {
|
|
4593
4979
|
const slpkGeometryPath = (0, import_path7.join)(childPath, "geometries");
|
|
4594
4980
|
await this.writeQueue.enqueue({
|
|
4595
4981
|
archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
|
|
4982
|
+
sourceId,
|
|
4983
|
+
outputId: nodeId,
|
|
4984
|
+
resourceType: "GEOMETRY" /* GEOMETRY */,
|
|
4596
4985
|
writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, "0.bin")
|
|
4597
4986
|
});
|
|
4598
4987
|
} else {
|
|
4599
4988
|
const geometryPath = (0, import_path7.join)(childPath, "geometries/0/");
|
|
4600
4989
|
await this.writeQueue.enqueue({
|
|
4990
|
+
sourceId,
|
|
4991
|
+
outputId: nodeId,
|
|
4992
|
+
resourceType: "GEOMETRY" /* GEOMETRY */,
|
|
4601
4993
|
writePromise: () => writeFile(geometryPath, geometryBuffer, "index.bin")
|
|
4602
4994
|
});
|
|
4603
4995
|
}
|
|
4604
4996
|
if (this.options.draco) {
|
|
4997
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, "DRACO_GEOMETRY" /* DRACO_GEOMETRY */, false);
|
|
4605
4998
|
if (this.options.slpk) {
|
|
4606
4999
|
const slpkCompressedGeometryPath = (0, import_path7.join)(childPath, "geometries");
|
|
4607
5000
|
await this.writeQueue.enqueue({
|
|
4608
5001
|
archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
|
|
5002
|
+
sourceId,
|
|
5003
|
+
outputId: nodeId,
|
|
5004
|
+
resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
|
|
4609
5005
|
writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, "1.bin")
|
|
4610
5006
|
});
|
|
4611
5007
|
} else {
|
|
4612
5008
|
const compressedGeometryPath = (0, import_path7.join)(childPath, "geometries/1/");
|
|
4613
5009
|
await this.writeQueue.enqueue({
|
|
5010
|
+
sourceId,
|
|
5011
|
+
outputId: nodeId,
|
|
5012
|
+
resourceType: "DRACO_GEOMETRY" /* DRACO_GEOMETRY */,
|
|
4614
5013
|
writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, "index.bin")
|
|
4615
5014
|
});
|
|
4616
5015
|
}
|
|
@@ -4622,23 +5021,34 @@ var I3SConverter = class {
|
|
|
4622
5021
|
* @param childPath - a child path to write resources
|
|
4623
5022
|
* @param slpkChildPath - resource path inside *slpk file
|
|
4624
5023
|
* @param nodePath - a node path
|
|
5024
|
+
* @param sourceId - source filename
|
|
5025
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
4625
5026
|
*/
|
|
4626
|
-
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
5027
|
+
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
|
|
4627
5028
|
if (!sharedResources) {
|
|
4628
5029
|
return;
|
|
4629
5030
|
}
|
|
4630
5031
|
sharedResources.nodePath = nodePath;
|
|
4631
5032
|
const sharedData = (0, import_json_map_transform8.default)(sharedResources, SHARED_RESOURCES());
|
|
4632
5033
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
5034
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, "SHARED" /* SHARED */, false);
|
|
4633
5035
|
if (this.options.slpk) {
|
|
4634
5036
|
const slpkSharedPath = (0, import_path7.join)(childPath, "shared");
|
|
4635
5037
|
await this.writeQueue.enqueue({
|
|
4636
5038
|
archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
|
|
5039
|
+
sourceId,
|
|
5040
|
+
outputId: nodeId,
|
|
5041
|
+
resourceType: "SHARED" /* SHARED */,
|
|
4637
5042
|
writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, "sharedResource.json")
|
|
4638
5043
|
});
|
|
4639
5044
|
} else {
|
|
4640
5045
|
const sharedPath = (0, import_path7.join)(childPath, "shared/");
|
|
4641
|
-
await this.writeQueue.enqueue({
|
|
5046
|
+
await this.writeQueue.enqueue({
|
|
5047
|
+
sourceId,
|
|
5048
|
+
outputId: nodeId,
|
|
5049
|
+
resourceType: "SHARED" /* SHARED */,
|
|
5050
|
+
writePromise: () => writeFile(sharedPath, sharedDataStr)
|
|
5051
|
+
});
|
|
4642
5052
|
}
|
|
4643
5053
|
}
|
|
4644
5054
|
/**
|
|
@@ -4646,8 +5056,10 @@ var I3SConverter = class {
|
|
|
4646
5056
|
* @param texture - the texture image
|
|
4647
5057
|
* @param childPath - a child path to write resources
|
|
4648
5058
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
5059
|
+
* @param sourceId - source filename
|
|
5060
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
4649
5061
|
*/
|
|
4650
|
-
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
5062
|
+
async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
|
|
4651
5063
|
if (texture) {
|
|
4652
5064
|
const format = this._getFormatByMimeType(texture == null ? void 0 : texture.mimeType);
|
|
4653
5065
|
const formats = [];
|
|
@@ -4656,7 +5068,21 @@ var I3SConverter = class {
|
|
|
4656
5068
|
case "jpg":
|
|
4657
5069
|
case "png": {
|
|
4658
5070
|
formats.push({ name: "0", format });
|
|
4659
|
-
|
|
5071
|
+
this.conversionDump.updateDoneStatus(
|
|
5072
|
+
sourceId,
|
|
5073
|
+
nodeId,
|
|
5074
|
+
`${"TEXTURE" /* TEXTURE */}/${format}`,
|
|
5075
|
+
false
|
|
5076
|
+
);
|
|
5077
|
+
await this.writeTextureFile(
|
|
5078
|
+
textureData,
|
|
5079
|
+
"0",
|
|
5080
|
+
format,
|
|
5081
|
+
childPath,
|
|
5082
|
+
slpkChildPath,
|
|
5083
|
+
sourceId,
|
|
5084
|
+
nodeId
|
|
5085
|
+
);
|
|
4660
5086
|
if (this.generateTextures) {
|
|
4661
5087
|
formats.push({ name: "1", format: "ktx2" });
|
|
4662
5088
|
const copyArrayBuffer = texture.image.data.subarray();
|
|
@@ -4676,22 +5102,58 @@ var I3SConverter = class {
|
|
|
4676
5102
|
useLocalLibraries: true
|
|
4677
5103
|
}
|
|
4678
5104
|
);
|
|
4679
|
-
|
|
5105
|
+
this.conversionDump.updateDoneStatus(
|
|
5106
|
+
sourceId,
|
|
5107
|
+
nodeId,
|
|
5108
|
+
`${"TEXTURE" /* TEXTURE */}/ktx2`,
|
|
5109
|
+
false
|
|
5110
|
+
);
|
|
5111
|
+
await this.writeTextureFile(
|
|
5112
|
+
ktx2TextureData,
|
|
5113
|
+
"1",
|
|
5114
|
+
"ktx2",
|
|
5115
|
+
childPath,
|
|
5116
|
+
slpkChildPath,
|
|
5117
|
+
sourceId,
|
|
5118
|
+
nodeId
|
|
5119
|
+
);
|
|
4680
5120
|
}
|
|
4681
5121
|
break;
|
|
4682
5122
|
}
|
|
4683
5123
|
case "ktx2": {
|
|
4684
5124
|
formats.push({ name: "1", format });
|
|
4685
|
-
|
|
5125
|
+
this.conversionDump.updateDoneStatus(
|
|
5126
|
+
sourceId,
|
|
5127
|
+
nodeId,
|
|
5128
|
+
`${"TEXTURE" /* TEXTURE */}/${format}`,
|
|
5129
|
+
false
|
|
5130
|
+
);
|
|
5131
|
+
await this.writeTextureFile(
|
|
5132
|
+
textureData,
|
|
5133
|
+
"1",
|
|
5134
|
+
format,
|
|
5135
|
+
childPath,
|
|
5136
|
+
slpkChildPath,
|
|
5137
|
+
sourceId,
|
|
5138
|
+
nodeId
|
|
5139
|
+
);
|
|
4686
5140
|
if (this.generateTextures) {
|
|
4687
5141
|
formats.push({ name: "0", format: "jpg" });
|
|
4688
5142
|
const decodedFromKTX2TextureData = (0, import_core9.encode)(texture.image.data[0], import_images.ImageWriter);
|
|
5143
|
+
this.conversionDump.updateDoneStatus(
|
|
5144
|
+
sourceId,
|
|
5145
|
+
nodeId,
|
|
5146
|
+
`${"TEXTURE" /* TEXTURE */}/jpg`,
|
|
5147
|
+
false
|
|
5148
|
+
);
|
|
4689
5149
|
await this.writeTextureFile(
|
|
4690
5150
|
decodedFromKTX2TextureData,
|
|
4691
5151
|
"0",
|
|
4692
5152
|
"jpg",
|
|
4693
5153
|
childPath,
|
|
4694
|
-
slpkChildPath
|
|
5154
|
+
slpkChildPath,
|
|
5155
|
+
sourceId,
|
|
5156
|
+
nodeId
|
|
4695
5157
|
);
|
|
4696
5158
|
}
|
|
4697
5159
|
}
|
|
@@ -4699,6 +5161,9 @@ var I3SConverter = class {
|
|
|
4699
5161
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
4700
5162
|
this.layers0.textureSetDefinitions.push({ formats });
|
|
4701
5163
|
this.layers0.textureSetDefinitions.push({ formats, atlas: true });
|
|
5164
|
+
if (this.layers0.textureSetDefinitions) {
|
|
5165
|
+
this.conversionDump.addTexturesDefinitions(this.layers0.textureSetDefinitions);
|
|
5166
|
+
}
|
|
4702
5167
|
}
|
|
4703
5168
|
}
|
|
4704
5169
|
}
|
|
@@ -4709,18 +5174,26 @@ var I3SConverter = class {
|
|
|
4709
5174
|
* @param format
|
|
4710
5175
|
* @param childPath
|
|
4711
5176
|
* @param slpkChildPath
|
|
5177
|
+
* @param sourceId
|
|
5178
|
+
* @param nodeId
|
|
4712
5179
|
*/
|
|
4713
|
-
async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
|
|
5180
|
+
async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
|
|
4714
5181
|
if (this.options.slpk) {
|
|
4715
5182
|
const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
|
|
4716
5183
|
const compress = false;
|
|
4717
5184
|
await this.writeQueue.enqueue({
|
|
4718
5185
|
archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
|
|
5186
|
+
sourceId,
|
|
5187
|
+
outputId: nodeId,
|
|
5188
|
+
resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
|
|
4719
5189
|
writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
|
|
4720
5190
|
});
|
|
4721
5191
|
} else {
|
|
4722
5192
|
const texturePath = (0, import_path7.join)(childPath, `textures/${name}/`);
|
|
4723
5193
|
await this.writeQueue.enqueue({
|
|
5194
|
+
sourceId,
|
|
5195
|
+
outputId: nodeId,
|
|
5196
|
+
resourceType: `${"TEXTURE" /* TEXTURE */}/${format}`,
|
|
4724
5197
|
writePromise: () => writeFile(texturePath, textureData, `index.${format}`)
|
|
4725
5198
|
});
|
|
4726
5199
|
}
|
|
@@ -4730,22 +5203,36 @@ var I3SConverter = class {
|
|
|
4730
5203
|
* @param attributes - feature attributes
|
|
4731
5204
|
* @param childPath - a child path to write resources
|
|
4732
5205
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
5206
|
+
* @param sourceId - source filename
|
|
5207
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
4733
5208
|
*/
|
|
4734
|
-
async _writeAttributes(attributes = [], childPath, slpkChildPath) {
|
|
5209
|
+
async _writeAttributes(attributes = [], childPath, slpkChildPath, sourceId, nodeId) {
|
|
4735
5210
|
if ((attributes == null ? void 0 : attributes.length) && this.attributeMetadataInfo.attributeStorageInfo.length) {
|
|
4736
5211
|
const minimumLength = attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length ? attributes.length : this.attributeMetadataInfo.attributeStorageInfo.length;
|
|
4737
5212
|
for (let index = 0; index < minimumLength; index++) {
|
|
4738
5213
|
const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
|
|
4739
5214
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
5215
|
+
this.conversionDump.updateDoneStatus(
|
|
5216
|
+
sourceId,
|
|
5217
|
+
nodeId,
|
|
5218
|
+
`${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
|
|
5219
|
+
false
|
|
5220
|
+
);
|
|
4740
5221
|
if (this.options.slpk) {
|
|
4741
5222
|
const slpkAttributesPath = (0, import_path7.join)(childPath, "attributes", folderName);
|
|
4742
5223
|
await this.writeQueue.enqueue({
|
|
4743
5224
|
archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
|
|
5225
|
+
sourceId,
|
|
5226
|
+
outputId: nodeId,
|
|
5227
|
+
resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
|
|
4744
5228
|
writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, "0.bin")
|
|
4745
5229
|
});
|
|
4746
5230
|
} else {
|
|
4747
5231
|
const attributesPath = (0, import_path7.join)(childPath, `attributes/${folderName}/0`);
|
|
4748
5232
|
await this.writeQueue.enqueue({
|
|
5233
|
+
sourceId,
|
|
5234
|
+
outputId: nodeId,
|
|
5235
|
+
resourceType: `${"ATTRIBUTES" /* ATTRIBUTES */}/${folderName}`,
|
|
4749
5236
|
writePromise: () => writeFile(attributesPath, fileBuffer, "index.bin")
|
|
4750
5237
|
});
|
|
4751
5238
|
}
|
|
@@ -4932,6 +5419,9 @@ var TILE = () => ({
|
|
|
4932
5419
|
geometricError: {
|
|
4933
5420
|
path: "geometricError"
|
|
4934
5421
|
},
|
|
5422
|
+
refine: {
|
|
5423
|
+
path: "refine"
|
|
5424
|
+
},
|
|
4935
5425
|
content: {
|
|
4936
5426
|
path: "content"
|
|
4937
5427
|
},
|
|
@@ -4956,7 +5446,7 @@ var TILESET = () => ({
|
|
|
4956
5446
|
});
|
|
4957
5447
|
|
|
4958
5448
|
// src/3d-tiles-converter/3d-tiles-converter.ts
|
|
4959
|
-
var
|
|
5449
|
+
var import_worker_utils2 = require("@loaders.gl/worker-utils");
|
|
4960
5450
|
|
|
4961
5451
|
// src/3d-tiles-converter/helpers/b3dm-converter.ts
|
|
4962
5452
|
var import_core12 = require("@loaders.gl/core");
|
|
@@ -4999,6 +5489,9 @@ function normalizeRegions(regions) {
|
|
|
4999
5489
|
// src/3d-tiles-converter/helpers/b3dm-converter.ts
|
|
5000
5490
|
var Z_UP_TO_Y_UP_MATRIX = new import_core13.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
|
|
5001
5491
|
var scratchVector2 = new import_core13.Vector3();
|
|
5492
|
+
var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
|
|
5493
|
+
var METALLIC_FACTOR_DEFAULT = 1;
|
|
5494
|
+
var ROUGHNESS_FACTOR_DEFAULT = 1;
|
|
5002
5495
|
var B3dmConverter = class {
|
|
5003
5496
|
/**
|
|
5004
5497
|
* The starter of content conversion
|
|
@@ -5028,6 +5521,11 @@ var B3dmConverter = class {
|
|
|
5028
5521
|
const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
|
|
5029
5522
|
const gltfBuilder = new import_gltf6.GLTFScenegraph();
|
|
5030
5523
|
const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);
|
|
5524
|
+
const pbrMetallicRoughness = material == null ? void 0 : material.pbrMetallicRoughness;
|
|
5525
|
+
if (pbrMetallicRoughness && (pbrMetallicRoughness.metallicFactor === void 0 || pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) && (pbrMetallicRoughness.roughnessFactor === void 0 || pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)) {
|
|
5526
|
+
gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});
|
|
5527
|
+
gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);
|
|
5528
|
+
}
|
|
5031
5529
|
const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);
|
|
5032
5530
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
5033
5531
|
const positions = attributes.positions;
|
|
@@ -5296,6 +5794,8 @@ var Tiles3DConverter = class {
|
|
|
5296
5794
|
this.loaderOptions = {
|
|
5297
5795
|
_nodeWorkers: true,
|
|
5298
5796
|
reuseWorkers: true,
|
|
5797
|
+
// TODO: converter freezes in the end because of i3s-content-worker
|
|
5798
|
+
worker: false,
|
|
5299
5799
|
i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
|
|
5300
5800
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
5301
5801
|
"i3s-content": {
|
|
@@ -5351,13 +5851,14 @@ var Tiles3DConverter = class {
|
|
|
5351
5851
|
box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)
|
|
5352
5852
|
},
|
|
5353
5853
|
geometricError: convertScreenThresholdToGeometricError(rootNode),
|
|
5354
|
-
children: []
|
|
5854
|
+
children: [],
|
|
5855
|
+
refine: "REPLACE"
|
|
5355
5856
|
};
|
|
5356
5857
|
await this._addChildren(rootNode, rootTile, 1);
|
|
5357
5858
|
const tileset = (0, import_json_map_transform10.default)({ root: rootTile }, TILESET());
|
|
5358
5859
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), "tileset.json");
|
|
5359
5860
|
this._finishConversion({ slpk: false, outputPath, tilesetName });
|
|
5360
|
-
const workerFarm =
|
|
5861
|
+
const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
|
|
5361
5862
|
workerFarm.destroy();
|
|
5362
5863
|
}
|
|
5363
5864
|
/**
|
|
@@ -5419,11 +5920,9 @@ var Tiles3DConverter = class {
|
|
|
5419
5920
|
if (this.options.maxDepth && level > this.options.maxDepth) {
|
|
5420
5921
|
return;
|
|
5421
5922
|
}
|
|
5422
|
-
const promises = [];
|
|
5423
5923
|
for (const childNodeInfo of parentSourceNode.children || []) {
|
|
5424
|
-
|
|
5924
|
+
await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);
|
|
5425
5925
|
}
|
|
5426
|
-
await Promise.all(promises);
|
|
5427
5926
|
}
|
|
5428
5927
|
/**
|
|
5429
5928
|
* Load a child node having information from the node header
|