@loaders.gl/tile-converter 4.2.0-alpha.5 → 4.2.0-beta.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 +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +42 -22
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +4 -0
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +3 -28
- package/dist/converter-cli.js +4 -2
- package/dist/converter.min.cjs +95 -95
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +9 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +4 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +2 -2
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +4 -2
- package/dist/i3s-converter/helpers/geometry-attributes.js +6 -5
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +15 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +52 -12
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +12 -14
- package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +18 -11
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +27 -26
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/progress.js +23 -18
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +8 -1
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +12 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +190 -66
- package/dist/i3s-converter/json-templates/node.js +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
- package/dist/i3s-server/bin/www.js +6 -4
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.js +3 -1
- package/dist/i3s-server/routes/index.js +11 -8
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
- package/dist/i3s-server/routes/slpk-router.js +24 -18
- package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
- package/dist/i3s-server/utils/server-utils.js +8 -5
- package/dist/index.cjs +421 -211
- package/dist/index.cjs.map +3 -3
- package/dist/lib/utils/cli-utils.d.ts.map +1 -1
- package/dist/lib/utils/cli-utils.js +2 -0
- package/dist/lib/utils/conversion-dump.d.ts +9 -1
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +44 -21
- package/dist/lib/utils/file-utils.d.ts +1 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +10 -12
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/statistic-utills.js +5 -7
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +7 -3
- package/dist/pgm-loader.d.ts +17 -2
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/pgm-loader.js +3 -1
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +2 -1
- package/dist/slpk-extractor-cli.d.ts.map +1 -1
- package/dist/slpk-extractor-cli.js +16 -8
- package/dist/slpk-extractor.min.cjs +36 -36
- package/package.json +23 -22
- package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
- package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
- package/src/converter-cli.ts +4 -2
- package/src/deps-installer/deps-installer.ts +11 -0
- package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
- package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
- package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
- package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
- package/src/i3s-converter/helpers/node-index-document.ts +18 -10
- package/src/i3s-converter/helpers/node-pages.ts +27 -29
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
- package/src/i3s-converter/helpers/progress.ts +1 -0
- package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
- package/src/i3s-converter/i3s-converter.ts +173 -114
- package/src/i3s-converter/json-templates/node.ts +1 -1
- package/src/i3s-server/bin/www.ts +6 -4
- package/src/i3s-server/controllers/slpk-controller.ts +4 -2
- package/src/i3s-server/routes/index.ts +10 -7
- package/src/i3s-server/routes/slpk-router.ts +22 -16
- package/src/i3s-server/utils/server-utils.ts +6 -4
- package/src/lib/utils/cli-utils.ts +2 -0
- package/src/lib/utils/conversion-dump.ts +35 -20
- package/src/lib/utils/file-utils.ts +11 -11
- package/src/lib/utils/statistic-utills.ts +5 -6
- package/src/lib/utils/write-queue.ts +2 -2
- package/src/pgm-loader.ts +5 -2
- package/src/slpk-extractor/slpk-extractor.ts +2 -1
- package/src/slpk-extractor-cli.ts +16 -8
- package/src/lib/utils/statistic-utills.d.ts +0 -25
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,9 @@ var ResourceType;
|
|
|
67
67
|
|
|
68
68
|
// dist/i3s-converter/helpers/attribute-metadata-info.js
|
|
69
69
|
var AttributeMetadataInfo = class {
|
|
70
|
+
_attributeStorageInfo;
|
|
71
|
+
_fields;
|
|
72
|
+
_popupInfo;
|
|
70
73
|
constructor() {
|
|
71
74
|
this._attributeStorageInfo = [];
|
|
72
75
|
this._fields = [];
|
|
@@ -127,7 +130,7 @@ var AttributeMetadataInfo = class {
|
|
|
127
130
|
}
|
|
128
131
|
if (isUpdated) {
|
|
129
132
|
const attributeNames = [];
|
|
130
|
-
for (
|
|
133
|
+
for (const info of this._attributeStorageInfo) {
|
|
131
134
|
attributeNames.push(info.name);
|
|
132
135
|
}
|
|
133
136
|
this._popupInfo = this.createPopupInfo(attributeNames);
|
|
@@ -364,14 +367,12 @@ async function writeFileForSlpk(path, data, fileName = "index.json", compress =
|
|
|
364
367
|
if (!compressList.includes(pathFile)) {
|
|
365
368
|
compressList.push(pathFile);
|
|
366
369
|
return `${pathFile}.gz`;
|
|
367
|
-
} else {
|
|
368
|
-
return null;
|
|
369
370
|
}
|
|
370
|
-
|
|
371
|
-
const pathGzFile = await compressFileWithGzip(pathFile);
|
|
372
|
-
await removeFile(pathFile);
|
|
373
|
-
return pathGzFile;
|
|
371
|
+
return null;
|
|
374
372
|
}
|
|
373
|
+
const pathGzFile = await compressFileWithGzip(pathFile);
|
|
374
|
+
await removeFile(pathFile);
|
|
375
|
+
return pathGzFile;
|
|
375
376
|
}
|
|
376
377
|
return pathFile;
|
|
377
378
|
}
|
|
@@ -421,6 +422,12 @@ async function renameFile(oldPath, newPath) {
|
|
|
421
422
|
|
|
422
423
|
// dist/i3s-converter/helpers/node-pages.js
|
|
423
424
|
var NodePages = class {
|
|
425
|
+
nodesPerPage;
|
|
426
|
+
nodesCounter;
|
|
427
|
+
writeFile;
|
|
428
|
+
converter;
|
|
429
|
+
nodePages;
|
|
430
|
+
length = 0;
|
|
424
431
|
/**
|
|
425
432
|
* @constructs
|
|
426
433
|
* Create a nodePages instance.
|
|
@@ -428,7 +435,6 @@ var NodePages = class {
|
|
|
428
435
|
* @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
|
|
429
436
|
*/
|
|
430
437
|
constructor(writeFileFunc, nodesPerPage, converter) {
|
|
431
|
-
this.length = 0;
|
|
432
438
|
this.nodesPerPage = nodesPerPage;
|
|
433
439
|
this.nodesCounter = 0;
|
|
434
440
|
this.nodePages = [{}];
|
|
@@ -472,9 +478,8 @@ var NodePages = class {
|
|
|
472
478
|
if (await isFileExists(fullName)) {
|
|
473
479
|
console.log(`load ${fullName}.`);
|
|
474
480
|
return await openJson(filePath, fileName);
|
|
475
|
-
} else {
|
|
476
|
-
return { nodes: [] };
|
|
477
481
|
}
|
|
482
|
+
return { nodes: [] };
|
|
478
483
|
}
|
|
479
484
|
/**
|
|
480
485
|
* Get nodepage id by node id
|
|
@@ -548,27 +553,26 @@ var NodePages = class {
|
|
|
548
553
|
async saveNode(node) {
|
|
549
554
|
if (!this.converter.options.instantNodeWriting) {
|
|
550
555
|
return;
|
|
556
|
+
}
|
|
557
|
+
const nodePageIndex = this.getPageIndexByNodeId(node.index);
|
|
558
|
+
const nodePage = await this.getPageByNodeId(node.index);
|
|
559
|
+
const { filePath, fileName } = this.getNodePageFileName(nodePageIndex);
|
|
560
|
+
const nodeToUpdate = await this.getNodeById(node.index, nodePage);
|
|
561
|
+
if (nodeToUpdate) {
|
|
562
|
+
NodePages.updateAll(nodeToUpdate, node);
|
|
551
563
|
} else {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
|
|
565
|
-
writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
|
|
566
|
-
}, true);
|
|
567
|
-
} else {
|
|
568
|
-
await this.converter.writeQueue.enqueue({
|
|
569
|
-
writePromise: () => this.writeFile(filePath, nodePageStr)
|
|
570
|
-
}, true);
|
|
571
|
-
}
|
|
564
|
+
nodePage.nodes.push(node);
|
|
565
|
+
}
|
|
566
|
+
const nodePageStr = JSON.stringify(nodePage);
|
|
567
|
+
if (this.converter.options.slpk) {
|
|
568
|
+
await this.converter.writeQueue.enqueue({
|
|
569
|
+
archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
|
|
570
|
+
writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
|
|
571
|
+
}, true);
|
|
572
|
+
} else {
|
|
573
|
+
await this.converter.writeQueue.enqueue({
|
|
574
|
+
writePromise: () => this.writeFile(filePath, nodePageStr)
|
|
575
|
+
}, true);
|
|
572
576
|
}
|
|
573
577
|
}
|
|
574
578
|
/**
|
|
@@ -695,15 +699,14 @@ var import_fs3 = require("fs");
|
|
|
695
699
|
function timeConverter(time) {
|
|
696
700
|
if (typeof time === "number") {
|
|
697
701
|
const milliSecondsInSecond = 1e3;
|
|
698
|
-
const
|
|
699
|
-
const
|
|
700
|
-
return timeConverterFromSecondsAndMilliseconds(
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
702
|
+
const timeInSeconds2 = Math.floor(time / milliSecondsInSecond);
|
|
703
|
+
const milliseconds2 = time - timeInSeconds2 * milliSecondsInSecond;
|
|
704
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds2, milliseconds2);
|
|
705
|
+
}
|
|
706
|
+
const nanoSecondsInMillisecond = 1e6;
|
|
707
|
+
const timeInSeconds = time[0];
|
|
708
|
+
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
709
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
707
710
|
}
|
|
708
711
|
function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
|
|
709
712
|
const hours = Math.floor(timeInSeconds / 3600);
|
|
@@ -833,11 +836,11 @@ function getFrequentValue(values) {
|
|
|
833
836
|
function makeAttributeObjects(attributes) {
|
|
834
837
|
const { featureIds, positions, normals, colors, uvRegions, texCoords, faceRange = new Uint32Array(0) } = attributes;
|
|
835
838
|
const groupedData = [];
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
839
|
+
const positionsList = new Float32Array(positions);
|
|
840
|
+
const normalsList = new Float32Array(normals);
|
|
841
|
+
const colorsList = new Uint8Array(colors);
|
|
842
|
+
const texCoordsList = new Float32Array(texCoords);
|
|
843
|
+
const uvRegionsList = new Uint16Array(uvRegions);
|
|
841
844
|
let positionsOffset = 0;
|
|
842
845
|
let normalsOffset = 0;
|
|
843
846
|
let colorsOffset = 0;
|
|
@@ -980,8 +983,8 @@ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel)
|
|
|
980
983
|
const positionVectors = convertPositionsToVectors(cartesianPositions);
|
|
981
984
|
const geometryObb = (0, import_culling.makeOrientedBoundingBoxFromPoints)(positionVectors);
|
|
982
985
|
const geometryMbs = (0, import_culling.makeBoundingSphereFromPoints)(positionVectors);
|
|
983
|
-
|
|
984
|
-
|
|
986
|
+
const mbsCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core2.Vector3());
|
|
987
|
+
const obbCenter = import_geospatial.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core2.Vector3());
|
|
985
988
|
mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
|
|
986
989
|
obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
|
|
987
990
|
return {
|
|
@@ -1033,24 +1036,23 @@ var import_core3 = require("@math.gl/core");
|
|
|
1033
1036
|
var import_geospatial2 = require("@math.gl/geospatial");
|
|
1034
1037
|
function prepareDataForAttributesConversion(tileContent, tileTransform, boundingVolume) {
|
|
1035
1038
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1036
|
-
|
|
1039
|
+
const nodes = ((_b = (_a2 = tileContent.gltf) == null ? void 0 : _a2.scene) == null ? void 0 : _b.nodes) || ((_e = (_d = (_c = tileContent.gltf) == null ? void 0 : _c.scenes) == null ? void 0 : _d[0]) == null ? void 0 : _e.nodes) || ((_f = tileContent.gltf) == null ? void 0 : _f.nodes) || [];
|
|
1037
1040
|
const images = ((_h = (_g = tileContent.gltf) == null ? void 0 : _g.images) == null ? void 0 : _h.map((imageObject) => {
|
|
1038
1041
|
var _a3, _b2;
|
|
1039
1042
|
if ((_a3 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _a3.compressed) {
|
|
1040
1043
|
return null;
|
|
1041
|
-
} else {
|
|
1042
|
-
const data = (_b2 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _b2.data;
|
|
1043
|
-
const dataCopy = new Uint8Array(data.length);
|
|
1044
|
-
dataCopy.set(data);
|
|
1045
|
-
return {
|
|
1046
|
-
data: dataCopy,
|
|
1047
|
-
compressed: false,
|
|
1048
|
-
height: imageObject.image.height,
|
|
1049
|
-
width: imageObject.image.width,
|
|
1050
|
-
components: imageObject.image.components,
|
|
1051
|
-
mimeType: imageObject.mimeType
|
|
1052
|
-
};
|
|
1053
1044
|
}
|
|
1045
|
+
const data = (_b2 = imageObject == null ? void 0 : imageObject.image) == null ? void 0 : _b2.data;
|
|
1046
|
+
const dataCopy = new Uint8Array(data.length);
|
|
1047
|
+
dataCopy.set(data);
|
|
1048
|
+
return {
|
|
1049
|
+
data: dataCopy,
|
|
1050
|
+
compressed: false,
|
|
1051
|
+
height: imageObject.image.height,
|
|
1052
|
+
width: imageObject.image.width,
|
|
1053
|
+
components: imageObject.image.components,
|
|
1054
|
+
mimeType: imageObject.mimeType
|
|
1055
|
+
};
|
|
1054
1056
|
})) || [];
|
|
1055
1057
|
prepareNodes(nodes);
|
|
1056
1058
|
const { cartographicOrigin, modelMatrix: cartesianModelMatrix } = calculateTransformProps(tileContent, tileTransform, boundingVolume);
|
|
@@ -1160,7 +1162,7 @@ function handleBatchIdsExtensions(attributes, primitive, images, featureTexture)
|
|
|
1160
1162
|
return [];
|
|
1161
1163
|
}
|
|
1162
1164
|
function handleExtMeshFeaturesExtension(attributes, extMeshFeatures) {
|
|
1163
|
-
for (
|
|
1165
|
+
for (const ids of extMeshFeatures.featureIds) {
|
|
1164
1166
|
if (typeof ids.propertyTable !== "undefined") {
|
|
1165
1167
|
return ids.data;
|
|
1166
1168
|
}
|
|
@@ -1295,7 +1297,7 @@ var getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
|
|
|
1295
1297
|
const attributeTypesMap = {};
|
|
1296
1298
|
const extFeatureMetadataSchemaClass = (_d = (_c = (_b = (_a2 = gltfJson.extensions) == null ? void 0 : _a2[import_gltf2.EXT_FEATURE_METADATA]) == null ? void 0 : _b.schema) == null ? void 0 : _c.classes) == null ? void 0 : _d[metadataClass];
|
|
1297
1299
|
if (extFeatureMetadataSchemaClass) {
|
|
1298
|
-
for (
|
|
1300
|
+
for (const propertyName in extFeatureMetadataSchemaClass.properties) {
|
|
1299
1301
|
const property = extFeatureMetadataSchemaClass.properties[propertyName];
|
|
1300
1302
|
const attributeProperty = getAttributeTypeFromExtFeatureMetadata(property);
|
|
1301
1303
|
attributeTypesMap[propertyName] = attributeProperty;
|
|
@@ -1304,7 +1306,7 @@ var getAttributeTypesMapFromSchema = (gltfJson, metadataClass) => {
|
|
|
1304
1306
|
}
|
|
1305
1307
|
const extStructuralMetadataSchemaClass = (_h = (_g = (_f = (_e = gltfJson.extensions) == null ? void 0 : _e[import_gltf2.EXT_STRUCTURAL_METADATA]) == null ? void 0 : _f.schema) == null ? void 0 : _g.classes) == null ? void 0 : _h[metadataClass];
|
|
1306
1308
|
if (extStructuralMetadataSchemaClass) {
|
|
1307
|
-
for (
|
|
1309
|
+
for (const propertyName in extStructuralMetadataSchemaClass.properties) {
|
|
1308
1310
|
const property = extStructuralMetadataSchemaClass.properties[propertyName];
|
|
1309
1311
|
const attributeProperty = getAttributeTypeFromExtStructuralMetadata(property);
|
|
1310
1312
|
attributeTypesMap[propertyName] = attributeProperty;
|
|
@@ -1397,7 +1399,7 @@ var DOUBLE_TYPE = "Float64";
|
|
|
1397
1399
|
var OBJECT_ID_TYPE = "Oid32";
|
|
1398
1400
|
var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
|
|
1399
1401
|
var scratchVector = new import_core4.Vector3();
|
|
1400
|
-
async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
|
|
1402
|
+
async function convertB3dmToI3sGeometry({ tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass }) {
|
|
1401
1403
|
var _a2;
|
|
1402
1404
|
const useCartesianPositions = generateBoundingVolumes;
|
|
1403
1405
|
const materialAndTextureList = await convertMaterials((_a2 = tileContent.gltf) == null ? void 0 : _a2.materials, shouldMergeMaterials);
|
|
@@ -1510,7 +1512,15 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
|
|
|
1510
1512
|
attributesMap.set(mergedMaterial.originalMaterialId, attributes);
|
|
1511
1513
|
}
|
|
1512
1514
|
}
|
|
1513
|
-
convertNodes(
|
|
1515
|
+
convertNodes({
|
|
1516
|
+
nodes,
|
|
1517
|
+
images,
|
|
1518
|
+
cartographicOrigin,
|
|
1519
|
+
cartesianModelMatrix,
|
|
1520
|
+
attributesMap,
|
|
1521
|
+
useCartesianPositions,
|
|
1522
|
+
featureTexture
|
|
1523
|
+
});
|
|
1514
1524
|
for (const attrKey of attributesMap.keys()) {
|
|
1515
1525
|
const attributes = attributesMap.get(attrKey);
|
|
1516
1526
|
if (!attributes) {
|
|
@@ -1527,10 +1537,19 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
|
|
|
1527
1537
|
}
|
|
1528
1538
|
return attributesMap;
|
|
1529
1539
|
}
|
|
1530
|
-
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
|
|
1540
|
+
function convertNodes({ nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture }) {
|
|
1531
1541
|
if (nodes) {
|
|
1532
1542
|
for (const node of nodes) {
|
|
1533
|
-
convertNode(
|
|
1543
|
+
convertNode({
|
|
1544
|
+
node,
|
|
1545
|
+
images,
|
|
1546
|
+
cartographicOrigin,
|
|
1547
|
+
cartesianModelMatrix,
|
|
1548
|
+
attributesMap,
|
|
1549
|
+
useCartesianPositions,
|
|
1550
|
+
matrix,
|
|
1551
|
+
featureTexture
|
|
1552
|
+
});
|
|
1534
1553
|
}
|
|
1535
1554
|
}
|
|
1536
1555
|
}
|
|
@@ -1551,15 +1570,33 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
1551
1570
|
}
|
|
1552
1571
|
return transformationMatrix;
|
|
1553
1572
|
}
|
|
1554
|
-
function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
|
|
1573
|
+
function convertNode({ node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core4.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture }) {
|
|
1555
1574
|
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
1556
1575
|
const mesh = node.mesh;
|
|
1557
1576
|
if (mesh) {
|
|
1558
|
-
convertMesh(
|
|
1577
|
+
convertMesh({
|
|
1578
|
+
mesh,
|
|
1579
|
+
images,
|
|
1580
|
+
cartographicOrigin,
|
|
1581
|
+
cartesianModelMatrix,
|
|
1582
|
+
attributesMap,
|
|
1583
|
+
useCartesianPositions,
|
|
1584
|
+
matrix: transformationMatrix,
|
|
1585
|
+
featureTexture
|
|
1586
|
+
});
|
|
1559
1587
|
}
|
|
1560
|
-
convertNodes(
|
|
1588
|
+
convertNodes({
|
|
1589
|
+
nodes: node.children || [],
|
|
1590
|
+
images,
|
|
1591
|
+
cartographicOrigin,
|
|
1592
|
+
cartesianModelMatrix,
|
|
1593
|
+
attributesMap,
|
|
1594
|
+
useCartesianPositions,
|
|
1595
|
+
matrix: transformationMatrix,
|
|
1596
|
+
featureTexture
|
|
1597
|
+
});
|
|
1561
1598
|
}
|
|
1562
|
-
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix
|
|
1599
|
+
function convertMesh({ mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix, featureTexture }) {
|
|
1563
1600
|
var _a2;
|
|
1564
1601
|
for (const primitive of mesh.primitives) {
|
|
1565
1602
|
let outputAttributes = null;
|
|
@@ -1834,7 +1871,7 @@ function convertMaterial(sourceMaterial) {
|
|
|
1834
1871
|
};
|
|
1835
1872
|
}
|
|
1836
1873
|
sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, import_uuid.v4)();
|
|
1837
|
-
|
|
1874
|
+
const mergedMaterials = [{ originalMaterialId: sourceMaterial.id }];
|
|
1838
1875
|
if (!texture) {
|
|
1839
1876
|
const baseColorFactor = (_e = sourceMaterial == null ? void 0 : sourceMaterial.pbrMetallicRoughness) == null ? void 0 : _e.baseColorFactor;
|
|
1840
1877
|
material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255)) || void 0;
|
|
@@ -2305,8 +2342,10 @@ function convertScreenThresholdToGeometricError(node) {
|
|
|
2305
2342
|
|
|
2306
2343
|
// dist/pgm-loader.js
|
|
2307
2344
|
var import_geoid = require("@math.gl/geoid");
|
|
2308
|
-
var VERSION = true ? "4.2.0-alpha.
|
|
2345
|
+
var VERSION = true ? "4.2.0-alpha.6" : "latest";
|
|
2309
2346
|
var PGMLoader = {
|
|
2347
|
+
dataType: null,
|
|
2348
|
+
batchType: null,
|
|
2310
2349
|
name: "PGM - Netpbm grayscale image format",
|
|
2311
2350
|
id: "pgm",
|
|
2312
2351
|
module: "tile-converter",
|
|
@@ -2931,10 +2970,15 @@ var Queue = class extends Array {
|
|
|
2931
2970
|
var import_process = __toESM(require("process"), 1);
|
|
2932
2971
|
var MEMORY_LIMIT = 4 * 1024 * 1024 * 1024;
|
|
2933
2972
|
var WriteQueue = class extends Queue {
|
|
2973
|
+
intervalId;
|
|
2974
|
+
// eslint-disable-line no-undef
|
|
2975
|
+
conversionDump;
|
|
2976
|
+
writePromise = null;
|
|
2977
|
+
fileMap = {};
|
|
2978
|
+
listeningInterval;
|
|
2979
|
+
writeConcurrency;
|
|
2934
2980
|
constructor(conversionDump, listeningInterval = 2e3, writeConcurrency = 400) {
|
|
2935
2981
|
super();
|
|
2936
|
-
this.writePromise = null;
|
|
2937
|
-
this.fileMap = {};
|
|
2938
2982
|
this.conversionDump = conversionDump;
|
|
2939
2983
|
this.listeningInterval = listeningInterval;
|
|
2940
2984
|
this.writeConcurrency = writeConcurrency;
|
|
@@ -2954,7 +2998,7 @@ var WriteQueue = class extends Queue {
|
|
|
2954
2998
|
}
|
|
2955
2999
|
}
|
|
2956
3000
|
startListening() {
|
|
2957
|
-
this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
|
|
3001
|
+
this.intervalId = setInterval(() => this.startWrite.bind(this), this.listeningInterval);
|
|
2958
3002
|
}
|
|
2959
3003
|
stopListening() {
|
|
2960
3004
|
if (this.intervalId) {
|
|
@@ -3098,6 +3142,21 @@ var NODE = () => ({
|
|
|
3098
3142
|
|
|
3099
3143
|
// dist/i3s-converter/helpers/node-index-document.js
|
|
3100
3144
|
var NodeIndexDocument = class {
|
|
3145
|
+
/** Node id */
|
|
3146
|
+
id;
|
|
3147
|
+
/** Id in node pages */
|
|
3148
|
+
inPageId;
|
|
3149
|
+
/** 3DNodeIndexDocument data */
|
|
3150
|
+
data = null;
|
|
3151
|
+
/** children */
|
|
3152
|
+
children = [];
|
|
3153
|
+
/** converter instance */
|
|
3154
|
+
converter;
|
|
3155
|
+
/**
|
|
3156
|
+
* Finalized property. It means that all child nodes are saved and their data
|
|
3157
|
+
* is unloaded
|
|
3158
|
+
*/
|
|
3159
|
+
_finalized = false;
|
|
3101
3160
|
get finalized() {
|
|
3102
3161
|
return this._finalized;
|
|
3103
3162
|
}
|
|
@@ -3107,9 +3166,6 @@ var NodeIndexDocument = class {
|
|
|
3107
3166
|
* @param converter - converter instance
|
|
3108
3167
|
*/
|
|
3109
3168
|
constructor(id, converter) {
|
|
3110
|
-
this.data = null;
|
|
3111
|
-
this.children = [];
|
|
3112
|
-
this._finalized = false;
|
|
3113
3169
|
this.inPageId = id;
|
|
3114
3170
|
this.id = id === 0 ? "root" : id.toString();
|
|
3115
3171
|
this.converter = converter;
|
|
@@ -3256,7 +3312,7 @@ var NodeIndexDocument = class {
|
|
|
3256
3312
|
* @param converter - I3SConverter instance
|
|
3257
3313
|
* @returns NodeIndexDocument instance
|
|
3258
3314
|
*/
|
|
3259
|
-
static async createNode(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
|
|
3315
|
+
static async createNode({ parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter }) {
|
|
3260
3316
|
const data = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
3261
3317
|
const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);
|
|
3262
3318
|
return node;
|
|
@@ -3297,6 +3353,7 @@ var NodeIndexDocument = class {
|
|
|
3297
3353
|
* @param resources.attributes - feature attributes
|
|
3298
3354
|
* @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
|
|
3299
3355
|
*/
|
|
3356
|
+
// eslint-disable-next-line complexity
|
|
3300
3357
|
static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
3301
3358
|
var _a2, _b, _c, _d, _e;
|
|
3302
3359
|
const nodeId = nodeInPage.index;
|
|
@@ -3428,7 +3485,7 @@ var import_core10 = require("@math.gl/core");
|
|
|
3428
3485
|
var import_tiles = require("@loaders.gl/tiles");
|
|
3429
3486
|
|
|
3430
3487
|
// dist/i3s-converter/helpers/tileset-traversal.js
|
|
3431
|
-
var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0) => {
|
|
3488
|
+
var traverseDatasetWith = async ({ tile, traversalProps, processTile, postprocessTile, maxDepth, level = 0 }) => {
|
|
3432
3489
|
if (maxDepth && level > maxDepth) {
|
|
3433
3490
|
return;
|
|
3434
3491
|
}
|
|
@@ -3436,9 +3493,18 @@ var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessT
|
|
|
3436
3493
|
const newTraversalProps = await processTile(tile, traversalProps);
|
|
3437
3494
|
processResults.push(newTraversalProps);
|
|
3438
3495
|
for (const childTile of tile.children) {
|
|
3439
|
-
await traverseDatasetWith(
|
|
3496
|
+
await traverseDatasetWith({
|
|
3497
|
+
tile: childTile,
|
|
3498
|
+
traversalProps: newTraversalProps,
|
|
3499
|
+
processTile,
|
|
3500
|
+
postprocessTile,
|
|
3501
|
+
maxDepth,
|
|
3502
|
+
level: level + 1
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
if (postprocessTile) {
|
|
3506
|
+
await postprocessTile(processResults, traversalProps);
|
|
3440
3507
|
}
|
|
3441
|
-
postprocessTile && await postprocessTile(processResults, traversalProps);
|
|
3442
3508
|
};
|
|
3443
3509
|
|
|
3444
3510
|
// dist/i3s-converter/helpers/preprocess-3d-tiles.js
|
|
@@ -3526,15 +3592,29 @@ var mergePreprocessData = (object1, object2) => {
|
|
|
3526
3592
|
var import_process2 = __toESM(require("process"), 1);
|
|
3527
3593
|
var THRESHOLD_DEFAULT = 0.2;
|
|
3528
3594
|
var Progress = class {
|
|
3595
|
+
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
3596
|
+
_stepsTotal = 0;
|
|
3597
|
+
/** Amount of work already done */
|
|
3598
|
+
_stepsDone = 0;
|
|
3599
|
+
/** Time in milli-seconds when the process started */
|
|
3600
|
+
startTime = 0;
|
|
3601
|
+
/** Time in milli-seconds when the process stopped */
|
|
3602
|
+
stopTime = 0;
|
|
3603
|
+
/** Time in milli-seconds when stepsDone was updated */
|
|
3604
|
+
timeOfUpdatingStepsDone = 0;
|
|
3605
|
+
/** Time in milli-seconds spent for performing one step*/
|
|
3606
|
+
milliSecForOneStep = 0;
|
|
3607
|
+
trust = false;
|
|
3608
|
+
/**
|
|
3609
|
+
* The number of digits to appear after decimal point in the string representation of the count of steps already done.
|
|
3610
|
+
* It's calculated based on the total count of steps.
|
|
3611
|
+
*/
|
|
3612
|
+
numberOfDigitsInPercentage = 0;
|
|
3613
|
+
/** Defines a threshold that is used to check if the process velocity can be consifered trust. */
|
|
3614
|
+
threshold;
|
|
3615
|
+
/** Function that is used to get the time stamp */
|
|
3616
|
+
getTime;
|
|
3529
3617
|
constructor(options = {}) {
|
|
3530
|
-
this._stepsTotal = 0;
|
|
3531
|
-
this._stepsDone = 0;
|
|
3532
|
-
this.startTime = 0;
|
|
3533
|
-
this.stopTime = 0;
|
|
3534
|
-
this.timeOfUpdatingStepsDone = 0;
|
|
3535
|
-
this.milliSecForOneStep = 0;
|
|
3536
|
-
this.trust = false;
|
|
3537
|
-
this.numberOfDigitsInPercentage = 0;
|
|
3538
3618
|
this.getTime = options.getTime || import_process2.default.hrtime.bigint;
|
|
3539
3619
|
this.threshold = options.threshold || THRESHOLD_DEFAULT;
|
|
3540
3620
|
}
|
|
@@ -3948,8 +4028,19 @@ var dumpJsonSchema = {
|
|
|
3948
4028
|
|
|
3949
4029
|
// dist/lib/utils/conversion-dump.js
|
|
3950
4030
|
var ConversionDump = class {
|
|
4031
|
+
/** Restored/resumed dump indicator */
|
|
4032
|
+
restored = false;
|
|
4033
|
+
/** Conversion options */
|
|
4034
|
+
options;
|
|
4035
|
+
/** Tiles conversion progress status map */
|
|
4036
|
+
tilesConverted;
|
|
4037
|
+
/** Textures formats definitions */
|
|
4038
|
+
textureSetDefinitions;
|
|
4039
|
+
/** Attributes Metadata */
|
|
4040
|
+
attributeMetadataInfo;
|
|
4041
|
+
/** Array of materials definitions */
|
|
4042
|
+
materialDefinitions;
|
|
3951
4043
|
constructor() {
|
|
3952
|
-
this.restored = false;
|
|
3953
4044
|
this.tilesConverted = {};
|
|
3954
4045
|
}
|
|
3955
4046
|
/**
|
|
@@ -4113,27 +4204,38 @@ var ConversionDump = class {
|
|
|
4113
4204
|
for (let i = 0; i < changedRecords.length; i++) {
|
|
4114
4205
|
if (changedRecords[i] && "value" in writeResults[i]) {
|
|
4115
4206
|
const { sourceId, resourceType, outputId } = changedRecords[i];
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4207
|
+
this.updateNodes(sourceId, outputId, resourceType);
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
await this.updateDumpFile();
|
|
4211
|
+
}
|
|
4212
|
+
/**
|
|
4213
|
+
* Update done status for a node
|
|
4214
|
+
* @param sourceId - source resource Id
|
|
4215
|
+
* @param outputId - output node/tile Id
|
|
4216
|
+
* @param resourceType - type of resource
|
|
4217
|
+
* @returns void
|
|
4218
|
+
*/
|
|
4219
|
+
updateNodes(sourceId, outputId, resourceType) {
|
|
4220
|
+
if (!sourceId || !resourceType || !outputId) {
|
|
4221
|
+
return;
|
|
4222
|
+
}
|
|
4223
|
+
for (const node of this.tilesConverted[sourceId].nodes) {
|
|
4224
|
+
if (node.nodeId === outputId && node.progress) {
|
|
4225
|
+
node.progress[resourceType] = true;
|
|
4226
|
+
let done = false;
|
|
4227
|
+
for (const key in node.progress) {
|
|
4228
|
+
done = node.progress[key];
|
|
4229
|
+
if (!done)
|
|
4131
4230
|
break;
|
|
4132
|
-
}
|
|
4133
4231
|
}
|
|
4232
|
+
node.done = done;
|
|
4233
|
+
if (node.done) {
|
|
4234
|
+
delete node.progress;
|
|
4235
|
+
}
|
|
4236
|
+
break;
|
|
4134
4237
|
}
|
|
4135
4238
|
}
|
|
4136
|
-
await this.updateDumpFile();
|
|
4137
4239
|
}
|
|
4138
4240
|
/**
|
|
4139
4241
|
* Update 3d-tiles-converter dump file
|
|
@@ -4184,35 +4286,52 @@ var REFRESH_TOKEN_TIMEOUT = 1800;
|
|
|
4184
4286
|
var CESIUM_DATASET_PREFIX = "https://";
|
|
4185
4287
|
var PROGRESS_PHASE1_COUNT = "phase1-count";
|
|
4186
4288
|
var I3SConverter = class {
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4289
|
+
attributeMetadataInfo;
|
|
4290
|
+
nodePages;
|
|
4291
|
+
options;
|
|
4292
|
+
layers0Path;
|
|
4293
|
+
materialMap;
|
|
4294
|
+
materialDefinitions;
|
|
4295
|
+
geometryMap;
|
|
4296
|
+
geometryConfigs;
|
|
4297
|
+
vertexCounter;
|
|
4298
|
+
layers0;
|
|
4299
|
+
featuresHashArray;
|
|
4300
|
+
refinementCounter;
|
|
4301
|
+
validate;
|
|
4302
|
+
boundingVolumeWarnings = [];
|
|
4303
|
+
conversionStartTime = [0, 0];
|
|
4304
|
+
refreshTokenTime = [0, 0];
|
|
4305
|
+
sourceTileset = null;
|
|
4306
|
+
loadOptions = {
|
|
4307
|
+
_nodeWorkers: true,
|
|
4308
|
+
reuseWorkers: true,
|
|
4309
|
+
useLocalLibraries: true,
|
|
4310
|
+
basis: {
|
|
4311
|
+
format: "rgba32",
|
|
4201
4312
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
}
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4313
|
+
workerUrl: "./modules/textures/dist/basis-worker-node.js"
|
|
4314
|
+
},
|
|
4315
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
4316
|
+
draco: { workerUrl: "./modules/draco/dist/draco-worker-node.js" },
|
|
4317
|
+
fetch: {},
|
|
4318
|
+
modules: {}
|
|
4319
|
+
};
|
|
4320
|
+
geoidHeightModel = null;
|
|
4321
|
+
Loader = import_d_tiles2.Tiles3DLoader;
|
|
4322
|
+
generateTextures;
|
|
4323
|
+
generateBoundingVolumes;
|
|
4324
|
+
layersHasTexture;
|
|
4325
|
+
workerSource = {};
|
|
4326
|
+
writeQueue = new WriteQueue(new ConversionDump());
|
|
4327
|
+
compressList = null;
|
|
4328
|
+
preprocessData = {
|
|
4329
|
+
meshTopologyTypes: /* @__PURE__ */ new Set(),
|
|
4330
|
+
metadataClasses: /* @__PURE__ */ new Set()
|
|
4331
|
+
};
|
|
4332
|
+
progresses = {};
|
|
4333
|
+
conversionDump;
|
|
4334
|
+
constructor() {
|
|
4216
4335
|
this.attributeMetadataInfo = new AttributeMetadataInfo();
|
|
4217
4336
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
4218
4337
|
this.options = {};
|
|
@@ -4252,6 +4371,7 @@ var I3SConverter = class {
|
|
|
4252
4371
|
* @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes
|
|
4253
4372
|
* @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed
|
|
4254
4373
|
*/
|
|
4374
|
+
// eslint-disable-next-line max-statements, complexity
|
|
4255
4375
|
async convert(options) {
|
|
4256
4376
|
if (import_core9.isBrowser) {
|
|
4257
4377
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
@@ -4321,12 +4441,18 @@ var I3SConverter = class {
|
|
|
4321
4441
|
* @returns true - the conversion is possible, false - the tileset's content is not supported
|
|
4322
4442
|
*/
|
|
4323
4443
|
async preprocessConversion() {
|
|
4324
|
-
console.log(
|
|
4444
|
+
console.log("Analyze source tileset");
|
|
4325
4445
|
const sourceRootTile = this.sourceTileset.root;
|
|
4326
|
-
await traverseDatasetWith(
|
|
4446
|
+
await traverseDatasetWith({
|
|
4447
|
+
tile: sourceRootTile,
|
|
4448
|
+
traversalProps: null,
|
|
4449
|
+
processTile: this.analyzeTile.bind(this),
|
|
4450
|
+
postprocessTile: void 0,
|
|
4451
|
+
maxDepth: this.options.maxDepth
|
|
4452
|
+
});
|
|
4327
4453
|
const { meshTopologyTypes, metadataClasses } = this.preprocessData;
|
|
4328
|
-
console.log(
|
|
4329
|
-
console.log(
|
|
4454
|
+
console.log("------------------------------------------------");
|
|
4455
|
+
console.log("Preprocess results:");
|
|
4330
4456
|
console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
|
|
4331
4457
|
console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
|
|
4332
4458
|
if (metadataClasses.size) {
|
|
@@ -4336,10 +4462,10 @@ var I3SConverter = class {
|
|
|
4336
4462
|
}
|
|
4337
4463
|
if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
|
|
4338
4464
|
console.log("The tileset is of unsupported mesh topology types. The conversion will be interrupted.");
|
|
4339
|
-
console.log(
|
|
4465
|
+
console.log("------------------------------------------------");
|
|
4340
4466
|
return false;
|
|
4341
4467
|
}
|
|
4342
|
-
console.log(
|
|
4468
|
+
console.log("------------------------------------------------");
|
|
4343
4469
|
return true;
|
|
4344
4470
|
}
|
|
4345
4471
|
/**
|
|
@@ -4394,7 +4520,7 @@ var I3SConverter = class {
|
|
|
4394
4520
|
console.log(`${result.metadataClass} has been selected`);
|
|
4395
4521
|
} else {
|
|
4396
4522
|
console.log(`A feature metadata class has not been selected. Start the converter with option "--metadata-class". For example, "npx tile-converter ... --metadata-class ${Array.from(metadataClasses)[0]}"`);
|
|
4397
|
-
console.log(
|
|
4523
|
+
console.log("------------------------------------------------");
|
|
4398
4524
|
return false;
|
|
4399
4525
|
}
|
|
4400
4526
|
}
|
|
@@ -4405,6 +4531,7 @@ var I3SConverter = class {
|
|
|
4405
4531
|
* @param outputPath - path to save output data
|
|
4406
4532
|
* @param tilesetName - new tileset path
|
|
4407
4533
|
*/
|
|
4534
|
+
// eslint-disable-next-line max-statements, complexity
|
|
4408
4535
|
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
4409
4536
|
var _a2, _b, _c;
|
|
4410
4537
|
const tilesetPath = (0, import_path7.join)(`${outputPath}`, `${tilesetName}`);
|
|
@@ -4451,10 +4578,16 @@ var I3SConverter = class {
|
|
|
4451
4578
|
});
|
|
4452
4579
|
this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
|
|
4453
4580
|
const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
4454
|
-
await traverseDatasetWith(
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4581
|
+
await traverseDatasetWith({
|
|
4582
|
+
tile: sourceRootTile,
|
|
4583
|
+
traversalProps: {
|
|
4584
|
+
transform: new import_core10.Matrix4(sourceRootTile.transform),
|
|
4585
|
+
parentNodes: [rootNode]
|
|
4586
|
+
},
|
|
4587
|
+
processTile: this.convertTile.bind(this),
|
|
4588
|
+
postprocessTile: this.finalizeTile.bind(this),
|
|
4589
|
+
maxDepth: this.options.maxDepth
|
|
4590
|
+
});
|
|
4458
4591
|
this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
|
|
4459
4592
|
console.log(`[finalizing conversion]`);
|
|
4460
4593
|
this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
|
|
@@ -4558,6 +4691,7 @@ var I3SConverter = class {
|
|
|
4558
4691
|
* @param traversalProps - traversal properties calculated recursively
|
|
4559
4692
|
* @returns - traversal properties for the child tiles
|
|
4560
4693
|
*/
|
|
4694
|
+
// eslint-disable-next-line max-statements
|
|
4561
4695
|
async convertTile(sourceTile, traversalProps) {
|
|
4562
4696
|
const isTileset = isNestedTileset(sourceTile);
|
|
4563
4697
|
if (isTileset || sourceTile.type === "empty") {
|
|
@@ -4659,7 +4793,7 @@ var I3SConverter = class {
|
|
|
4659
4793
|
await this._updateTilesetOptions();
|
|
4660
4794
|
if (this.conversionDump.restored && sourceTile.id && this.conversionDump.isFileConversionComplete(sourceTile.id)) {
|
|
4661
4795
|
const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
|
|
4662
|
-
|
|
4796
|
+
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
4663
4797
|
const nodes = [];
|
|
4664
4798
|
for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
|
|
4665
4799
|
const { node } = await this._generateNodeIndexDocument(boundingVolumes, {
|
|
@@ -4682,6 +4816,7 @@ var I3SConverter = class {
|
|
|
4682
4816
|
* transform of all parent tiles and transform of the current tile
|
|
4683
4817
|
* @param level - tree level
|
|
4684
4818
|
*/
|
|
4819
|
+
// eslint-disable-next-line max-statements
|
|
4685
4820
|
async _createNode(parentNode, sourceTile, transformationMatrix) {
|
|
4686
4821
|
var _a2;
|
|
4687
4822
|
this._checkAddRefinementTypeForTile(sourceTile);
|
|
@@ -4693,7 +4828,7 @@ var I3SConverter = class {
|
|
|
4693
4828
|
console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);
|
|
4694
4829
|
}
|
|
4695
4830
|
const sourceBoundingVolume = (0, import_tiles.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
|
|
4696
|
-
|
|
4831
|
+
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
4697
4832
|
const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
|
|
4698
4833
|
this.createAttributeStorageInfo(tileContent, propertyTable);
|
|
4699
4834
|
this.conversionDump.attributeMetadataInfo = {
|
|
@@ -4701,7 +4836,14 @@ var I3SConverter = class {
|
|
|
4701
4836
|
fields: this.attributeMetadataInfo.fields,
|
|
4702
4837
|
popupInfo: this.attributeMetadataInfo.popupInfo
|
|
4703
4838
|
};
|
|
4704
|
-
const resourcesData = await this._convertResources(
|
|
4839
|
+
const resourcesData = await this._convertResources({
|
|
4840
|
+
sourceTile,
|
|
4841
|
+
transformationMatrix,
|
|
4842
|
+
boundingVolume: sourceBoundingVolume,
|
|
4843
|
+
tileContent,
|
|
4844
|
+
parentId: parentNode.inPageId,
|
|
4845
|
+
propertyTable
|
|
4846
|
+
});
|
|
4705
4847
|
const nodes = [];
|
|
4706
4848
|
const nodeIds = [];
|
|
4707
4849
|
const nodesInPage = [];
|
|
@@ -4759,7 +4901,7 @@ var I3SConverter = class {
|
|
|
4759
4901
|
* @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA
|
|
4760
4902
|
* @returns - converted node resources
|
|
4761
4903
|
*/
|
|
4762
|
-
async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
|
|
4904
|
+
async _convertResources({ sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable }) {
|
|
4763
4905
|
if (!this.isContentSupported(sourceTile) || !tileContent) {
|
|
4764
4906
|
return null;
|
|
4765
4907
|
}
|
|
@@ -4768,7 +4910,21 @@ var I3SConverter = class {
|
|
|
4768
4910
|
halfSize: [],
|
|
4769
4911
|
quaternion: []
|
|
4770
4912
|
};
|
|
4771
|
-
const resourcesData = await convertB3dmToI3sGeometry(
|
|
4913
|
+
const resourcesData = await convertB3dmToI3sGeometry({
|
|
4914
|
+
tileContent,
|
|
4915
|
+
tileTransform: transformationMatrix,
|
|
4916
|
+
tileBoundingVolume: boundingVolume,
|
|
4917
|
+
addNodeToNodePage: async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index,
|
|
4918
|
+
propertyTable,
|
|
4919
|
+
featuresHashArray: this.featuresHashArray,
|
|
4920
|
+
attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
|
|
4921
|
+
draco: this.options.draco,
|
|
4922
|
+
generateBoundingVolumes: this.generateBoundingVolumes,
|
|
4923
|
+
shouldMergeMaterials: this.options.mergeMaterials,
|
|
4924
|
+
geoidHeightModel: this.geoidHeightModel,
|
|
4925
|
+
libraries: this.loadOptions.modules,
|
|
4926
|
+
metadataClass: this.options.metadataClass
|
|
4927
|
+
});
|
|
4772
4928
|
return resourcesData;
|
|
4773
4929
|
}
|
|
4774
4930
|
/**
|
|
@@ -4786,6 +4942,7 @@ var I3SConverter = class {
|
|
|
4786
4942
|
* @param resources.geometry - Uint8Array with geometry attributes
|
|
4787
4943
|
* @return the node object in node pages
|
|
4788
4944
|
*/
|
|
4945
|
+
// eslint-disable-next-line max-statements, complexity
|
|
4789
4946
|
async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
4790
4947
|
const { vertexCount, featureCount, geometry, hasUvRegions } = resources;
|
|
4791
4948
|
const nodeInPage = {
|
|
@@ -4808,7 +4965,7 @@ var I3SConverter = class {
|
|
|
4808
4965
|
}
|
|
4809
4966
|
};
|
|
4810
4967
|
}
|
|
4811
|
-
|
|
4968
|
+
const nodeId = "nodeId" in resources ? resources.nodeId : void 0;
|
|
4812
4969
|
let node;
|
|
4813
4970
|
if (!nodeId) {
|
|
4814
4971
|
node = await this.nodePages.push(nodeInPage, parentId);
|
|
@@ -4857,8 +5014,22 @@ var I3SConverter = class {
|
|
|
4857
5014
|
const { geometry: geometryBuffer, compressedGeometry, texture, sharedResources, attributes } = resources;
|
|
4858
5015
|
const childPath = (0, import_path7.join)(this.layers0Path, "nodes", nodePath);
|
|
4859
5016
|
const slpkChildPath = (0, import_path7.join)("nodes", nodePath);
|
|
4860
|
-
await this._writeGeometries(
|
|
4861
|
-
|
|
5017
|
+
await this._writeGeometries({
|
|
5018
|
+
geometryBuffer,
|
|
5019
|
+
compressedGeometry,
|
|
5020
|
+
childPath,
|
|
5021
|
+
slpkChildPath,
|
|
5022
|
+
sourceId: sourceTile.id || "",
|
|
5023
|
+
nodeId: parseInt(nodePath)
|
|
5024
|
+
});
|
|
5025
|
+
await this._writeShared({
|
|
5026
|
+
sharedResources,
|
|
5027
|
+
childPath,
|
|
5028
|
+
slpkChildPath,
|
|
5029
|
+
nodePath,
|
|
5030
|
+
sourceId: sourceTile.id || "",
|
|
5031
|
+
nodeId: parseInt(nodePath)
|
|
5032
|
+
});
|
|
4862
5033
|
await this._writeTexture(texture, childPath, slpkChildPath, sourceTile.id || "", parseInt(nodePath));
|
|
4863
5034
|
await this._writeAttributes(attributes, childPath, slpkChildPath, sourceTile.id || "", parseInt(nodePath));
|
|
4864
5035
|
}
|
|
@@ -4871,7 +5042,10 @@ var I3SConverter = class {
|
|
|
4871
5042
|
* @param sourceId - source filename
|
|
4872
5043
|
* @param nodeId - nodeId of a converted node for the writing
|
|
4873
5044
|
*/
|
|
4874
|
-
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
|
|
5045
|
+
async _writeGeometries({ geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId }) {
|
|
5046
|
+
if (!geometryBuffer) {
|
|
5047
|
+
return;
|
|
5048
|
+
}
|
|
4875
5049
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
|
|
4876
5050
|
if (this.options.slpk) {
|
|
4877
5051
|
const slpkGeometryPath = (0, import_path7.join)(childPath, "geometries");
|
|
@@ -4891,7 +5065,7 @@ var I3SConverter = class {
|
|
|
4891
5065
|
writePromise: () => writeFile(geometryPath, geometryBuffer, "index.bin")
|
|
4892
5066
|
});
|
|
4893
5067
|
}
|
|
4894
|
-
if (this.options.draco) {
|
|
5068
|
+
if (this.options.draco && compressedGeometry) {
|
|
4895
5069
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
|
|
4896
5070
|
if (this.options.slpk) {
|
|
4897
5071
|
const slpkCompressedGeometryPath = (0, import_path7.join)(childPath, "geometries");
|
|
@@ -4922,7 +5096,7 @@ var I3SConverter = class {
|
|
|
4922
5096
|
* @param sourceId - source filename
|
|
4923
5097
|
* @param nodeId - nodeId of a converted node for the writing
|
|
4924
5098
|
*/
|
|
4925
|
-
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
|
|
5099
|
+
async _writeShared({ sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId }) {
|
|
4926
5100
|
if (!sharedResources) {
|
|
4927
5101
|
return;
|
|
4928
5102
|
}
|
|
@@ -4957,6 +5131,7 @@ var I3SConverter = class {
|
|
|
4957
5131
|
* @param sourceId - source filename
|
|
4958
5132
|
* @param nodeId - nodeId of a converted node for the writing
|
|
4959
5133
|
*/
|
|
5134
|
+
// eslint-disable-next-line max-statements
|
|
4960
5135
|
async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
|
|
4961
5136
|
if (texture) {
|
|
4962
5137
|
const format = this._getFormatByMimeType(texture == null ? void 0 : texture.mimeType);
|
|
@@ -4967,7 +5142,15 @@ var I3SConverter = class {
|
|
|
4967
5142
|
case "png": {
|
|
4968
5143
|
formats.push({ name: "0", format });
|
|
4969
5144
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
|
|
4970
|
-
await this.writeTextureFile(
|
|
5145
|
+
await this.writeTextureFile({
|
|
5146
|
+
textureData,
|
|
5147
|
+
name: "0",
|
|
5148
|
+
format,
|
|
5149
|
+
childPath,
|
|
5150
|
+
slpkChildPath,
|
|
5151
|
+
sourceId,
|
|
5152
|
+
nodeId
|
|
5153
|
+
});
|
|
4971
5154
|
if (this.generateTextures) {
|
|
4972
5155
|
formats.push({ name: "1", format: "ktx2" });
|
|
4973
5156
|
const copyArrayBuffer = texture.image.data.subarray();
|
|
@@ -4988,21 +5171,47 @@ var I3SConverter = class {
|
|
|
4988
5171
|
}
|
|
4989
5172
|
);
|
|
4990
5173
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/ktx2`, false);
|
|
4991
|
-
await this.writeTextureFile(
|
|
5174
|
+
await this.writeTextureFile({
|
|
5175
|
+
textureData: ktx2TextureData,
|
|
5176
|
+
name: "1",
|
|
5177
|
+
format: "ktx2",
|
|
5178
|
+
childPath,
|
|
5179
|
+
slpkChildPath,
|
|
5180
|
+
sourceId,
|
|
5181
|
+
nodeId
|
|
5182
|
+
});
|
|
4992
5183
|
}
|
|
4993
5184
|
break;
|
|
4994
5185
|
}
|
|
4995
5186
|
case "ktx2": {
|
|
4996
5187
|
formats.push({ name: "1", format });
|
|
4997
5188
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
|
|
4998
|
-
await this.writeTextureFile(
|
|
5189
|
+
await this.writeTextureFile({
|
|
5190
|
+
textureData,
|
|
5191
|
+
name: "1",
|
|
5192
|
+
format,
|
|
5193
|
+
childPath,
|
|
5194
|
+
slpkChildPath,
|
|
5195
|
+
sourceId,
|
|
5196
|
+
nodeId
|
|
5197
|
+
});
|
|
4999
5198
|
if (this.generateTextures) {
|
|
5000
5199
|
formats.push({ name: "0", format: "jpg" });
|
|
5001
5200
|
const decodedFromKTX2TextureData = (0, import_core9.encode)(texture.image.data[0], import_images.ImageWriter);
|
|
5002
5201
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/jpg`, false);
|
|
5003
|
-
await this.writeTextureFile(
|
|
5202
|
+
await this.writeTextureFile({
|
|
5203
|
+
textureData: decodedFromKTX2TextureData,
|
|
5204
|
+
name: "0",
|
|
5205
|
+
format: "jpg",
|
|
5206
|
+
childPath,
|
|
5207
|
+
slpkChildPath,
|
|
5208
|
+
sourceId,
|
|
5209
|
+
nodeId
|
|
5210
|
+
});
|
|
5004
5211
|
}
|
|
5212
|
+
break;
|
|
5005
5213
|
}
|
|
5214
|
+
default:
|
|
5006
5215
|
}
|
|
5007
5216
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
5008
5217
|
this.layers0.textureSetDefinitions.push({ formats });
|
|
@@ -5023,7 +5232,7 @@ var I3SConverter = class {
|
|
|
5023
5232
|
* @param sourceId
|
|
5024
5233
|
* @param nodeId
|
|
5025
5234
|
*/
|
|
5026
|
-
async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
|
|
5235
|
+
async writeTextureFile({ textureData, name, format, childPath, slpkChildPath, sourceId, nodeId }) {
|
|
5027
5236
|
if (this.options.slpk) {
|
|
5028
5237
|
const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
|
|
5029
5238
|
const compress = false;
|
|
@@ -5155,13 +5364,13 @@ var I3SConverter = class {
|
|
|
5155
5364
|
const filesSize = await calculateFilesSize(params);
|
|
5156
5365
|
const diff = import_process4.default.hrtime(this.conversionStartTime);
|
|
5157
5366
|
const conversionTime = timeConverter(diff);
|
|
5158
|
-
console.log(
|
|
5367
|
+
console.log("------------------------------------------------");
|
|
5159
5368
|
console.log(`Finishing conversion of ${_3D_TILES}`);
|
|
5160
5369
|
console.log(`Total conversion time: ${conversionTime}`);
|
|
5161
|
-
console.log(
|
|
5162
|
-
console.log(
|
|
5163
|
-
console.log(
|
|
5164
|
-
console.log(
|
|
5370
|
+
console.log("Vertex count: ", this.vertexCounter);
|
|
5371
|
+
console.log("File(s) size: ", filesSize, " bytes");
|
|
5372
|
+
console.log('Percentage of tiles with "ADD" refinement type:', addRefinementPercentage, "%");
|
|
5373
|
+
console.log("------------------------------------------------");
|
|
5165
5374
|
}
|
|
5166
5375
|
/**
|
|
5167
5376
|
* Fetch preload options for ION tileset
|
|
@@ -5199,7 +5408,7 @@ var I3SConverter = class {
|
|
|
5199
5408
|
* @param tile
|
|
5200
5409
|
*/
|
|
5201
5410
|
_checkAddRefinementTypeForTile(tile) {
|
|
5202
|
-
const ADD_TILE_REFINEMENT =
|
|
5411
|
+
const ADD_TILE_REFINEMENT = import_tiles.TILE_REFINEMENT.ADD;
|
|
5203
5412
|
if (tile.refine === ADD_TILE_REFINEMENT) {
|
|
5204
5413
|
this.refinementCounter.tilesWithAddRefineCount += 1;
|
|
5205
5414
|
console.warn('This tile uses "ADD" type of refinement');
|
|
@@ -5327,6 +5536,9 @@ var KHR_MATERIALS_UNLIT = "KHR_materials_unlit";
|
|
|
5327
5536
|
var METALLIC_FACTOR_DEFAULT = 1;
|
|
5328
5537
|
var ROUGHNESS_FACTOR_DEFAULT = 1;
|
|
5329
5538
|
var B3dmConverter = class {
|
|
5539
|
+
// @ts-expect-error
|
|
5540
|
+
rtcCenter;
|
|
5541
|
+
i3sTile;
|
|
5330
5542
|
/**
|
|
5331
5543
|
* The starter of content conversion
|
|
5332
5544
|
* @param i3sTile - Tile3D instance for I3S node
|
|
@@ -5347,6 +5559,7 @@ var B3dmConverter = class {
|
|
|
5347
5559
|
* @param i3sTile - Tile3D instance for I3S node
|
|
5348
5560
|
* @returns - encoded glb content
|
|
5349
5561
|
*/
|
|
5562
|
+
// eslint-disable-next-line max-statements
|
|
5350
5563
|
async buildGLTF(i3sAttributesData, featureAttributes) {
|
|
5351
5564
|
const { tileContent, textureFormat, box } = i3sAttributesData;
|
|
5352
5565
|
const { material, attributes, indices: originalIndices, modelMatrix } = tileContent;
|
|
@@ -5613,21 +5826,18 @@ var loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions, slpkF
|
|
|
5613
5826
|
};
|
|
5614
5827
|
async function openSLPK(url) {
|
|
5615
5828
|
const slpkUrlParts = url.split(".slpk");
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
const
|
|
5619
|
-
const
|
|
5620
|
-
const archive = await (0, import_i3s.parseSLPKArchive)(fileProvider, void 0, slpkFileName2);
|
|
5829
|
+
if (slpkUrlParts.length === 2) {
|
|
5830
|
+
const slpkFileName = `${slpkUrlParts[0]}.slpk`;
|
|
5831
|
+
const fileProvider = new import_loader_utils5.FileHandleFile(slpkFileName);
|
|
5832
|
+
const archive = await (0, import_i3s.parseSLPKArchive)(fileProvider, void 0, slpkFileName);
|
|
5621
5833
|
const fileSystem = new import_zip3.ZipFileSystem(archive);
|
|
5622
5834
|
return fileSystem;
|
|
5623
5835
|
}
|
|
5624
5836
|
return null;
|
|
5625
5837
|
}
|
|
5626
5838
|
async function loadFromArchive2(url, loader, loadOptions, fileSystem) {
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
const { internalFileName } = slpkUrlParts;
|
|
5630
|
-
const content = await (0, import_core14.load)(internalFileName, loader, {
|
|
5839
|
+
if (fileSystem !== null) {
|
|
5840
|
+
const content = await (0, import_core14.load)(url, loader, {
|
|
5631
5841
|
...loadOptions,
|
|
5632
5842
|
fetch: fileSystem.fetch.bind(fileSystem)
|
|
5633
5843
|
});
|
|
@@ -5635,18 +5845,6 @@ async function loadFromArchive2(url, loader, loadOptions, fileSystem) {
|
|
|
5635
5845
|
}
|
|
5636
5846
|
return await (0, import_core14.load)(url, loader, loadOptions);
|
|
5637
5847
|
}
|
|
5638
|
-
function getSlpkUrlParts(url) {
|
|
5639
|
-
const slpkUrlParts = url.split(".slpk");
|
|
5640
|
-
let result;
|
|
5641
|
-
if (slpkUrlParts.length === 1) {
|
|
5642
|
-
result = null;
|
|
5643
|
-
} else if (slpkUrlParts.length === 2) {
|
|
5644
|
-
result = { slpkFileName: `${slpkUrlParts[0]}.slpk`, internalFileName: slpkUrlParts[1].slice(1) };
|
|
5645
|
-
} else {
|
|
5646
|
-
throw new Error("Unexpected URL format");
|
|
5647
|
-
}
|
|
5648
|
-
return result;
|
|
5649
|
-
}
|
|
5650
5848
|
async function getNodeCount(fileSystem) {
|
|
5651
5849
|
if (!(fileSystem == null ? void 0 : fileSystem.fileProvider)) {
|
|
5652
5850
|
return 0;
|
|
@@ -5665,20 +5863,29 @@ async function getNodeCount(fileSystem) {
|
|
|
5665
5863
|
// dist/3d-tiles-converter/3d-tiles-converter.js
|
|
5666
5864
|
var I3S = "I3S";
|
|
5667
5865
|
var Tiles3DConverter = class {
|
|
5866
|
+
options;
|
|
5867
|
+
tilesetPath;
|
|
5868
|
+
vertexCounter;
|
|
5869
|
+
conversionStartTime;
|
|
5870
|
+
geoidHeightModel;
|
|
5871
|
+
sourceTileset;
|
|
5872
|
+
attributeStorageInfo;
|
|
5873
|
+
workerSource = {};
|
|
5874
|
+
slpkFilesystem = null;
|
|
5875
|
+
loaderOptions = {
|
|
5876
|
+
_nodeWorkers: true,
|
|
5877
|
+
reuseWorkers: true,
|
|
5878
|
+
// TODO: converter freezes in the end because of i3s-content-worker
|
|
5879
|
+
worker: false,
|
|
5880
|
+
i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
|
|
5881
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
5882
|
+
"i3s-content": {
|
|
5883
|
+
workerUrl: "./modules/i3s/dist/i3s-content-worker-node.js"
|
|
5884
|
+
}
|
|
5885
|
+
};
|
|
5886
|
+
conversionDump;
|
|
5887
|
+
progress;
|
|
5668
5888
|
constructor() {
|
|
5669
|
-
this.workerSource = {};
|
|
5670
|
-
this.slpkFilesystem = null;
|
|
5671
|
-
this.loaderOptions = {
|
|
5672
|
-
_nodeWorkers: true,
|
|
5673
|
-
reuseWorkers: true,
|
|
5674
|
-
// TODO: converter freezes in the end because of i3s-content-worker
|
|
5675
|
-
worker: false,
|
|
5676
|
-
i3s: { coordinateSystem: import_i3s2.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
|
|
5677
|
-
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
5678
|
-
"i3s-content": {
|
|
5679
|
-
workerUrl: "./modules/i3s/dist/i3s-content-worker-node.js"
|
|
5680
|
-
}
|
|
5681
|
-
};
|
|
5682
5889
|
this.options = {};
|
|
5683
5890
|
this.tilesetPath = "";
|
|
5684
5891
|
this.vertexCounter = 0;
|
|
@@ -5699,6 +5906,7 @@ var Tiles3DConverter = class {
|
|
|
5699
5906
|
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
5700
5907
|
* @param options.maxDepth The max tree depth of conversion
|
|
5701
5908
|
*/
|
|
5909
|
+
// eslint-disable-next-line complexity, max-statements
|
|
5702
5910
|
async convert(options) {
|
|
5703
5911
|
var _a2;
|
|
5704
5912
|
if (import_core15.isBrowser) {
|
|
@@ -5716,7 +5924,7 @@ var Tiles3DConverter = class {
|
|
|
5716
5924
|
if (analyze || this.slpkFilesystem) {
|
|
5717
5925
|
preprocessResult = await this.preprocessConversion();
|
|
5718
5926
|
if (!preprocessResult || analyze) {
|
|
5719
|
-
return;
|
|
5927
|
+
return void 0;
|
|
5720
5928
|
}
|
|
5721
5929
|
}
|
|
5722
5930
|
this.progress.startMonitoring();
|
|
@@ -5726,7 +5934,7 @@ var Tiles3DConverter = class {
|
|
|
5726
5934
|
i3s: { ...this.loaderOptions.i3s, isTileset: true }
|
|
5727
5935
|
}, this.slpkFilesystem);
|
|
5728
5936
|
if (!this.sourceTileset) {
|
|
5729
|
-
return;
|
|
5937
|
+
return void 0;
|
|
5730
5938
|
}
|
|
5731
5939
|
const rootNode = (_a2 = this.sourceTileset) == null ? void 0 : _a2.root;
|
|
5732
5940
|
if (!rootNode.obb) {
|
|
@@ -5772,28 +5980,29 @@ var Tiles3DConverter = class {
|
|
|
5772
5980
|
}
|
|
5773
5981
|
const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
|
|
5774
5982
|
workerFarm.destroy();
|
|
5983
|
+
return void 0;
|
|
5775
5984
|
}
|
|
5776
5985
|
/**
|
|
5777
5986
|
* Preprocess stage of the tile converter. Calculate number of nodes
|
|
5778
5987
|
* @returns true - the conversion is possible, false - the tileset's content is not supported
|
|
5779
5988
|
*/
|
|
5780
5989
|
async preprocessConversion() {
|
|
5781
|
-
console.log(
|
|
5990
|
+
console.log("Analyze source layer");
|
|
5782
5991
|
const nodesCount = await getNodeCount(this.slpkFilesystem);
|
|
5783
5992
|
this.progress.stepsTotal = nodesCount;
|
|
5784
|
-
console.log(
|
|
5785
|
-
console.log(
|
|
5993
|
+
console.log("------------------------------------------------");
|
|
5994
|
+
console.log("Preprocess results:");
|
|
5786
5995
|
if (this.slpkFilesystem) {
|
|
5787
5996
|
console.log(`Node count: ${nodesCount}`);
|
|
5788
5997
|
if (nodesCount === 0) {
|
|
5789
5998
|
console.log("Node count is 0. The conversion will be interrupted.");
|
|
5790
|
-
console.log(
|
|
5999
|
+
console.log("------------------------------------------------");
|
|
5791
6000
|
return false;
|
|
5792
6001
|
}
|
|
5793
6002
|
} else {
|
|
5794
|
-
console.log(
|
|
6003
|
+
console.log("Node count cannot be calculated for the remote dataset");
|
|
5795
6004
|
}
|
|
5796
|
-
console.log(
|
|
6005
|
+
console.log("------------------------------------------------");
|
|
5797
6006
|
return true;
|
|
5798
6007
|
}
|
|
5799
6008
|
/**
|
|
@@ -5803,6 +6012,7 @@ var Tiles3DConverter = class {
|
|
|
5803
6012
|
* @param level a current level of a tree depth
|
|
5804
6013
|
* @param childNodeInfo child node to convert
|
|
5805
6014
|
*/
|
|
6015
|
+
// eslint-disable-next-line complexity, max-statements
|
|
5806
6016
|
async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
|
|
5807
6017
|
let nextParentNode = parentNode;
|
|
5808
6018
|
const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
|