@inweb/viewer-visualize 26.10.6 → 26.11.1
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 +470 -422
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +462 -422
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Commands/GetSelected2.d.ts +2 -0
- package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
- package/lib/Viewer/Commands/SetSelected2.d.ts +2 -0
- package/lib/Viewer/Components/index.d.ts +8 -7
- package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +1 -1
- package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +1 -1
- package/lib/Viewer/Loaders/index.d.ts +14 -9
- package/lib/Viewer/Models/IModelImpl.d.ts +5 -0
- package/lib/Viewer/Models/ModelImpl.d.ts +5 -0
- package/lib/Viewer/Viewer.d.ts +129 -136
- package/package.json +6 -6
- package/src/Viewer/Commands/ClearSelected.ts +3 -1
- package/src/Viewer/Commands/GetSelected2.ts +33 -0
- package/src/Viewer/Commands/HideSelected.ts +3 -1
- package/src/Viewer/Commands/SelectModel.ts +2 -3
- package/src/Viewer/Commands/SetSelected.ts +5 -2
- package/src/Viewer/Commands/SetSelected2.ts +39 -0
- package/src/Viewer/Commands/index.ts +4 -0
- package/src/Viewer/Components/index.ts +8 -7
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +3 -2
- package/src/Viewer/Draggers/OdJoyStickDragger.ts +2 -2
- package/src/Viewer/Loaders/VSFCloudLoader.ts +6 -0
- package/src/Viewer/Loaders/VSFFileLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXCloudLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +8 -2
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +7 -1
- package/src/Viewer/Loaders/VSFXFileLoader.ts +7 -1
- package/src/Viewer/Loaders/index.ts +14 -9
- package/src/Viewer/Models/IModelImpl.ts +29 -0
- package/src/Viewer/Models/ModelImpl.ts +32 -0
- package/src/Viewer/Viewer.ts +780 -775
|
@@ -213,8 +213,8 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
213
213
|
viewer.select(x, y, x, y);
|
|
214
214
|
this.subject.update();
|
|
215
215
|
const selectionSet = viewer.getSelected();
|
|
216
|
-
|
|
217
|
-
this.onmessage({ type: "
|
|
216
|
+
this.onmessage({ type: "select", data: selectionSet, handles: this.subject.getSelected() });
|
|
217
|
+
this.onmessage({ type: "select2", data: selectionSet, handles: this.subject.getSelected2() });
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
dblclick(ev) {
|
|
@@ -819,7 +819,7 @@ class OdJoyStickDragger {
|
|
|
819
819
|
callback({
|
|
820
820
|
x: 100 * ((movedX - centerX) / maxMoveStick),
|
|
821
821
|
y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
|
|
822
|
-
global
|
|
822
|
+
global,
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
825
|
};
|
|
@@ -834,7 +834,7 @@ class OdJoyStickDragger {
|
|
|
834
834
|
callback({
|
|
835
835
|
x: 100 * ((movedX - centerX) / maxMoveStick),
|
|
836
836
|
y: 100 * ((movedY - centerY) / maxMoveStick) * -1,
|
|
837
|
-
global
|
|
837
|
+
global,
|
|
838
838
|
});
|
|
839
839
|
};
|
|
840
840
|
this.drawExternal = () => {
|
|
@@ -2325,7 +2325,8 @@ function clearSelected(viewer) {
|
|
|
2325
2325
|
const visViewer = viewer.visViewer();
|
|
2326
2326
|
visViewer.unselect();
|
|
2327
2327
|
viewer.update();
|
|
2328
|
-
viewer.emitEvent({ type: "select",
|
|
2328
|
+
viewer.emitEvent({ type: "select", handles: [] });
|
|
2329
|
+
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2329
2330
|
}
|
|
2330
2331
|
|
|
2331
2332
|
function clearSlices(viewer) {
|
|
@@ -2401,6 +2402,13 @@ function getSelected(viewer) {
|
|
|
2401
2402
|
return handles;
|
|
2402
2403
|
}
|
|
2403
2404
|
|
|
2405
|
+
function getSelected2(viewer) {
|
|
2406
|
+
const handles = viewer.executeCommand("getSelected");
|
|
2407
|
+
const model = viewer.models[0];
|
|
2408
|
+
const handles2 = handles.map((handle) => `${model.id}:${handle}`);
|
|
2409
|
+
return handles2;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2404
2412
|
function hideSelected(viewer) {
|
|
2405
2413
|
if (!viewer.visualizeJs)
|
|
2406
2414
|
return;
|
|
@@ -2408,7 +2416,8 @@ function hideSelected(viewer) {
|
|
|
2408
2416
|
visViewer.hideSelectedObjects(false);
|
|
2409
2417
|
viewer.update();
|
|
2410
2418
|
viewer.emitEvent({ type: "hide" });
|
|
2411
|
-
viewer.emitEvent({ type: "select",
|
|
2419
|
+
viewer.emitEvent({ type: "select", handles: [] });
|
|
2420
|
+
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2412
2421
|
}
|
|
2413
2422
|
|
|
2414
2423
|
function isolateSelected(viewer) {
|
|
@@ -2456,9 +2465,9 @@ function selectModel(viewer, handle) {
|
|
|
2456
2465
|
if (modelPtr.getDatabaseHandle() === handle) {
|
|
2457
2466
|
const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
|
|
2458
2467
|
visViewer.setSelected(selectionSet);
|
|
2459
|
-
const handles = viewer.getSelected();
|
|
2460
2468
|
viewer.update();
|
|
2461
|
-
viewer.emitEvent({ type: "select",
|
|
2469
|
+
viewer.emitEvent({ type: "select", handles: viewer.getSelected() });
|
|
2470
|
+
viewer.emitEvent({ type: "select2", handles: viewer.getSelected2() });
|
|
2462
2471
|
selectionSet.delete();
|
|
2463
2472
|
break;
|
|
2464
2473
|
}
|
|
@@ -2485,13 +2494,14 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
|
2485
2494
|
viewer.markup.setMarkupColor(r, g, b);
|
|
2486
2495
|
}
|
|
2487
2496
|
|
|
2488
|
-
function setSelected(viewer,
|
|
2497
|
+
function setSelected(viewer, handles2 = []) {
|
|
2489
2498
|
if (!viewer.visualizeJs)
|
|
2490
2499
|
return;
|
|
2500
|
+
const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
|
|
2491
2501
|
const visLib = viewer.visLib();
|
|
2492
2502
|
const visViewer = viewer.visViewer();
|
|
2493
2503
|
const selectionSet = new visLib.OdTvSelectionSet();
|
|
2494
|
-
handles
|
|
2504
|
+
handles.forEach((handle) => {
|
|
2495
2505
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2496
2506
|
if (!entityId.isNull())
|
|
2497
2507
|
selectionSet.appendEntity(entityId);
|
|
@@ -2499,9 +2509,25 @@ function setSelected(viewer, handles = []) {
|
|
|
2499
2509
|
visViewer.setSelected(selectionSet);
|
|
2500
2510
|
viewer.update();
|
|
2501
2511
|
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
2512
|
+
viewer.emitEvent({ type: "select2", data: selectionSet, handles: handles2 });
|
|
2502
2513
|
selectionSet.delete();
|
|
2503
2514
|
}
|
|
2504
2515
|
|
|
2516
|
+
function setSelected2(viewer, handles2 = []) {
|
|
2517
|
+
const handles = [];
|
|
2518
|
+
handles2.forEach((handle) => {
|
|
2519
|
+
if (!handle.includes(":")) {
|
|
2520
|
+
handles.push(handle);
|
|
2521
|
+
}
|
|
2522
|
+
else
|
|
2523
|
+
viewer.models.forEach((model) => {
|
|
2524
|
+
if (handle.split(":", 1)[0] === model.id + "")
|
|
2525
|
+
handles.push(handle);
|
|
2526
|
+
});
|
|
2527
|
+
});
|
|
2528
|
+
return viewer.executeCommand("setSelected", handles);
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2505
2531
|
function showAll(viewer) {
|
|
2506
2532
|
if (!viewer.visualizeJs)
|
|
2507
2533
|
return;
|
|
@@ -2624,6 +2650,7 @@ commands.registerCommand("collect", collect);
|
|
|
2624
2650
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
2625
2651
|
commands.registerCommand("getModels", getModels);
|
|
2626
2652
|
commands.registerCommand("getSelected", getSelected);
|
|
2653
|
+
commands.registerCommand("getSelected2", getSelected2);
|
|
2627
2654
|
commands.registerCommand("hideSelected", hideSelected);
|
|
2628
2655
|
commands.registerCommand("isolateSelected", isolateSelected);
|
|
2629
2656
|
commands.registerCommand("regenerateAll", regenerateAll);
|
|
@@ -2633,6 +2660,7 @@ commands.registerCommand("setActiveDragger", setActiveDragger);
|
|
|
2633
2660
|
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
2634
2661
|
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
2635
2662
|
commands.registerCommand("setSelected", setSelected);
|
|
2663
|
+
commands.registerCommand("setSelected2", setSelected2);
|
|
2636
2664
|
commands.registerCommand("showAll", showAll);
|
|
2637
2665
|
commands.registerCommand("zoomToExtents", zoomToExtents);
|
|
2638
2666
|
commands.registerCommand("zoomToObjects", zoomToObjects);
|
|
@@ -2981,6 +3009,10 @@ components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComp
|
|
|
2981
3009
|
components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
|
|
2982
3010
|
components.registerComponent("ResetComponent", (viewer) => new ResetComponent(viewer));
|
|
2983
3011
|
|
|
3012
|
+
class ModelImpl {
|
|
3013
|
+
dispose() { }
|
|
3014
|
+
}
|
|
3015
|
+
|
|
2984
3016
|
class FileLoader {
|
|
2985
3017
|
constructor() {
|
|
2986
3018
|
this.requestHeader = {};
|
|
@@ -3064,7 +3096,7 @@ class VSFFileLoader extends Loader {
|
|
|
3064
3096
|
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
3065
3097
|
/vsf$/i.test(format));
|
|
3066
3098
|
}
|
|
3067
|
-
async load(file, format, params) {
|
|
3099
|
+
async load(file, format, params = {}) {
|
|
3068
3100
|
if (!this.viewer.visualizeJs)
|
|
3069
3101
|
return this;
|
|
3070
3102
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3088,6 +3120,9 @@ class VSFFileLoader extends Loader {
|
|
|
3088
3120
|
console.error("VSF parse error.", error);
|
|
3089
3121
|
throw error;
|
|
3090
3122
|
}
|
|
3123
|
+
const modelImpl = new ModelImpl();
|
|
3124
|
+
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
3125
|
+
this.viewer.models.push(modelImpl);
|
|
3091
3126
|
this.viewer.syncOptions();
|
|
3092
3127
|
this.viewer.syncOverlay();
|
|
3093
3128
|
this.viewer.update(true);
|
|
@@ -3131,6 +3166,9 @@ class VSFCloudLoader extends Loader {
|
|
|
3131
3166
|
throw error;
|
|
3132
3167
|
}
|
|
3133
3168
|
if (i === 0) {
|
|
3169
|
+
const modelImpl = new ModelImpl();
|
|
3170
|
+
modelImpl.id = model.file.id;
|
|
3171
|
+
this.viewer.models.push(modelImpl);
|
|
3134
3172
|
this.viewer.syncOptions();
|
|
3135
3173
|
this.viewer.syncOverlay();
|
|
3136
3174
|
this.viewer.update(true);
|
|
@@ -3155,7 +3193,7 @@ class VSFXFileLoader extends Loader {
|
|
|
3155
3193
|
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
3156
3194
|
/vsfx$/i.test(format));
|
|
3157
3195
|
}
|
|
3158
|
-
async load(file, format, params) {
|
|
3196
|
+
async load(file, format, params = {}) {
|
|
3159
3197
|
if (!this.viewer.visualizeJs)
|
|
3160
3198
|
return this;
|
|
3161
3199
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3179,6 +3217,9 @@ class VSFXFileLoader extends Loader {
|
|
|
3179
3217
|
console.error("VSFX parse error.", error);
|
|
3180
3218
|
throw error;
|
|
3181
3219
|
}
|
|
3220
|
+
const modelImpl = new ModelImpl();
|
|
3221
|
+
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
3222
|
+
this.viewer.models.push(modelImpl);
|
|
3182
3223
|
this.viewer.syncOptions();
|
|
3183
3224
|
this.viewer.syncOverlay();
|
|
3184
3225
|
this.viewer.update(true);
|
|
@@ -3199,7 +3240,7 @@ class VSFXCloudLoader extends Loader {
|
|
|
3199
3240
|
/.vsfx$/i.test(file.database) &&
|
|
3200
3241
|
this.viewer.options.enableStreamingMode === false);
|
|
3201
3242
|
}
|
|
3202
|
-
async load(model
|
|
3243
|
+
async load(model) {
|
|
3203
3244
|
if (!this.viewer.visualizeJs)
|
|
3204
3245
|
return Promise.resolve(this);
|
|
3205
3246
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3218,6 +3259,9 @@ class VSFXCloudLoader extends Loader {
|
|
|
3218
3259
|
console.error("VSFX parse error.", error);
|
|
3219
3260
|
throw error;
|
|
3220
3261
|
}
|
|
3262
|
+
const modelImpl = new ModelImpl();
|
|
3263
|
+
modelImpl.id = model.file.id;
|
|
3264
|
+
this.viewer.models.push(modelImpl);
|
|
3221
3265
|
this.viewer.syncOptions();
|
|
3222
3266
|
this.viewer.syncOverlay();
|
|
3223
3267
|
this.viewer.update(true);
|
|
@@ -3296,6 +3340,9 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
3296
3340
|
isDatabaseChunk = true;
|
|
3297
3341
|
}
|
|
3298
3342
|
if (isDatabaseChunk) {
|
|
3343
|
+
const modelImpl = new ModelImpl();
|
|
3344
|
+
modelImpl.id = model.file.id;
|
|
3345
|
+
this.viewer.models.push(modelImpl);
|
|
3299
3346
|
this.viewer.syncOptions();
|
|
3300
3347
|
this.viewer.syncOverlay();
|
|
3301
3348
|
updateController.update(UpdateType.kForce);
|
|
@@ -3330,7 +3377,7 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3330
3377
|
/.vsfx$/i.test(file.database) &&
|
|
3331
3378
|
(this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
|
|
3332
3379
|
}
|
|
3333
|
-
async load(model
|
|
3380
|
+
async load(model) {
|
|
3334
3381
|
if (!this.viewer.visualizeJs)
|
|
3335
3382
|
return this;
|
|
3336
3383
|
const visViewer = this.viewer.visViewer();
|
|
@@ -3356,6 +3403,9 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
3356
3403
|
}
|
|
3357
3404
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
3358
3405
|
if (isDatabaseChunk) {
|
|
3406
|
+
const modelImpl = new ModelImpl();
|
|
3407
|
+
modelImpl.id = model.file.id;
|
|
3408
|
+
this.viewer.models.push(modelImpl);
|
|
3359
3409
|
this.viewer.syncOptions();
|
|
3360
3410
|
this.viewer.syncOverlay();
|
|
3361
3411
|
updateController.update(UpdateType.kForce);
|
|
@@ -3844,42 +3894,56 @@ class Viewer extends EventEmitter2 {
|
|
|
3844
3894
|
super();
|
|
3845
3895
|
this._visualizeJsUrl = "";
|
|
3846
3896
|
this.configure(params);
|
|
3847
|
-
this._options = new Options(this);
|
|
3848
3897
|
this.client = client;
|
|
3898
|
+
this.options = new Options(this);
|
|
3849
3899
|
this.loaders = [];
|
|
3900
|
+
this.models = [];
|
|
3901
|
+
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
3902
|
+
this.canvaseventlistener = (event) => this.emit(event);
|
|
3850
3903
|
this._activeDragger = null;
|
|
3851
3904
|
this._components = [];
|
|
3905
|
+
this._renderNeeded = false;
|
|
3852
3906
|
this._renderTime = 0;
|
|
3853
|
-
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
3854
|
-
this.canvaseventlistener = (event) => this.emit(event);
|
|
3855
3907
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
3856
|
-
this._renderNeeded = false;
|
|
3857
3908
|
this._isRunAsyncUpdate = false;
|
|
3858
3909
|
this.render = this.render.bind(this);
|
|
3859
3910
|
this.update = this.update.bind(this);
|
|
3860
3911
|
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
3861
3912
|
}
|
|
3862
|
-
get options() {
|
|
3863
|
-
return this._options;
|
|
3864
|
-
}
|
|
3865
3913
|
get visualizeJsUrl() {
|
|
3866
3914
|
return this._visualizeJsUrl;
|
|
3867
3915
|
}
|
|
3916
|
+
get visualizeJs() {
|
|
3917
|
+
return this._visualizeJs;
|
|
3918
|
+
}
|
|
3919
|
+
visLib() {
|
|
3920
|
+
return this._visualizeJs;
|
|
3921
|
+
}
|
|
3922
|
+
visViewer() {
|
|
3923
|
+
return this._viewer;
|
|
3924
|
+
}
|
|
3868
3925
|
get markup() {
|
|
3869
3926
|
return this._markup;
|
|
3870
3927
|
}
|
|
3871
3928
|
configure(params) {
|
|
3872
|
-
this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/
|
|
3929
|
+
this._visualizeJsUrl = params.visualizeJsUrl || "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/26.11/Visualize.js";
|
|
3873
3930
|
this._crossOrigin = params.crossOrigin;
|
|
3874
3931
|
return this;
|
|
3875
3932
|
}
|
|
3933
|
+
get draggers() {
|
|
3934
|
+
return [...draggers.getDraggers().keys()];
|
|
3935
|
+
}
|
|
3936
|
+
get components() {
|
|
3937
|
+
return [...components.getComponents().keys()];
|
|
3938
|
+
}
|
|
3876
3939
|
async initialize(canvas, onProgress) {
|
|
3877
3940
|
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
3941
|
+
const pixelRatio = window.devicePixelRatio;
|
|
3878
3942
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
3879
3943
|
const width = rect.width || 1;
|
|
3880
3944
|
const height = rect.height || 1;
|
|
3881
|
-
canvas.width = Math.round(width *
|
|
3882
|
-
canvas.height = Math.round(height *
|
|
3945
|
+
canvas.width = Math.round(width * pixelRatio);
|
|
3946
|
+
canvas.height = Math.round(height * pixelRatio);
|
|
3883
3947
|
canvas.style.width = width + "px";
|
|
3884
3948
|
canvas.style.height = height + "px";
|
|
3885
3949
|
canvas.parentElement.style.touchAction = "none";
|
|
@@ -3947,6 +4011,26 @@ class Viewer extends EventEmitter2 {
|
|
|
3947
4011
|
this.update(true);
|
|
3948
4012
|
this.emitEvent({ type: "resize", width, height });
|
|
3949
4013
|
}
|
|
4014
|
+
resize() {
|
|
4015
|
+
console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
|
|
4016
|
+
if (!this.visualizeJs)
|
|
4017
|
+
return this;
|
|
4018
|
+
if (!this.canvas.parentElement)
|
|
4019
|
+
return this;
|
|
4020
|
+
const { width, height } = this.canvas.parentElement.getBoundingClientRect();
|
|
4021
|
+
if (!width || !height)
|
|
4022
|
+
return this;
|
|
4023
|
+
this.setSize(width, height);
|
|
4024
|
+
return this;
|
|
4025
|
+
}
|
|
4026
|
+
update(force = false) {
|
|
4027
|
+
if (this._enableAutoUpdate) {
|
|
4028
|
+
this._renderNeeded = true;
|
|
4029
|
+
if (force)
|
|
4030
|
+
this.render();
|
|
4031
|
+
}
|
|
4032
|
+
this.emitEvent({ type: "update", data: force });
|
|
4033
|
+
}
|
|
3950
4034
|
render(time) {
|
|
3951
4035
|
var _a, _b;
|
|
3952
4036
|
if (!this.visualizeJs)
|
|
@@ -3965,73 +4049,177 @@ class Viewer extends EventEmitter2 {
|
|
|
3965
4049
|
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3966
4050
|
this.emitEvent({ type: "render", time, deltaTime });
|
|
3967
4051
|
}
|
|
3968
|
-
|
|
3969
|
-
|
|
4052
|
+
async loadReferences(model) {
|
|
4053
|
+
var _a;
|
|
3970
4054
|
if (!this.visualizeJs)
|
|
3971
4055
|
return this;
|
|
3972
|
-
if (!this.
|
|
4056
|
+
if (!this.client)
|
|
3973
4057
|
return this;
|
|
3974
|
-
|
|
3975
|
-
if (!width || !height)
|
|
4058
|
+
if (!model.getReferences)
|
|
3976
4059
|
return this;
|
|
3977
|
-
|
|
4060
|
+
const abortController = new AbortController();
|
|
4061
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4062
|
+
this._abortControllerForReferences = abortController;
|
|
4063
|
+
let references = [];
|
|
4064
|
+
await model
|
|
4065
|
+
.getReferences(abortController.signal)
|
|
4066
|
+
.then((data) => (references = data.references))
|
|
4067
|
+
.catch((e) => console.error("Cannot load model references.", e));
|
|
4068
|
+
for (const file of references) {
|
|
4069
|
+
await this.client
|
|
4070
|
+
.downloadFile(file.id, undefined, abortController.signal)
|
|
4071
|
+
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
4072
|
+
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
4073
|
+
}
|
|
3978
4074
|
return this;
|
|
3979
4075
|
}
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
4076
|
+
applyModelTransformMatrix(model) {
|
|
4077
|
+
this.executeCommand("applyModelTransform", model);
|
|
4078
|
+
}
|
|
4079
|
+
applySceneGraphSettings(options = this.options) {
|
|
4080
|
+
if (!this.visualizeJs)
|
|
4081
|
+
return;
|
|
4082
|
+
const visLib = this.visLib();
|
|
4083
|
+
const visViewer = this.visViewer();
|
|
4084
|
+
const device = visViewer.getActiveDevice();
|
|
4085
|
+
if (isExist(options.sceneGraph)) {
|
|
4086
|
+
device.setOptionBool(visLib.DeviceOptions.kDelaySceneGraphProc, !options.sceneGraph);
|
|
3985
4087
|
}
|
|
3986
|
-
|
|
4088
|
+
device.delete();
|
|
4089
|
+
this.update();
|
|
3987
4090
|
}
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4091
|
+
async open(file, params = {}) {
|
|
4092
|
+
if (!this.visualizeJs)
|
|
4093
|
+
return this;
|
|
4094
|
+
this.cancel();
|
|
4095
|
+
this.clear();
|
|
4096
|
+
this.emitEvent({ type: "open", mode: "file", file });
|
|
4097
|
+
let model = file;
|
|
4098
|
+
if (model && typeof model.getModels === "function") {
|
|
4099
|
+
const models = await model.getModels();
|
|
4100
|
+
model = models.find((model) => model.default) || models[0] || file;
|
|
4101
|
+
}
|
|
4102
|
+
if (model && typeof model.database === "string") {
|
|
4103
|
+
file = model.file;
|
|
4104
|
+
}
|
|
4105
|
+
if (!model)
|
|
4106
|
+
throw new Error(`Format not supported`);
|
|
4107
|
+
let format = params.format;
|
|
4108
|
+
if (!format && typeof file["type"] === "string")
|
|
4109
|
+
format = file["type"].split(".").pop();
|
|
4110
|
+
if (!format && typeof file === "string")
|
|
4111
|
+
format = file.split(".").pop();
|
|
4112
|
+
if (!format && file instanceof globalThis.File)
|
|
4113
|
+
format = file.name.split(".").pop();
|
|
4114
|
+
const loader = loaders.createLoader(this, model, format);
|
|
4115
|
+
if (!loader)
|
|
4116
|
+
throw new Error(`Format not supported`);
|
|
4117
|
+
this.loaders.push(loader);
|
|
4118
|
+
this.emitEvent({ type: "geometrystart", file, model });
|
|
4119
|
+
try {
|
|
4120
|
+
await this.loadReferences(model);
|
|
4121
|
+
await loader.load(model, format, params);
|
|
4122
|
+
}
|
|
4123
|
+
catch (error) {
|
|
4124
|
+
this.emitEvent({ type: "geometryerror", data: error, file, model });
|
|
4125
|
+
throw error;
|
|
4126
|
+
}
|
|
4127
|
+
this.emitEvent({ type: "geometryend", file, model });
|
|
4128
|
+
if (this.visualizeJs) {
|
|
4129
|
+
this.applyModelTransformMatrix(model);
|
|
4130
|
+
this.applySceneGraphSettings();
|
|
4131
|
+
}
|
|
4132
|
+
return this;
|
|
4006
4133
|
}
|
|
4007
|
-
|
|
4134
|
+
openVsfFile(buffer) {
|
|
4135
|
+
console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4008
4136
|
if (!this.visualizeJs)
|
|
4009
|
-
return;
|
|
4010
|
-
this.
|
|
4137
|
+
return this;
|
|
4138
|
+
this.cancel();
|
|
4139
|
+
this.clear();
|
|
4140
|
+
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
4141
|
+
const visViewer = this.visViewer();
|
|
4142
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4011
4143
|
try {
|
|
4012
|
-
const
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4144
|
+
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4145
|
+
visViewer.parseFile(data);
|
|
4146
|
+
this.syncOptions();
|
|
4147
|
+
this.syncOverlay();
|
|
4148
|
+
this.update(true);
|
|
4149
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4150
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4017
4151
|
}
|
|
4018
|
-
catch (
|
|
4019
|
-
|
|
4152
|
+
catch (error) {
|
|
4153
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4154
|
+
throw error;
|
|
4020
4155
|
}
|
|
4021
|
-
|
|
4022
|
-
|
|
4156
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4157
|
+
return this;
|
|
4158
|
+
}
|
|
4159
|
+
openVsfxFile(buffer) {
|
|
4160
|
+
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4161
|
+
if (!this.visualizeJs)
|
|
4162
|
+
return this;
|
|
4163
|
+
this.cancel();
|
|
4164
|
+
this.clear();
|
|
4165
|
+
this.emitEvent({ type: "open", mode: "file", file: "", buffer });
|
|
4166
|
+
const visViewer = this.visViewer();
|
|
4167
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4168
|
+
try {
|
|
4169
|
+
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4170
|
+
visViewer.parseVsfx(data);
|
|
4171
|
+
this.syncOptions();
|
|
4172
|
+
this.syncOverlay();
|
|
4173
|
+
this.update(true);
|
|
4174
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4175
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4176
|
+
}
|
|
4177
|
+
catch (error) {
|
|
4178
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4179
|
+
throw error;
|
|
4023
4180
|
}
|
|
4181
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4182
|
+
return this;
|
|
4024
4183
|
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4184
|
+
cancel() {
|
|
4185
|
+
var _a;
|
|
4186
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4187
|
+
this._abortControllerForReferences = undefined;
|
|
4188
|
+
this.loaders.forEach((loader) => loader.cancel());
|
|
4189
|
+
this.emitEvent({ type: "cancel" });
|
|
4190
|
+
return this;
|
|
4027
4191
|
}
|
|
4028
|
-
|
|
4029
|
-
|
|
4192
|
+
clear() {
|
|
4193
|
+
if (!this.visualizeJs)
|
|
4194
|
+
return this;
|
|
4195
|
+
const visViewer = this.visViewer();
|
|
4196
|
+
this.setActiveDragger();
|
|
4197
|
+
this.clearSlices();
|
|
4198
|
+
this.clearOverlay();
|
|
4199
|
+
this.clearSelected();
|
|
4200
|
+
this.loaders.forEach((loader) => loader.dispose());
|
|
4201
|
+
this.loaders = [];
|
|
4202
|
+
this.models.forEach((model) => model.dispose());
|
|
4203
|
+
this.models = [];
|
|
4204
|
+
visViewer.clear();
|
|
4205
|
+
visViewer.createLocalDatabase();
|
|
4206
|
+
this.syncOptions();
|
|
4207
|
+
this.syncOverlay();
|
|
4208
|
+
this.update(true);
|
|
4209
|
+
this.emitEvent({ type: "clear" });
|
|
4210
|
+
return this;
|
|
4030
4211
|
}
|
|
4031
|
-
|
|
4032
|
-
|
|
4212
|
+
is3D() {
|
|
4213
|
+
if (!this.visualizeJs)
|
|
4214
|
+
return false;
|
|
4215
|
+
const visViewer = this.visViewer();
|
|
4216
|
+
const ext = visViewer.getActiveExtents();
|
|
4217
|
+
const min = ext.min();
|
|
4218
|
+
const max = ext.max();
|
|
4219
|
+
const extHeight = max[2] - min[2];
|
|
4220
|
+
return extHeight !== 0;
|
|
4033
4221
|
}
|
|
4034
|
-
|
|
4222
|
+
syncOptions(options = this.options) {
|
|
4035
4223
|
if (!this.visualizeJs)
|
|
4036
4224
|
return this;
|
|
4037
4225
|
const visLib = this.visLib();
|
|
@@ -4064,19 +4252,6 @@ class Viewer extends EventEmitter2 {
|
|
|
4064
4252
|
visualStylePtr.delete();
|
|
4065
4253
|
}
|
|
4066
4254
|
view.visualStyle = visualStyleId;
|
|
4067
|
-
view.delete();
|
|
4068
|
-
device.delete();
|
|
4069
|
-
return this;
|
|
4070
|
-
}
|
|
4071
|
-
syncOptions(options = this.options) {
|
|
4072
|
-
if (!this.visualizeJs)
|
|
4073
|
-
return this;
|
|
4074
|
-
this.syncOpenCloudVisualStyle();
|
|
4075
|
-
const visLib = this.visLib();
|
|
4076
|
-
const visViewer = this.visViewer();
|
|
4077
|
-
const device = visViewer.getActiveDevice();
|
|
4078
|
-
if (device.isNull())
|
|
4079
|
-
return this;
|
|
4080
4255
|
if (options.showWCS !== visViewer.getEnableWCS()) {
|
|
4081
4256
|
visViewer.setEnableWCS(options.showWCS);
|
|
4082
4257
|
}
|
|
@@ -4090,8 +4265,6 @@ class Viewer extends EventEmitter2 {
|
|
|
4090
4265
|
}
|
|
4091
4266
|
if (options.shadows !== visViewer.shadows) {
|
|
4092
4267
|
visViewer.shadows = options.shadows;
|
|
4093
|
-
const canvas = visLib.canvas;
|
|
4094
|
-
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
4095
4268
|
}
|
|
4096
4269
|
if (options.groundShadow !== visViewer.groundShadow) {
|
|
4097
4270
|
visViewer.groundShadow = options.groundShadow;
|
|
@@ -4117,17 +4290,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4117
4290
|
visualStyleId.delete();
|
|
4118
4291
|
activeView.delete();
|
|
4119
4292
|
}
|
|
4120
|
-
device.delete();
|
|
4121
|
-
this.syncHighlightingOptions(options);
|
|
4122
|
-
this.update();
|
|
4123
|
-
return this;
|
|
4124
|
-
}
|
|
4125
|
-
syncHighlightingOptions(options = this.options) {
|
|
4126
|
-
if (!this.visualizeJs)
|
|
4127
|
-
return this;
|
|
4128
4293
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
4129
|
-
const visLib = this.visLib();
|
|
4130
|
-
const visViewer = this.visViewer();
|
|
4131
4294
|
const { Entry, OdTvRGBColorDef } = visLib;
|
|
4132
4295
|
const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
|
|
4133
4296
|
const highlightStylePtr = highlightStyleId.openObject();
|
|
@@ -4154,19 +4317,80 @@ class Viewer extends EventEmitter2 {
|
|
|
4154
4317
|
const visibility = !isExist(params.edgesVisibility) ? true : params.edgesVisibility;
|
|
4155
4318
|
highlightStylePtr.setEdgesVisibility(Entry.k2DTop.value | Entry.k3DTop.value, params.edgesOverlap && visibility);
|
|
4156
4319
|
}
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
4161
|
-
device.delete();
|
|
4162
|
-
}
|
|
4320
|
+
view.delete();
|
|
4321
|
+
device.delete();
|
|
4322
|
+
this.update();
|
|
4163
4323
|
return this;
|
|
4164
4324
|
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4325
|
+
syncOverlay() {
|
|
4326
|
+
if (!this.visualizeJs)
|
|
4327
|
+
return;
|
|
4328
|
+
const visViewer = this.visViewer();
|
|
4329
|
+
const activeView = visViewer.activeView;
|
|
4330
|
+
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
4331
|
+
if (!overlayView) {
|
|
4332
|
+
const markupModel = visViewer.getMarkupModel();
|
|
4333
|
+
const pDevice = visViewer.getActiveDevice();
|
|
4334
|
+
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
4335
|
+
overlayView.addModel(markupModel);
|
|
4336
|
+
activeView.addSibling(overlayView);
|
|
4337
|
+
pDevice.addView(overlayView);
|
|
4338
|
+
}
|
|
4339
|
+
overlayView.viewPosition = activeView.viewPosition;
|
|
4340
|
+
overlayView.viewTarget = activeView.viewTarget;
|
|
4341
|
+
overlayView.upVector = activeView.upVector;
|
|
4342
|
+
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
4343
|
+
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
4344
|
+
const viewPort = overlayView.getViewport();
|
|
4345
|
+
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
4346
|
+
overlayView.vportRect = activeView.vportRect;
|
|
4347
|
+
this._markup.syncOverlay();
|
|
4348
|
+
this.update();
|
|
4167
4349
|
}
|
|
4168
|
-
|
|
4169
|
-
|
|
4350
|
+
clearOverlay() {
|
|
4351
|
+
if (!this.visualizeJs)
|
|
4352
|
+
return;
|
|
4353
|
+
this._markup.clearOverlay();
|
|
4354
|
+
this.update();
|
|
4355
|
+
}
|
|
4356
|
+
clearSlices() {
|
|
4357
|
+
if (!this.visualizeJs)
|
|
4358
|
+
return;
|
|
4359
|
+
const visViewer = this.visViewer();
|
|
4360
|
+
const activeView = visViewer.activeView;
|
|
4361
|
+
activeView.removeCuttingPlanes();
|
|
4362
|
+
activeView.delete();
|
|
4363
|
+
this.update();
|
|
4364
|
+
}
|
|
4365
|
+
getSelected() {
|
|
4366
|
+
return this.executeCommand("getSelected");
|
|
4367
|
+
}
|
|
4368
|
+
setSelected(handles) {
|
|
4369
|
+
this.executeCommand("setSelected", handles);
|
|
4370
|
+
}
|
|
4371
|
+
getSelected2() {
|
|
4372
|
+
return this.executeCommand("getSelected2");
|
|
4373
|
+
}
|
|
4374
|
+
setSelected2(handles) {
|
|
4375
|
+
this.executeCommand("setSelected2", handles);
|
|
4376
|
+
}
|
|
4377
|
+
clearSelected() {
|
|
4378
|
+
this.executeCommand("clearSelected");
|
|
4379
|
+
}
|
|
4380
|
+
hideSelected() {
|
|
4381
|
+
this.executeCommand("hideSelected");
|
|
4382
|
+
}
|
|
4383
|
+
isolateSelected() {
|
|
4384
|
+
this.executeCommand("isolateSelected");
|
|
4385
|
+
}
|
|
4386
|
+
showAll() {
|
|
4387
|
+
this.executeCommand("showAll");
|
|
4388
|
+
}
|
|
4389
|
+
explode(index = 0) {
|
|
4390
|
+
this.executeCommand("explode", index);
|
|
4391
|
+
}
|
|
4392
|
+
collect() {
|
|
4393
|
+
this.executeCommand("collect");
|
|
4170
4394
|
}
|
|
4171
4395
|
registerDragger(name, dragger) {
|
|
4172
4396
|
console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead.");
|
|
@@ -4213,55 +4437,102 @@ class Viewer extends EventEmitter2 {
|
|
|
4213
4437
|
getComponent(name) {
|
|
4214
4438
|
return this._components.find((component) => component.name === name);
|
|
4215
4439
|
}
|
|
4216
|
-
|
|
4440
|
+
drawViewpoint(viewpoint) {
|
|
4441
|
+
var _a, _b;
|
|
4217
4442
|
if (!this.visualizeJs)
|
|
4218
4443
|
return;
|
|
4219
4444
|
const visViewer = this.visViewer();
|
|
4220
4445
|
const activeView = visViewer.activeView;
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4446
|
+
const getPoint3dAsArray = (point3d) => {
|
|
4447
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
4448
|
+
};
|
|
4449
|
+
const setOrthogonalCamera = (orthogonal_camera) => {
|
|
4450
|
+
if (orthogonal_camera) {
|
|
4451
|
+
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);
|
|
4452
|
+
this.syncOverlay();
|
|
4453
|
+
this.emitEvent({ type: "changecameramode", mode: "orthographic" });
|
|
4454
|
+
}
|
|
4455
|
+
};
|
|
4456
|
+
const setPerspectiveCamera = (perspective_camera) => { };
|
|
4457
|
+
const setClippingPlanes = (clipping_planes) => {
|
|
4458
|
+
if (clipping_planes) {
|
|
4459
|
+
for (const clipping_plane of clipping_planes) {
|
|
4460
|
+
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
4461
|
+
cuttingPlane.set(getPoint3dAsArray(clipping_plane.location), getPoint3dAsArray(clipping_plane.direction));
|
|
4462
|
+
activeView.addCuttingPlane(cuttingPlane);
|
|
4463
|
+
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
};
|
|
4467
|
+
const setSelection = (selection) => {
|
|
4468
|
+
if (selection)
|
|
4469
|
+
this.setSelected(selection.map((component) => component.handle));
|
|
4470
|
+
};
|
|
4471
|
+
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
4472
|
+
this.setActiveDragger();
|
|
4473
|
+
this.clearSlices();
|
|
4474
|
+
this.clearOverlay();
|
|
4475
|
+
this.clearSelected();
|
|
4476
|
+
this.showAll();
|
|
4477
|
+
this.explode();
|
|
4478
|
+
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
4479
|
+
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
4480
|
+
setClippingPlanes(viewpoint.clipping_planes);
|
|
4481
|
+
setSelection(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.selection2) || viewpoint.selection);
|
|
4482
|
+
this._markup.setViewpoint(viewpoint);
|
|
4483
|
+
this.setActiveDragger(draggerName);
|
|
4484
|
+
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
4229
4485
|
this.update();
|
|
4230
4486
|
}
|
|
4231
|
-
|
|
4487
|
+
createViewpoint() {
|
|
4232
4488
|
if (!this.visualizeJs)
|
|
4233
|
-
return;
|
|
4489
|
+
return {};
|
|
4234
4490
|
const visViewer = this.visViewer();
|
|
4235
4491
|
const activeView = visViewer.activeView;
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4492
|
+
const getPoint3dFromArray = (array) => {
|
|
4493
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
4494
|
+
};
|
|
4495
|
+
const getOrthogonalCamera = () => {
|
|
4496
|
+
return {
|
|
4497
|
+
view_point: getPoint3dFromArray(activeView.viewPosition),
|
|
4498
|
+
direction: getPoint3dFromArray(activeView.viewTarget),
|
|
4499
|
+
up_vector: getPoint3dFromArray(activeView.upVector),
|
|
4500
|
+
field_width: activeView.viewFieldWidth,
|
|
4501
|
+
field_height: activeView.viewFieldHeight,
|
|
4502
|
+
view_to_world_scale: 1,
|
|
4503
|
+
};
|
|
4504
|
+
};
|
|
4505
|
+
const getPerspectiveCamera = () => {
|
|
4506
|
+
return undefined;
|
|
4507
|
+
};
|
|
4508
|
+
const getClippingPlanes = () => {
|
|
4509
|
+
const clipping_planes = [];
|
|
4510
|
+
for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
|
|
4511
|
+
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
4512
|
+
const clipping_plane = {
|
|
4513
|
+
location: getPoint3dFromArray(cuttingPlane.getOrigin()),
|
|
4514
|
+
direction: getPoint3dFromArray(cuttingPlane.normal()),
|
|
4515
|
+
};
|
|
4516
|
+
clipping_planes.push(clipping_plane);
|
|
4517
|
+
}
|
|
4518
|
+
return clipping_planes;
|
|
4519
|
+
};
|
|
4520
|
+
const getSelection = () => {
|
|
4521
|
+
return this.getSelected().map((handle) => ({ handle }));
|
|
4522
|
+
};
|
|
4523
|
+
const getSelection2 = () => {
|
|
4524
|
+
return this.getSelected2().map((handle) => ({ handle }));
|
|
4525
|
+
};
|
|
4526
|
+
const viewpoint = { custom_fields: {} };
|
|
4527
|
+
viewpoint.orthogonal_camera = getOrthogonalCamera();
|
|
4528
|
+
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
4529
|
+
viewpoint.clipping_planes = getClippingPlanes();
|
|
4530
|
+
viewpoint.selection = getSelection();
|
|
4531
|
+
viewpoint.description = new Date().toDateString();
|
|
4532
|
+
this._markup.getViewpoint(viewpoint);
|
|
4533
|
+
viewpoint.custom_fields.selection2 = getSelection2();
|
|
4534
|
+
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
4535
|
+
return viewpoint;
|
|
4265
4536
|
}
|
|
4266
4537
|
screenToWorld(position) {
|
|
4267
4538
|
if (!this.visualizeJs)
|
|
@@ -4296,184 +4567,23 @@ class Viewer extends EventEmitter2 {
|
|
|
4296
4567
|
result.z = 1 / z;
|
|
4297
4568
|
return result;
|
|
4298
4569
|
}
|
|
4299
|
-
|
|
4300
|
-
return
|
|
4301
|
-
}
|
|
4302
|
-
setSelected(handles) {
|
|
4303
|
-
this.executeCommand("setSelected", handles);
|
|
4304
|
-
}
|
|
4305
|
-
clearSelected() {
|
|
4306
|
-
this.executeCommand("clearSelected");
|
|
4307
|
-
}
|
|
4308
|
-
hideSelected() {
|
|
4309
|
-
this.executeCommand("hideSelected");
|
|
4310
|
-
}
|
|
4311
|
-
isolateSelected() {
|
|
4312
|
-
this.executeCommand("isolateSelected");
|
|
4313
|
-
}
|
|
4314
|
-
showAll() {
|
|
4315
|
-
this.executeCommand("showAll");
|
|
4316
|
-
}
|
|
4317
|
-
explode(index = 0) {
|
|
4318
|
-
this.executeCommand("explode", index);
|
|
4319
|
-
}
|
|
4320
|
-
collect() {
|
|
4321
|
-
this.executeCommand("collect");
|
|
4322
|
-
}
|
|
4323
|
-
async loadReferences(model) {
|
|
4324
|
-
var _a;
|
|
4325
|
-
if (!this.visualizeJs)
|
|
4326
|
-
return this;
|
|
4327
|
-
if (!this.client)
|
|
4328
|
-
return this;
|
|
4329
|
-
if (!model.getReferences)
|
|
4330
|
-
return this;
|
|
4331
|
-
const abortController = new AbortController();
|
|
4332
|
-
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4333
|
-
this._abortControllerForReferences = abortController;
|
|
4334
|
-
let references = [];
|
|
4335
|
-
await model
|
|
4336
|
-
.getReferences(abortController.signal)
|
|
4337
|
-
.then((data) => (references = data.references))
|
|
4338
|
-
.catch((e) => console.error("Cannot load model references.", e));
|
|
4339
|
-
for (const file of references) {
|
|
4340
|
-
await this.client
|
|
4341
|
-
.downloadFile(file.id, undefined, abortController.signal)
|
|
4342
|
-
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
4343
|
-
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
4344
|
-
}
|
|
4345
|
-
return this;
|
|
4346
|
-
}
|
|
4347
|
-
applyModelTransformMatrix(model) {
|
|
4348
|
-
this.executeCommand("applyModelTransform", model);
|
|
4570
|
+
executeCommand(id, ...args) {
|
|
4571
|
+
return commands.executeCommand(id, this, ...args);
|
|
4349
4572
|
}
|
|
4350
|
-
|
|
4573
|
+
addMarkupEntity(entityName) {
|
|
4351
4574
|
if (!this.visualizeJs)
|
|
4352
|
-
return;
|
|
4353
|
-
|
|
4575
|
+
return null;
|
|
4576
|
+
this.syncOverlay();
|
|
4354
4577
|
const visViewer = this.visViewer();
|
|
4355
|
-
const
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4578
|
+
const model = visViewer.getMarkupModel();
|
|
4579
|
+
const entityId = model.appendEntity(entityName);
|
|
4580
|
+
const entityPtr = entityId.openObject();
|
|
4581
|
+
const color = this.getMarkupColor();
|
|
4582
|
+
entityPtr.setColor(color.r, color.g, color.b);
|
|
4583
|
+
entityPtr.setLineWeight(2);
|
|
4584
|
+
entityPtr.delete();
|
|
4360
4585
|
this.update();
|
|
4361
|
-
|
|
4362
|
-
async open(file, params = {}) {
|
|
4363
|
-
if (!this.visualizeJs)
|
|
4364
|
-
return this;
|
|
4365
|
-
this.cancel();
|
|
4366
|
-
this.clear();
|
|
4367
|
-
this.emitEvent({ type: "open", file });
|
|
4368
|
-
let model = file;
|
|
4369
|
-
if (model && typeof model.getModels === "function") {
|
|
4370
|
-
const models = await model.getModels();
|
|
4371
|
-
model = models.find((model) => model.default) || models[0] || file;
|
|
4372
|
-
}
|
|
4373
|
-
if (!model)
|
|
4374
|
-
throw new Error(`Format not supported`);
|
|
4375
|
-
let format = params.format;
|
|
4376
|
-
if (!format && typeof model.type === "string")
|
|
4377
|
-
format = model.type.split(".").pop();
|
|
4378
|
-
if (!format && typeof file === "string")
|
|
4379
|
-
format = file.split(".").pop();
|
|
4380
|
-
if (!format && file instanceof globalThis.File)
|
|
4381
|
-
format = file.name.split(".").pop();
|
|
4382
|
-
const loader = loaders.createLoader(this, model, format);
|
|
4383
|
-
if (!loader)
|
|
4384
|
-
throw new Error(`Format not supported`);
|
|
4385
|
-
this.loaders.push(loader);
|
|
4386
|
-
this.emitEvent({ type: "geometrystart", file, model });
|
|
4387
|
-
try {
|
|
4388
|
-
await this.loadReferences(model);
|
|
4389
|
-
await loader.load(model, format, params);
|
|
4390
|
-
}
|
|
4391
|
-
catch (error) {
|
|
4392
|
-
this.emitEvent({ type: "geometryerror", data: error, file, model });
|
|
4393
|
-
throw error;
|
|
4394
|
-
}
|
|
4395
|
-
this.emitEvent({ type: "geometryend", file, model });
|
|
4396
|
-
if (this.visualizeJs) {
|
|
4397
|
-
this.applyModelTransformMatrix(model);
|
|
4398
|
-
this.applySceneGraphSettings();
|
|
4399
|
-
}
|
|
4400
|
-
return this;
|
|
4401
|
-
}
|
|
4402
|
-
openVsfFile(buffer) {
|
|
4403
|
-
console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4404
|
-
if (!this.visualizeJs)
|
|
4405
|
-
return this;
|
|
4406
|
-
this.cancel();
|
|
4407
|
-
this.clear();
|
|
4408
|
-
this.emitEvent({ type: "open", file: "", buffer });
|
|
4409
|
-
const visViewer = this.visViewer();
|
|
4410
|
-
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4411
|
-
try {
|
|
4412
|
-
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4413
|
-
visViewer.parseFile(data);
|
|
4414
|
-
this.syncOptions();
|
|
4415
|
-
this.syncOverlay();
|
|
4416
|
-
this.update(true);
|
|
4417
|
-
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4418
|
-
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4419
|
-
}
|
|
4420
|
-
catch (error) {
|
|
4421
|
-
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4422
|
-
throw error;
|
|
4423
|
-
}
|
|
4424
|
-
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4425
|
-
return this;
|
|
4426
|
-
}
|
|
4427
|
-
openVsfxFile(buffer) {
|
|
4428
|
-
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4429
|
-
if (!this.visualizeJs)
|
|
4430
|
-
return this;
|
|
4431
|
-
this.cancel();
|
|
4432
|
-
this.clear();
|
|
4433
|
-
this.emitEvent({ type: "open", file: "", buffer });
|
|
4434
|
-
const visViewer = this.visViewer();
|
|
4435
|
-
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4436
|
-
try {
|
|
4437
|
-
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4438
|
-
visViewer.parseVsfx(data);
|
|
4439
|
-
this.syncOptions();
|
|
4440
|
-
this.syncOverlay();
|
|
4441
|
-
this.update(true);
|
|
4442
|
-
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4443
|
-
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4444
|
-
}
|
|
4445
|
-
catch (error) {
|
|
4446
|
-
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4447
|
-
throw error;
|
|
4448
|
-
}
|
|
4449
|
-
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4450
|
-
return this;
|
|
4451
|
-
}
|
|
4452
|
-
cancel() {
|
|
4453
|
-
var _a;
|
|
4454
|
-
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4455
|
-
this._abortControllerForReferences = undefined;
|
|
4456
|
-
this.loaders.forEach((loader) => loader.cancel());
|
|
4457
|
-
this.emitEvent({ type: "cancel" });
|
|
4458
|
-
return this;
|
|
4459
|
-
}
|
|
4460
|
-
clear() {
|
|
4461
|
-
if (!this.visualizeJs)
|
|
4462
|
-
return this;
|
|
4463
|
-
const visViewer = this.visViewer();
|
|
4464
|
-
this.setActiveDragger();
|
|
4465
|
-
this.clearSlices();
|
|
4466
|
-
this.clearOverlay();
|
|
4467
|
-
this.clearSelected();
|
|
4468
|
-
this.loaders.forEach((loader) => loader.dispose());
|
|
4469
|
-
this.loaders = [];
|
|
4470
|
-
visViewer.clear();
|
|
4471
|
-
visViewer.createLocalDatabase();
|
|
4472
|
-
this.syncOptions();
|
|
4473
|
-
this.syncOverlay();
|
|
4474
|
-
this.update(true);
|
|
4475
|
-
this.emitEvent({ type: "clear" });
|
|
4476
|
-
return this;
|
|
4586
|
+
return entityId;
|
|
4477
4587
|
}
|
|
4478
4588
|
getMarkupColor() {
|
|
4479
4589
|
console.warn("Viewer.getMarkupColor() has been deprecated since 25.11 and will be removed in a future release, use Viewer.markup.getMarkupColor() instead.");
|
|
@@ -4490,113 +4600,43 @@ class Viewer extends EventEmitter2 {
|
|
|
4490
4600
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0) {
|
|
4491
4601
|
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
4492
4602
|
}
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4603
|
+
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
4604
|
+
return new Promise((resolve, reject) => {
|
|
4605
|
+
setTimeout(() => {
|
|
4606
|
+
var _a, _b, _c;
|
|
4607
|
+
try {
|
|
4608
|
+
if (this._enableAutoUpdate) {
|
|
4609
|
+
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
4610
|
+
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
4611
|
+
}
|
|
4612
|
+
this.emitEvent({ type: "update", data: false });
|
|
4613
|
+
resolve();
|
|
4614
|
+
}
|
|
4615
|
+
catch (e) {
|
|
4616
|
+
console.error(e);
|
|
4617
|
+
reject();
|
|
4618
|
+
}
|
|
4619
|
+
}, 0);
|
|
4620
|
+
});
|
|
4507
4621
|
}
|
|
4508
|
-
|
|
4509
|
-
var _a;
|
|
4622
|
+
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
4510
4623
|
if (!this.visualizeJs)
|
|
4511
4624
|
return;
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
|
|
4520
|
-
this.setClippingPlanes(viewpoint.clipping_planes);
|
|
4521
|
-
this.setSelection(viewpoint.selection);
|
|
4522
|
-
this._markup.setViewpoint(viewpoint);
|
|
4523
|
-
this.setActiveDragger(draggerName);
|
|
4524
|
-
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
4525
|
-
this.update();
|
|
4526
|
-
}
|
|
4527
|
-
createViewpoint() {
|
|
4528
|
-
if (!this.visualizeJs)
|
|
4529
|
-
return {};
|
|
4530
|
-
const viewpoint = {};
|
|
4531
|
-
viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
4532
|
-
viewpoint.clipping_planes = this.getClippingPlanes();
|
|
4533
|
-
viewpoint.selection = this.getSelection();
|
|
4534
|
-
viewpoint.description = new Date().toDateString();
|
|
4535
|
-
this._markup.getViewpoint(viewpoint);
|
|
4536
|
-
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
4537
|
-
return viewpoint;
|
|
4538
|
-
}
|
|
4539
|
-
getPoint3dFromArray(array) {
|
|
4540
|
-
return { x: array[0], y: array[1], z: array[2] };
|
|
4541
|
-
}
|
|
4542
|
-
getLogicalPoint3dAsArray(point3d) {
|
|
4543
|
-
return [point3d.x, point3d.y, point3d.z];
|
|
4544
|
-
}
|
|
4545
|
-
getOrthogonalCameraSettings() {
|
|
4546
|
-
const visViewer = this.visViewer();
|
|
4547
|
-
const activeView = visViewer.activeView;
|
|
4548
|
-
return {
|
|
4549
|
-
view_point: this.getPoint3dFromArray(activeView.viewPosition),
|
|
4550
|
-
direction: this.getPoint3dFromArray(activeView.viewTarget),
|
|
4551
|
-
up_vector: this.getPoint3dFromArray(activeView.upVector),
|
|
4552
|
-
field_width: activeView.viewFieldWidth,
|
|
4553
|
-
field_height: activeView.viewFieldHeight,
|
|
4554
|
-
view_to_world_scale: 1,
|
|
4555
|
-
};
|
|
4556
|
-
}
|
|
4557
|
-
setOrthogonalCameraSettings(settings) {
|
|
4558
|
-
const visViewer = this.visViewer();
|
|
4559
|
-
const activeView = visViewer.activeView;
|
|
4560
|
-
if (settings) {
|
|
4561
|
-
activeView.setView(this.getLogicalPoint3dAsArray(settings.view_point), this.getLogicalPoint3dAsArray(settings.direction), this.getLogicalPoint3dAsArray(settings.up_vector), settings.field_width, settings.field_height, true);
|
|
4562
|
-
this.syncOverlay();
|
|
4625
|
+
this._isRunAsyncUpdate = true;
|
|
4626
|
+
try {
|
|
4627
|
+
const device = this.visViewer().getActiveDevice();
|
|
4628
|
+
for (let iterationCount = 0; !device.isValid() && iterationCount < maxScheduleUpdateCount; iterationCount++) {
|
|
4629
|
+
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
4630
|
+
}
|
|
4631
|
+
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
4563
4632
|
}
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
const visViewer = this.visViewer();
|
|
4567
|
-
const activeView = visViewer.activeView;
|
|
4568
|
-
const clipping_planes = [];
|
|
4569
|
-
for (let i = 0; i < activeView.numCuttingPlanes(); i++) {
|
|
4570
|
-
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
4571
|
-
const clipping_plane = {
|
|
4572
|
-
location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
|
|
4573
|
-
direction: this.getPoint3dFromArray(cuttingPlane.normal()),
|
|
4574
|
-
};
|
|
4575
|
-
clipping_planes.push(clipping_plane);
|
|
4633
|
+
catch (e) {
|
|
4634
|
+
console.error(e);
|
|
4576
4635
|
}
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
setClippingPlanes(clipping_planes) {
|
|
4580
|
-
if (clipping_planes) {
|
|
4581
|
-
const visViewer = this.visViewer();
|
|
4582
|
-
const activeView = visViewer.activeView;
|
|
4583
|
-
for (const clipping_plane of clipping_planes) {
|
|
4584
|
-
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
4585
|
-
cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
|
|
4586
|
-
activeView.addCuttingPlane(cuttingPlane);
|
|
4587
|
-
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
4588
|
-
}
|
|
4636
|
+
finally {
|
|
4637
|
+
this._isRunAsyncUpdate = false;
|
|
4589
4638
|
}
|
|
4590
4639
|
}
|
|
4591
|
-
getSelection() {
|
|
4592
|
-
return this.getSelected().map((handle) => ({ handle }));
|
|
4593
|
-
}
|
|
4594
|
-
setSelection(selection) {
|
|
4595
|
-
this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
|
|
4596
|
-
}
|
|
4597
|
-
executeCommand(id, ...args) {
|
|
4598
|
-
return commands.executeCommand(id, this, ...args);
|
|
4599
|
-
}
|
|
4600
4640
|
deviceAutoRegeneration() {
|
|
4601
4641
|
const visViewer = this.visViewer();
|
|
4602
4642
|
const device = visViewer.getActiveDevice();
|