@loaders.gl/tile-converter 4.2.0-alpha.1 → 4.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +19 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +121 -30
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +28 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +63 -4
- package/dist/3d-tiles-converter/helpers/load-i3s.js.map +1 -1
- package/dist/converter-cli.js +30 -21
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +137 -130
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js +22 -2
- package/dist/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +1 -1
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +86 -86
- package/dist/index.cjs +590 -70
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +463 -0
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +1 -0
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +463 -0
- package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +1 -0
- package/dist/lib/utils/conversion-dump.d.ts +12 -5
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +44 -24
- package/dist/lib/utils/conversion-dump.js.map +1 -1
- package/dist/lib/utils/file-utils.d.ts +6 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +7 -0
- package/dist/lib/utils/file-utils.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/package.json +15 -14
- package/src/3d-tiles-converter/3d-tiles-converter.ts +159 -34
- package/src/3d-tiles-converter/helpers/load-i3s.ts +106 -7
- package/src/converter-cli.ts +44 -29
- package/src/i3s-converter/helpers/load-3d-tiles.ts +52 -2
- package/src/i3s-converter/i3s-converter.ts +1 -1
- package/src/lib/json-schemas/conversion-dump-json-schema.ts +285 -0
- package/src/lib/utils/conversion-dump.ts +79 -27
- package/src/lib/utils/file-utils.ts +13 -0
package/dist/index.cjs
CHANGED
|
@@ -261,7 +261,7 @@ var import_core9 = require("@loaders.gl/core");
|
|
|
261
261
|
var import_d_tiles2 = require("@loaders.gl/3d-tiles");
|
|
262
262
|
var import_path7 = require("path");
|
|
263
263
|
var import_uuid4 = require("uuid");
|
|
264
|
-
var
|
|
264
|
+
var import_process4 = __toESM(require("process"), 1);
|
|
265
265
|
var import_json_map_transform8 = __toESM(require("json-map-transform"), 1);
|
|
266
266
|
var import_md52 = __toESM(require("md5"), 1);
|
|
267
267
|
|
|
@@ -393,6 +393,13 @@ function removeFile(path) {
|
|
|
393
393
|
function getAbsoluteFilePath(filePath) {
|
|
394
394
|
return (0, import_path.isAbsolute)(filePath) ? filePath : (0, import_path.join)(process.cwd(), filePath);
|
|
395
395
|
}
|
|
396
|
+
async function renameFile(oldPath, newPath) {
|
|
397
|
+
try {
|
|
398
|
+
await import_fs2.promises.rename(oldPath, newPath);
|
|
399
|
+
} catch (err) {
|
|
400
|
+
console.log("Can't rename file", err);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
396
403
|
|
|
397
404
|
// src/i3s-converter/helpers/node-pages.ts
|
|
398
405
|
var NodePages = class {
|
|
@@ -3559,6 +3566,8 @@ var NodeIndexDocument = class {
|
|
|
3559
3566
|
// src/i3s-converter/helpers/load-3d-tiles.ts
|
|
3560
3567
|
var import_d_tiles = require("@loaders.gl/3d-tiles");
|
|
3561
3568
|
var import_core7 = require("@loaders.gl/core");
|
|
3569
|
+
var import_loader_utils4 = require("@loaders.gl/loader-utils");
|
|
3570
|
+
var import_zip = require("@loaders.gl/zip");
|
|
3562
3571
|
var loadNestedTileset = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
|
|
3563
3572
|
const isTileset = isNestedTileset(sourceTile);
|
|
3564
3573
|
if (!sourceTileset || !sourceTile.contentUrl || !isTileset) {
|
|
@@ -3616,7 +3625,10 @@ async function loadFromArchive(url, loader, loadOptions) {
|
|
|
3616
3625
|
}
|
|
3617
3626
|
if (filename) {
|
|
3618
3627
|
const tz3Path = `${tz3UrlParts[0]}.3tz`;
|
|
3619
|
-
const
|
|
3628
|
+
const fileProvider = new import_loader_utils4.FileHandleFile(tz3Path);
|
|
3629
|
+
const hashTable = await loadHashTable(fileProvider);
|
|
3630
|
+
const archive = new import_d_tiles.Tiles3DArchive(fileProvider, hashTable, tz3Path);
|
|
3631
|
+
const fileSystem = new import_zip.ZipFileSystem(archive);
|
|
3620
3632
|
const content = await (0, import_core7.load)(filename, loader, {
|
|
3621
3633
|
...loadOptions,
|
|
3622
3634
|
fetch: fileSystem.fetch.bind(fileSystem)
|
|
@@ -3629,6 +3641,27 @@ async function loadFromArchive(url, loader, loadOptions) {
|
|
|
3629
3641
|
function isNestedTileset(tile) {
|
|
3630
3642
|
return (tile == null ? void 0 : tile.type) === "json" || (tile == null ? void 0 : tile.type) === "3tz";
|
|
3631
3643
|
}
|
|
3644
|
+
async function loadHashTable(fileProvider) {
|
|
3645
|
+
let hashTable;
|
|
3646
|
+
const hashCDOffset = await (0, import_zip.searchFromTheEnd)(fileProvider, import_zip.CD_HEADER_SIGNATURE);
|
|
3647
|
+
const cdFileHeader = await (0, import_zip.parseZipCDFileHeader)(hashCDOffset, fileProvider);
|
|
3648
|
+
if ((cdFileHeader == null ? void 0 : cdFileHeader.fileName) === "@3dtilesIndex1@") {
|
|
3649
|
+
const localFileHeader = await (0, import_zip.parseZipLocalFileHeader)(
|
|
3650
|
+
cdFileHeader.localHeaderOffset,
|
|
3651
|
+
fileProvider
|
|
3652
|
+
);
|
|
3653
|
+
if (!localFileHeader) {
|
|
3654
|
+
throw new Error("corrupted 3tz");
|
|
3655
|
+
}
|
|
3656
|
+
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
3657
|
+
const hashFile = await fileProvider.slice(
|
|
3658
|
+
fileDataOffset,
|
|
3659
|
+
fileDataOffset + localFileHeader.compressedSize
|
|
3660
|
+
);
|
|
3661
|
+
hashTable = (0, import_zip.parseHashTable)(hashFile);
|
|
3662
|
+
}
|
|
3663
|
+
return hashTable;
|
|
3664
|
+
}
|
|
3632
3665
|
|
|
3633
3666
|
// src/i3s-converter/i3s-converter.ts
|
|
3634
3667
|
var import_core10 = require("@math.gl/core");
|
|
@@ -3875,17 +3908,306 @@ var Progress = class {
|
|
|
3875
3908
|
};
|
|
3876
3909
|
|
|
3877
3910
|
// src/i3s-converter/i3s-converter.ts
|
|
3878
|
-
var
|
|
3911
|
+
var import_zip2 = require("@loaders.gl/zip");
|
|
3879
3912
|
|
|
3880
3913
|
// src/lib/utils/conversion-dump.ts
|
|
3881
3914
|
var import_util = require("util");
|
|
3882
3915
|
var import_path6 = require("path");
|
|
3916
|
+
var import_process3 = __toESM(require("process"), 1);
|
|
3917
|
+
var import_ajv = __toESM(require("ajv"), 1);
|
|
3918
|
+
|
|
3919
|
+
// src/lib/json-schemas/conversion-dump-json-schema.ts
|
|
3920
|
+
var dumpJsonSchema = {
|
|
3921
|
+
type: "object",
|
|
3922
|
+
properties: {
|
|
3923
|
+
options: {
|
|
3924
|
+
type: "object",
|
|
3925
|
+
properties: {
|
|
3926
|
+
inputUrl: { type: "string" },
|
|
3927
|
+
outputPath: { type: "string" },
|
|
3928
|
+
tilesetName: { type: "string" },
|
|
3929
|
+
maxDepth: { type: "number" },
|
|
3930
|
+
slpk: { type: "boolean" },
|
|
3931
|
+
egmFilePath: { type: "string" },
|
|
3932
|
+
token: { type: "string" },
|
|
3933
|
+
draco: { type: "boolean" },
|
|
3934
|
+
mergeMaterials: { type: "boolean" },
|
|
3935
|
+
generateTextures: { type: "boolean" },
|
|
3936
|
+
generateBoundingVolumes: { type: "boolean" },
|
|
3937
|
+
metadataClass: { type: "string" },
|
|
3938
|
+
analyze: { type: "boolean" }
|
|
3939
|
+
},
|
|
3940
|
+
required: ["inputUrl", "outputPath", "tilesetName"]
|
|
3941
|
+
},
|
|
3942
|
+
tilesConverted: {
|
|
3943
|
+
type: "object",
|
|
3944
|
+
patternProperties: {
|
|
3945
|
+
".*": {
|
|
3946
|
+
type: "object",
|
|
3947
|
+
properties: {
|
|
3948
|
+
nodes: {
|
|
3949
|
+
type: "array",
|
|
3950
|
+
items: {
|
|
3951
|
+
type: "object",
|
|
3952
|
+
properties: {
|
|
3953
|
+
nodeId: { type: ["number", "string"] },
|
|
3954
|
+
done: { type: "boolean" },
|
|
3955
|
+
progress: { type: "object", patternProperties: { ".*": { type: "boolean" } } },
|
|
3956
|
+
dumpMetadata: {
|
|
3957
|
+
type: "object",
|
|
3958
|
+
properties: {
|
|
3959
|
+
boundingVolumes: {
|
|
3960
|
+
type: ["object", "null"],
|
|
3961
|
+
properties: {
|
|
3962
|
+
mbs: {
|
|
3963
|
+
type: "array",
|
|
3964
|
+
minItems: 4,
|
|
3965
|
+
maxItems: 4,
|
|
3966
|
+
items: { type: "number" }
|
|
3967
|
+
},
|
|
3968
|
+
obb: {
|
|
3969
|
+
type: "object",
|
|
3970
|
+
properties: {
|
|
3971
|
+
center: {
|
|
3972
|
+
type: "array",
|
|
3973
|
+
minItems: 3,
|
|
3974
|
+
maxItems: 3,
|
|
3975
|
+
items: { type: "number" }
|
|
3976
|
+
},
|
|
3977
|
+
halfSize: {
|
|
3978
|
+
type: "array",
|
|
3979
|
+
minItems: 3,
|
|
3980
|
+
maxItems: 3,
|
|
3981
|
+
items: { type: "number" }
|
|
3982
|
+
},
|
|
3983
|
+
quaternion: {
|
|
3984
|
+
type: "array",
|
|
3985
|
+
minItems: 4,
|
|
3986
|
+
maxItems: 4,
|
|
3987
|
+
items: { type: "number" }
|
|
3988
|
+
}
|
|
3989
|
+
},
|
|
3990
|
+
required: ["center", "halfSize", "quaternion"]
|
|
3991
|
+
}
|
|
3992
|
+
},
|
|
3993
|
+
required: ["mbs", "obb"]
|
|
3994
|
+
},
|
|
3995
|
+
attributesCount: { type: "number" },
|
|
3996
|
+
featureCount: { type: "number" },
|
|
3997
|
+
geometry: { type: "boolean" },
|
|
3998
|
+
hasUvRegions: { type: "boolean" },
|
|
3999
|
+
materialId: { type: "number" },
|
|
4000
|
+
texelCountHint: { type: "number" },
|
|
4001
|
+
vertexCount: { type: "number" }
|
|
4002
|
+
},
|
|
4003
|
+
required: [
|
|
4004
|
+
"boundingVolumes",
|
|
4005
|
+
"featureCount",
|
|
4006
|
+
"geometry",
|
|
4007
|
+
"hasUvRegions",
|
|
4008
|
+
"materialId",
|
|
4009
|
+
"vertexCount"
|
|
4010
|
+
]
|
|
4011
|
+
}
|
|
4012
|
+
},
|
|
4013
|
+
required: ["nodeId", "done"]
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
},
|
|
4017
|
+
required: ["nodes"]
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
},
|
|
4021
|
+
textureSetDefinitions: {
|
|
4022
|
+
type: "array",
|
|
4023
|
+
items: {
|
|
4024
|
+
type: "object",
|
|
4025
|
+
properties: {
|
|
4026
|
+
formats: {
|
|
4027
|
+
type: "array",
|
|
4028
|
+
items: {
|
|
4029
|
+
type: "object",
|
|
4030
|
+
properties: {
|
|
4031
|
+
name: { type: "string" },
|
|
4032
|
+
format: { enum: ["jpg", "png", "ktx-etc2", "dds", "ktx2"] }
|
|
4033
|
+
},
|
|
4034
|
+
required: ["name", "format"]
|
|
4035
|
+
}
|
|
4036
|
+
},
|
|
4037
|
+
atlas: { type: "boolean" }
|
|
4038
|
+
},
|
|
4039
|
+
required: ["formats"]
|
|
4040
|
+
}
|
|
4041
|
+
},
|
|
4042
|
+
attributeMetadataInfo: {
|
|
4043
|
+
type: "object",
|
|
4044
|
+
properties: {
|
|
4045
|
+
attributeStorageInfo: {
|
|
4046
|
+
type: "array",
|
|
4047
|
+
items: {
|
|
4048
|
+
type: "object",
|
|
4049
|
+
properties: {
|
|
4050
|
+
key: { type: "string" },
|
|
4051
|
+
name: { type: "string" },
|
|
4052
|
+
header: {
|
|
4053
|
+
type: "array",
|
|
4054
|
+
items: {
|
|
4055
|
+
type: "object",
|
|
4056
|
+
properties: { property: { type: "string" }, valueType: { type: "string" } },
|
|
4057
|
+
required: ["property", "valueType"]
|
|
4058
|
+
}
|
|
4059
|
+
},
|
|
4060
|
+
ordering: { type: "array", items: { type: "string" } },
|
|
4061
|
+
attributeValues: { $ref: "#/$defs/AttributeValue" },
|
|
4062
|
+
attributeByteCounts: { $ref: "#/$defs/AttributeValue" },
|
|
4063
|
+
objectIds: { $ref: "#/$defs/AttributeValue" }
|
|
4064
|
+
},
|
|
4065
|
+
required: ["key", "name", "header"]
|
|
4066
|
+
}
|
|
4067
|
+
},
|
|
4068
|
+
fields: {
|
|
4069
|
+
type: "array",
|
|
4070
|
+
items: {
|
|
4071
|
+
type: "object",
|
|
4072
|
+
properties: {
|
|
4073
|
+
name: { type: "string" },
|
|
4074
|
+
type: { $ref: "#/$defs/ESRIField" },
|
|
4075
|
+
alias: { type: "string" },
|
|
4076
|
+
domain: { $ref: "#/$defs/Domain" }
|
|
4077
|
+
},
|
|
4078
|
+
required: ["name", "type"]
|
|
4079
|
+
}
|
|
4080
|
+
},
|
|
4081
|
+
popupInfo: {
|
|
4082
|
+
type: "object",
|
|
4083
|
+
properties: {
|
|
4084
|
+
title: { type: "string" },
|
|
4085
|
+
description: { type: "string" },
|
|
4086
|
+
expressionInfos: { type: "array", items: {} },
|
|
4087
|
+
fieldInfos: { type: "array", items: { $ref: "#/$defs/FieldInfo" } },
|
|
4088
|
+
mediaInfos: { type: "array", items: {} },
|
|
4089
|
+
popupElements: {
|
|
4090
|
+
type: "array",
|
|
4091
|
+
items: {
|
|
4092
|
+
type: "object",
|
|
4093
|
+
properties: {
|
|
4094
|
+
text: { type: "string" },
|
|
4095
|
+
type: { type: "string" },
|
|
4096
|
+
fieldInfos: { type: "array", items: { $ref: "#/$defs/FieldInfo" } }
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
},
|
|
4103
|
+
required: ["attributeStorageInfo", "fields"]
|
|
4104
|
+
},
|
|
4105
|
+
materialDefinitions: {
|
|
4106
|
+
type: "array",
|
|
4107
|
+
items: {
|
|
4108
|
+
type: "object",
|
|
4109
|
+
properties: {
|
|
4110
|
+
pbrMetallicRoughness: {
|
|
4111
|
+
type: "object",
|
|
4112
|
+
properties: {
|
|
4113
|
+
baseColorFactor: {
|
|
4114
|
+
type: "array",
|
|
4115
|
+
minItems: 4,
|
|
4116
|
+
maxItems: 4,
|
|
4117
|
+
items: { type: "number" }
|
|
4118
|
+
},
|
|
4119
|
+
baseColorTexture: { $ref: "#/$defs/I3SMaterialTexture" },
|
|
4120
|
+
metallicFactor: { type: "number" },
|
|
4121
|
+
roughnessFactor: { type: "number" },
|
|
4122
|
+
metallicRoughnessTexture: { $ref: "#/$defs/I3SMaterialTexture" }
|
|
4123
|
+
},
|
|
4124
|
+
required: ["metallicFactor", "roughnessFactor"]
|
|
4125
|
+
},
|
|
4126
|
+
normalTexture: { $ref: "#/$defs/I3SMaterialTexture" },
|
|
4127
|
+
occlusionTexture: { $ref: "#/$defs/I3SMaterialTexture" },
|
|
4128
|
+
emissiveTexture: { $ref: "#/$defs/I3SMaterialTexture" },
|
|
4129
|
+
emissiveFactor: { type: "array", minItems: 3, maxItems: 3, items: { type: "number" } },
|
|
4130
|
+
alphaMode: { enum: ["opaque", "mask", "blend"] },
|
|
4131
|
+
alphaCutoff: { type: "number" },
|
|
4132
|
+
doubleSided: { type: "boolean" },
|
|
4133
|
+
cullFace: { enum: ["none", "front", "back"] }
|
|
4134
|
+
},
|
|
4135
|
+
required: ["pbrMetallicRoughness", "alphaMode"]
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
},
|
|
4139
|
+
required: ["options", "tilesConverted"],
|
|
4140
|
+
$defs: {
|
|
4141
|
+
AttributeValue: {
|
|
4142
|
+
type: "object",
|
|
4143
|
+
properties: {
|
|
4144
|
+
valueType: { type: "string" },
|
|
4145
|
+
encoding: { type: "string" },
|
|
4146
|
+
valuesPerElement: { type: "number" }
|
|
4147
|
+
},
|
|
4148
|
+
required: ["valueType"]
|
|
4149
|
+
},
|
|
4150
|
+
ESRIField: {
|
|
4151
|
+
enum: [
|
|
4152
|
+
"esriFieldTypeDate",
|
|
4153
|
+
"esriFieldTypeSingle",
|
|
4154
|
+
"esriFieldTypeDouble",
|
|
4155
|
+
"esriFieldTypeGUID",
|
|
4156
|
+
"esriFieldTypeGlobalID",
|
|
4157
|
+
"esriFieldTypeInteger",
|
|
4158
|
+
"esriFieldTypeOID",
|
|
4159
|
+
"esriFieldTypeSmallInteger",
|
|
4160
|
+
"esriFieldTypeString"
|
|
4161
|
+
]
|
|
4162
|
+
},
|
|
4163
|
+
Domain: {
|
|
4164
|
+
type: "object",
|
|
4165
|
+
properties: {
|
|
4166
|
+
type: { type: "string" },
|
|
4167
|
+
name: { type: "string" },
|
|
4168
|
+
description: { type: "string" },
|
|
4169
|
+
fieldType: { type: "string" },
|
|
4170
|
+
range: { type: "array", items: { type: "number" } },
|
|
4171
|
+
codedValues: {
|
|
4172
|
+
type: "array",
|
|
4173
|
+
items: {
|
|
4174
|
+
type: "object",
|
|
4175
|
+
properties: { name: { type: "string" }, code: { type: ["string", "number"] } },
|
|
4176
|
+
required: ["name", "code"]
|
|
4177
|
+
}
|
|
4178
|
+
},
|
|
4179
|
+
mergePolicy: { type: "string" },
|
|
4180
|
+
splitPolicy: { type: "string" }
|
|
4181
|
+
},
|
|
4182
|
+
required: ["type", "name"]
|
|
4183
|
+
},
|
|
4184
|
+
FieldInfo: {
|
|
4185
|
+
type: "object",
|
|
4186
|
+
properties: {
|
|
4187
|
+
fieldName: { type: "string" },
|
|
4188
|
+
visible: { type: "boolean" },
|
|
4189
|
+
isEditable: { type: "boolean" },
|
|
4190
|
+
label: { type: "string" }
|
|
4191
|
+
},
|
|
4192
|
+
required: ["fieldName", "visible", "isEditable", "label"]
|
|
4193
|
+
},
|
|
4194
|
+
I3SMaterialTexture: {
|
|
4195
|
+
type: "object",
|
|
4196
|
+
properties: {
|
|
4197
|
+
textureSetDefinitionId: { type: "number" },
|
|
4198
|
+
texCoord: { type: "number" },
|
|
4199
|
+
factor: { type: "number" }
|
|
4200
|
+
},
|
|
4201
|
+
required: ["textureSetDefinitionId"]
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
};
|
|
4205
|
+
|
|
4206
|
+
// src/lib/utils/conversion-dump.ts
|
|
3883
4207
|
var ConversionDump = class {
|
|
3884
4208
|
constructor() {
|
|
3885
4209
|
/**Restored/resumed dump indicator */
|
|
3886
4210
|
this.restored = false;
|
|
3887
|
-
/** Array of materials definitions */
|
|
3888
|
-
this.materialDefinitions = [];
|
|
3889
4211
|
this.tilesConverted = {};
|
|
3890
4212
|
}
|
|
3891
4213
|
/**
|
|
@@ -3929,23 +4251,31 @@ var ConversionDump = class {
|
|
|
3929
4251
|
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
3930
4252
|
);
|
|
3931
4253
|
if (await isFileExists(dumpFilename)) {
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
this.
|
|
3948
|
-
|
|
4254
|
+
try {
|
|
4255
|
+
const dump = await openJson(
|
|
4256
|
+
(0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
|
|
4257
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
4258
|
+
);
|
|
4259
|
+
const {
|
|
4260
|
+
options,
|
|
4261
|
+
tilesConverted,
|
|
4262
|
+
textureSetDefinitions,
|
|
4263
|
+
attributeMetadataInfo,
|
|
4264
|
+
materialDefinitions
|
|
4265
|
+
} = dump;
|
|
4266
|
+
const ajv = new import_ajv.default();
|
|
4267
|
+
const dumpJsonValidate = ajv.compile(dumpJsonSchema);
|
|
4268
|
+
const isDumpValid = dumpJsonValidate(dump);
|
|
4269
|
+
if (isDumpValid && (0, import_util.isDeepStrictEqual)(options, JSON.parse(JSON.stringify(this.options)))) {
|
|
4270
|
+
this.tilesConverted = tilesConverted;
|
|
4271
|
+
this.textureSetDefinitions = textureSetDefinitions;
|
|
4272
|
+
this.attributeMetadataInfo = attributeMetadataInfo;
|
|
4273
|
+
this.materialDefinitions = materialDefinitions;
|
|
4274
|
+
this.restored = true;
|
|
4275
|
+
return;
|
|
4276
|
+
}
|
|
4277
|
+
} catch (error) {
|
|
4278
|
+
console.log("Can't open dump file", error);
|
|
3949
4279
|
}
|
|
3950
4280
|
}
|
|
3951
4281
|
await this.deleteDumpFile();
|
|
@@ -3962,8 +4292,8 @@ var ConversionDump = class {
|
|
|
3962
4292
|
if (this.attributeMetadataInfo) {
|
|
3963
4293
|
delete this.attributeMetadataInfo;
|
|
3964
4294
|
}
|
|
3965
|
-
if (this.materialDefinitions
|
|
3966
|
-
this.materialDefinitions
|
|
4295
|
+
if (this.materialDefinitions) {
|
|
4296
|
+
delete this.materialDefinitions;
|
|
3967
4297
|
}
|
|
3968
4298
|
}
|
|
3969
4299
|
/**
|
|
@@ -3973,6 +4303,7 @@ var ConversionDump = class {
|
|
|
3973
4303
|
var _a2;
|
|
3974
4304
|
if (((_a2 = this.options) == null ? void 0 : _a2.outputPath) && this.options.tilesetName) {
|
|
3975
4305
|
try {
|
|
4306
|
+
const time = import_process3.default.hrtime();
|
|
3976
4307
|
await writeFile(
|
|
3977
4308
|
(0, import_path6.join)(this.options.outputPath, this.options.tilesetName),
|
|
3978
4309
|
JSON.stringify({
|
|
@@ -3982,7 +4313,19 @@ var ConversionDump = class {
|
|
|
3982
4313
|
attributeMetadataInfo: this.attributeMetadataInfo,
|
|
3983
4314
|
materialDefinitions: this.materialDefinitions
|
|
3984
4315
|
}),
|
|
3985
|
-
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
4316
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`
|
|
4317
|
+
);
|
|
4318
|
+
await renameFile(
|
|
4319
|
+
(0, import_path6.join)(
|
|
4320
|
+
this.options.outputPath,
|
|
4321
|
+
this.options.tilesetName,
|
|
4322
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`
|
|
4323
|
+
),
|
|
4324
|
+
(0, import_path6.join)(
|
|
4325
|
+
this.options.outputPath,
|
|
4326
|
+
this.options.tilesetName,
|
|
4327
|
+
`${this.options.tilesetName}${DUMP_FILE_SUFFIX}`
|
|
4328
|
+
)
|
|
3986
4329
|
);
|
|
3987
4330
|
} catch (error) {
|
|
3988
4331
|
console.log("Can't update dump file", error);
|
|
@@ -4033,7 +4376,7 @@ var ConversionDump = class {
|
|
|
4033
4376
|
*/
|
|
4034
4377
|
async addNode(filename, nodeId, dumpMetadata) {
|
|
4035
4378
|
const { nodes } = this.getRecord(filename) || { nodes: [] };
|
|
4036
|
-
nodes.push({ nodeId, done: false,
|
|
4379
|
+
nodes.push({ nodeId, done: false, dumpMetadata });
|
|
4037
4380
|
if (nodes.length === 1) {
|
|
4038
4381
|
this.setRecord(filename, { nodes });
|
|
4039
4382
|
}
|
|
@@ -4106,6 +4449,22 @@ var ConversionDump = class {
|
|
|
4106
4449
|
}
|
|
4107
4450
|
await this.updateDumpFile();
|
|
4108
4451
|
}
|
|
4452
|
+
/**
|
|
4453
|
+
* Update 3d-tiles-converter dump file
|
|
4454
|
+
* @param filename - source filename
|
|
4455
|
+
* @param nodeId - nodeId
|
|
4456
|
+
* @param done - conversion status
|
|
4457
|
+
*/
|
|
4458
|
+
async updateConvertedNodesDumpFile(filename, nodeId, done) {
|
|
4459
|
+
var _a2;
|
|
4460
|
+
const nodeDump = (_a2 = this.tilesConverted[filename]) == null ? void 0 : _a2.nodes.find(
|
|
4461
|
+
(element) => element.nodeId === nodeId
|
|
4462
|
+
);
|
|
4463
|
+
if (nodeDump) {
|
|
4464
|
+
nodeDump.done = done;
|
|
4465
|
+
await this.updateDumpFile();
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4109
4468
|
/**
|
|
4110
4469
|
* Check is source file conversion complete
|
|
4111
4470
|
* @param filename - source filename
|
|
@@ -4133,7 +4492,7 @@ var ConversionDump = class {
|
|
|
4133
4492
|
|
|
4134
4493
|
// src/i3s-converter/i3s-converter.ts
|
|
4135
4494
|
var _a;
|
|
4136
|
-
var ION_DEFAULT_TOKEN = (_a =
|
|
4495
|
+
var ION_DEFAULT_TOKEN = (_a = import_process4.default.env) == null ? void 0 : _a.IonToken;
|
|
4137
4496
|
var HARDCODED_NODES_PER_PAGE = 64;
|
|
4138
4497
|
var _3D_TILES = "3DTILES";
|
|
4139
4498
|
var _3D_OBJECT_LAYER_TYPE = "3DObject";
|
|
@@ -4214,7 +4573,7 @@ var I3SConverter = class {
|
|
|
4214
4573
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
4215
4574
|
return BROWSER_ERROR_MESSAGE;
|
|
4216
4575
|
}
|
|
4217
|
-
this.conversionStartTime =
|
|
4576
|
+
this.conversionStartTime = import_process4.default.hrtime();
|
|
4218
4577
|
const {
|
|
4219
4578
|
tilesetName,
|
|
4220
4579
|
slpk,
|
|
@@ -4317,7 +4676,6 @@ var I3SConverter = class {
|
|
|
4317
4676
|
} else {
|
|
4318
4677
|
console.log("Feature metadata classes have not been found");
|
|
4319
4678
|
}
|
|
4320
|
-
console.log(`------------------------------------------------`);
|
|
4321
4679
|
if (!meshTopologyTypes.has("TRIANGLES" /* TRIANGLES */) && !meshTopologyTypes.has("TRIANGLE_STRIP" /* TRIANGLE_STRIP */)) {
|
|
4322
4680
|
console.log(
|
|
4323
4681
|
"The tileset is of unsupported mesh topology types. The conversion will be interrupted."
|
|
@@ -4325,6 +4683,7 @@ var I3SConverter = class {
|
|
|
4325
4683
|
console.log(`------------------------------------------------`);
|
|
4326
4684
|
return false;
|
|
4327
4685
|
}
|
|
4686
|
+
console.log(`------------------------------------------------`);
|
|
4328
4687
|
return true;
|
|
4329
4688
|
}
|
|
4330
4689
|
/**
|
|
@@ -4549,9 +4908,9 @@ var I3SConverter = class {
|
|
|
4549
4908
|
if (this.options.slpk) {
|
|
4550
4909
|
const slpkTilesetPath = (0, import_path7.join)(tilesetPath, "SceneServer", "layers", "0");
|
|
4551
4910
|
const slpkFileName = `${tilesetPath}.slpk`;
|
|
4552
|
-
await (0,
|
|
4911
|
+
await (0, import_zip2.createZip)(slpkTilesetPath, slpkFileName, async (fileList) => ({
|
|
4553
4912
|
path: "@specialIndexFileHASH128@",
|
|
4554
|
-
file: await (0,
|
|
4913
|
+
file: await (0, import_zip2.composeHashFile)(fileList)
|
|
4555
4914
|
}));
|
|
4556
4915
|
try {
|
|
4557
4916
|
await removeDir(tilesetPath);
|
|
@@ -5315,7 +5674,7 @@ var I3SConverter = class {
|
|
|
5315
5674
|
const { tilesCount, tilesWithAddRefineCount } = this.refinementCounter;
|
|
5316
5675
|
const addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
|
|
5317
5676
|
const filesSize = await calculateFilesSize(params);
|
|
5318
|
-
const diff =
|
|
5677
|
+
const diff = import_process4.default.hrtime(this.conversionStartTime);
|
|
5319
5678
|
const conversionTime = timeConverter(diff);
|
|
5320
5679
|
console.log(`------------------------------------------------`);
|
|
5321
5680
|
console.log(`Finishing conversion of ${_3D_TILES}`);
|
|
@@ -5336,18 +5695,18 @@ var I3SConverter = class {
|
|
|
5336
5695
|
"cesium-ion": { accessToken: this.options.token || ION_DEFAULT_TOKEN }
|
|
5337
5696
|
};
|
|
5338
5697
|
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
5339
|
-
this.refreshTokenTime =
|
|
5698
|
+
this.refreshTokenTime = import_process4.default.hrtime();
|
|
5340
5699
|
return { ...options, ...preloadOptions };
|
|
5341
5700
|
}
|
|
5342
5701
|
/**
|
|
5343
5702
|
* Update options of source tileset
|
|
5344
5703
|
*/
|
|
5345
5704
|
async _updateTilesetOptions() {
|
|
5346
|
-
const diff =
|
|
5705
|
+
const diff = import_process4.default.hrtime(this.refreshTokenTime);
|
|
5347
5706
|
if (diff[0] < REFRESH_TOKEN_TIMEOUT) {
|
|
5348
5707
|
return;
|
|
5349
5708
|
}
|
|
5350
|
-
this.refreshTokenTime =
|
|
5709
|
+
this.refreshTokenTime = import_process4.default.hrtime();
|
|
5351
5710
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
5352
5711
|
if (preloadOptions.headers) {
|
|
5353
5712
|
this.loadOptions.fetch = {
|
|
@@ -5380,7 +5739,7 @@ var I3SConverter = class {
|
|
|
5380
5739
|
|
|
5381
5740
|
// src/3d-tiles-converter/3d-tiles-converter.ts
|
|
5382
5741
|
var import_path8 = require("path");
|
|
5383
|
-
var
|
|
5742
|
+
var import_process5 = __toESM(require("process"), 1);
|
|
5384
5743
|
var import_json_map_transform10 = __toESM(require("json-map-transform"), 1);
|
|
5385
5744
|
var import_core15 = require("@loaders.gl/core");
|
|
5386
5745
|
var import_i3s2 = require("@loaders.gl/i3s");
|
|
@@ -5756,7 +6115,9 @@ var B3dmConverter = class {
|
|
|
5756
6115
|
// src/3d-tiles-converter/helpers/load-i3s.ts
|
|
5757
6116
|
var import_core14 = require("@loaders.gl/core");
|
|
5758
6117
|
var import_i3s = require("@loaders.gl/i3s");
|
|
5759
|
-
var
|
|
6118
|
+
var import_loader_utils5 = require("@loaders.gl/loader-utils");
|
|
6119
|
+
var import_zip3 = require("@loaders.gl/zip");
|
|
6120
|
+
var loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions, slpkFilesystem) => {
|
|
5760
6121
|
if (!sourceTileset || !sourceTile.contentUrl) {
|
|
5761
6122
|
return null;
|
|
5762
6123
|
}
|
|
@@ -5764,10 +6125,12 @@ var loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
|
|
|
5764
6125
|
...tilesetLoadOptions,
|
|
5765
6126
|
i3s: {
|
|
5766
6127
|
...tilesetLoadOptions.i3s,
|
|
6128
|
+
// @ts-expect-error
|
|
5767
6129
|
isTileset: false,
|
|
6130
|
+
// @ts-expect-error
|
|
5768
6131
|
isTileHeader: false,
|
|
5769
6132
|
_tileOptions: {
|
|
5770
|
-
attributeUrls: sourceTile.attributeUrls,
|
|
6133
|
+
attributeUrls: sourceTile.attributeUrls || [],
|
|
5771
6134
|
textureUrl: sourceTile.textureUrl,
|
|
5772
6135
|
textureFormat: sourceTile.textureFormat,
|
|
5773
6136
|
textureLoaderOptions: sourceTile.textureLoaderOptions,
|
|
@@ -5777,20 +6140,78 @@ var loadI3SContent = async (sourceTileset, sourceTile, tilesetLoadOptions) => {
|
|
|
5777
6140
|
},
|
|
5778
6141
|
_tilesetOptions: {
|
|
5779
6142
|
store: sourceTileset.store,
|
|
6143
|
+
// @ts-expect-error
|
|
5780
6144
|
attributeStorageInfo: sourceTileset.attributeStorageInfo,
|
|
6145
|
+
// @ts-expect-error
|
|
5781
6146
|
fields: sourceTileset.fields
|
|
5782
6147
|
}
|
|
5783
6148
|
}
|
|
5784
6149
|
};
|
|
5785
|
-
const tileContent = await (
|
|
6150
|
+
const tileContent = await loadFromArchive2(
|
|
6151
|
+
sourceTile.contentUrl,
|
|
6152
|
+
import_i3s.I3SLoader,
|
|
6153
|
+
loadOptions,
|
|
6154
|
+
slpkFilesystem
|
|
6155
|
+
);
|
|
5786
6156
|
return tileContent;
|
|
5787
6157
|
};
|
|
6158
|
+
async function openSLPK(url) {
|
|
6159
|
+
const slpkUrlParts = url.split(".slpk");
|
|
6160
|
+
const { slpkFileName } = getSlpkUrlParts(url) || {};
|
|
6161
|
+
if (slpkFileName) {
|
|
6162
|
+
const slpkFileName2 = `${slpkUrlParts[0]}.slpk`;
|
|
6163
|
+
const fileProvider = new import_loader_utils5.FileHandleFile(slpkFileName2);
|
|
6164
|
+
const archive = await (0, import_i3s.parseSLPKArchive)(fileProvider, void 0, slpkFileName2);
|
|
6165
|
+
const fileSystem = new import_zip3.ZipFileSystem(archive);
|
|
6166
|
+
return fileSystem;
|
|
6167
|
+
}
|
|
6168
|
+
return null;
|
|
6169
|
+
}
|
|
6170
|
+
async function loadFromArchive2(url, loader, loadOptions, fileSystem) {
|
|
6171
|
+
const slpkUrlParts = getSlpkUrlParts(url);
|
|
6172
|
+
if (fileSystem !== null && slpkUrlParts !== null) {
|
|
6173
|
+
const { internalFileName } = slpkUrlParts;
|
|
6174
|
+
const content = await (0, import_core14.load)(internalFileName, loader, {
|
|
6175
|
+
...loadOptions,
|
|
6176
|
+
fetch: fileSystem.fetch.bind(fileSystem)
|
|
6177
|
+
});
|
|
6178
|
+
return content;
|
|
6179
|
+
}
|
|
6180
|
+
return await (0, import_core14.load)(url, loader, loadOptions);
|
|
6181
|
+
}
|
|
6182
|
+
function getSlpkUrlParts(url) {
|
|
6183
|
+
const slpkUrlParts = url.split(".slpk");
|
|
6184
|
+
let result;
|
|
6185
|
+
if (slpkUrlParts.length === 1) {
|
|
6186
|
+
result = null;
|
|
6187
|
+
} else if (slpkUrlParts.length === 2) {
|
|
6188
|
+
result = { slpkFileName: `${slpkUrlParts[0]}.slpk`, internalFileName: slpkUrlParts[1].slice(1) };
|
|
6189
|
+
} else {
|
|
6190
|
+
throw new Error("Unexpected URL format");
|
|
6191
|
+
}
|
|
6192
|
+
return result;
|
|
6193
|
+
}
|
|
6194
|
+
async function getNodeCount(fileSystem) {
|
|
6195
|
+
if (!(fileSystem == null ? void 0 : fileSystem.fileProvider)) {
|
|
6196
|
+
return 0;
|
|
6197
|
+
}
|
|
6198
|
+
let count = 0;
|
|
6199
|
+
const filesIterator = (0, import_zip3.makeZipCDHeaderIterator)(fileSystem.fileProvider);
|
|
6200
|
+
for await (const file of filesIterator) {
|
|
6201
|
+
const filename = file.fileName;
|
|
6202
|
+
if (filename.indexOf("3dNodeIndexDocument.json.gz") >= 0) {
|
|
6203
|
+
count++;
|
|
6204
|
+
}
|
|
6205
|
+
}
|
|
6206
|
+
return count;
|
|
6207
|
+
}
|
|
5788
6208
|
|
|
5789
6209
|
// src/3d-tiles-converter/3d-tiles-converter.ts
|
|
5790
6210
|
var I3S = "I3S";
|
|
5791
6211
|
var Tiles3DConverter = class {
|
|
5792
6212
|
constructor() {
|
|
5793
6213
|
this.workerSource = {};
|
|
6214
|
+
this.slpkFilesystem = null;
|
|
5794
6215
|
this.loaderOptions = {
|
|
5795
6216
|
_nodeWorkers: true,
|
|
5796
6217
|
reuseWorkers: true,
|
|
@@ -5810,6 +6231,8 @@ var Tiles3DConverter = class {
|
|
|
5810
6231
|
this.sourceTileset = null;
|
|
5811
6232
|
this.attributeStorageInfo = null;
|
|
5812
6233
|
this.workerSource = {};
|
|
6234
|
+
this.conversionDump = new ConversionDump();
|
|
6235
|
+
this.progress = new Progress();
|
|
5813
6236
|
}
|
|
5814
6237
|
/**
|
|
5815
6238
|
* Convert i3s format data to 3dTiles
|
|
@@ -5826,13 +6249,31 @@ var Tiles3DConverter = class {
|
|
|
5826
6249
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
5827
6250
|
return BROWSER_ERROR_MESSAGE;
|
|
5828
6251
|
}
|
|
5829
|
-
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
|
|
5830
|
-
this.conversionStartTime =
|
|
5831
|
-
this.options = { maxDepth };
|
|
6252
|
+
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
|
|
6253
|
+
this.conversionStartTime = import_process5.default.hrtime();
|
|
6254
|
+
this.options = { maxDepth, inquirer };
|
|
5832
6255
|
console.log("Loading egm file...");
|
|
5833
6256
|
this.geoidHeightModel = await (0, import_core15.load)(egmFilePath, PGMLoader);
|
|
5834
6257
|
console.log("Loading egm file completed!");
|
|
5835
|
-
this.
|
|
6258
|
+
this.slpkFilesystem = await openSLPK(inputUrl);
|
|
6259
|
+
let preprocessResult = true;
|
|
6260
|
+
if (analyze || this.slpkFilesystem) {
|
|
6261
|
+
preprocessResult = await this.preprocessConversion();
|
|
6262
|
+
if (!preprocessResult || analyze) {
|
|
6263
|
+
return;
|
|
6264
|
+
}
|
|
6265
|
+
}
|
|
6266
|
+
this.progress.startMonitoring();
|
|
6267
|
+
this.sourceTileset = await loadFromArchive2(
|
|
6268
|
+
inputUrl,
|
|
6269
|
+
import_i3s2.I3SLoader,
|
|
6270
|
+
{
|
|
6271
|
+
...this.loaderOptions,
|
|
6272
|
+
// @ts-expect-error `isTileset` can be boolean of 'auto' but TS expects a string
|
|
6273
|
+
i3s: { ...this.loaderOptions.i3s, isTileset: true }
|
|
6274
|
+
},
|
|
6275
|
+
this.slpkFilesystem
|
|
6276
|
+
);
|
|
5836
6277
|
if (!this.sourceTileset) {
|
|
5837
6278
|
return;
|
|
5838
6279
|
}
|
|
@@ -5842,9 +6283,24 @@ var Tiles3DConverter = class {
|
|
|
5842
6283
|
}
|
|
5843
6284
|
this.tilesetPath = (0, import_path8.join)(`${outputPath}`, `${tilesetName}`);
|
|
5844
6285
|
this.attributeStorageInfo = this.sourceTileset.attributeStorageInfo;
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
6286
|
+
await this.conversionDump.createDump(options);
|
|
6287
|
+
if (this.conversionDump.restored && this.options.inquirer) {
|
|
6288
|
+
const result = await this.options.inquirer.prompt([
|
|
6289
|
+
{
|
|
6290
|
+
name: "resumeConversion",
|
|
6291
|
+
type: "confirm",
|
|
6292
|
+
message: "Dump file of the previous conversion exists, do you want to resume that conversion?"
|
|
6293
|
+
}
|
|
6294
|
+
]);
|
|
6295
|
+
if (!result.resumeConversion) {
|
|
6296
|
+
this.conversionDump.reset();
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
if (!this.conversionDump.restored) {
|
|
6300
|
+
try {
|
|
6301
|
+
await removeDir(this.tilesetPath);
|
|
6302
|
+
} catch (e) {
|
|
6303
|
+
}
|
|
5848
6304
|
}
|
|
5849
6305
|
const rootTile = {
|
|
5850
6306
|
boundingVolume: {
|
|
@@ -5857,10 +6313,38 @@ var Tiles3DConverter = class {
|
|
|
5857
6313
|
await this._addChildren(rootNode, rootTile, 1);
|
|
5858
6314
|
const tileset = (0, import_json_map_transform10.default)({ root: rootTile }, TILESET());
|
|
5859
6315
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), "tileset.json");
|
|
5860
|
-
this.
|
|
6316
|
+
await this.conversionDump.deleteDumpFile();
|
|
6317
|
+
this.progress.stopMonitoring();
|
|
6318
|
+
await this._finishConversion({ slpk: false, outputPath, tilesetName });
|
|
6319
|
+
if (this.slpkFilesystem) {
|
|
6320
|
+
this.slpkFilesystem.destroy();
|
|
6321
|
+
}
|
|
5861
6322
|
const workerFarm = import_worker_utils2.WorkerFarm.getWorkerFarm({});
|
|
5862
6323
|
workerFarm.destroy();
|
|
5863
6324
|
}
|
|
6325
|
+
/**
|
|
6326
|
+
* Preprocess stage of the tile converter. Calculate number of nodes
|
|
6327
|
+
* @returns true - the conversion is possible, false - the tileset's content is not supported
|
|
6328
|
+
*/
|
|
6329
|
+
async preprocessConversion() {
|
|
6330
|
+
console.log(`Analyze source layer`);
|
|
6331
|
+
const nodesCount = await getNodeCount(this.slpkFilesystem);
|
|
6332
|
+
this.progress.stepsTotal = nodesCount;
|
|
6333
|
+
console.log(`------------------------------------------------`);
|
|
6334
|
+
console.log(`Preprocess results:`);
|
|
6335
|
+
if (this.slpkFilesystem) {
|
|
6336
|
+
console.log(`Node count: ${nodesCount}`);
|
|
6337
|
+
if (nodesCount === 0) {
|
|
6338
|
+
console.log("Node count is 0. The conversion will be interrupted.");
|
|
6339
|
+
console.log(`------------------------------------------------`);
|
|
6340
|
+
return false;
|
|
6341
|
+
}
|
|
6342
|
+
} else {
|
|
6343
|
+
console.log(`Node count cannot be calculated for the remote dataset`);
|
|
6344
|
+
}
|
|
6345
|
+
console.log(`------------------------------------------------`);
|
|
6346
|
+
return true;
|
|
6347
|
+
}
|
|
5864
6348
|
/**
|
|
5865
6349
|
* Convert particular I3S Node
|
|
5866
6350
|
* @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
@@ -5869,9 +6353,21 @@ var Tiles3DConverter = class {
|
|
|
5869
6353
|
* @param childNodeInfo child node to convert
|
|
5870
6354
|
*/
|
|
5871
6355
|
async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
|
|
6356
|
+
let nextParentNode = parentNode;
|
|
5872
6357
|
const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
|
|
5873
6358
|
if (sourceChild.contentUrl) {
|
|
5874
|
-
|
|
6359
|
+
if (this.conversionDump.restored && this.conversionDump.isFileConversionComplete(`${sourceChild.id}.b3dm`) && (sourceChild.obb || sourceChild.mbs)) {
|
|
6360
|
+
const { child: child2 } = this._createChildAndBoundingVolume(sourceChild);
|
|
6361
|
+
parentNode.children.push(child2);
|
|
6362
|
+
await this._addChildren(sourceChild, child2, level + 1);
|
|
6363
|
+
return;
|
|
6364
|
+
}
|
|
6365
|
+
const content = await loadI3SContent(
|
|
6366
|
+
this.sourceTileset,
|
|
6367
|
+
sourceChild,
|
|
6368
|
+
this.loaderOptions,
|
|
6369
|
+
this.slpkFilesystem
|
|
6370
|
+
);
|
|
5875
6371
|
if (!content) {
|
|
5876
6372
|
await this._addChildren(sourceChild, parentNode, level + 1);
|
|
5877
6373
|
return;
|
|
@@ -5881,34 +6377,34 @@ var Tiles3DConverter = class {
|
|
|
5881
6377
|
if (this.attributeStorageInfo) {
|
|
5882
6378
|
featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
|
|
5883
6379
|
}
|
|
5884
|
-
|
|
5885
|
-
sourceChild.obb = createObbFromMbs(sourceChild.mbs);
|
|
5886
|
-
}
|
|
5887
|
-
const boundingVolume = {
|
|
5888
|
-
box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)
|
|
5889
|
-
};
|
|
5890
|
-
const child = {
|
|
5891
|
-
boundingVolume,
|
|
5892
|
-
geometricError: convertScreenThresholdToGeometricError(sourceChild),
|
|
5893
|
-
children: []
|
|
5894
|
-
};
|
|
6380
|
+
const { child, boundingVolume } = this._createChildAndBoundingVolume(sourceChild);
|
|
5895
6381
|
const i3sAttributesData = {
|
|
5896
6382
|
tileContent: content,
|
|
5897
|
-
box: boundingVolume.box,
|
|
6383
|
+
box: boundingVolume.box || [],
|
|
5898
6384
|
textureFormat: sourceChild.textureFormat
|
|
5899
6385
|
};
|
|
5900
6386
|
const b3dmConverter = new B3dmConverter();
|
|
5901
6387
|
const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);
|
|
5902
|
-
|
|
5903
|
-
uri: `${sourceChild.id}.b3dm`,
|
|
5904
|
-
boundingVolume
|
|
5905
|
-
};
|
|
6388
|
+
await this.conversionDump.addNode(`${sourceChild.id}.b3dm`, sourceChild.id);
|
|
5906
6389
|
await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
|
|
6390
|
+
await this.conversionDump.updateConvertedNodesDumpFile(
|
|
6391
|
+
`${sourceChild.id}.b3dm`,
|
|
6392
|
+
sourceChild.id,
|
|
6393
|
+
true
|
|
6394
|
+
);
|
|
5907
6395
|
parentNode.children.push(child);
|
|
5908
|
-
|
|
5909
|
-
}
|
|
5910
|
-
|
|
6396
|
+
nextParentNode = child;
|
|
6397
|
+
}
|
|
6398
|
+
this.progress.stepsDone += 1;
|
|
6399
|
+
let timeRemainingString = "Calculating time left...";
|
|
6400
|
+
const timeRemaining = this.progress.getTimeRemainingString();
|
|
6401
|
+
if (timeRemaining) {
|
|
6402
|
+
timeRemainingString = `${timeRemaining} left`;
|
|
5911
6403
|
}
|
|
6404
|
+
const percentString = this.progress.getPercentString();
|
|
6405
|
+
const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : "";
|
|
6406
|
+
console.log(`[converted${progressString}]: ${childNodeInfo.id}`);
|
|
6407
|
+
await this._addChildren(sourceChild, nextParentNode, level + 1);
|
|
5912
6408
|
}
|
|
5913
6409
|
/**
|
|
5914
6410
|
* The recursive function of traversal of a nodes tree
|
|
@@ -5943,15 +6439,39 @@ var Tiles3DConverter = class {
|
|
|
5943
6439
|
const options = {
|
|
5944
6440
|
i3s: {
|
|
5945
6441
|
...this.loaderOptions,
|
|
6442
|
+
// @ts-expect-error
|
|
5946
6443
|
isTileHeader: true,
|
|
5947
6444
|
loadContent: false
|
|
5948
6445
|
}
|
|
5949
6446
|
};
|
|
5950
6447
|
console.log(`Node conversion: ${nodeUrl}`);
|
|
5951
|
-
header = await (
|
|
6448
|
+
header = await loadFromArchive2(nodeUrl, import_i3s2.I3SLoader, options, this.slpkFilesystem);
|
|
5952
6449
|
}
|
|
5953
6450
|
return header;
|
|
5954
6451
|
}
|
|
6452
|
+
/**
|
|
6453
|
+
* Create child and child's boundingVolume for the converted node
|
|
6454
|
+
* @param sourceChild
|
|
6455
|
+
* @returns child and child's boundingVolume
|
|
6456
|
+
*/
|
|
6457
|
+
_createChildAndBoundingVolume(sourceChild) {
|
|
6458
|
+
if (!sourceChild.obb) {
|
|
6459
|
+
sourceChild.obb = createObbFromMbs(sourceChild.mbs);
|
|
6460
|
+
}
|
|
6461
|
+
const boundingVolume = {
|
|
6462
|
+
box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)
|
|
6463
|
+
};
|
|
6464
|
+
const child = {
|
|
6465
|
+
boundingVolume,
|
|
6466
|
+
geometricError: convertScreenThresholdToGeometricError(sourceChild),
|
|
6467
|
+
children: [],
|
|
6468
|
+
content: {
|
|
6469
|
+
uri: `${sourceChild.id}.b3dm`,
|
|
6470
|
+
boundingVolume
|
|
6471
|
+
}
|
|
6472
|
+
};
|
|
6473
|
+
return { boundingVolume, child };
|
|
6474
|
+
}
|
|
5955
6475
|
/**
|
|
5956
6476
|
* Make an url of a resource from its relative url having the base url
|
|
5957
6477
|
* @param baseUrl the base url. A resulting url will be related from this url
|
|
@@ -5989,7 +6509,7 @@ var Tiles3DConverter = class {
|
|
|
5989
6509
|
attributeName: attribute.name,
|
|
5990
6510
|
attributeType: this._getAttributeType(attribute)
|
|
5991
6511
|
};
|
|
5992
|
-
promises.push((
|
|
6512
|
+
promises.push(loadFromArchive2(inputUrl, import_i3s2.I3SAttributeLoader, options, this.slpkFilesystem));
|
|
5993
6513
|
}
|
|
5994
6514
|
const attributesList = await Promise.all(promises);
|
|
5995
6515
|
this._replaceNestedArrays(attributesList);
|
|
@@ -6028,7 +6548,7 @@ var Tiles3DConverter = class {
|
|
|
6028
6548
|
*/
|
|
6029
6549
|
async _finishConversion(params) {
|
|
6030
6550
|
const filesSize = await calculateFilesSize(params);
|
|
6031
|
-
const diff =
|
|
6551
|
+
const diff = import_process5.default.hrtime(this.conversionStartTime);
|
|
6032
6552
|
const conversionTime = timeConverter(diff);
|
|
6033
6553
|
console.log(`------------------------------------------------`);
|
|
6034
6554
|
console.log(`Finish conversion of ${I3S}`);
|