@loaders.gl/tile-converter 4.0.2 → 4.0.4
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/converter.min.cjs +98 -98
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/progress.d.ts +90 -0
- package/dist/i3s-converter/helpers/progress.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/progress.js +92 -0
- package/dist/i3s-converter/helpers/progress.js.map +1 -0
- package/dist/i3s-converter/i3s-converter.d.ts +2 -9
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +20 -13
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/index.cjs +199 -46
- package/dist/lib/utils/statistic-utills.d.ts +6 -1
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/statistic-utills.js +13 -3
- package/dist/lib/utils/statistic-utills.js.map +1 -1
- package/package.json +14 -14
- package/src/deps-installer/deps-installer.ts +1 -1
- package/src/i3s-converter/helpers/geometry-converter.ts +19 -14
- package/src/i3s-converter/helpers/progress.ts +166 -0
- package/src/i3s-converter/i3s-converter.ts +24 -25
- package/src/lib/utils/statistic-utills.ts +22 -4
package/dist/index.cjs
CHANGED
|
@@ -252,7 +252,7 @@ var import_core9 = require("@loaders.gl/core");
|
|
|
252
252
|
var import_d_tiles2 = require("@loaders.gl/3d-tiles");
|
|
253
253
|
var import_path7 = require("path");
|
|
254
254
|
var import_uuid4 = require("uuid");
|
|
255
|
-
var
|
|
255
|
+
var import_process3 = __toESM(require("process"), 1);
|
|
256
256
|
var import_json_map_transform8 = __toESM(require("json-map-transform"), 1);
|
|
257
257
|
var import_md52 = __toESM(require("md5"), 1);
|
|
258
258
|
|
|
@@ -712,14 +712,24 @@ var NodePages = class {
|
|
|
712
712
|
var import_path4 = require("path");
|
|
713
713
|
var import_fs3 = require("fs");
|
|
714
714
|
function timeConverter(time) {
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
if (typeof time === "number") {
|
|
716
|
+
const milliSecondsInSecond = 1e3;
|
|
717
|
+
const timeInSeconds = Math.floor(time / milliSecondsInSecond);
|
|
718
|
+
const milliseconds = time - timeInSeconds * milliSecondsInSecond;
|
|
719
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
720
|
+
} else {
|
|
721
|
+
const nanoSecondsInMillisecond = 1e6;
|
|
722
|
+
const timeInSeconds = time[0];
|
|
723
|
+
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
724
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
|
|
717
728
|
const hours = Math.floor(timeInSeconds / 3600);
|
|
718
729
|
timeInSeconds = timeInSeconds - hours * 3600;
|
|
719
730
|
const minutes = Math.floor(timeInSeconds / 60);
|
|
720
731
|
timeInSeconds = timeInSeconds - minutes * 60;
|
|
721
732
|
const seconds = Math.floor(timeInSeconds);
|
|
722
|
-
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
723
733
|
let result = "";
|
|
724
734
|
if (hours) {
|
|
725
735
|
result += `${hours}h `;
|
|
@@ -2297,21 +2307,26 @@ async function generateCompressedGeometry(vertexCount, convertedAttributes, attr
|
|
|
2297
2307
|
"i3s-attribute-type": "uv-region"
|
|
2298
2308
|
};
|
|
2299
2309
|
}
|
|
2300
|
-
return (0, import_core5.encode)(
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2310
|
+
return (0, import_core5.encode)(
|
|
2311
|
+
{ attributes: compressedAttributes, indices },
|
|
2312
|
+
// @ts-expect-error if encoded supports worker writer, we should update its type signature
|
|
2313
|
+
import_draco.DracoWriterWorker,
|
|
2314
|
+
{
|
|
2315
|
+
...import_draco.DracoWriterWorker.options,
|
|
2316
|
+
reuseWorkers: true,
|
|
2317
|
+
_nodeWorkers: true,
|
|
2318
|
+
modules: libraries,
|
|
2319
|
+
useLocalLibraries: true,
|
|
2320
|
+
draco: {
|
|
2321
|
+
method: "MESH_SEQUENTIAL_ENCODING",
|
|
2322
|
+
attributesMetadata
|
|
2323
|
+
},
|
|
2324
|
+
["draco-writer"]: {
|
|
2325
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
2326
|
+
workerUrl: "./modules/draco/dist/draco-writer-worker-node.js"
|
|
2327
|
+
}
|
|
2313
2328
|
}
|
|
2314
|
-
|
|
2329
|
+
);
|
|
2315
2330
|
}
|
|
2316
2331
|
function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
2317
2332
|
const orderedFeatureIndices = new Uint32Array(featureIndex.length);
|
|
@@ -3749,14 +3764,153 @@ var mergePreprocessData = (object1, object2) => {
|
|
|
3749
3764
|
}
|
|
3750
3765
|
};
|
|
3751
3766
|
|
|
3767
|
+
// src/i3s-converter/helpers/progress.ts
|
|
3768
|
+
var import_process2 = __toESM(require("process"), 1);
|
|
3769
|
+
var THRESHOLD_DEFAULT = 0.2;
|
|
3770
|
+
var Progress = class {
|
|
3771
|
+
constructor(options = {}) {
|
|
3772
|
+
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
3773
|
+
this._stepsTotal = 0;
|
|
3774
|
+
/** Amount of work already done */
|
|
3775
|
+
this._stepsDone = 0;
|
|
3776
|
+
/** Time in milli-seconds when the process started */
|
|
3777
|
+
this.startTime = 0;
|
|
3778
|
+
/** Time in milli-seconds when the process stopped */
|
|
3779
|
+
this.stopTime = 0;
|
|
3780
|
+
/** Time in milli-seconds when stepsDone was updated */
|
|
3781
|
+
this.timeOfUpdatingStepsDone = 0;
|
|
3782
|
+
/** Time in milli-seconds spent for performing one step*/
|
|
3783
|
+
this.milliSecForOneStep = 0;
|
|
3784
|
+
this.trust = false;
|
|
3785
|
+
/**
|
|
3786
|
+
* The number of digits to appear after decimal point in the string representation of the count of steps already done.
|
|
3787
|
+
* It's calculated based on the total count of steps.
|
|
3788
|
+
*/
|
|
3789
|
+
this.numberOfDigitsInPercentage = 0;
|
|
3790
|
+
this.getTime = options.getTime || import_process2.default.hrtime.bigint;
|
|
3791
|
+
this.threshold = options.threshold || THRESHOLD_DEFAULT;
|
|
3792
|
+
}
|
|
3793
|
+
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
3794
|
+
get stepsTotal() {
|
|
3795
|
+
return this._stepsTotal;
|
|
3796
|
+
}
|
|
3797
|
+
set stepsTotal(stepsTotal) {
|
|
3798
|
+
this._stepsTotal = stepsTotal;
|
|
3799
|
+
this.numberOfDigitsInPercentage = this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;
|
|
3800
|
+
}
|
|
3801
|
+
/** Amount of work already done */
|
|
3802
|
+
get stepsDone() {
|
|
3803
|
+
return this._stepsDone;
|
|
3804
|
+
}
|
|
3805
|
+
set stepsDone(stepsDone) {
|
|
3806
|
+
this._stepsDone = stepsDone;
|
|
3807
|
+
this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();
|
|
3808
|
+
if (this._stepsDone) {
|
|
3809
|
+
const diff = this.timeOfUpdatingStepsDone - this.startTime;
|
|
3810
|
+
const milliSecForOneStep = diff / this._stepsDone;
|
|
3811
|
+
this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);
|
|
3812
|
+
this.milliSecForOneStep = milliSecForOneStep;
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
/**
|
|
3816
|
+
* Saves the current time as we start monitoring the process.
|
|
3817
|
+
*/
|
|
3818
|
+
startMonitoring() {
|
|
3819
|
+
this.startTime = this.getCurrentTimeInMilliSeconds();
|
|
3820
|
+
this.milliSecForOneStep = 0;
|
|
3821
|
+
this.trust = false;
|
|
3822
|
+
this.timeOfUpdatingStepsDone = 0;
|
|
3823
|
+
this.stopTime = 0;
|
|
3824
|
+
this.stepsDone = 0;
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* Saves the current time as we stop monitoring the process.
|
|
3828
|
+
*/
|
|
3829
|
+
stopMonitoring() {
|
|
3830
|
+
this.stopTime = this.getCurrentTimeInMilliSeconds();
|
|
3831
|
+
}
|
|
3832
|
+
/**
|
|
3833
|
+
* Gets percentage of the work already done.
|
|
3834
|
+
* @returns percentage of the work already done.
|
|
3835
|
+
*/
|
|
3836
|
+
getPercent() {
|
|
3837
|
+
if (!this._stepsTotal) {
|
|
3838
|
+
return null;
|
|
3839
|
+
}
|
|
3840
|
+
const percent = this._stepsDone / this._stepsTotal * 100;
|
|
3841
|
+
return percent;
|
|
3842
|
+
}
|
|
3843
|
+
/**
|
|
3844
|
+
* Gets string representation of percentage of the work already done.
|
|
3845
|
+
* @returns string representation of percentage or an empty string if the percetage value cannot be calculated.
|
|
3846
|
+
*/
|
|
3847
|
+
getPercentString() {
|
|
3848
|
+
const percent = this.getPercent();
|
|
3849
|
+
return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : "";
|
|
3850
|
+
}
|
|
3851
|
+
/**
|
|
3852
|
+
* Gets the time elapsed since the monitoring started
|
|
3853
|
+
* @returns Number of milliseconds elapsed
|
|
3854
|
+
*/
|
|
3855
|
+
getTimeCurrentlyElapsed() {
|
|
3856
|
+
const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();
|
|
3857
|
+
const diff = currentTime - this.startTime;
|
|
3858
|
+
return diff;
|
|
3859
|
+
}
|
|
3860
|
+
/**
|
|
3861
|
+
* Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
3862
|
+
* @returns Number of milliseconds remaining
|
|
3863
|
+
*/
|
|
3864
|
+
getTimeRemaining() {
|
|
3865
|
+
if (!this._stepsDone || !this.startTime) {
|
|
3866
|
+
return null;
|
|
3867
|
+
}
|
|
3868
|
+
const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
|
|
3869
|
+
return { timeRemaining: timeRemainingInMilliSeconds, trust: this.trust };
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
3873
|
+
* @returns string representation of the time remaining.
|
|
3874
|
+
* It's an empty string if the time cannot be pedicted or it's still being calculated.
|
|
3875
|
+
*/
|
|
3876
|
+
getTimeRemainingString() {
|
|
3877
|
+
const timeRemainingObject = this.getTimeRemaining();
|
|
3878
|
+
return (timeRemainingObject == null ? void 0 : timeRemainingObject.trust) ? timeConverter(timeRemainingObject.timeRemaining) : "";
|
|
3879
|
+
}
|
|
3880
|
+
/**
|
|
3881
|
+
* Check if the computed velociy of the process can be considered trust.
|
|
3882
|
+
* At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,
|
|
3883
|
+
* which results in huge deviation of the cumputed velocity of the process.
|
|
3884
|
+
* It makes sense to perform the check before reporting the time remainig so the end user is not confused.
|
|
3885
|
+
* @param current - current value
|
|
3886
|
+
* @param previous - previous value
|
|
3887
|
+
* @returns true if the computed velociy can be considered trust, or false otherwise
|
|
3888
|
+
*/
|
|
3889
|
+
isVelocityTrust(current, previous) {
|
|
3890
|
+
if (previous) {
|
|
3891
|
+
const dev = Math.abs((current - previous) / previous);
|
|
3892
|
+
return dev < this.threshold;
|
|
3893
|
+
}
|
|
3894
|
+
return false;
|
|
3895
|
+
}
|
|
3896
|
+
/**
|
|
3897
|
+
* Gets current time in milliseconds.
|
|
3898
|
+
* @returns current time in milliseconds.
|
|
3899
|
+
*/
|
|
3900
|
+
getCurrentTimeInMilliSeconds() {
|
|
3901
|
+
return Number(this.getTime() / BigInt(1e6));
|
|
3902
|
+
}
|
|
3903
|
+
};
|
|
3904
|
+
|
|
3752
3905
|
// src/i3s-converter/i3s-converter.ts
|
|
3753
3906
|
var _a;
|
|
3754
|
-
var ION_DEFAULT_TOKEN = (_a =
|
|
3907
|
+
var ION_DEFAULT_TOKEN = (_a = import_process3.default.env) == null ? void 0 : _a.IonToken;
|
|
3755
3908
|
var HARDCODED_NODES_PER_PAGE = 64;
|
|
3756
3909
|
var _3D_TILES = "3DTILES";
|
|
3757
3910
|
var _3D_OBJECT_LAYER_TYPE = "3DObject";
|
|
3758
3911
|
var REFRESH_TOKEN_TIMEOUT = 1800;
|
|
3759
3912
|
var CESIUM_DATASET_PREFIX = "https://";
|
|
3913
|
+
var PROGRESS_PHASE1_COUNT = "phase1-count";
|
|
3760
3914
|
var I3SConverter = class {
|
|
3761
3915
|
constructor() {
|
|
3762
3916
|
this.boundingVolumeWarnings = [];
|
|
@@ -3786,15 +3940,7 @@ var I3SConverter = class {
|
|
|
3786
3940
|
meshTopologyTypes: /* @__PURE__ */ new Set(),
|
|
3787
3941
|
metadataClasses: /* @__PURE__ */ new Set()
|
|
3788
3942
|
};
|
|
3789
|
-
|
|
3790
|
-
this.tileCountTotal = 0;
|
|
3791
|
-
/** Count of tiles already converted plus one (refers to the tile currently being converted) */
|
|
3792
|
-
this.tileCountCurrentlyConverting = 0;
|
|
3793
|
-
/**
|
|
3794
|
-
* The number of digits to appear after decimal point in the string representation of the tile count.
|
|
3795
|
-
* It's calculated based on the total count of tiles.
|
|
3796
|
-
*/
|
|
3797
|
-
this.numberOfDigitsInPercentage = 0;
|
|
3943
|
+
this.progresses = {};
|
|
3798
3944
|
this.attributeMetadataInfo = new AttributeMetadataInfo();
|
|
3799
3945
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
3800
3946
|
this.options = {};
|
|
@@ -3838,7 +3984,7 @@ var I3SConverter = class {
|
|
|
3838
3984
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
3839
3985
|
return BROWSER_ERROR_MESSAGE;
|
|
3840
3986
|
}
|
|
3841
|
-
this.conversionStartTime =
|
|
3987
|
+
this.conversionStartTime = import_process3.default.hrtime();
|
|
3842
3988
|
const {
|
|
3843
3989
|
tilesetName,
|
|
3844
3990
|
slpk,
|
|
@@ -3871,6 +4017,7 @@ var I3SConverter = class {
|
|
|
3871
4017
|
inquirer,
|
|
3872
4018
|
metadataClass
|
|
3873
4019
|
};
|
|
4020
|
+
this.progresses[PROGRESS_PHASE1_COUNT] = new Progress();
|
|
3874
4021
|
this.compressList = this.options.instantNodeWriting && [] || null;
|
|
3875
4022
|
this.validate = Boolean(validate);
|
|
3876
4023
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? import_d_tiles2.CesiumIonLoader : import_d_tiles2.Tiles3DLoader;
|
|
@@ -3927,10 +4074,9 @@ var I3SConverter = class {
|
|
|
3927
4074
|
this.options.maxDepth
|
|
3928
4075
|
);
|
|
3929
4076
|
const { meshTopologyTypes, metadataClasses } = this.preprocessData;
|
|
3930
|
-
this.numberOfDigitsInPercentage = this.tileCountTotal > 100 ? Math.ceil(Math.log10(this.tileCountTotal)) - 2 : 0;
|
|
3931
4077
|
console.log(`------------------------------------------------`);
|
|
3932
4078
|
console.log(`Preprocess results:`);
|
|
3933
|
-
console.log(`Tile count: ${this.
|
|
4079
|
+
console.log(`Tile count: ${this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal}`);
|
|
3934
4080
|
console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
|
|
3935
4081
|
if (metadataClasses.size) {
|
|
3936
4082
|
console.log(
|
|
@@ -3962,7 +4108,7 @@ var I3SConverter = class {
|
|
|
3962
4108
|
return null;
|
|
3963
4109
|
}
|
|
3964
4110
|
if (sourceTile.id) {
|
|
3965
|
-
this.
|
|
4111
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stepsTotal += 1;
|
|
3966
4112
|
console.log(`[analyze]: ${sourceTile.id}`);
|
|
3967
4113
|
}
|
|
3968
4114
|
let tileContent = null;
|
|
@@ -4044,6 +4190,7 @@ var I3SConverter = class {
|
|
|
4044
4190
|
obb: boundingVolumes.obb,
|
|
4045
4191
|
children: []
|
|
4046
4192
|
});
|
|
4193
|
+
this.progresses[PROGRESS_PHASE1_COUNT].startMonitoring();
|
|
4047
4194
|
const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
4048
4195
|
await traverseDatasetWith(
|
|
4049
4196
|
sourceRootTile,
|
|
@@ -4055,6 +4202,8 @@ var I3SConverter = class {
|
|
|
4055
4202
|
this.finalizeTile.bind(this),
|
|
4056
4203
|
this.options.maxDepth
|
|
4057
4204
|
);
|
|
4205
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stopMonitoring();
|
|
4206
|
+
console.log(`[finalizing conversion]`);
|
|
4058
4207
|
this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
|
|
4059
4208
|
this.layers0.fields = this.attributeMetadataInfo.fields;
|
|
4060
4209
|
this.layers0.popupInfo = this.attributeMetadataInfo.popupInfo;
|
|
@@ -4172,13 +4321,7 @@ var I3SConverter = class {
|
|
|
4172
4321
|
return traversalProps;
|
|
4173
4322
|
}
|
|
4174
4323
|
if (sourceTile.id) {
|
|
4175
|
-
|
|
4176
|
-
let percentString = "";
|
|
4177
|
-
if (this.tileCountTotal) {
|
|
4178
|
-
const percent = this.tileCountCurrentlyConverting / this.tileCountTotal * 100;
|
|
4179
|
-
percentString = " " + percent.toFixed(this.numberOfDigitsInPercentage);
|
|
4180
|
-
}
|
|
4181
|
-
console.log(`[convert${percentString}%]: ${sourceTile.id}`);
|
|
4324
|
+
console.log(`[convert]: ${sourceTile.id}`);
|
|
4182
4325
|
}
|
|
4183
4326
|
const { parentNodes, transform: transform11 } = traversalProps;
|
|
4184
4327
|
let transformationMatrix = transform11.clone();
|
|
@@ -4192,6 +4335,16 @@ var I3SConverter = class {
|
|
|
4192
4335
|
transform: transformationMatrix,
|
|
4193
4336
|
parentNodes: childNodes
|
|
4194
4337
|
};
|
|
4338
|
+
if (sourceTile.id) {
|
|
4339
|
+
this.progresses[PROGRESS_PHASE1_COUNT].stepsDone += 1;
|
|
4340
|
+
let timeRemainingString = "Calculating time left...";
|
|
4341
|
+
const timeRemainingStringBasedOnCount = this.progresses[PROGRESS_PHASE1_COUNT].getTimeRemainingString();
|
|
4342
|
+
if (timeRemainingStringBasedOnCount) {
|
|
4343
|
+
timeRemainingString = `${timeRemainingStringBasedOnCount} left`;
|
|
4344
|
+
}
|
|
4345
|
+
let percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
|
|
4346
|
+
console.log(`[converted ${percentString}%, ${timeRemainingString}]: ${sourceTile.id}`);
|
|
4347
|
+
}
|
|
4195
4348
|
return newTraversalProps;
|
|
4196
4349
|
}
|
|
4197
4350
|
/**
|
|
@@ -4670,7 +4823,7 @@ var I3SConverter = class {
|
|
|
4670
4823
|
const { tilesCount, tilesWithAddRefineCount } = this.refinementCounter;
|
|
4671
4824
|
const addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
|
|
4672
4825
|
const filesSize = await calculateFilesSize(params);
|
|
4673
|
-
const diff =
|
|
4826
|
+
const diff = import_process3.default.hrtime(this.conversionStartTime);
|
|
4674
4827
|
const conversionTime = timeConverter(diff);
|
|
4675
4828
|
console.log(`------------------------------------------------`);
|
|
4676
4829
|
console.log(`Finishing conversion of ${_3D_TILES}`);
|
|
@@ -4691,18 +4844,18 @@ var I3SConverter = class {
|
|
|
4691
4844
|
"cesium-ion": { accessToken: this.options.token || ION_DEFAULT_TOKEN }
|
|
4692
4845
|
};
|
|
4693
4846
|
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
4694
|
-
this.refreshTokenTime =
|
|
4847
|
+
this.refreshTokenTime = import_process3.default.hrtime();
|
|
4695
4848
|
return { ...options, ...preloadOptions };
|
|
4696
4849
|
}
|
|
4697
4850
|
/**
|
|
4698
4851
|
* Update options of source tileset
|
|
4699
4852
|
*/
|
|
4700
4853
|
async _updateTilesetOptions() {
|
|
4701
|
-
const diff =
|
|
4854
|
+
const diff = import_process3.default.hrtime(this.refreshTokenTime);
|
|
4702
4855
|
if (diff[0] < REFRESH_TOKEN_TIMEOUT) {
|
|
4703
4856
|
return;
|
|
4704
4857
|
}
|
|
4705
|
-
this.refreshTokenTime =
|
|
4858
|
+
this.refreshTokenTime = import_process3.default.hrtime();
|
|
4706
4859
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
4707
4860
|
if (preloadOptions.headers) {
|
|
4708
4861
|
this.loadOptions.fetch = {
|
|
@@ -4735,7 +4888,7 @@ var I3SConverter = class {
|
|
|
4735
4888
|
|
|
4736
4889
|
// src/3d-tiles-converter/3d-tiles-converter.ts
|
|
4737
4890
|
var import_path8 = require("path");
|
|
4738
|
-
var
|
|
4891
|
+
var import_process4 = __toESM(require("process"), 1);
|
|
4739
4892
|
var import_json_map_transform10 = __toESM(require("json-map-transform"), 1);
|
|
4740
4893
|
var import_core15 = require("@loaders.gl/core");
|
|
4741
4894
|
var import_i3s2 = require("@loaders.gl/i3s");
|
|
@@ -5169,7 +5322,7 @@ var Tiles3DConverter = class {
|
|
|
5169
5322
|
return BROWSER_ERROR_MESSAGE;
|
|
5170
5323
|
}
|
|
5171
5324
|
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
|
|
5172
|
-
this.conversionStartTime =
|
|
5325
|
+
this.conversionStartTime = import_process4.default.hrtime();
|
|
5173
5326
|
this.options = { maxDepth };
|
|
5174
5327
|
console.log("Loading egm file...");
|
|
5175
5328
|
this.geoidHeightModel = await (0, import_core15.load)(egmFilePath, PGMLoader);
|
|
@@ -5371,7 +5524,7 @@ var Tiles3DConverter = class {
|
|
|
5371
5524
|
*/
|
|
5372
5525
|
async _finishConversion(params) {
|
|
5373
5526
|
const filesSize = await calculateFilesSize(params);
|
|
5374
|
-
const diff =
|
|
5527
|
+
const diff = import_process4.default.hrtime(this.conversionStartTime);
|
|
5375
5528
|
const conversionTime = timeConverter(diff);
|
|
5376
5529
|
console.log(`------------------------------------------------`);
|
|
5377
5530
|
console.log(`Finish conversion of ${I3S}`);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Converts time value to string.
|
|
3
|
+
* @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
|
|
4
|
+
* @returns string representation of the time
|
|
5
|
+
*/
|
|
6
|
+
export declare function timeConverter(time: number | [number, number]): string;
|
|
2
7
|
export declare function calculateFilesSize(params: any): Promise<number | null>;
|
|
3
8
|
//# sourceMappingURL=statistic-utills.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAcrE;AA6BD,wBAAsB,kBAAkB,CAAC,MAAM,KAAA,0BAkB9C"}
|
|
@@ -2,14 +2,24 @@ import { join } from 'path';
|
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import { getAbsoluteFilePath } from "./file-utils.js";
|
|
4
4
|
export function timeConverter(time) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (typeof time === 'number') {
|
|
6
|
+
const milliSecondsInSecond = 1e3;
|
|
7
|
+
const timeInSeconds = Math.floor(time / milliSecondsInSecond);
|
|
8
|
+
const milliseconds = time - timeInSeconds * milliSecondsInSecond;
|
|
9
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
10
|
+
} else {
|
|
11
|
+
const nanoSecondsInMillisecond = 1e6;
|
|
12
|
+
const timeInSeconds = time[0];
|
|
13
|
+
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
14
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
|
|
7
18
|
const hours = Math.floor(timeInSeconds / 3600);
|
|
8
19
|
timeInSeconds = timeInSeconds - hours * 3600;
|
|
9
20
|
const minutes = Math.floor(timeInSeconds / 60);
|
|
10
21
|
timeInSeconds = timeInSeconds - minutes * 60;
|
|
11
22
|
const seconds = Math.floor(timeInSeconds);
|
|
12
|
-
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
13
23
|
let result = '';
|
|
14
24
|
if (hours) {
|
|
15
25
|
result += `${hours}h `;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistic-utills.js","names":["join","promises","fs","getAbsoluteFilePath","timeConverter","time","
|
|
1
|
+
{"version":3,"file":"statistic-utills.js","names":["join","promises","fs","getAbsoluteFilePath","timeConverter","time","milliSecondsInSecond","timeInSeconds","Math","floor","milliseconds","timeConverterFromSecondsAndMilliseconds","nanoSecondsInMillisecond","hours","minutes","seconds","result","calculateFilesSize","params","slpk","outputPath","tilesetName","fullOutputPath","slpkPath","stat","size","directoryPath","totalSize","getTotalFilesSize","error","console","log","dirPath","totalFileSize","files","readdir","file","fileStat","isDirectory"],"sources":["../../../src/lib/utils/statistic-utills.ts"],"sourcesContent":["import {join} from 'path';\nimport {promises as fs} from 'fs';\nimport {getAbsoluteFilePath} from './file-utils';\n\n/**\n * Converts time value to string.\n * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.\n * @returns string representation of the time\n */\nexport function timeConverter(time: number | [number, number]): string {\n if (typeof time === 'number') {\n // time - real time in milli-seconds\n const milliSecondsInSecond = 1e3;\n const timeInSeconds = Math.floor(time / milliSecondsInSecond);\n const milliseconds = time - timeInSeconds * milliSecondsInSecond;\n return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);\n } else {\n // time - high-resolution real time in a [seconds, nanoseconds] tuple Array\n const nanoSecondsInMillisecond = 1e6;\n const timeInSeconds = time[0];\n const milliseconds = time[1] / nanoSecondsInMillisecond;\n return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);\n }\n}\n\nfunction timeConverterFromSecondsAndMilliseconds(timeInSeconds: number, milliseconds: number) {\n const hours = Math.floor(timeInSeconds / 3600);\n timeInSeconds = timeInSeconds - hours * 3600;\n const minutes = Math.floor(timeInSeconds / 60);\n timeInSeconds = timeInSeconds - minutes * 60;\n const seconds = Math.floor(timeInSeconds);\n let result = '';\n\n if (hours) {\n result += `${hours}h `;\n }\n\n if (minutes) {\n result += `${minutes}m `;\n }\n\n if (seconds) {\n result += `${seconds}s`;\n }\n\n if (!result) {\n result += `${milliseconds}ms`;\n }\n\n return result;\n}\n\nexport async function calculateFilesSize(params) {\n const {slpk, outputPath, tilesetName} = params;\n const fullOutputPath = getAbsoluteFilePath(outputPath);\n\n try {\n if (slpk) {\n const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);\n const stat = await fs.stat(slpkPath);\n return stat.size;\n }\n\n const directoryPath = join(fullOutputPath, tilesetName);\n const totalSize = await getTotalFilesSize(directoryPath);\n return totalSize;\n } catch (error) {\n console.log('Calculate file sizes error: ', error); // eslint-disable-line\n return null;\n }\n}\n\nasync function getTotalFilesSize(dirPath) {\n let totalFileSize = 0;\n\n const files = await fs.readdir(dirPath);\n\n for (const file of files) {\n const fileStat = await fs.stat(join(dirPath, file));\n if (fileStat.isDirectory()) {\n totalFileSize += await getTotalFilesSize(join(dirPath, file));\n } else {\n totalFileSize += fileStat.size;\n }\n }\n return totalFileSize;\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,IAAI,CAAC,CAAC;IAC/D,CAAC,MAAM;MACLH,aAAa,IAAII,QAAQ,CAACZ,IAAI;IAChC;EACF;EACA,OAAOQ,aAAa;AACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/i3s-server/bin/i3s-server.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@loaders.gl/3d-tiles": "4.0.
|
|
56
|
-
"@loaders.gl/crypto": "4.0.
|
|
57
|
-
"@loaders.gl/draco": "4.0.
|
|
58
|
-
"@loaders.gl/gltf": "4.0.
|
|
59
|
-
"@loaders.gl/i3s": "4.0.
|
|
60
|
-
"@loaders.gl/images": "4.0.
|
|
61
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
62
|
-
"@loaders.gl/polyfills": "4.0.
|
|
63
|
-
"@loaders.gl/textures": "4.0.
|
|
64
|
-
"@loaders.gl/tiles": "4.0.
|
|
65
|
-
"@loaders.gl/worker-utils": "4.0.
|
|
66
|
-
"@loaders.gl/zip": "4.0.
|
|
55
|
+
"@loaders.gl/3d-tiles": "4.0.4",
|
|
56
|
+
"@loaders.gl/crypto": "4.0.4",
|
|
57
|
+
"@loaders.gl/draco": "4.0.4",
|
|
58
|
+
"@loaders.gl/gltf": "4.0.4",
|
|
59
|
+
"@loaders.gl/i3s": "4.0.4",
|
|
60
|
+
"@loaders.gl/images": "4.0.4",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.0.4",
|
|
62
|
+
"@loaders.gl/polyfills": "4.0.4",
|
|
63
|
+
"@loaders.gl/textures": "4.0.4",
|
|
64
|
+
"@loaders.gl/tiles": "4.0.4",
|
|
65
|
+
"@loaders.gl/worker-utils": "4.0.4",
|
|
66
|
+
"@loaders.gl/zip": "4.0.4",
|
|
67
67
|
"@math.gl/core": "^4.0.0",
|
|
68
68
|
"@math.gl/culling": "^4.0.0",
|
|
69
69
|
"@math.gl/geoid": "^4.0.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"join-images": "^1.1.3",
|
|
88
88
|
"sharp": "^0.31.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "4dc810fa04bb400f4aedfef98a83c7ef882ed3d7",
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/express": "^4.17.17",
|
|
93
93
|
"@types/node": "^20.4.2"
|
|
@@ -7,7 +7,7 @@ import {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl
|
|
|
7
7
|
import {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';
|
|
8
8
|
|
|
9
9
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
10
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : '
|
|
10
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
11
11
|
|
|
12
12
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
13
13
|
|
|
@@ -1561,21 +1561,26 @@ async function generateCompressedGeometry(
|
|
|
1561
1561
|
};
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
|
-
return encode(
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1564
|
+
return encode(
|
|
1565
|
+
{attributes: compressedAttributes, indices},
|
|
1566
|
+
// @ts-expect-error if encoded supports worker writer, we should update its type signature
|
|
1567
|
+
DracoWriterWorker,
|
|
1568
|
+
{
|
|
1569
|
+
...DracoWriterWorker.options,
|
|
1570
|
+
reuseWorkers: true,
|
|
1571
|
+
_nodeWorkers: true,
|
|
1572
|
+
modules: libraries,
|
|
1573
|
+
useLocalLibraries: true,
|
|
1574
|
+
draco: {
|
|
1575
|
+
method: 'MESH_SEQUENTIAL_ENCODING',
|
|
1576
|
+
attributesMetadata
|
|
1577
|
+
},
|
|
1578
|
+
['draco-writer']: {
|
|
1579
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
1580
|
+
workerUrl: './modules/draco/dist/draco-writer-worker-node.js'
|
|
1581
|
+
}
|
|
1577
1582
|
}
|
|
1578
|
-
|
|
1583
|
+
);
|
|
1579
1584
|
}
|
|
1580
1585
|
|
|
1581
1586
|
/**
|