@inweb/viewer-visualize 26.9.0 → 26.9.2
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 +144 -115
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +142 -119
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Components/ResizeCanvasComponent.d.ts +1 -1
- package/lib/Viewer/Loaders/index.d.ts +1 -2
- package/lib/Viewer/Viewer.d.ts +6 -4
- package/package.json +5 -5
- package/src/Viewer/Commands/ApplyModelTransform.ts +1 -1
- package/src/Viewer/Commands/AutoTransformAllModelsToCentralPoint.ts +1 -1
- package/src/Viewer/Commands/SetSelected.ts +1 -1
- package/src/Viewer/Components/ResizeCanvasComponent.ts +6 -2
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +6 -0
- package/src/Viewer/Draggers/Actions/PanAction.ts +3 -0
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +4 -0
- package/src/Viewer/Draggers/OdaWalkDragger.ts +4 -0
- package/src/Viewer/Loaders/VSFCloudLoader.ts +10 -9
- package/src/Viewer/Loaders/VSFFileLoader.ts +12 -7
- package/src/Viewer/Loaders/VSFXCloudLoader.ts +4 -6
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +6 -11
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -11
- package/src/Viewer/Loaders/VSFXFileLoader.ts +12 -7
- package/src/Viewer/Loaders/index.ts +1 -2
- package/src/Viewer/Markup/Visualize/VisualizeMarkup.ts +2 -2
- package/src/Viewer/Viewer.ts +83 -67
|
@@ -938,6 +938,9 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
940
|
this.subject.update();
|
|
941
|
+
this.subject.emitEvent({
|
|
942
|
+
type: "changecamera"
|
|
943
|
+
});
|
|
941
944
|
}
|
|
942
945
|
this.lastFrameTS = timestamp;
|
|
943
946
|
}
|
|
@@ -958,6 +961,9 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
958
961
|
if (dltX !== 0) this.turnLeft(-dltX * this.deltaAngle);
|
|
959
962
|
if (dltY !== 0) this.cameraWalker.turnDown(dltY * this.deltaAngle);
|
|
960
963
|
this.subject.update();
|
|
964
|
+
this.subject.emitEvent({
|
|
965
|
+
type: "changecamera"
|
|
966
|
+
});
|
|
961
967
|
}
|
|
962
968
|
}
|
|
963
969
|
turnLeft(angle) {
|
|
@@ -1208,6 +1214,12 @@ class OrbitAction {
|
|
|
1208
1214
|
extView.setView(viewParams.position, viewParams.target, viewParams.upVector, viewParams.viewFieldWidth, viewParams.viewFieldHeight, viewParams.perspective);
|
|
1209
1215
|
extView.delete();
|
|
1210
1216
|
(_b = (_a = this._subject.activeDragger()) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
|
|
1217
|
+
this._subject.emitEvent({
|
|
1218
|
+
type: "orbit"
|
|
1219
|
+
});
|
|
1220
|
+
this._subject.emitEvent({
|
|
1221
|
+
type: "changecamera"
|
|
1222
|
+
});
|
|
1211
1223
|
}
|
|
1212
1224
|
endAction() {
|
|
1213
1225
|
this._endInteractivity();
|
|
@@ -1387,6 +1399,9 @@ class PanAction {
|
|
|
1387
1399
|
dX: absoluteX - this._deltaScreenPosition.x,
|
|
1388
1400
|
dY: absoluteY - this._deltaScreenPosition.y
|
|
1389
1401
|
});
|
|
1402
|
+
this._subject.emitEvent({
|
|
1403
|
+
type: "changecamera"
|
|
1404
|
+
});
|
|
1390
1405
|
this._deltaScreenPosition = {
|
|
1391
1406
|
x: absoluteX,
|
|
1392
1407
|
y: absoluteY
|
|
@@ -1439,6 +1454,9 @@ class ZoomAction {
|
|
|
1439
1454
|
x: absoluteX,
|
|
1440
1455
|
y: absoluteY
|
|
1441
1456
|
});
|
|
1457
|
+
this._subject.emitEvent({
|
|
1458
|
+
type: "changecamera"
|
|
1459
|
+
});
|
|
1442
1460
|
}
|
|
1443
1461
|
}
|
|
1444
1462
|
|
|
@@ -1781,7 +1799,7 @@ function applyModelTransform(viewer, model) {
|
|
|
1781
1799
|
if (!viewer.visualizeJs) return;
|
|
1782
1800
|
if (!model.getModelTransformMatrix) return;
|
|
1783
1801
|
const visLib = viewer.visLib();
|
|
1784
|
-
const visViewer =
|
|
1802
|
+
const visViewer = viewer.visViewer();
|
|
1785
1803
|
const modelItr = visViewer.getModelIterator();
|
|
1786
1804
|
for (;!modelItr.done(); modelItr.step()) {
|
|
1787
1805
|
const modelPtr = modelItr.getModel();
|
|
@@ -1979,7 +1997,7 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
|
1979
1997
|
function setSelected(viewer, handles = []) {
|
|
1980
1998
|
if (!viewer.visualizeJs) return;
|
|
1981
1999
|
const visLib = viewer.visLib();
|
|
1982
|
-
const visViewer =
|
|
2000
|
+
const visViewer = viewer.visViewer();
|
|
1983
2001
|
const selectionSet = new visLib.OdTvSelectionSet;
|
|
1984
2002
|
handles === null || handles === undefined ? undefined : handles.forEach((handle => {
|
|
1985
2003
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
@@ -2061,7 +2079,7 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
|
2061
2079
|
if (!viewer.visualizeJs) return;
|
|
2062
2080
|
if (!model.getModelTransformMatrix) return;
|
|
2063
2081
|
const visLib = viewer.visLib();
|
|
2064
|
-
const visViewer =
|
|
2082
|
+
const visViewer = viewer.visViewer();
|
|
2065
2083
|
const viewExt = visViewer.getActiveExtents();
|
|
2066
2084
|
const centralPoint = viewExt.center();
|
|
2067
2085
|
const modelItr = visViewer.getModelIterator();
|
|
@@ -2202,8 +2220,10 @@ class RenderLoopComponent {
|
|
|
2202
2220
|
|
|
2203
2221
|
class ResizeCanvasComponent {
|
|
2204
2222
|
constructor(viewer) {
|
|
2205
|
-
this.resizeViewer =
|
|
2206
|
-
|
|
2223
|
+
this.resizeViewer = entries => {
|
|
2224
|
+
const {width: width, height: height} = entries[0].contentRect;
|
|
2225
|
+
if (!width || !height) return;
|
|
2226
|
+
this.viewer.setSize(width, height);
|
|
2207
2227
|
};
|
|
2208
2228
|
this.viewer = viewer;
|
|
2209
2229
|
this.resizeObserver = new ResizeObserver(this.resizeViewer);
|
|
@@ -2512,6 +2532,7 @@ class VSFFileLoader extends Loader {
|
|
|
2512
2532
|
}
|
|
2513
2533
|
async load(file, format, params) {
|
|
2514
2534
|
if (!this.viewer.visualizeJs) return this;
|
|
2535
|
+
const visViewer = this.viewer.visViewer();
|
|
2515
2536
|
const progress = event => {
|
|
2516
2537
|
const {lengthComputable: lengthComputable, loaded: loaded, total: total} = event;
|
|
2517
2538
|
const progress = lengthComputable ? loaded / total : 1;
|
|
@@ -2525,15 +2546,18 @@ class VSFFileLoader extends Loader {
|
|
|
2525
2546
|
loader.setRequestHeader(params.requestHeader);
|
|
2526
2547
|
loader.setWithCredentials(params.withCredentials);
|
|
2527
2548
|
loader.setAbortSignal(this.abortController.signal);
|
|
2528
|
-
const
|
|
2529
|
-
const data = new Uint8Array(
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2549
|
+
const arrayBuffer = await loader.load(file, progress);
|
|
2550
|
+
const data = new Uint8Array(arrayBuffer);
|
|
2551
|
+
if (!this.viewer.visualizeJs) return this;
|
|
2552
|
+
try {
|
|
2553
|
+
visViewer.parseFile(data);
|
|
2554
|
+
} catch (error) {
|
|
2555
|
+
console.error("VSF parse error.", error);
|
|
2556
|
+
throw error;
|
|
2557
|
+
}
|
|
2534
2558
|
this.viewer.syncOptions();
|
|
2535
2559
|
this.viewer.syncOverlay();
|
|
2536
|
-
this.viewer.
|
|
2560
|
+
this.viewer.update(true);
|
|
2537
2561
|
this.viewer.emitEvent({
|
|
2538
2562
|
type: "databasechunk",
|
|
2539
2563
|
data: data,
|
|
@@ -2553,8 +2577,7 @@ class VSFCloudLoader extends Loader {
|
|
|
2553
2577
|
}
|
|
2554
2578
|
async load(model, format) {
|
|
2555
2579
|
if (!this.viewer.visualizeJs) return this;
|
|
2556
|
-
const
|
|
2557
|
-
const visViewer = visLib.getViewer();
|
|
2580
|
+
const visViewer = this.viewer.visViewer();
|
|
2558
2581
|
const filesToDownload = [ model.database, ...model.geometry ];
|
|
2559
2582
|
console.time("File load time");
|
|
2560
2583
|
for (let i = 0; i < filesToDownload.length; i++) {
|
|
@@ -2569,15 +2592,18 @@ class VSFCloudLoader extends Loader {
|
|
|
2569
2592
|
});
|
|
2570
2593
|
};
|
|
2571
2594
|
const arrayBuffer = await model.downloadResource(dataId, progress, this.abortController.signal);
|
|
2572
|
-
if (!this.viewer.visualizeJs) return this;
|
|
2573
2595
|
const data = new Uint8Array(arrayBuffer);
|
|
2574
|
-
|
|
2596
|
+
if (!this.viewer.visualizeJs) return this;
|
|
2597
|
+
try {
|
|
2598
|
+
visViewer.parseStream(data);
|
|
2599
|
+
} catch (error) {
|
|
2600
|
+
console.error("VSF parse error.", error);
|
|
2601
|
+
throw error;
|
|
2602
|
+
}
|
|
2575
2603
|
if (i === 0) {
|
|
2576
|
-
this.viewer.update(true);
|
|
2577
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2578
2604
|
this.viewer.syncOptions();
|
|
2579
2605
|
this.viewer.syncOverlay();
|
|
2580
|
-
this.viewer.
|
|
2606
|
+
this.viewer.update(true);
|
|
2581
2607
|
this.viewer.emitEvent({
|
|
2582
2608
|
type: "databasechunk",
|
|
2583
2609
|
data: data,
|
|
@@ -2609,6 +2635,7 @@ class VSFXFileLoader extends Loader {
|
|
|
2609
2635
|
}
|
|
2610
2636
|
async load(file, format, params) {
|
|
2611
2637
|
if (!this.viewer.visualizeJs) return this;
|
|
2638
|
+
const visViewer = this.viewer.visViewer();
|
|
2612
2639
|
const progress = event => {
|
|
2613
2640
|
const {lengthComputable: lengthComputable, loaded: loaded, total: total} = event;
|
|
2614
2641
|
const progress = lengthComputable ? loaded / total : 1;
|
|
@@ -2622,15 +2649,18 @@ class VSFXFileLoader extends Loader {
|
|
|
2622
2649
|
loader.setRequestHeader(params.requestHeader);
|
|
2623
2650
|
loader.setWithCredentials(params.withCredentials);
|
|
2624
2651
|
loader.setAbortSignal(this.abortController.signal);
|
|
2625
|
-
const
|
|
2626
|
-
const data = new Uint8Array(
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2652
|
+
const arrayBuffer = await loader.load(file, progress);
|
|
2653
|
+
const data = new Uint8Array(arrayBuffer);
|
|
2654
|
+
if (!this.viewer.visualizeJs) return this;
|
|
2655
|
+
try {
|
|
2656
|
+
visViewer.parseVsfx(data);
|
|
2657
|
+
} catch (error) {
|
|
2658
|
+
console.error("VSFX parse error.", error);
|
|
2659
|
+
throw error;
|
|
2660
|
+
}
|
|
2631
2661
|
this.viewer.syncOptions();
|
|
2632
2662
|
this.viewer.syncOverlay();
|
|
2633
|
-
this.viewer.
|
|
2663
|
+
this.viewer.update(true);
|
|
2634
2664
|
this.viewer.emitEvent({
|
|
2635
2665
|
type: "databasechunk",
|
|
2636
2666
|
data: data,
|
|
@@ -2650,8 +2680,7 @@ class VSFXCloudLoader extends Loader {
|
|
|
2650
2680
|
}
|
|
2651
2681
|
async load(model, format, params = {}) {
|
|
2652
2682
|
if (!this.viewer.visualizeJs) return Promise.resolve(this);
|
|
2653
|
-
const
|
|
2654
|
-
const visViewer = visLib.getViewer();
|
|
2683
|
+
const visViewer = this.viewer.visViewer();
|
|
2655
2684
|
const progress = progress => {
|
|
2656
2685
|
this.viewer.emitEvent({
|
|
2657
2686
|
type: "geometryprogress",
|
|
@@ -2662,18 +2691,17 @@ class VSFXCloudLoader extends Loader {
|
|
|
2662
2691
|
};
|
|
2663
2692
|
console.time("File load time");
|
|
2664
2693
|
const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
|
|
2665
|
-
if (!this.viewer.visualizeJs) return this;
|
|
2666
2694
|
const data = new Uint8Array(arrayBuffer);
|
|
2695
|
+
if (!this.viewer.visualizeJs) return this;
|
|
2667
2696
|
try {
|
|
2668
2697
|
visViewer.parseVsfx(data);
|
|
2669
2698
|
} catch (error) {
|
|
2670
2699
|
console.error("VSFX parse error.", error);
|
|
2671
2700
|
throw error;
|
|
2672
2701
|
}
|
|
2673
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2674
2702
|
this.viewer.syncOptions();
|
|
2675
2703
|
this.viewer.syncOverlay();
|
|
2676
|
-
this.viewer.
|
|
2704
|
+
this.viewer.update(true);
|
|
2677
2705
|
this.viewer.emitEvent({
|
|
2678
2706
|
type: "databasechunk",
|
|
2679
2707
|
data: data,
|
|
@@ -2728,7 +2756,7 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2728
2756
|
async load(model) {
|
|
2729
2757
|
if (!this.viewer.visualizeJs) return this;
|
|
2730
2758
|
const visLib = this.viewer.visLib();
|
|
2731
|
-
const visViewer =
|
|
2759
|
+
const visViewer = this.viewer.visViewer();
|
|
2732
2760
|
const updateController = new UpdateController;
|
|
2733
2761
|
updateController.initialize(this.viewer);
|
|
2734
2762
|
let isFireDatabaseChunk = false;
|
|
@@ -2741,24 +2769,21 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2741
2769
|
console.error("VSFX parse error.", error);
|
|
2742
2770
|
throw error;
|
|
2743
2771
|
}
|
|
2744
|
-
updateController.update(UpdateType.kDelay);
|
|
2745
2772
|
this.viewer.emitEvent({
|
|
2746
2773
|
type: "geometryprogress",
|
|
2747
2774
|
data: progress,
|
|
2748
2775
|
file: model.file,
|
|
2749
2776
|
model: model
|
|
2750
2777
|
});
|
|
2751
|
-
let
|
|
2778
|
+
let isDatabaseChunk = false;
|
|
2752
2779
|
if (status === visLib.DatabaseStreamStatus.ReadyServiceData || status === visLib.DatabaseStreamStatus.Complete && !isFireDatabaseChunk) {
|
|
2753
2780
|
isFireDatabaseChunk = true;
|
|
2754
|
-
|
|
2781
|
+
isDatabaseChunk = true;
|
|
2755
2782
|
}
|
|
2756
|
-
if (
|
|
2757
|
-
updateController.update(UpdateType.kForce);
|
|
2758
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2783
|
+
if (isDatabaseChunk) {
|
|
2759
2784
|
this.viewer.syncOptions();
|
|
2760
2785
|
this.viewer.syncOverlay();
|
|
2761
|
-
|
|
2786
|
+
updateController.update(UpdateType.kForce);
|
|
2762
2787
|
this.viewer.emitEvent({
|
|
2763
2788
|
type: "databasechunk",
|
|
2764
2789
|
data: chunk,
|
|
@@ -2766,6 +2791,7 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2766
2791
|
model: model
|
|
2767
2792
|
});
|
|
2768
2793
|
} else {
|
|
2794
|
+
updateController.update(UpdateType.kDelay);
|
|
2769
2795
|
this.viewer.emitEvent({
|
|
2770
2796
|
type: "geometrychunk",
|
|
2771
2797
|
data: chunk,
|
|
@@ -2797,8 +2823,7 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2797
2823
|
}
|
|
2798
2824
|
async load(model, format) {
|
|
2799
2825
|
if (!this.viewer.visualizeJs) return this;
|
|
2800
|
-
const
|
|
2801
|
-
const visViewer = visLib.getViewer();
|
|
2826
|
+
const visViewer = this.viewer.visViewer();
|
|
2802
2827
|
let servicePartAborted = false;
|
|
2803
2828
|
const pendingRequestsMap = new Map;
|
|
2804
2829
|
let pendingRequestsTimerId = 0;
|
|
@@ -2810,26 +2835,23 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2810
2835
|
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
2811
2836
|
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
2812
2837
|
if (!this.viewer.visualizeJs) return;
|
|
2813
|
-
let
|
|
2838
|
+
let isDatabaseChunk;
|
|
2814
2839
|
try {
|
|
2815
|
-
|
|
2840
|
+
isDatabaseChunk = visViewer.parseVsfxInPartialMode(requestId, chunk);
|
|
2816
2841
|
} catch (error) {
|
|
2817
2842
|
console.error("VSFX parse error.", error);
|
|
2818
2843
|
throw error;
|
|
2819
2844
|
}
|
|
2820
|
-
updateController.update(UpdateType.kDelay);
|
|
2821
2845
|
this.viewer.emitEvent({
|
|
2822
2846
|
type: "geometryprogress",
|
|
2823
2847
|
data: progress,
|
|
2824
2848
|
file: model.file,
|
|
2825
2849
|
model: model
|
|
2826
2850
|
});
|
|
2827
|
-
if (
|
|
2828
|
-
updateController.update(UpdateType.kForce);
|
|
2829
|
-
this.viewer.syncOpenCloudVisualStyle(false);
|
|
2851
|
+
if (isDatabaseChunk) {
|
|
2830
2852
|
this.viewer.syncOptions();
|
|
2831
2853
|
this.viewer.syncOverlay();
|
|
2832
|
-
|
|
2854
|
+
updateController.update(UpdateType.kForce);
|
|
2833
2855
|
this.viewer.emitEvent({
|
|
2834
2856
|
type: "databasechunk",
|
|
2835
2857
|
data: chunk,
|
|
@@ -2837,6 +2859,7 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2837
2859
|
model: model
|
|
2838
2860
|
});
|
|
2839
2861
|
} else {
|
|
2862
|
+
updateController.update(UpdateType.kDelay);
|
|
2840
2863
|
this.viewer.emitEvent({
|
|
2841
2864
|
type: "geometrychunk",
|
|
2842
2865
|
data: chunk,
|
|
@@ -3216,7 +3239,7 @@ class VisualizeMarkup {
|
|
|
3216
3239
|
}
|
|
3217
3240
|
if (!this._viewer.visualizeJs) return;
|
|
3218
3241
|
const visLib = this._viewer.visLib();
|
|
3219
|
-
const visViewer =
|
|
3242
|
+
const visViewer = this._viewer.visViewer();
|
|
3220
3243
|
const activeView = visViewer.activeView;
|
|
3221
3244
|
this._viewer.syncOverlay();
|
|
3222
3245
|
const markupColor = viewpoint.custom_fields.markup_color || {
|
|
@@ -3267,7 +3290,7 @@ class VisualizeMarkup {
|
|
|
3267
3290
|
};
|
|
3268
3291
|
}
|
|
3269
3292
|
const visLib = this._viewer.visLib();
|
|
3270
|
-
const visViewer =
|
|
3293
|
+
const visViewer = this._viewer.visViewer();
|
|
3271
3294
|
if (!viewpoint) viewpoint = {};
|
|
3272
3295
|
viewpoint.lines = [];
|
|
3273
3296
|
viewpoint.texts = [];
|
|
@@ -3371,7 +3394,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3371
3394
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
3372
3395
|
this.canvaseventlistener = event => this.emit(event);
|
|
3373
3396
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== undefined ? _a : true;
|
|
3374
|
-
this.
|
|
3397
|
+
this._renderNeeded = false;
|
|
3375
3398
|
this._isRunAsyncUpdate = false;
|
|
3376
3399
|
this.render = this.render.bind(this);
|
|
3377
3400
|
this.update = this.update.bind(this);
|
|
@@ -3393,14 +3416,15 @@ class Viewer extends EventEmitter2 {
|
|
|
3393
3416
|
}
|
|
3394
3417
|
async initialize(canvas, onProgress) {
|
|
3395
3418
|
this.addEventListener("optionschange", (event => this.syncOptions(event.data)));
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3419
|
+
const rect = canvas.parentElement.getBoundingClientRect();
|
|
3420
|
+
const width = rect.width || 1;
|
|
3421
|
+
const height = rect.height || 1;
|
|
3422
|
+
canvas.width = Math.round(width * window.devicePixelRatio);
|
|
3423
|
+
canvas.height = Math.round(height * window.devicePixelRatio);
|
|
3424
|
+
canvas.style.width = width + "px";
|
|
3425
|
+
canvas.style.height = height + "px";
|
|
3400
3426
|
canvas.parentElement.style.touchAction = "none";
|
|
3401
3427
|
canvas.style.touchAction = "none";
|
|
3402
|
-
canvas.width = canvas.clientWidth * window.devicePixelRatio;
|
|
3403
|
-
canvas.height = canvas.clientHeight * window.devicePixelRatio;
|
|
3404
3428
|
this._visualizeTimestamp = Date.now();
|
|
3405
3429
|
const visualizeTimestamp = this._visualizeTimestamp;
|
|
3406
3430
|
const visualizeJs = await loadVisualizeJs(this.visualizeJsUrl, (event => {
|
|
@@ -3421,16 +3445,15 @@ class Viewer extends EventEmitter2 {
|
|
|
3421
3445
|
});
|
|
3422
3446
|
if (visualizeTimestamp !== this._visualizeTimestamp) throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
|
|
3423
3447
|
this._visualizeJs = visualizeJs;
|
|
3424
|
-
this.
|
|
3425
|
-
this.visualizeJs.Viewer.create();
|
|
3426
|
-
this.
|
|
3448
|
+
this._visualizeJs.canvas = canvas;
|
|
3449
|
+
this._viewer = visualizeJs.Viewer.create();
|
|
3450
|
+
this._viewer.resize(0, canvas.width, canvas.height, 0);
|
|
3427
3451
|
this.canvas = canvas;
|
|
3428
3452
|
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener)));
|
|
3429
3453
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
3430
3454
|
for (const name of components.getComponents().keys()) {
|
|
3431
3455
|
this._components.push(components.createComponent(name, this));
|
|
3432
3456
|
}
|
|
3433
|
-
this.syncOpenCloudVisualStyle(true);
|
|
3434
3457
|
this.syncOptions();
|
|
3435
3458
|
this.syncOverlay();
|
|
3436
3459
|
this._renderTime = performance.now();
|
|
@@ -3455,57 +3478,62 @@ class Viewer extends EventEmitter2 {
|
|
|
3455
3478
|
this.canvasEvents.forEach((x => this.canvas.removeEventListener(x, this.canvaseventlistener)));
|
|
3456
3479
|
this.canvas = undefined;
|
|
3457
3480
|
}
|
|
3458
|
-
if (this.
|
|
3481
|
+
if (this._viewer) this._viewer.clear();
|
|
3459
3482
|
this._visualizeJs = undefined;
|
|
3460
3483
|
this._visualizeTimestamp = undefined;
|
|
3484
|
+
this._viewer = undefined;
|
|
3461
3485
|
return this;
|
|
3462
3486
|
}
|
|
3463
3487
|
isInitialized() {
|
|
3464
3488
|
return !!this.visualizeJs;
|
|
3465
3489
|
}
|
|
3490
|
+
setSize(width, height, updateStyle = true) {
|
|
3491
|
+
if (!this.visualizeJs) return;
|
|
3492
|
+
this.canvas.width = Math.round(width * window.devicePixelRatio);
|
|
3493
|
+
this.canvas.height = Math.round(height * window.devicePixelRatio);
|
|
3494
|
+
if (updateStyle) {
|
|
3495
|
+
this.canvas.style.width = width + "px";
|
|
3496
|
+
this.canvas.style.height = height + "px";
|
|
3497
|
+
}
|
|
3498
|
+
this._viewer.resize(0, this.canvas.width, this.canvas.height, 0);
|
|
3499
|
+
this.update(true);
|
|
3500
|
+
this.emitEvent({
|
|
3501
|
+
type: "resize",
|
|
3502
|
+
width: width,
|
|
3503
|
+
height: height
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3466
3506
|
render(time) {
|
|
3467
3507
|
var _a, _b;
|
|
3468
3508
|
if (!this.visualizeJs) return;
|
|
3469
3509
|
if (this._isRunAsyncUpdate) return;
|
|
3470
|
-
const
|
|
3471
|
-
if (
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
}
|
|
3510
|
+
const renderNeeded = this.visViewer().isRunningAnimation() || this._renderNeeded;
|
|
3511
|
+
if (!renderNeeded) return;
|
|
3512
|
+
if (!time) time = performance.now();
|
|
3513
|
+
const deltaTime = (time - this._renderTime) / 1e3;
|
|
3514
|
+
this._renderTime = time;
|
|
3515
|
+
this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
|
|
3516
|
+
this.visViewer().update();
|
|
3517
|
+
(_b = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
|
|
3518
|
+
this.emitEvent({
|
|
3519
|
+
type: "render",
|
|
3520
|
+
time: time,
|
|
3521
|
+
deltaTime: deltaTime
|
|
3522
|
+
});
|
|
3483
3523
|
}
|
|
3484
3524
|
resize() {
|
|
3525
|
+
console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
|
|
3485
3526
|
if (!this.visualizeJs) return this;
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
this.
|
|
3490
|
-
const visViewer = this.visualizeJs.getViewer();
|
|
3491
|
-
visViewer.resize(0, this.canvas.width, this.canvas.height, 0);
|
|
3492
|
-
this.update(true);
|
|
3493
|
-
this.emitEvent({
|
|
3494
|
-
type: "resize",
|
|
3495
|
-
width: clientWidth,
|
|
3496
|
-
height: clientHeight
|
|
3497
|
-
});
|
|
3527
|
+
if (!this.canvas.parentElement) return this;
|
|
3528
|
+
const {width: width, height: height} = this.canvas.parentElement.getBoundingClientRect();
|
|
3529
|
+
if (!width || !height) return this;
|
|
3530
|
+
this.setSize(width, height);
|
|
3498
3531
|
return this;
|
|
3499
3532
|
}
|
|
3500
3533
|
update(force = false) {
|
|
3501
|
-
var _a, _b, _c;
|
|
3502
3534
|
if (this._enableAutoUpdate) {
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
(_c = (_b = this._activeDragger) === null || _b === undefined ? undefined : _b.updatePreview) === null || _c === undefined ? undefined : _c.call(_b);
|
|
3506
|
-
} else {
|
|
3507
|
-
this._isNeedRender = true;
|
|
3508
|
-
}
|
|
3535
|
+
this._renderNeeded = true;
|
|
3536
|
+
if (force) this.render();
|
|
3509
3537
|
}
|
|
3510
3538
|
this.emitEvent({
|
|
3511
3539
|
type: "update",
|
|
@@ -3534,9 +3562,10 @@ class Viewer extends EventEmitter2 {
|
|
|
3534
3562
|
}));
|
|
3535
3563
|
}
|
|
3536
3564
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
3565
|
+
if (!this.visualizeJs) return;
|
|
3537
3566
|
this._isRunAsyncUpdate = true;
|
|
3538
|
-
const device = this.visViewer().getActiveDevice();
|
|
3539
3567
|
try {
|
|
3568
|
+
const device = this.visViewer().getActiveDevice();
|
|
3540
3569
|
for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
|
|
3541
3570
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
3542
3571
|
}
|
|
@@ -3551,16 +3580,15 @@ class Viewer extends EventEmitter2 {
|
|
|
3551
3580
|
return this._visualizeJs;
|
|
3552
3581
|
}
|
|
3553
3582
|
visLib() {
|
|
3554
|
-
return this.
|
|
3583
|
+
return this._visualizeJs;
|
|
3555
3584
|
}
|
|
3556
3585
|
visViewer() {
|
|
3557
|
-
|
|
3558
|
-
return (_a = this.visualizeJs) === null || _a === undefined ? undefined : _a.getViewer();
|
|
3586
|
+
return this._viewer;
|
|
3559
3587
|
}
|
|
3560
|
-
syncOpenCloudVisualStyle(
|
|
3588
|
+
syncOpenCloudVisualStyle() {
|
|
3561
3589
|
if (!this.visualizeJs) return this;
|
|
3562
3590
|
const visLib = this.visLib();
|
|
3563
|
-
const visViewer =
|
|
3591
|
+
const visViewer = this.visViewer();
|
|
3564
3592
|
const device = visViewer.getActiveDevice();
|
|
3565
3593
|
if (device.isNull()) return this;
|
|
3566
3594
|
const view = device.getActiveView();
|
|
@@ -3593,8 +3621,9 @@ class Viewer extends EventEmitter2 {
|
|
|
3593
3621
|
}
|
|
3594
3622
|
syncOptions(options = this.options) {
|
|
3595
3623
|
if (!this.visualizeJs) return this;
|
|
3624
|
+
this.syncOpenCloudVisualStyle();
|
|
3596
3625
|
const visLib = this.visLib();
|
|
3597
|
-
const visViewer =
|
|
3626
|
+
const visViewer = this.visViewer();
|
|
3598
3627
|
const device = visViewer.getActiveDevice();
|
|
3599
3628
|
if (device.isNull()) return this;
|
|
3600
3629
|
if (options.showWCS !== visViewer.getEnableWCS()) {
|
|
@@ -3611,7 +3640,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3611
3640
|
if (options.shadows !== visViewer.shadows) {
|
|
3612
3641
|
visViewer.shadows = options.shadows;
|
|
3613
3642
|
const canvas = visLib.canvas;
|
|
3614
|
-
device.invalidate([ 0, canvas.
|
|
3643
|
+
device.invalidate([ 0, canvas.width, canvas.height, 0 ]);
|
|
3615
3644
|
}
|
|
3616
3645
|
if (options.groundShadow !== visViewer.groundShadow) {
|
|
3617
3646
|
visViewer.groundShadow = options.groundShadow;
|
|
@@ -3646,7 +3675,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3646
3675
|
if (!this.visualizeJs) return this;
|
|
3647
3676
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
3648
3677
|
const visLib = this.visLib();
|
|
3649
|
-
const visViewer =
|
|
3678
|
+
const visViewer = this.visViewer();
|
|
3650
3679
|
const {Entry: Entry, OdTvRGBColorDef: OdTvRGBColorDef} = visLib;
|
|
3651
3680
|
const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
|
|
3652
3681
|
const highlightStylePtr = highlightStyleId.openObject();
|
|
@@ -3676,7 +3705,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3676
3705
|
const device = visViewer.getActiveDevice();
|
|
3677
3706
|
if (!device.isNull()) {
|
|
3678
3707
|
const canvas = visLib.canvas;
|
|
3679
|
-
device.invalidate([ 0, canvas.
|
|
3708
|
+
device.invalidate([ 0, canvas.width, canvas.height, 0 ]);
|
|
3680
3709
|
device.delete();
|
|
3681
3710
|
}
|
|
3682
3711
|
return this;
|
|
@@ -3873,7 +3902,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3873
3902
|
applySceneGraphSettings(options = this.options) {
|
|
3874
3903
|
if (!this.visualizeJs) return;
|
|
3875
3904
|
const visLib = this.visLib();
|
|
3876
|
-
const visViewer =
|
|
3905
|
+
const visViewer = this.visViewer();
|
|
3877
3906
|
const device = visViewer.getActiveDevice();
|
|
3878
3907
|
if (isExist(options.sceneGraph)) {
|
|
3879
3908
|
device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
|
|
@@ -3939,8 +3968,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3939
3968
|
type: "open",
|
|
3940
3969
|
file: buffer
|
|
3941
3970
|
});
|
|
3942
|
-
const
|
|
3943
|
-
const visViewer = visLib.getViewer();
|
|
3971
|
+
const visViewer = this.visViewer();
|
|
3944
3972
|
this.emitEvent({
|
|
3945
3973
|
type: "geometrystart",
|
|
3946
3974
|
file: buffer
|
|
@@ -3948,10 +3976,9 @@ class Viewer extends EventEmitter2 {
|
|
|
3948
3976
|
try {
|
|
3949
3977
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
3950
3978
|
visViewer.parseFile(data);
|
|
3951
|
-
this.syncOpenCloudVisualStyle(false);
|
|
3952
3979
|
this.syncOptions();
|
|
3953
3980
|
this.syncOverlay();
|
|
3954
|
-
this.
|
|
3981
|
+
this.update(true);
|
|
3955
3982
|
this.emitEvent({
|
|
3956
3983
|
type: "geometryprogress",
|
|
3957
3984
|
data: 1,
|
|
@@ -3985,8 +4012,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3985
4012
|
type: "open",
|
|
3986
4013
|
file: buffer
|
|
3987
4014
|
});
|
|
3988
|
-
const
|
|
3989
|
-
const visViewer = visLib.getViewer();
|
|
4015
|
+
const visViewer = this.visViewer();
|
|
3990
4016
|
this.emitEvent({
|
|
3991
4017
|
type: "geometrystart",
|
|
3992
4018
|
file: buffer
|
|
@@ -3994,10 +4020,9 @@ class Viewer extends EventEmitter2 {
|
|
|
3994
4020
|
try {
|
|
3995
4021
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
3996
4022
|
visViewer.parseVsfx(data);
|
|
3997
|
-
this.syncOpenCloudVisualStyle(false);
|
|
3998
4023
|
this.syncOptions();
|
|
3999
4024
|
this.syncOverlay();
|
|
4000
|
-
this.
|
|
4025
|
+
this.update(true);
|
|
4001
4026
|
this.emitEvent({
|
|
4002
4027
|
type: "geometryprogress",
|
|
4003
4028
|
data: 1,
|
|
@@ -4034,20 +4059,18 @@ class Viewer extends EventEmitter2 {
|
|
|
4034
4059
|
}
|
|
4035
4060
|
clear() {
|
|
4036
4061
|
if (!this.visualizeJs) return this;
|
|
4037
|
-
const
|
|
4038
|
-
const visViewer = visLib.getViewer();
|
|
4062
|
+
const visViewer = this.visViewer();
|
|
4039
4063
|
this.setActiveDragger();
|
|
4040
4064
|
this.clearSlices();
|
|
4041
4065
|
this.clearOverlay();
|
|
4042
4066
|
this.clearSelected();
|
|
4043
|
-
visViewer.clear();
|
|
4044
|
-
visViewer.createLocalDatabase();
|
|
4045
4067
|
this.loaders.forEach((loader => loader.dispose()));
|
|
4046
4068
|
this.loaders = [];
|
|
4047
|
-
|
|
4069
|
+
visViewer.clear();
|
|
4070
|
+
visViewer.createLocalDatabase();
|
|
4048
4071
|
this.syncOptions();
|
|
4049
4072
|
this.syncOverlay();
|
|
4050
|
-
this.
|
|
4073
|
+
this.update(true);
|
|
4051
4074
|
this.emitEvent({
|
|
4052
4075
|
type: "clear"
|
|
4053
4076
|
});
|