@inweb/viewer-visualize 26.12.7 → 27.1.0
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/viewer-visualize.js +110 -54
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +110 -54
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Components/InfoComponent.d.ts +22 -0
- package/lib/Viewer/Viewer.d.ts +1 -0
- package/package.json +5 -5
- package/src/Viewer/Components/InfoComponent.ts +139 -0
- package/src/Viewer/Components/index.ts +2 -0
- package/src/Viewer/Loaders/VSFCloudLoader.ts +0 -4
- package/src/Viewer/Loaders/VSFXCloudLoader.ts +0 -4
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +7 -12
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +6 -15
- package/src/Viewer/Viewer.ts +9 -3
- package/lib/Viewer/Loaders/UpdateController.d.ts +0 -14
- package/src/Viewer/Loaders/UpdateController.ts +0 -60
package/dist/viewer-visualize.js
CHANGED
|
@@ -3336,6 +3336,99 @@
|
|
|
3336
3336
|
}
|
|
3337
3337
|
}
|
|
3338
3338
|
|
|
3339
|
+
class InfoComponent {
|
|
3340
|
+
constructor(viewer) {
|
|
3341
|
+
this.initialize = () => {
|
|
3342
|
+
this.resize();
|
|
3343
|
+
this.optionsChange({ data: this.viewer.options });
|
|
3344
|
+
};
|
|
3345
|
+
this.clear = () => {
|
|
3346
|
+
this.viewer.info.performance.timeToFirstRender = 0;
|
|
3347
|
+
this.viewer.info.performance.loadTime = 0;
|
|
3348
|
+
this.viewer.info.scene.objects = 0;
|
|
3349
|
+
this.viewer.info.scene.triangles = 0;
|
|
3350
|
+
this.viewer.info.scene.points = 0;
|
|
3351
|
+
this.viewer.info.scene.lines = 0;
|
|
3352
|
+
this.viewer.info.scene.edges = 0;
|
|
3353
|
+
this.viewer.info.optimizedScene.objects = 0;
|
|
3354
|
+
this.viewer.info.optimizedScene.triangles = 0;
|
|
3355
|
+
this.viewer.info.optimizedScene.points = 0;
|
|
3356
|
+
this.viewer.info.optimizedScene.lines = 0;
|
|
3357
|
+
this.viewer.info.optimizedScene.edges = 0;
|
|
3358
|
+
this.viewer.info.memory.geometries = 0;
|
|
3359
|
+
this.viewer.info.memory.geometryBytes = 0;
|
|
3360
|
+
this.viewer.info.memory.textures = 0;
|
|
3361
|
+
this.viewer.info.memory.textureBytes = 0;
|
|
3362
|
+
this.viewer.info.memory.materials = 0;
|
|
3363
|
+
this.viewer.info.memory.totalEstimatedGpuBytes = 0;
|
|
3364
|
+
this.viewer.info.memory.usedJSHeapSize = 0;
|
|
3365
|
+
};
|
|
3366
|
+
this.optionsChange = ({ data: options }) => {
|
|
3367
|
+
const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
|
|
3368
|
+
if (antialiasing)
|
|
3369
|
+
this.viewer.info.render.antialiasing = "fxaa";
|
|
3370
|
+
else
|
|
3371
|
+
this.viewer.info.render.antialiasing = "";
|
|
3372
|
+
};
|
|
3373
|
+
this.geometryStart = () => {
|
|
3374
|
+
this.startTime = performance.now();
|
|
3375
|
+
};
|
|
3376
|
+
this.databaseChunk = () => {
|
|
3377
|
+
this.viewer.info.performance.timeToFirstRender += performance.now() - this.startTime;
|
|
3378
|
+
console.log("Time to first render:", this.viewer.info.performance.timeToFirstRender, "ms");
|
|
3379
|
+
};
|
|
3380
|
+
this.geometryEnd = () => {
|
|
3381
|
+
const memory = performance["memory"];
|
|
3382
|
+
if (memory)
|
|
3383
|
+
this.viewer.info.memory.usedJSHeapSize = memory.usedJSHeapSize;
|
|
3384
|
+
this.viewer.info.performance.loadTime += performance.now() - this.startTime;
|
|
3385
|
+
console.log("File load time:", this.viewer.info.performance.loadTime, "ms");
|
|
3386
|
+
};
|
|
3387
|
+
this.resize = () => {
|
|
3388
|
+
const { width, height } = this.viewer.canvas;
|
|
3389
|
+
this.viewer.info.render.viewport.width = width;
|
|
3390
|
+
this.viewer.info.render.viewport.height = height;
|
|
3391
|
+
};
|
|
3392
|
+
this.render = () => { };
|
|
3393
|
+
this.animate = () => {
|
|
3394
|
+
const time = performance.now();
|
|
3395
|
+
this.viewer.info.performance.frameTime = Math.round(time - this.beginTime);
|
|
3396
|
+
this.beginTime = time;
|
|
3397
|
+
this.frames++;
|
|
3398
|
+
if (time - this.prevTime >= 1000) {
|
|
3399
|
+
this.viewer.info.performance.fps = Math.round((this.frames * 1000) / (time - this.prevTime));
|
|
3400
|
+
this.prevTime = time;
|
|
3401
|
+
this.frames = 0;
|
|
3402
|
+
}
|
|
3403
|
+
};
|
|
3404
|
+
this.viewer = viewer;
|
|
3405
|
+
this.startTime = 0;
|
|
3406
|
+
this.beginTime = performance.now();
|
|
3407
|
+
this.prevTime = performance.now();
|
|
3408
|
+
this.frames = 0;
|
|
3409
|
+
this.viewer.addEventListener("initialize", this.initialize);
|
|
3410
|
+
this.viewer.addEventListener("clear", this.clear);
|
|
3411
|
+
this.viewer.addEventListener("optionschange", this.optionsChange);
|
|
3412
|
+
this.viewer.addEventListener("geometrystart", this.geometryStart);
|
|
3413
|
+
this.viewer.addEventListener("databasechunk", this.databaseChunk);
|
|
3414
|
+
this.viewer.addEventListener("geometryend", this.geometryEnd);
|
|
3415
|
+
this.viewer.addEventListener("resize", this.resize);
|
|
3416
|
+
this.viewer.addEventListener("render", this.render);
|
|
3417
|
+
this.viewer.addEventListener("animate", this.animate);
|
|
3418
|
+
}
|
|
3419
|
+
dispose() {
|
|
3420
|
+
this.viewer.removeEventListener("initialize", this.initialize);
|
|
3421
|
+
this.viewer.removeEventListener("clear", this.clear);
|
|
3422
|
+
this.viewer.removeEventListener("optionschange", this.optionsChange);
|
|
3423
|
+
this.viewer.removeEventListener("geometrystart", this.geometryStart);
|
|
3424
|
+
this.viewer.removeEventListener("databasechunk", this.databaseChunk);
|
|
3425
|
+
this.viewer.removeEventListener("geometryend", this.geometryEnd);
|
|
3426
|
+
this.viewer.removeEventListener("resize", this.resize);
|
|
3427
|
+
this.viewer.removeEventListener("render", this.render);
|
|
3428
|
+
this.viewer.addEventListener("animate", this.animate);
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3339
3432
|
class RenderLoopComponent {
|
|
3340
3433
|
constructor(viewer) {
|
|
3341
3434
|
this.animate = (time = 0) => {
|
|
@@ -3621,6 +3714,7 @@
|
|
|
3621
3714
|
|
|
3622
3715
|
const components = componentsRegistry("visualizejs");
|
|
3623
3716
|
components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
|
|
3717
|
+
components.registerComponent("InfoComponent", (viewer) => new InfoComponent(viewer));
|
|
3624
3718
|
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
3625
3719
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
3626
3720
|
components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
|
|
@@ -3765,7 +3859,6 @@
|
|
|
3765
3859
|
return this;
|
|
3766
3860
|
const visViewer = this.viewer.visViewer();
|
|
3767
3861
|
const filesToDownload = [model.database, ...model.geometry];
|
|
3768
|
-
console.time("File load time");
|
|
3769
3862
|
for (let i = 0; i < filesToDownload.length; i++) {
|
|
3770
3863
|
const dataId = filesToDownload[i];
|
|
3771
3864
|
const progress = (progress) => {
|
|
@@ -3797,7 +3890,6 @@
|
|
|
3797
3890
|
this.viewer.emitEvent({ type: "geometrychunk", data, file: model.file, model });
|
|
3798
3891
|
}
|
|
3799
3892
|
}
|
|
3800
|
-
console.timeEnd("File load time");
|
|
3801
3893
|
return this;
|
|
3802
3894
|
}
|
|
3803
3895
|
}
|
|
@@ -3865,7 +3957,6 @@
|
|
|
3865
3957
|
const progress = (progress) => {
|
|
3866
3958
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3867
3959
|
};
|
|
3868
|
-
console.time("File load time");
|
|
3869
3960
|
const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
|
|
3870
3961
|
const data = new Uint8Array(arrayBuffer);
|
|
3871
3962
|
if (!this.viewer.visualizeJs)
|
|
@@ -3884,39 +3975,10 @@
|
|
|
3884
3975
|
this.viewer.syncOverlay();
|
|
3885
3976
|
this.viewer.update(true);
|
|
3886
3977
|
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
3887
|
-
console.timeEnd("File load time");
|
|
3888
3978
|
return this;
|
|
3889
3979
|
}
|
|
3890
3980
|
}
|
|
3891
3981
|
|
|
3892
|
-
const DELAY_TIME_MULTIPLEXER = 2.0;
|
|
3893
|
-
const START_UPDATE_TIME = 1000;
|
|
3894
|
-
var UpdateType;
|
|
3895
|
-
(function (UpdateType) {
|
|
3896
|
-
UpdateType[UpdateType["kDelay"] = 0] = "kDelay";
|
|
3897
|
-
UpdateType[UpdateType["kNormal"] = 1] = "kNormal";
|
|
3898
|
-
UpdateType[UpdateType["kForce"] = 2] = "kForce";
|
|
3899
|
-
})(UpdateType || (UpdateType = {}));
|
|
3900
|
-
class UpdateController {
|
|
3901
|
-
constructor() {
|
|
3902
|
-
this.lastUpdate = 0;
|
|
3903
|
-
this.delayUpdateTime = START_UPDATE_TIME;
|
|
3904
|
-
}
|
|
3905
|
-
initialize(viewer) {
|
|
3906
|
-
this.viewer = viewer;
|
|
3907
|
-
this.lastUpdate = performance.now();
|
|
3908
|
-
}
|
|
3909
|
-
update(type) {
|
|
3910
|
-
const isNeedUpdate = type !== UpdateType.kDelay || performance.now() - this.lastUpdate >= this.delayUpdateTime;
|
|
3911
|
-
const isForce = type === UpdateType.kForce;
|
|
3912
|
-
if (isNeedUpdate) {
|
|
3913
|
-
this.viewer.update(isForce);
|
|
3914
|
-
this.lastUpdate = performance.now();
|
|
3915
|
-
this.delayUpdateTime *= DELAY_TIME_MULTIPLEXER;
|
|
3916
|
-
}
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3919
|
-
|
|
3920
3982
|
class VSFXCloudStreamingLoader extends Loader {
|
|
3921
3983
|
constructor(viewer) {
|
|
3922
3984
|
super();
|
|
@@ -3936,9 +3998,7 @@
|
|
|
3936
3998
|
return this;
|
|
3937
3999
|
const visLib = this.viewer.visLib();
|
|
3938
4000
|
const visViewer = this.viewer.visViewer();
|
|
3939
|
-
|
|
3940
|
-
updateController.initialize(this.viewer);
|
|
3941
|
-
let isFireDatabaseChunk = false;
|
|
4001
|
+
let isServiceDataReady = false;
|
|
3942
4002
|
const chunkLoadHandler = (progress, chunk) => {
|
|
3943
4003
|
if (!this.viewer.visualizeJs)
|
|
3944
4004
|
return;
|
|
@@ -3953,8 +4013,8 @@
|
|
|
3953
4013
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3954
4014
|
let isDatabaseChunk = false;
|
|
3955
4015
|
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
3956
|
-
(status === visLib.DatabaseStreamStatus.Complete && !
|
|
3957
|
-
|
|
4016
|
+
(status === visLib.DatabaseStreamStatus.Complete && !isServiceDataReady)) {
|
|
4017
|
+
isServiceDataReady = true;
|
|
3958
4018
|
isDatabaseChunk = true;
|
|
3959
4019
|
}
|
|
3960
4020
|
if (isDatabaseChunk) {
|
|
@@ -3963,19 +4023,16 @@
|
|
|
3963
4023
|
this.viewer.models.push(modelImpl);
|
|
3964
4024
|
this.viewer.syncOptions();
|
|
3965
4025
|
this.viewer.syncOverlay();
|
|
3966
|
-
|
|
4026
|
+
this.viewer.update(true);
|
|
3967
4027
|
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
3968
4028
|
}
|
|
3969
4029
|
else {
|
|
3970
|
-
|
|
4030
|
+
this.viewer.update();
|
|
3971
4031
|
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
3972
4032
|
}
|
|
3973
4033
|
};
|
|
3974
|
-
console.time("File load time");
|
|
3975
4034
|
await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
|
|
3976
|
-
|
|
3977
|
-
console.timeEnd("File load time");
|
|
3978
|
-
return Promise.resolve(this);
|
|
4035
|
+
return this;
|
|
3979
4036
|
}
|
|
3980
4037
|
}
|
|
3981
4038
|
|
|
@@ -3999,15 +4056,13 @@
|
|
|
3999
4056
|
if (!this.viewer.visualizeJs)
|
|
4000
4057
|
return this;
|
|
4001
4058
|
const visViewer = this.viewer.visViewer();
|
|
4059
|
+
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
4002
4060
|
let servicePartAborted = false;
|
|
4003
4061
|
const pendingRequestsMap = new Map();
|
|
4004
4062
|
let pendingRequestsTimerId = 0;
|
|
4005
4063
|
const pendingRequestsAbortHandler = () => clearTimeout(pendingRequestsTimerId);
|
|
4006
4064
|
const pendingRequestsAbortController = new AbortController();
|
|
4007
4065
|
this.abortControllerForRequestMap.set(0, pendingRequestsAbortController);
|
|
4008
|
-
const updateController = new UpdateController();
|
|
4009
|
-
updateController.initialize(this.viewer);
|
|
4010
|
-
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
4011
4066
|
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
4012
4067
|
if (!this.viewer.visualizeJs)
|
|
4013
4068
|
return;
|
|
@@ -4026,11 +4081,11 @@
|
|
|
4026
4081
|
this.viewer.models.push(modelImpl);
|
|
4027
4082
|
this.viewer.syncOptions();
|
|
4028
4083
|
this.viewer.syncOverlay();
|
|
4029
|
-
|
|
4084
|
+
this.viewer.update(true);
|
|
4030
4085
|
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
4031
4086
|
}
|
|
4032
4087
|
else {
|
|
4033
|
-
|
|
4088
|
+
this.viewer.update();
|
|
4034
4089
|
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
4035
4090
|
}
|
|
4036
4091
|
};
|
|
@@ -4046,7 +4101,6 @@
|
|
|
4046
4101
|
finally {
|
|
4047
4102
|
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
4048
4103
|
this.abortControllerForRequestMap.delete(requestId);
|
|
4049
|
-
updateController.update(UpdateType.kNormal);
|
|
4050
4104
|
}
|
|
4051
4105
|
};
|
|
4052
4106
|
const requestRecordsToRanges = (requestId, records) => {
|
|
@@ -4074,11 +4128,10 @@
|
|
|
4074
4128
|
downloadResourceRange(model.database, requestId, ranges);
|
|
4075
4129
|
},
|
|
4076
4130
|
onFullLoaded: () => {
|
|
4077
|
-
|
|
4131
|
+
this.viewer.update(true);
|
|
4078
4132
|
},
|
|
4079
4133
|
onRequestResponseParsed: (requestId) => {
|
|
4080
4134
|
this.abortControllerForRequestMap.delete(requestId);
|
|
4081
|
-
updateController.update(UpdateType.kNormal);
|
|
4082
4135
|
},
|
|
4083
4136
|
onRequestAborted: (requestId) => {
|
|
4084
4137
|
const abortCtrl = this.abortControllerForRequestMap.get(requestId);
|
|
@@ -18049,6 +18102,7 @@ js: import "konva/skia-backend";
|
|
|
18049
18102
|
this.canvaseventlistener = (event) => this.emit(event);
|
|
18050
18103
|
this._activeDragger = null;
|
|
18051
18104
|
this._components = [];
|
|
18105
|
+
this._updateDelay = 1000;
|
|
18052
18106
|
this._renderNeeded = false;
|
|
18053
18107
|
this._renderTime = 0;
|
|
18054
18108
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
@@ -18171,12 +18225,14 @@ js: import "konva/skia-backend";
|
|
|
18171
18225
|
return this;
|
|
18172
18226
|
}
|
|
18173
18227
|
update(force = false) {
|
|
18228
|
+
const time = performance.now();
|
|
18229
|
+
force = force || time - this._renderTime >= this._updateDelay;
|
|
18174
18230
|
if (this._enableAutoUpdate) {
|
|
18175
18231
|
this._renderNeeded = true;
|
|
18176
18232
|
if (force)
|
|
18177
|
-
this.render();
|
|
18233
|
+
this.render(time);
|
|
18178
18234
|
}
|
|
18179
|
-
this.emitEvent({ type: "update",
|
|
18235
|
+
this.emitEvent({ type: "update", force });
|
|
18180
18236
|
}
|
|
18181
18237
|
render(time) {
|
|
18182
18238
|
var _a, _b;
|
|
@@ -18793,7 +18849,7 @@ js: import "konva/skia-backend";
|
|
|
18793
18849
|
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
18794
18850
|
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
18795
18851
|
}
|
|
18796
|
-
this.emitEvent({ type: "update",
|
|
18852
|
+
this.emitEvent({ type: "update", force: false });
|
|
18797
18853
|
resolve();
|
|
18798
18854
|
}
|
|
18799
18855
|
catch (e) {
|