@inweb/viewer-visualize 27.9.1 → 27.11.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 +573 -236
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +458 -236
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Commands/ClearSelected.d.ts +1 -1
- package/lib/Viewer/Commands/Deselect.d.ts +2 -0
- package/lib/Viewer/Commands/Explode.d.ts +1 -1
- package/lib/Viewer/Commands/GetHidden.d.ts +2 -0
- package/lib/Viewer/Commands/GetIsolated.d.ts +2 -0
- package/lib/Viewer/Commands/GetSelected.d.ts +2 -2
- package/lib/Viewer/Commands/GetSelected2.d.ts +1 -1
- package/lib/Viewer/Commands/Hide.d.ts +2 -0
- package/lib/Viewer/Commands/HideAll.d.ts +2 -0
- package/lib/Viewer/Commands/HideSelected.d.ts +1 -1
- package/lib/Viewer/Commands/Isolate.d.ts +2 -0
- package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -1
- package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -1
- package/lib/Viewer/Commands/ResetView.d.ts +1 -1
- package/lib/Viewer/Commands/Select.d.ts +2 -0
- package/lib/Viewer/Commands/SelectModel.d.ts +1 -1
- package/lib/Viewer/Commands/SetSelected.d.ts +2 -2
- package/lib/Viewer/Commands/SetSelected2.d.ts +2 -2
- package/lib/Viewer/Commands/Show.d.ts +2 -0
- package/lib/Viewer/Commands/ShowAll.d.ts +1 -1
- package/lib/Viewer/Commands/ToHandles.d.ts +2 -0
- package/lib/Viewer/Commands/ToHandles2.d.ts +2 -0
- package/lib/Viewer/Commands/ToggleSelection.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomExtents.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomTo.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -1
- package/lib/Viewer/Components/index.d.ts +1 -1
- package/lib/Viewer/Draggers/index.d.ts +2 -2
- package/lib/Viewer/Loaders/VSFCloudLoader.d.ts +2 -2
- package/lib/Viewer/Loaders/VSFXCloudLoader.d.ts +2 -2
- package/lib/Viewer/Loaders/VSFXCloudPartialLoader.d.ts +2 -2
- package/lib/Viewer/Loaders/VSFXCloudStreamingLoader.d.ts +2 -2
- package/lib/Viewer/Loaders/index.d.ts +4 -2
- package/lib/Viewer/Models/ModelImpl.d.ts +15 -1
- package/lib/Viewer/Models/ModelImpl.types.d.ts +10 -0
- package/lib/Viewer/Viewer.d.ts +19 -4
- package/package.json +6 -6
- package/src/Viewer/Commands/ClearSelected.ts +4 -8
- package/src/Viewer/Commands/Deselect.ts +35 -0
- package/src/Viewer/Commands/Explode.ts +4 -6
- package/src/Viewer/Commands/GetHidden.ts +30 -0
- package/src/Viewer/Commands/GetIsolated.ts +30 -0
- package/src/Viewer/Commands/GetModels.ts +2 -3
- package/src/Viewer/Commands/GetSelected.ts +5 -30
- package/src/Viewer/Commands/GetSelected2.ts +5 -7
- package/src/Viewer/Commands/Hide.ts +35 -0
- package/src/Viewer/Commands/HideAll.ts +32 -0
- package/src/Viewer/Commands/HideSelected.ts +2 -11
- package/src/Viewer/Commands/Isolate.ts +41 -0
- package/src/Viewer/Commands/IsolateSelected.ts +2 -8
- package/src/Viewer/Commands/RegenerateAll.ts +2 -3
- package/src/Viewer/Commands/ResetView.ts +2 -4
- package/src/Viewer/Commands/Select.ts +36 -0
- package/src/Viewer/Commands/SelectModel.ts +11 -14
- package/src/Viewer/Commands/SetSelected.ts +8 -19
- package/src/Viewer/Commands/SetSelected2.ts +6 -14
- package/src/Viewer/Commands/Show.ts +34 -0
- package/src/Viewer/Commands/ShowAll.ts +3 -6
- package/src/Viewer/Commands/ToHandles.ts +35 -0
- package/src/Viewer/Commands/ToHandles2.ts +36 -0
- package/src/Viewer/Commands/ToggleSelection.ts +40 -0
- package/src/Viewer/Commands/{ZoomToExtents.ts → ZoomExtents.ts} +2 -8
- package/src/Viewer/Commands/{ZoomToObjects.ts → ZoomTo.ts} +8 -13
- package/src/Viewer/Commands/ZoomToSelected.ts +3 -11
- package/src/Viewer/Commands/index.ts +29 -8
- package/src/Viewer/Components/index.ts +1 -1
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +21 -14
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +32 -32
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +2 -2
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +14 -10
- package/src/Viewer/Draggers/index.ts +2 -2
- package/src/Viewer/Loaders/VSFCloudLoader.ts +5 -4
- package/src/Viewer/Loaders/VSFFileLoader.ts +2 -1
- package/src/Viewer/Loaders/VSFXCloudLoader.ts +5 -4
- package/src/Viewer/Loaders/VSFXCloudPartialLoader.ts +5 -4
- package/src/Viewer/Loaders/VSFXCloudStreamingLoader.ts +5 -4
- package/src/Viewer/Loaders/VSFXFileLoader.ts +2 -1
- package/src/Viewer/Loaders/index.ts +4 -2
- package/src/Viewer/Models/ModelImpl.ts +150 -3
- package/src/Viewer/Models/{IModelImpl.ts → ModelImpl.types.ts} +9 -1
- package/src/Viewer/Viewer.ts +121 -19
- package/lib/Viewer/Commands/ZoomToExtents.d.ts +0 -2
- package/lib/Viewer/Commands/ZoomToObjects.d.ts +0 -2
- package/lib/Viewer/Models/IModelImpl.d.ts +0 -5
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -40,9 +40,12 @@ import {
|
|
|
40
40
|
IPoint,
|
|
41
41
|
IViewer,
|
|
42
42
|
IViewpoint,
|
|
43
|
+
IVisibility,
|
|
43
44
|
Options,
|
|
44
45
|
OptionsEventMap,
|
|
46
|
+
Selector,
|
|
45
47
|
ViewerEventMap,
|
|
48
|
+
VisibilityManager,
|
|
46
49
|
} from "@inweb/viewer-core";
|
|
47
50
|
import { IMarkup, IWorldTransform } from "@inweb/markup";
|
|
48
51
|
|
|
@@ -50,10 +53,11 @@ import { draggers } from "./Draggers";
|
|
|
50
53
|
import { commands } from "./Commands";
|
|
51
54
|
import { components } from "./Components";
|
|
52
55
|
import { loaders } from "./Loaders";
|
|
53
|
-
import { IModelImpl } from "./Models/
|
|
56
|
+
import { IModelImpl } from "./Models/ModelImpl.types";
|
|
54
57
|
|
|
55
58
|
import { loadVisualizeJs } from "./utils";
|
|
56
59
|
import { MarkupFactory, MarkupType } from "./Markup/MarkupFactory";
|
|
60
|
+
import { toHandles2 } from "./Commands/ToHandles2";
|
|
57
61
|
|
|
58
62
|
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
59
63
|
|
|
@@ -82,8 +86,12 @@ export class Viewer
|
|
|
82
86
|
private _viewer: any;
|
|
83
87
|
private _crossOrigin;
|
|
84
88
|
|
|
89
|
+
public selector: Selector;
|
|
90
|
+
public visibilityManager: VisibilityManager;
|
|
91
|
+
public explodeScale: number;
|
|
92
|
+
|
|
85
93
|
private _activeDragger: IDragger | null;
|
|
86
|
-
private _components: IComponent
|
|
94
|
+
private _components: Map<string, IComponent>;
|
|
87
95
|
|
|
88
96
|
private _renderNeeded: boolean;
|
|
89
97
|
private _renderTime: DOMHighResTimeStamp;
|
|
@@ -127,9 +135,13 @@ export class Viewer
|
|
|
127
135
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
128
136
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
129
137
|
|
|
138
|
+
this.selector = new Selector(this.models);
|
|
139
|
+
this.visibilityManager = new VisibilityManager(this.models);
|
|
140
|
+
this.explodeScale = 0;
|
|
141
|
+
|
|
130
142
|
this._visualizeTimestamp = 0;
|
|
131
143
|
this._activeDragger = null;
|
|
132
|
-
this._components =
|
|
144
|
+
this._components = new Map();
|
|
133
145
|
|
|
134
146
|
this._renderNeeded = false;
|
|
135
147
|
this._renderTime = 0;
|
|
@@ -276,7 +288,7 @@ export class Viewer
|
|
|
276
288
|
|
|
277
289
|
for (const name of components.getComponents().keys()) {
|
|
278
290
|
const component = components.createComponent(name, this);
|
|
279
|
-
if (component) this._components.
|
|
291
|
+
if (component) this._components.set(name, component);
|
|
280
292
|
}
|
|
281
293
|
|
|
282
294
|
this.syncOptions();
|
|
@@ -300,7 +312,7 @@ export class Viewer
|
|
|
300
312
|
this.setActiveDragger();
|
|
301
313
|
|
|
302
314
|
this._components.forEach((component: IComponent) => component.dispose());
|
|
303
|
-
this._components.
|
|
315
|
+
this._components.clear();
|
|
304
316
|
|
|
305
317
|
this._markup.dispose();
|
|
306
318
|
|
|
@@ -359,7 +371,7 @@ export class Viewer
|
|
|
359
371
|
*/
|
|
360
372
|
update(force: boolean | number = false) {
|
|
361
373
|
const time = performance.now();
|
|
362
|
-
if (typeof force === "number"
|
|
374
|
+
if (typeof force === "number") force = time - this._renderTime >= force;
|
|
363
375
|
|
|
364
376
|
if (this._enableAutoUpdate) {
|
|
365
377
|
this._renderNeeded = true;
|
|
@@ -538,6 +550,7 @@ export class Viewer
|
|
|
538
550
|
|
|
539
551
|
const loader = loaders.createLoader(this, model, format);
|
|
540
552
|
if (!loader) throw new Error(`Format not supported (${format})`);
|
|
553
|
+
|
|
541
554
|
this.loaders.push(loader);
|
|
542
555
|
|
|
543
556
|
this.emitEvent({ type: "geometrystart", file, model });
|
|
@@ -837,38 +850,86 @@ export class Viewer
|
|
|
837
850
|
this.update();
|
|
838
851
|
}
|
|
839
852
|
|
|
840
|
-
getSelected(): string[] {
|
|
841
|
-
return this.executeCommand("getSelected");
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
setSelected(handles?: string[]): void {
|
|
845
|
-
this.executeCommand("setSelected", handles);
|
|
853
|
+
getSelected(multimodel?: boolean): string[] {
|
|
854
|
+
return this.executeCommand("getSelected", multimodel);
|
|
846
855
|
}
|
|
847
856
|
|
|
848
857
|
getSelected2(): string[] {
|
|
849
858
|
return this.executeCommand("getSelected2");
|
|
850
859
|
}
|
|
851
860
|
|
|
861
|
+
setSelected(handles?: string[]): void {
|
|
862
|
+
this.executeCommand("setSelected", handles);
|
|
863
|
+
}
|
|
864
|
+
|
|
852
865
|
setSelected2(handles?: string[]): void {
|
|
853
866
|
this.executeCommand("setSelected2", handles);
|
|
854
867
|
}
|
|
855
868
|
|
|
869
|
+
select(handles: string | string[]): void {
|
|
870
|
+
this.executeCommand("select", handles);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
deselect(handles: string | string[]): void {
|
|
874
|
+
this.executeCommand("deselect", handles);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
toggleSelection(handles: string | string[]): void {
|
|
878
|
+
this.executeCommand("toggleSelection", handles);
|
|
879
|
+
}
|
|
880
|
+
|
|
856
881
|
clearSelected(): void {
|
|
857
882
|
this.executeCommand("clearSelected");
|
|
858
883
|
}
|
|
859
884
|
|
|
885
|
+
getHidden(multimodel?: boolean): string[] {
|
|
886
|
+
return this.executeCommand("getHidden", multimodel);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
getIsolated(multimodel?: boolean): string[] {
|
|
890
|
+
return this.executeCommand("getIsolated", multimodel);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
hide(handle: string | string[]): void {
|
|
894
|
+
this.executeCommand("hide", handle);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
hideAll(): void {
|
|
898
|
+
this.executeCommand("hideAll");
|
|
899
|
+
}
|
|
900
|
+
|
|
860
901
|
hideSelected(): void {
|
|
861
902
|
this.executeCommand("hideSelected");
|
|
862
903
|
}
|
|
863
904
|
|
|
905
|
+
isolate(handle: string | string[]): void {
|
|
906
|
+
this.executeCommand("isolate", handle);
|
|
907
|
+
}
|
|
908
|
+
|
|
864
909
|
isolateSelected(): void {
|
|
865
910
|
this.executeCommand("isolateSelected");
|
|
866
911
|
}
|
|
867
912
|
|
|
913
|
+
show(handle: string | string[]): void {
|
|
914
|
+
this.executeCommand("show", handle);
|
|
915
|
+
}
|
|
916
|
+
|
|
868
917
|
showAll(): void {
|
|
869
918
|
this.executeCommand("showAll");
|
|
870
919
|
}
|
|
871
920
|
|
|
921
|
+
zoomExtents(): void {
|
|
922
|
+
this.executeCommand("zoomExtents");
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
zoomTo(handles: string | string[]): void {
|
|
926
|
+
this.executeCommand("zoomTo", handles);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
zoomToSelected(): void {
|
|
930
|
+
this.executeCommand("zoomToSelected");
|
|
931
|
+
}
|
|
932
|
+
|
|
872
933
|
explode(index = 0): void {
|
|
873
934
|
this.executeCommand("explode", index);
|
|
874
935
|
}
|
|
@@ -915,7 +976,7 @@ export class Viewer
|
|
|
915
976
|
}
|
|
916
977
|
|
|
917
978
|
getComponent(name: string): IComponent | null {
|
|
918
|
-
return this._components.
|
|
979
|
+
return this._components.get(name) || null;
|
|
919
980
|
}
|
|
920
981
|
|
|
921
982
|
drawViewpoint(viewpoint: IViewpoint): void {
|
|
@@ -998,7 +1059,22 @@ export class Viewer
|
|
|
998
1059
|
};
|
|
999
1060
|
|
|
1000
1061
|
const setSelection = (selection: IEntity[]) => {
|
|
1001
|
-
if (selection)
|
|
1062
|
+
if (selection) {
|
|
1063
|
+
this.setSelected(selection.map(({ handle }) => handle));
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const setVisibility = (visibility: IVisibility) => {
|
|
1068
|
+
if (visibility && visibility.exceptions)
|
|
1069
|
+
if (visibility.default_visibility) {
|
|
1070
|
+
this.hide(visibility.exceptions.map(({ handle }) => handle));
|
|
1071
|
+
} else {
|
|
1072
|
+
this.isolate(visibility.exceptions.map(({ handle }) => handle));
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const setExplodeScale = (scale: number) => {
|
|
1077
|
+
if (scale > 0) this.explode(scale);
|
|
1002
1078
|
};
|
|
1003
1079
|
|
|
1004
1080
|
const draggerName = this._activeDragger?.name;
|
|
@@ -1007,14 +1083,16 @@ export class Viewer
|
|
|
1007
1083
|
this.clearSlices();
|
|
1008
1084
|
this.clearOverlay();
|
|
1009
1085
|
this.clearSelected();
|
|
1010
|
-
|
|
1011
1086
|
this.showAll();
|
|
1012
1087
|
this.explode();
|
|
1013
1088
|
|
|
1014
1089
|
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
1015
1090
|
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
1016
1091
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
1092
|
+
setVisibility(viewpoint.custom_fields?.visibility2 || viewpoint.visibility);
|
|
1017
1093
|
setSelection(viewpoint.custom_fields?.selection2 || viewpoint.selection);
|
|
1094
|
+
setExplodeScale(viewpoint.custom_fields?.explodeScale);
|
|
1095
|
+
|
|
1018
1096
|
this._markup.setViewpoint(viewpoint);
|
|
1019
1097
|
|
|
1020
1098
|
this.syncOverlay();
|
|
@@ -1095,11 +1173,31 @@ export class Viewer
|
|
|
1095
1173
|
};
|
|
1096
1174
|
|
|
1097
1175
|
const getSelection = (): IEntity[] => {
|
|
1098
|
-
|
|
1176
|
+
const selected = Array.from(this.selector.selected);
|
|
1177
|
+
return selected.map((handle) => ({ handle }));
|
|
1099
1178
|
};
|
|
1100
1179
|
|
|
1101
1180
|
const getSelection2 = (): IEntity[] => {
|
|
1102
|
-
|
|
1181
|
+
const selected = Array.from(this.selector.selected);
|
|
1182
|
+
const selected2 = toHandles2(this, selected);
|
|
1183
|
+
return selected2.map((handle) => ({ handle }));
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
const getVisibility = (): IVisibility => {
|
|
1187
|
+
const exceptions = Array.from(this.visibilityManager.exceptions);
|
|
1188
|
+
return {
|
|
1189
|
+
default_visibility: this.visibilityManager.defaultVisible,
|
|
1190
|
+
exceptions: exceptions.map((handle) => ({ handle })),
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
const getVisibility2 = (): IVisibility => {
|
|
1195
|
+
const exceptions = Array.from(this.visibilityManager.exceptions);
|
|
1196
|
+
const exceptions2 = toHandles2(this, exceptions);
|
|
1197
|
+
return {
|
|
1198
|
+
default_visibility: this.visibilityManager.defaultVisible,
|
|
1199
|
+
exceptions: exceptions2.map((handle) => ({ handle })),
|
|
1200
|
+
};
|
|
1103
1201
|
};
|
|
1104
1202
|
|
|
1105
1203
|
const viewpoint: IViewpoint = { custom_fields: {} };
|
|
@@ -1108,12 +1206,16 @@ export class Viewer
|
|
|
1108
1206
|
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
1109
1207
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
1110
1208
|
viewpoint.selection = getSelection();
|
|
1209
|
+
viewpoint.visibility = getVisibility();
|
|
1111
1210
|
viewpoint.description = new Date().toDateString();
|
|
1112
1211
|
viewpoint.snapshot = { data: this.getSnapshot() };
|
|
1113
1212
|
|
|
1114
|
-
this._markup.getViewpoint(viewpoint);
|
|
1115
|
-
|
|
1116
1213
|
viewpoint.custom_fields.selection2 = getSelection2();
|
|
1214
|
+
viewpoint.custom_fields.visibility2 = getVisibility2();
|
|
1215
|
+
viewpoint.custom_fields.explodeScale = this.explodeScale;
|
|
1216
|
+
viewpoint.custom_fields.files = this.models.map((model) => model.id);
|
|
1217
|
+
|
|
1218
|
+
this._markup.getViewpoint(viewpoint);
|
|
1117
1219
|
|
|
1118
1220
|
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
1119
1221
|
|