@inweb/viewer-visualize 26.12.6 → 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 +163 -74
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +161 -72
- 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/Markup/Visualize/VisualizeMarkup.ts +3 -8
- package/src/Viewer/Viewer.ts +88 -14
- package/lib/Viewer/Loaders/UpdateController.d.ts +0 -14
- package/src/Viewer/Loaders/UpdateController.ts +0 -60
|
@@ -2781,6 +2781,99 @@ class CameraComponent {
|
|
|
2781
2781
|
}
|
|
2782
2782
|
}
|
|
2783
2783
|
|
|
2784
|
+
class InfoComponent {
|
|
2785
|
+
constructor(viewer) {
|
|
2786
|
+
this.initialize = () => {
|
|
2787
|
+
this.resize();
|
|
2788
|
+
this.optionsChange({ data: this.viewer.options });
|
|
2789
|
+
};
|
|
2790
|
+
this.clear = () => {
|
|
2791
|
+
this.viewer.info.performance.timeToFirstRender = 0;
|
|
2792
|
+
this.viewer.info.performance.loadTime = 0;
|
|
2793
|
+
this.viewer.info.scene.objects = 0;
|
|
2794
|
+
this.viewer.info.scene.triangles = 0;
|
|
2795
|
+
this.viewer.info.scene.points = 0;
|
|
2796
|
+
this.viewer.info.scene.lines = 0;
|
|
2797
|
+
this.viewer.info.scene.edges = 0;
|
|
2798
|
+
this.viewer.info.optimizedScene.objects = 0;
|
|
2799
|
+
this.viewer.info.optimizedScene.triangles = 0;
|
|
2800
|
+
this.viewer.info.optimizedScene.points = 0;
|
|
2801
|
+
this.viewer.info.optimizedScene.lines = 0;
|
|
2802
|
+
this.viewer.info.optimizedScene.edges = 0;
|
|
2803
|
+
this.viewer.info.memory.geometries = 0;
|
|
2804
|
+
this.viewer.info.memory.geometryBytes = 0;
|
|
2805
|
+
this.viewer.info.memory.textures = 0;
|
|
2806
|
+
this.viewer.info.memory.textureBytes = 0;
|
|
2807
|
+
this.viewer.info.memory.materials = 0;
|
|
2808
|
+
this.viewer.info.memory.totalEstimatedGpuBytes = 0;
|
|
2809
|
+
this.viewer.info.memory.usedJSHeapSize = 0;
|
|
2810
|
+
};
|
|
2811
|
+
this.optionsChange = ({ data: options }) => {
|
|
2812
|
+
const antialiasing = options.antialiasing === true || options.antialiasing === "fxaa";
|
|
2813
|
+
if (antialiasing)
|
|
2814
|
+
this.viewer.info.render.antialiasing = "fxaa";
|
|
2815
|
+
else
|
|
2816
|
+
this.viewer.info.render.antialiasing = "";
|
|
2817
|
+
};
|
|
2818
|
+
this.geometryStart = () => {
|
|
2819
|
+
this.startTime = performance.now();
|
|
2820
|
+
};
|
|
2821
|
+
this.databaseChunk = () => {
|
|
2822
|
+
this.viewer.info.performance.timeToFirstRender += performance.now() - this.startTime;
|
|
2823
|
+
console.log("Time to first render:", this.viewer.info.performance.timeToFirstRender, "ms");
|
|
2824
|
+
};
|
|
2825
|
+
this.geometryEnd = () => {
|
|
2826
|
+
const memory = performance["memory"];
|
|
2827
|
+
if (memory)
|
|
2828
|
+
this.viewer.info.memory.usedJSHeapSize = memory.usedJSHeapSize;
|
|
2829
|
+
this.viewer.info.performance.loadTime += performance.now() - this.startTime;
|
|
2830
|
+
console.log("File load time:", this.viewer.info.performance.loadTime, "ms");
|
|
2831
|
+
};
|
|
2832
|
+
this.resize = () => {
|
|
2833
|
+
const { width, height } = this.viewer.canvas;
|
|
2834
|
+
this.viewer.info.render.viewport.width = width;
|
|
2835
|
+
this.viewer.info.render.viewport.height = height;
|
|
2836
|
+
};
|
|
2837
|
+
this.render = () => { };
|
|
2838
|
+
this.animate = () => {
|
|
2839
|
+
const time = performance.now();
|
|
2840
|
+
this.viewer.info.performance.frameTime = Math.round(time - this.beginTime);
|
|
2841
|
+
this.beginTime = time;
|
|
2842
|
+
this.frames++;
|
|
2843
|
+
if (time - this.prevTime >= 1000) {
|
|
2844
|
+
this.viewer.info.performance.fps = Math.round((this.frames * 1000) / (time - this.prevTime));
|
|
2845
|
+
this.prevTime = time;
|
|
2846
|
+
this.frames = 0;
|
|
2847
|
+
}
|
|
2848
|
+
};
|
|
2849
|
+
this.viewer = viewer;
|
|
2850
|
+
this.startTime = 0;
|
|
2851
|
+
this.beginTime = performance.now();
|
|
2852
|
+
this.prevTime = performance.now();
|
|
2853
|
+
this.frames = 0;
|
|
2854
|
+
this.viewer.addEventListener("initialize", this.initialize);
|
|
2855
|
+
this.viewer.addEventListener("clear", this.clear);
|
|
2856
|
+
this.viewer.addEventListener("optionschange", this.optionsChange);
|
|
2857
|
+
this.viewer.addEventListener("geometrystart", this.geometryStart);
|
|
2858
|
+
this.viewer.addEventListener("databasechunk", this.databaseChunk);
|
|
2859
|
+
this.viewer.addEventListener("geometryend", this.geometryEnd);
|
|
2860
|
+
this.viewer.addEventListener("resize", this.resize);
|
|
2861
|
+
this.viewer.addEventListener("render", this.render);
|
|
2862
|
+
this.viewer.addEventListener("animate", this.animate);
|
|
2863
|
+
}
|
|
2864
|
+
dispose() {
|
|
2865
|
+
this.viewer.removeEventListener("initialize", this.initialize);
|
|
2866
|
+
this.viewer.removeEventListener("clear", this.clear);
|
|
2867
|
+
this.viewer.removeEventListener("optionschange", this.optionsChange);
|
|
2868
|
+
this.viewer.removeEventListener("geometrystart", this.geometryStart);
|
|
2869
|
+
this.viewer.removeEventListener("databasechunk", this.databaseChunk);
|
|
2870
|
+
this.viewer.removeEventListener("geometryend", this.geometryEnd);
|
|
2871
|
+
this.viewer.removeEventListener("resize", this.resize);
|
|
2872
|
+
this.viewer.removeEventListener("render", this.render);
|
|
2873
|
+
this.viewer.addEventListener("animate", this.animate);
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2784
2877
|
class RenderLoopComponent {
|
|
2785
2878
|
constructor(viewer) {
|
|
2786
2879
|
this.animate = (time = 0) => {
|
|
@@ -3066,6 +3159,7 @@ class ResetComponent {
|
|
|
3066
3159
|
|
|
3067
3160
|
const components = componentsRegistry("visualizejs");
|
|
3068
3161
|
components.registerComponent("CameraComponent", (viewer) => new CameraComponent(viewer));
|
|
3162
|
+
components.registerComponent("InfoComponent", (viewer) => new InfoComponent(viewer));
|
|
3069
3163
|
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
3070
3164
|
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
3071
3165
|
components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
|
|
@@ -3210,7 +3304,6 @@ class VSFCloudLoader extends Loader {
|
|
|
3210
3304
|
return this;
|
|
3211
3305
|
const visViewer = this.viewer.visViewer();
|
|
3212
3306
|
const filesToDownload = [model.database, ...model.geometry];
|
|
3213
|
-
console.time("File load time");
|
|
3214
3307
|
for (let i = 0; i < filesToDownload.length; i++) {
|
|
3215
3308
|
const dataId = filesToDownload[i];
|
|
3216
3309
|
const progress = (progress) => {
|
|
@@ -3242,7 +3335,6 @@ class VSFCloudLoader extends Loader {
|
|
|
3242
3335
|
this.viewer.emitEvent({ type: "geometrychunk", data, file: model.file, model });
|
|
3243
3336
|
}
|
|
3244
3337
|
}
|
|
3245
|
-
console.timeEnd("File load time");
|
|
3246
3338
|
return this;
|
|
3247
3339
|
}
|
|
3248
3340
|
}
|
|
@@ -3310,7 +3402,6 @@ class VSFXCloudLoader extends Loader {
|
|
|
3310
3402
|
const progress = (progress) => {
|
|
3311
3403
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3312
3404
|
};
|
|
3313
|
-
console.time("File load time");
|
|
3314
3405
|
const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
|
|
3315
3406
|
const data = new Uint8Array(arrayBuffer);
|
|
3316
3407
|
if (!this.viewer.visualizeJs)
|
|
@@ -3329,39 +3420,10 @@ class VSFXCloudLoader extends Loader {
|
|
|
3329
3420
|
this.viewer.syncOverlay();
|
|
3330
3421
|
this.viewer.update(true);
|
|
3331
3422
|
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
3332
|
-
console.timeEnd("File load time");
|
|
3333
3423
|
return this;
|
|
3334
3424
|
}
|
|
3335
3425
|
}
|
|
3336
3426
|
|
|
3337
|
-
const DELAY_TIME_MULTIPLEXER = 2.0;
|
|
3338
|
-
const START_UPDATE_TIME = 1000;
|
|
3339
|
-
var UpdateType;
|
|
3340
|
-
(function (UpdateType) {
|
|
3341
|
-
UpdateType[UpdateType["kDelay"] = 0] = "kDelay";
|
|
3342
|
-
UpdateType[UpdateType["kNormal"] = 1] = "kNormal";
|
|
3343
|
-
UpdateType[UpdateType["kForce"] = 2] = "kForce";
|
|
3344
|
-
})(UpdateType || (UpdateType = {}));
|
|
3345
|
-
class UpdateController {
|
|
3346
|
-
constructor() {
|
|
3347
|
-
this.lastUpdate = 0;
|
|
3348
|
-
this.delayUpdateTime = START_UPDATE_TIME;
|
|
3349
|
-
}
|
|
3350
|
-
initialize(viewer) {
|
|
3351
|
-
this.viewer = viewer;
|
|
3352
|
-
this.lastUpdate = performance.now();
|
|
3353
|
-
}
|
|
3354
|
-
update(type) {
|
|
3355
|
-
const isNeedUpdate = type !== UpdateType.kDelay || performance.now() - this.lastUpdate >= this.delayUpdateTime;
|
|
3356
|
-
const isForce = type === UpdateType.kForce;
|
|
3357
|
-
if (isNeedUpdate) {
|
|
3358
|
-
this.viewer.update(isForce);
|
|
3359
|
-
this.lastUpdate = performance.now();
|
|
3360
|
-
this.delayUpdateTime *= DELAY_TIME_MULTIPLEXER;
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
}
|
|
3364
|
-
|
|
3365
3427
|
class VSFXCloudStreamingLoader extends Loader {
|
|
3366
3428
|
constructor(viewer) {
|
|
3367
3429
|
super();
|
|
@@ -3381,9 +3443,7 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
3381
3443
|
return this;
|
|
3382
3444
|
const visLib = this.viewer.visLib();
|
|
3383
3445
|
const visViewer = this.viewer.visViewer();
|
|
3384
|
-
|
|
3385
|
-
updateController.initialize(this.viewer);
|
|
3386
|
-
let isFireDatabaseChunk = false;
|
|
3446
|
+
let isServiceDataReady = false;
|
|
3387
3447
|
const chunkLoadHandler = (progress, chunk) => {
|
|
3388
3448
|
if (!this.viewer.visualizeJs)
|
|
3389
3449
|
return;
|
|
@@ -3398,8 +3458,8 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
3398
3458
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3399
3459
|
let isDatabaseChunk = false;
|
|
3400
3460
|
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
3401
|
-
(status === visLib.DatabaseStreamStatus.Complete && !
|
|
3402
|
-
|
|
3461
|
+
(status === visLib.DatabaseStreamStatus.Complete && !isServiceDataReady)) {
|
|
3462
|
+
isServiceDataReady = true;
|
|
3403
3463
|
isDatabaseChunk = true;
|
|
3404
3464
|
}
|
|
3405
3465
|
if (isDatabaseChunk) {
|
|
@@ -3408,19 +3468,16 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
3408
3468
|
this.viewer.models.push(modelImpl);
|
|
3409
3469
|
this.viewer.syncOptions();
|
|
3410
3470
|
this.viewer.syncOverlay();
|
|
3411
|
-
|
|
3471
|
+
this.viewer.update(true);
|
|
3412
3472
|
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
3413
3473
|
}
|
|
3414
3474
|
else {
|
|
3415
|
-
|
|
3475
|
+
this.viewer.update();
|
|
3416
3476
|
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
3417
3477
|
}
|
|
3418
3478
|
};
|
|
3419
|
-
console.time("File load time");
|
|
3420
3479
|
await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
|
|
3421
|
-
|
|
3422
|
-
console.timeEnd("File load time");
|
|
3423
|
-
return Promise.resolve(this);
|
|
3480
|
+
return this;
|
|
3424
3481
|
}
|
|
3425
3482
|
}
|
|
3426
3483
|
|
|
@@ -3444,15 +3501,13 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3444
3501
|
if (!this.viewer.visualizeJs)
|
|
3445
3502
|
return this;
|
|
3446
3503
|
const visViewer = this.viewer.visViewer();
|
|
3504
|
+
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
3447
3505
|
let servicePartAborted = false;
|
|
3448
3506
|
const pendingRequestsMap = new Map();
|
|
3449
3507
|
let pendingRequestsTimerId = 0;
|
|
3450
3508
|
const pendingRequestsAbortHandler = () => clearTimeout(pendingRequestsTimerId);
|
|
3451
3509
|
const pendingRequestsAbortController = new AbortController();
|
|
3452
3510
|
this.abortControllerForRequestMap.set(0, pendingRequestsAbortController);
|
|
3453
|
-
const updateController = new UpdateController();
|
|
3454
|
-
updateController.initialize(this.viewer);
|
|
3455
|
-
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
3456
3511
|
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
3457
3512
|
if (!this.viewer.visualizeJs)
|
|
3458
3513
|
return;
|
|
@@ -3471,11 +3526,11 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3471
3526
|
this.viewer.models.push(modelImpl);
|
|
3472
3527
|
this.viewer.syncOptions();
|
|
3473
3528
|
this.viewer.syncOverlay();
|
|
3474
|
-
|
|
3529
|
+
this.viewer.update(true);
|
|
3475
3530
|
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
3476
3531
|
}
|
|
3477
3532
|
else {
|
|
3478
|
-
|
|
3533
|
+
this.viewer.update();
|
|
3479
3534
|
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
3480
3535
|
}
|
|
3481
3536
|
};
|
|
@@ -3491,7 +3546,6 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3491
3546
|
finally {
|
|
3492
3547
|
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
3493
3548
|
this.abortControllerForRequestMap.delete(requestId);
|
|
3494
|
-
updateController.update(UpdateType.kNormal);
|
|
3495
3549
|
}
|
|
3496
3550
|
};
|
|
3497
3551
|
const requestRecordsToRanges = (requestId, records) => {
|
|
@@ -3519,11 +3573,10 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3519
3573
|
downloadResourceRange(model.database, requestId, ranges);
|
|
3520
3574
|
},
|
|
3521
3575
|
onFullLoaded: () => {
|
|
3522
|
-
|
|
3576
|
+
this.viewer.update(true);
|
|
3523
3577
|
},
|
|
3524
3578
|
onRequestResponseParsed: (requestId) => {
|
|
3525
3579
|
this.abortControllerForRequestMap.delete(requestId);
|
|
3526
|
-
updateController.update(UpdateType.kNormal);
|
|
3527
3580
|
},
|
|
3528
3581
|
onRequestAborted: (requestId) => {
|
|
3529
3582
|
const abortCtrl = this.abortControllerForRequestMap.get(requestId);
|
|
@@ -3866,7 +3919,7 @@ class VisualizeMarkup {
|
|
|
3866
3919
|
const visLib = this._viewer.visLib();
|
|
3867
3920
|
const visViewer = this._viewer.visViewer();
|
|
3868
3921
|
if (!viewpoint)
|
|
3869
|
-
viewpoint = {};
|
|
3922
|
+
viewpoint = { custom_fields: {} };
|
|
3870
3923
|
viewpoint.lines = [];
|
|
3871
3924
|
viewpoint.texts = [];
|
|
3872
3925
|
const model = visViewer.getMarkupModel();
|
|
@@ -3908,12 +3961,8 @@ class VisualizeMarkup {
|
|
|
3908
3961
|
entityPtr.delete();
|
|
3909
3962
|
}
|
|
3910
3963
|
itr.delete();
|
|
3911
|
-
viewpoint.snapshot = {
|
|
3912
|
-
|
|
3913
|
-
};
|
|
3914
|
-
viewpoint.custom_fields = {
|
|
3915
|
-
markup_color: this.getMarkupColor(),
|
|
3916
|
-
};
|
|
3964
|
+
viewpoint.snapshot = { data: visLib.canvas.toDataURL("image/jpeg", 0.25) };
|
|
3965
|
+
viewpoint.custom_fields.markup_color = this.getMarkupColor();
|
|
3917
3966
|
return viewpoint;
|
|
3918
3967
|
}
|
|
3919
3968
|
enableEditMode(mode) {
|
|
@@ -3966,6 +4015,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3966
4015
|
this.canvaseventlistener = (event) => this.emit(event);
|
|
3967
4016
|
this._activeDragger = null;
|
|
3968
4017
|
this._components = [];
|
|
4018
|
+
this._updateDelay = 1000;
|
|
3969
4019
|
this._renderNeeded = false;
|
|
3970
4020
|
this._renderTime = 0;
|
|
3971
4021
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
@@ -4088,12 +4138,14 @@ class Viewer extends EventEmitter2 {
|
|
|
4088
4138
|
return this;
|
|
4089
4139
|
}
|
|
4090
4140
|
update(force = false) {
|
|
4141
|
+
const time = performance.now();
|
|
4142
|
+
force = force || time - this._renderTime >= this._updateDelay;
|
|
4091
4143
|
if (this._enableAutoUpdate) {
|
|
4092
4144
|
this._renderNeeded = true;
|
|
4093
4145
|
if (force)
|
|
4094
|
-
this.render();
|
|
4146
|
+
this.render(time);
|
|
4095
4147
|
}
|
|
4096
|
-
this.emitEvent({ type: "update",
|
|
4148
|
+
this.emitEvent({ type: "update", force });
|
|
4097
4149
|
}
|
|
4098
4150
|
render(time) {
|
|
4099
4151
|
var _a, _b;
|
|
@@ -4513,11 +4565,27 @@ class Viewer extends EventEmitter2 {
|
|
|
4513
4565
|
const setOrthogonalCamera = (orthogonal_camera) => {
|
|
4514
4566
|
if (orthogonal_camera) {
|
|
4515
4567
|
activeView.setView(getPoint3dAsArray(orthogonal_camera.view_point), getPoint3dAsArray(orthogonal_camera.direction), getPoint3dAsArray(orthogonal_camera.up_vector), orthogonal_camera.field_width, orthogonal_camera.field_height, true);
|
|
4516
|
-
this.
|
|
4568
|
+
this.options.cameraMode = "orthographic";
|
|
4517
4569
|
this.emitEvent({ type: "changecameramode", mode: "orthographic" });
|
|
4518
4570
|
}
|
|
4519
4571
|
};
|
|
4520
|
-
const setPerspectiveCamera = (perspective_camera) => {
|
|
4572
|
+
const setPerspectiveCamera = (perspective_camera) => {
|
|
4573
|
+
if (perspective_camera) {
|
|
4574
|
+
const aspectRatio = this.canvas.width / this.canvas.height;
|
|
4575
|
+
const position = perspective_camera.view_point;
|
|
4576
|
+
const target = perspective_camera.direction;
|
|
4577
|
+
const fov = (perspective_camera.field_of_view * Math.PI) / 180;
|
|
4578
|
+
const dx = target.x - position.x;
|
|
4579
|
+
const dy = target.y - position.y;
|
|
4580
|
+
const dz = target.z - position.z;
|
|
4581
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
4582
|
+
const fieldHeight = 2 * distance * Math.tan(fov / 2);
|
|
4583
|
+
const fieldWidth = fieldHeight * aspectRatio;
|
|
4584
|
+
activeView.setView(getPoint3dAsArray(perspective_camera.view_point), getPoint3dAsArray(perspective_camera.direction), getPoint3dAsArray(perspective_camera.up_vector), fieldWidth, fieldHeight, false);
|
|
4585
|
+
this.options.cameraMode = "perspective";
|
|
4586
|
+
this.emitEvent({ type: "changecameramode", mode: "perspective" });
|
|
4587
|
+
}
|
|
4588
|
+
};
|
|
4521
4589
|
const setClippingPlanes = (clipping_planes) => {
|
|
4522
4590
|
if (clipping_planes) {
|
|
4523
4591
|
for (const clipping_plane of clipping_planes) {
|
|
@@ -4544,6 +4612,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4544
4612
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
4545
4613
|
setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
|
|
4546
4614
|
this._markup.setViewpoint(viewpoint);
|
|
4615
|
+
this.syncOverlay();
|
|
4547
4616
|
this.setActiveDragger(draggerName);
|
|
4548
4617
|
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
4549
4618
|
this.update();
|
|
@@ -4557,17 +4626,37 @@ class Viewer extends EventEmitter2 {
|
|
|
4557
4626
|
return { x: array[0], y: array[1], z: array[2] };
|
|
4558
4627
|
};
|
|
4559
4628
|
const getOrthogonalCamera = () => {
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4629
|
+
if (!activeView.perspective)
|
|
4630
|
+
return {
|
|
4631
|
+
view_point: getPoint3dFromArray(activeView.viewPosition),
|
|
4632
|
+
direction: getPoint3dFromArray(activeView.viewTarget),
|
|
4633
|
+
up_vector: getPoint3dFromArray(activeView.upVector),
|
|
4634
|
+
field_width: activeView.viewFieldWidth,
|
|
4635
|
+
field_height: activeView.viewFieldHeight,
|
|
4636
|
+
view_to_world_scale: 1,
|
|
4637
|
+
};
|
|
4638
|
+
else
|
|
4639
|
+
return undefined;
|
|
4568
4640
|
};
|
|
4569
4641
|
const getPerspectiveCamera = () => {
|
|
4570
|
-
|
|
4642
|
+
if (activeView.perspective) {
|
|
4643
|
+
const position = activeView.viewPosition;
|
|
4644
|
+
const target = activeView.viewTarget;
|
|
4645
|
+
const fieldHeight = activeView.viewFieldHeight;
|
|
4646
|
+
const dx = target[0] - position[0];
|
|
4647
|
+
const dy = target[1] - position[1];
|
|
4648
|
+
const dz = target[2] - position[2];
|
|
4649
|
+
const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
4650
|
+
const fov = 2 * Math.atan(fieldHeight / (2 * distance));
|
|
4651
|
+
return {
|
|
4652
|
+
view_point: getPoint3dFromArray(activeView.viewPosition),
|
|
4653
|
+
direction: getPoint3dFromArray(activeView.viewTarget),
|
|
4654
|
+
up_vector: getPoint3dFromArray(activeView.upVector),
|
|
4655
|
+
field_of_view: (fov * 180) / Math.PI,
|
|
4656
|
+
};
|
|
4657
|
+
}
|
|
4658
|
+
else
|
|
4659
|
+
return undefined;
|
|
4571
4660
|
};
|
|
4572
4661
|
const getClippingPlanes = () => {
|
|
4573
4662
|
const clipping_planes = [];
|
|
@@ -4673,7 +4762,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4673
4762
|
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
4674
4763
|
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
4675
4764
|
}
|
|
4676
|
-
this.emitEvent({ type: "update",
|
|
4765
|
+
this.emitEvent({ type: "update", force: false });
|
|
4677
4766
|
resolve();
|
|
4678
4767
|
}
|
|
4679
4768
|
catch (e) {
|