@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
|
@@ -258,27 +258,34 @@ export class OrbitAction {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
private getCenter(): any {
|
|
261
|
+
const handles = this._subject.getSelected();
|
|
262
|
+
const selectionSet = this._subject.models[0].getSelectionSetByHandles(handles);
|
|
263
|
+
|
|
261
264
|
const viewer = this.getViewer();
|
|
262
|
-
let center;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
265
|
+
let center: any;
|
|
266
|
+
|
|
267
|
+
if (selectionSet.numItems() > 0) {
|
|
268
|
+
let extSelected: any;
|
|
269
|
+
|
|
270
|
+
const itemItr = selectionSet.getIterator();
|
|
271
|
+
while (!itemItr.done()) {
|
|
272
|
+
const entityId = itemItr.getEntity();
|
|
273
|
+
|
|
274
|
+
const entityExt = entityId.getWCSExtents();
|
|
275
|
+
if (extSelected) extSelected.addExt(entityExt);
|
|
276
|
+
else extSelected = entityExt;
|
|
277
|
+
|
|
278
|
+
itemItr.step();
|
|
273
279
|
}
|
|
274
|
-
|
|
280
|
+
itemItr.delete();
|
|
275
281
|
|
|
276
|
-
extSelected.
|
|
277
|
-
itr.delete();
|
|
282
|
+
center = extSelected.center();
|
|
278
283
|
} else {
|
|
279
284
|
center = viewer.getActiveExtents().center();
|
|
280
285
|
}
|
|
281
286
|
|
|
287
|
+
selectionSet.delete();
|
|
288
|
+
|
|
282
289
|
return center;
|
|
283
290
|
}
|
|
284
291
|
|
|
@@ -55,23 +55,23 @@ export class OdBaseDragger extends OdaGeAction {
|
|
|
55
55
|
this.click = this.click.bind(this);
|
|
56
56
|
this.dblclick = this.dblclick.bind(this);
|
|
57
57
|
|
|
58
|
-
this.subject.addEventListener("pointerdown", this.pointerdown);
|
|
59
|
-
this.subject.addEventListener("pointerup", this.pointerup);
|
|
60
|
-
this.subject.addEventListener("pointercancel", this.pointercancel);
|
|
61
|
-
this.subject.addEventListener("pointermove", this.pointermove);
|
|
62
|
-
this.subject.addEventListener("click", this.click);
|
|
63
|
-
this.subject.addEventListener("dblclick", this.dblclick);
|
|
58
|
+
this.subject.canvas.addEventListener("pointerdown", this.pointerdown);
|
|
59
|
+
this.subject.canvas.addEventListener("pointerup", this.pointerup);
|
|
60
|
+
this.subject.canvas.addEventListener("pointercancel", this.pointercancel);
|
|
61
|
+
this.subject.canvas.addEventListener("pointermove", this.pointermove);
|
|
62
|
+
this.subject.canvas.addEventListener("click", this.click);
|
|
63
|
+
this.subject.canvas.addEventListener("dblclick", this.dblclick);
|
|
64
64
|
|
|
65
65
|
this.getViewer().setEnableAutoSelect(false);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
public dispose(): void {
|
|
69
|
-
this.subject.removeEventListener("pointerdown", this.pointerdown);
|
|
70
|
-
this.subject.removeEventListener("pointerup", this.pointerup);
|
|
71
|
-
this.subject.removeEventListener("pointercancel", this.pointercancel);
|
|
72
|
-
this.subject.removeEventListener("pointermove", this.pointermove);
|
|
73
|
-
this.subject.removeEventListener("click", this.click);
|
|
74
|
-
this.subject.removeEventListener("dblclick", this.dblclick);
|
|
69
|
+
this.subject.canvas.removeEventListener("pointerdown", this.pointerdown);
|
|
70
|
+
this.subject.canvas.removeEventListener("pointerup", this.pointerup);
|
|
71
|
+
this.subject.canvas.removeEventListener("pointercancel", this.pointercancel);
|
|
72
|
+
this.subject.canvas.removeEventListener("pointermove", this.pointermove);
|
|
73
|
+
this.subject.canvas.removeEventListener("click", this.click);
|
|
74
|
+
this.subject.canvas.removeEventListener("dblclick", this.dblclick);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
protected relativeCoords(event: MouseEvent): Point2d {
|
|
@@ -130,7 +130,6 @@ export class OdBaseDragger extends OdaGeAction {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
protected click(ev: MouseEvent): void {
|
|
133
|
-
const viewer = this.getViewer();
|
|
134
133
|
const relCoord = this.relativeCoords(ev);
|
|
135
134
|
const x = relCoord.x;
|
|
136
135
|
const y = relCoord.y;
|
|
@@ -139,42 +138,43 @@ export class OdBaseDragger extends OdaGeAction {
|
|
|
139
138
|
Math.abs(x - this.mouseDownPosition.x) < CLICK_DELTA && Math.abs(y - this.mouseDownPosition.y) < CLICK_DELTA;
|
|
140
139
|
|
|
141
140
|
if (this.autoSelect && isNotDragging) {
|
|
142
|
-
viewer.
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
const viewer = this.getViewer();
|
|
142
|
+
const view = viewer.activeView;
|
|
143
|
+
const model = viewer.getActiveModel();
|
|
144
|
+
|
|
145
|
+
const opt = new this.m_module.OdTvSelectionOptions();
|
|
146
|
+
opt.setMode(this.m_module.SelectionMode.kPoint);
|
|
145
147
|
|
|
146
|
-
const selectionSet =
|
|
148
|
+
const selectionSet = view.select([x, y], opt, model);
|
|
149
|
+
const handles = this.subject.models[0].getHandlesBySelectionSet(selectionSet);
|
|
147
150
|
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
selectionSet.delete();
|
|
152
|
+
opt.delete();
|
|
153
|
+
|
|
154
|
+
if (handles.length > 0) {
|
|
155
|
+
if (!ev.shiftKey) this.subject.setSelected(handles);
|
|
156
|
+
else this.subject.toggleSelection(handles);
|
|
157
|
+
} else {
|
|
158
|
+
if (!ev.shiftKey) this.subject.clearSelected();
|
|
159
|
+
}
|
|
150
160
|
}
|
|
151
161
|
}
|
|
152
162
|
|
|
153
163
|
protected dblclick(ev: MouseEvent): void {
|
|
154
|
-
const viewer = this.getViewer();
|
|
155
164
|
const relCoord = this.relativeCoords(ev);
|
|
156
165
|
const x = relCoord.x;
|
|
157
166
|
const y = relCoord.y;
|
|
158
167
|
|
|
168
|
+
const viewer = this.getViewer();
|
|
159
169
|
const device = viewer.getActiveDevice();
|
|
170
|
+
|
|
160
171
|
const clickView = device.viewAt([x, y]);
|
|
161
172
|
if (clickView && !clickView.active) {
|
|
162
173
|
viewer.activeView = clickView;
|
|
163
174
|
clickView.delete();
|
|
164
175
|
this.subject.update();
|
|
165
176
|
} else if (this.autoSelect) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (!pSelected.isNull() && pSelected.numItems() !== 0) {
|
|
169
|
-
const itr = pSelected.getIterator();
|
|
170
|
-
const entity = itr.getEntity();
|
|
171
|
-
viewer.zoomToEntity(entity);
|
|
172
|
-
|
|
173
|
-
this.subject.emitEvent({ type: "zoomtoentity", data: entity });
|
|
174
|
-
this.subject.update();
|
|
175
|
-
|
|
176
|
-
this.deleteAll([itr, entity]);
|
|
177
|
-
}
|
|
177
|
+
this.subject.zoomToSelected();
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
device.delete();
|
|
@@ -36,7 +36,7 @@ export class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
36
36
|
super(subject);
|
|
37
37
|
|
|
38
38
|
this.wheel = this.wheel.bind(this);
|
|
39
|
-
this.subject.addEventListener("wheel", this.wheel);
|
|
39
|
+
this.subject.canvas.addEventListener("wheel", this.wheel);
|
|
40
40
|
|
|
41
41
|
this._zoomAction = new ZoomAction(this.m_module, this.subject);
|
|
42
42
|
this._endInteractivityTimeOutId = undefined;
|
|
@@ -46,7 +46,7 @@ export class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
46
46
|
override dispose(): void {
|
|
47
47
|
super.dispose();
|
|
48
48
|
|
|
49
|
-
this.subject.removeEventListener("wheel", this.wheel);
|
|
49
|
+
this.subject.canvas.removeEventListener("wheel", this.wheel);
|
|
50
50
|
|
|
51
51
|
if (this._endInteractivityTimeOutId) {
|
|
52
52
|
clearTimeout(this._endInteractivityTimeOutId);
|
|
@@ -146,24 +146,26 @@ export class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
getCenter(): any {
|
|
149
|
-
const
|
|
149
|
+
const handles = this.subject.getSelected();
|
|
150
|
+
const selectionSet = this.subject.models[0].getSelectionSetByHandles(handles);
|
|
150
151
|
|
|
152
|
+
const viewer = this.getViewer();
|
|
151
153
|
let ext = viewer.getActiveExtents();
|
|
152
154
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
const entId = itr.getEntity();
|
|
155
|
+
if (selectionSet.numItems() > 0) {
|
|
156
|
+
const itemItr = selectionSet.getIterator();
|
|
157
|
+
const entityId = itemItr.getEntity();
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
const type = entityId.getType();
|
|
160
|
+
if (type === this.m_module.OdTvEntityType.kEntity.value) {
|
|
161
|
+
const obj = entityId.openObject();
|
|
160
162
|
|
|
161
163
|
ext.delete();
|
|
162
164
|
ext = obj.getExtents();
|
|
163
165
|
|
|
164
166
|
obj.delete();
|
|
165
|
-
} else if (
|
|
166
|
-
const obj =
|
|
167
|
+
} else if (type === this.m_module.OdTvEntityType.kInsert.value) {
|
|
168
|
+
const obj = entityId.openObjectAsInsert();
|
|
167
169
|
const extTuple = obj.getExtents();
|
|
168
170
|
|
|
169
171
|
ext.delete();
|
|
@@ -173,9 +175,11 @@ export class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
173
175
|
obj.delete();
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
itemItr.delete();
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
selectionSet.delete();
|
|
182
|
+
|
|
179
183
|
const center = ext.center();
|
|
180
184
|
|
|
181
185
|
ext.delete();
|
|
@@ -60,11 +60,11 @@ import { OdaTextDragger } from "./OdaTextDragger";
|
|
|
60
60
|
*
|
|
61
61
|
* constructor(viewer: Viewer) {
|
|
62
62
|
* this.viewer = viewer;
|
|
63
|
-
* this.viewer.addEventListener("pointermove", this.onPointerMove);
|
|
63
|
+
* this.viewer.canvas.addEventListener("pointermove", this.onPointerMove);
|
|
64
64
|
* }
|
|
65
65
|
*
|
|
66
66
|
* override dispose() {
|
|
67
|
-
* this.viewer.removeEventListener("pointermove", this.onPointerMove);
|
|
67
|
+
* this.viewer.canvas.removeEventListener("pointermove", this.onPointerMove);
|
|
68
68
|
* }
|
|
69
69
|
*
|
|
70
70
|
* onPointerMove = (event: PointerEvent) => {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Loader } from "@inweb/viewer-core";
|
|
24
|
+
import { Loader, LoadParams } from "@inweb/viewer-core";
|
|
25
25
|
import { Viewer } from "../Viewer";
|
|
26
26
|
import { ModelImpl } from "../Models/ModelImpl";
|
|
27
27
|
|
|
@@ -42,7 +42,7 @@ export class VSFCloudLoader extends Loader {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
override async load(model: any, format?: string): Promise<this> {
|
|
45
|
+
override async load(model: any, format?: string, params: LoadParams = {}): Promise<this> {
|
|
46
46
|
if (!this.viewer.visualizeJs) return this;
|
|
47
47
|
|
|
48
48
|
const visViewer = this.viewer.visViewer();
|
|
@@ -69,8 +69,9 @@ export class VSFCloudLoader extends Loader {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (i === 0) {
|
|
72
|
-
const modelImpl = new ModelImpl();
|
|
73
|
-
modelImpl.id = model.file.id;
|
|
72
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
73
|
+
modelImpl.id = params.modelId || model.file.id;
|
|
74
|
+
modelImpl.initialize();
|
|
74
75
|
|
|
75
76
|
this.viewer.models.push(modelImpl);
|
|
76
77
|
|
|
@@ -69,8 +69,9 @@ export class VSFFileLoader extends Loader {
|
|
|
69
69
|
throw error;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const modelImpl = new ModelImpl();
|
|
72
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
73
73
|
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
74
|
+
modelImpl.initialize();
|
|
74
75
|
|
|
75
76
|
this.viewer.models.push(modelImpl);
|
|
76
77
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Loader } from "@inweb/viewer-core";
|
|
24
|
+
import { Loader, LoadParams } from "@inweb/viewer-core";
|
|
25
25
|
import { Viewer } from "../Viewer";
|
|
26
26
|
import { ModelImpl } from "../Models/ModelImpl";
|
|
27
27
|
|
|
@@ -43,7 +43,7 @@ export class VSFXCloudLoader extends Loader {
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
override async load(model: any): Promise<this> {
|
|
46
|
+
override async load(model: any, format?: string, params: LoadParams = {}): Promise<this> {
|
|
47
47
|
if (!this.viewer.visualizeJs) return Promise.resolve(this);
|
|
48
48
|
|
|
49
49
|
const visViewer = this.viewer.visViewer();
|
|
@@ -64,8 +64,9 @@ export class VSFXCloudLoader extends Loader {
|
|
|
64
64
|
throw error;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const modelImpl = new ModelImpl();
|
|
68
|
-
modelImpl.id = model.file.id;
|
|
67
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
68
|
+
modelImpl.id = params.modelId || model.file.id;
|
|
69
|
+
modelImpl.initialize();
|
|
69
70
|
|
|
70
71
|
this.viewer.models.push(modelImpl);
|
|
71
72
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Loader } from "@inweb/viewer-core";
|
|
24
|
+
import { Loader, LoadParams } from "@inweb/viewer-core";
|
|
25
25
|
import { Viewer } from "../Viewer";
|
|
26
26
|
import { ModelImpl } from "../Models/ModelImpl";
|
|
27
27
|
|
|
@@ -49,7 +49,7 @@ export class VSFXCloudPartialLoader extends Loader {
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
override async load(model: any): Promise<this> {
|
|
52
|
+
override async load(model: any, format?: string, params: LoadParams = {}): Promise<this> {
|
|
53
53
|
if (!this.viewer.visualizeJs) return this;
|
|
54
54
|
|
|
55
55
|
type Range = { requestId: number; begin: number; end: number };
|
|
@@ -80,8 +80,9 @@ export class VSFXCloudPartialLoader extends Loader {
|
|
|
80
80
|
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
81
81
|
|
|
82
82
|
if (isDatabaseChunk) {
|
|
83
|
-
const modelImpl = new ModelImpl();
|
|
84
|
-
modelImpl.id = model.file.id;
|
|
83
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
84
|
+
modelImpl.id = params.modelId || model.file.id;
|
|
85
|
+
modelImpl.initialize();
|
|
85
86
|
|
|
86
87
|
this.viewer.models.push(modelImpl);
|
|
87
88
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Loader } from "@inweb/viewer-core";
|
|
24
|
+
import { Loader, LoadParams } from "@inweb/viewer-core";
|
|
25
25
|
import { Viewer } from "../Viewer";
|
|
26
26
|
import { ModelImpl } from "../Models/ModelImpl";
|
|
27
27
|
|
|
@@ -45,7 +45,7 @@ export class VSFXCloudStreamingLoader extends Loader {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
override async load(model: any): Promise<this> {
|
|
48
|
+
override async load(model: any, format?: string, params: LoadParams = {}): Promise<this> {
|
|
49
49
|
if (!this.viewer.visualizeJs) return this;
|
|
50
50
|
|
|
51
51
|
const visLib = this.viewer.visLib();
|
|
@@ -76,8 +76,9 @@ export class VSFXCloudStreamingLoader extends Loader {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (isDatabaseChunk) {
|
|
79
|
-
const modelImpl = new ModelImpl();
|
|
80
|
-
modelImpl.id = model.file.id;
|
|
79
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
80
|
+
modelImpl.id = params.modelId || model.file.id;
|
|
81
|
+
modelImpl.initialize();
|
|
81
82
|
|
|
82
83
|
this.viewer.models.push(modelImpl);
|
|
83
84
|
|
|
@@ -69,8 +69,9 @@ export class VSFXFileLoader extends Loader {
|
|
|
69
69
|
throw error;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const modelImpl = new ModelImpl();
|
|
72
|
+
const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
73
73
|
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
74
|
+
modelImpl.initialize();
|
|
74
75
|
|
|
75
76
|
this.viewer.models.push(modelImpl);
|
|
76
77
|
|
|
@@ -79,10 +79,12 @@ import { VSFXCloudPartialLoader } from "./VSFXCloudPartialLoader";
|
|
|
79
79
|
* // load VSFX data from file (custom loading logic)
|
|
80
80
|
* const data = await fetch(file).then((result) => result.arrayBuffer());
|
|
81
81
|
*
|
|
82
|
-
*
|
|
82
|
+
* this.viewer.visViewer().parseVsfx(new Uint8Array(data));
|
|
83
|
+
*
|
|
84
|
+
* const modelImpl = new ModelImpl(this.viewer.visualizeJs);
|
|
83
85
|
* modelImpl.id = params.modelId;
|
|
86
|
+
* modelImpl.initialize();
|
|
84
87
|
*
|
|
85
|
-
* this.viewer.visViewer().parseVsfx(new Uint8Array(data));
|
|
86
88
|
* this.viewer.models.push(modelImpl);
|
|
87
89
|
*
|
|
88
90
|
* this.viewer.syncOptions();
|
|
@@ -21,12 +21,159 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { IModelImpl } from "./
|
|
25
|
-
|
|
26
|
-
// Basic model implementation.
|
|
24
|
+
import { IModelImpl } from "./ModelImpl.types";
|
|
27
25
|
|
|
28
26
|
export class ModelImpl implements IModelImpl {
|
|
29
27
|
public id = "";
|
|
28
|
+
public visualizeJs: any;
|
|
29
|
+
|
|
30
|
+
constructor(visualizeJs: any) {
|
|
31
|
+
this.id = "";
|
|
32
|
+
this.visualizeJs = visualizeJs;
|
|
33
|
+
}
|
|
30
34
|
|
|
31
35
|
dispose(): void {}
|
|
36
|
+
|
|
37
|
+
initialize(): void {
|
|
38
|
+
// reserved for future use
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getHandlesByEntityIterator(iterator: any): string[] {
|
|
42
|
+
const handles2: string[] = [];
|
|
43
|
+
|
|
44
|
+
while (!iterator.done()) {
|
|
45
|
+
const entityId = iterator.getEntity();
|
|
46
|
+
|
|
47
|
+
const entityType = entityId.getType();
|
|
48
|
+
let entityPtr = null;
|
|
49
|
+
if (entityType === this.visualizeJs.OdTvEntityType.kEntity.value) entityPtr = entityId.openObject();
|
|
50
|
+
if (entityType === this.visualizeJs.OdTvEntityType.kInsert.value) entityPtr = entityId.openObjectAsInsert();
|
|
51
|
+
|
|
52
|
+
if (entityPtr) {
|
|
53
|
+
const handle = entityPtr.getNativeDatabaseHandle();
|
|
54
|
+
if (handle !== "-1") handles2.push(handle);
|
|
55
|
+
entityPtr.delete();
|
|
56
|
+
}
|
|
57
|
+
iterator.step();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return handles2;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getHandlesBySelectionSet(selectionSet: any): string[] {
|
|
64
|
+
const iterator = selectionSet.getIterator();
|
|
65
|
+
const handles = this.getHandlesByEntityIterator(iterator);
|
|
66
|
+
iterator.delete();
|
|
67
|
+
return handles;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getSelectionSetByHandles(handles: string[]): any {
|
|
71
|
+
const viewer = this.visualizeJs.getViewer();
|
|
72
|
+
const selectionSet = viewer.getEntitySetByOriginalHandles(handles);
|
|
73
|
+
|
|
74
|
+
return selectionSet;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// IModel
|
|
78
|
+
|
|
79
|
+
hide(handles: string[]): this {
|
|
80
|
+
const viewer = this.visualizeJs.getViewer();
|
|
81
|
+
const model = viewer.getActiveModel();
|
|
82
|
+
|
|
83
|
+
const selectionSet = this.getSelectionSetByHandles(handles);
|
|
84
|
+
model.hideBySelectionSet(selectionSet, false);
|
|
85
|
+
selectionSet.delete();
|
|
86
|
+
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
hideAll(): this {
|
|
91
|
+
const viewer = this.visualizeJs.getViewer();
|
|
92
|
+
const model = viewer.getActiveModel();
|
|
93
|
+
const selectionSet = new this.visualizeJs.OdTvSelectionSet();
|
|
94
|
+
|
|
95
|
+
const entityItr = model.getEntitiesIterator();
|
|
96
|
+
while (!entityItr.done()) {
|
|
97
|
+
const entityId = entityItr.getEntity();
|
|
98
|
+
|
|
99
|
+
const entityType = entityId.getType();
|
|
100
|
+
const isEntity = entityType === this.visualizeJs.OdTvEntityType.kEntity.value;
|
|
101
|
+
const isInsert = entityType === this.visualizeJs.OdTvEntityType.kInsert.value;
|
|
102
|
+
|
|
103
|
+
if (isEntity || isInsert) selectionSet.appendEntity(entityId);
|
|
104
|
+
|
|
105
|
+
entityItr.step();
|
|
106
|
+
}
|
|
107
|
+
entityItr.delete();
|
|
108
|
+
|
|
109
|
+
model.hideBySelectionSet(selectionSet, false);
|
|
110
|
+
selectionSet.delete();
|
|
111
|
+
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
isolate(handles: string[]): this {
|
|
116
|
+
if (handles.length > 0) {
|
|
117
|
+
const viewer = this.visualizeJs.getViewer();
|
|
118
|
+
const model = viewer.getActiveModel();
|
|
119
|
+
|
|
120
|
+
const selectionSet = this.getSelectionSetByHandles(handles);
|
|
121
|
+
model.isolateBySelectionSet(selectionSet, false);
|
|
122
|
+
selectionSet.delete();
|
|
123
|
+
} else {
|
|
124
|
+
this.hideAll();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
show(handles: string[]): this {
|
|
131
|
+
const viewer = this.visualizeJs.getViewer();
|
|
132
|
+
const model = viewer.getActiveModel();
|
|
133
|
+
|
|
134
|
+
const selectionSet = this.getSelectionSetByHandles(handles);
|
|
135
|
+
model.unHideBySelectionSet(selectionSet, true, false);
|
|
136
|
+
selectionSet.delete();
|
|
137
|
+
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
showAll(): this {
|
|
142
|
+
const viewer = this.visualizeJs.getViewer();
|
|
143
|
+
const model = viewer.getActiveModel();
|
|
144
|
+
|
|
145
|
+
model.unIsolate(false);
|
|
146
|
+
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
highlight(handles: string[]): this {
|
|
151
|
+
const viewer = this.visualizeJs.getViewer();
|
|
152
|
+
const view = viewer.activeView;
|
|
153
|
+
|
|
154
|
+
const selectionSet = this.getSelectionSetByHandles(handles);
|
|
155
|
+
view.highlightAll(selectionSet, true);
|
|
156
|
+
selectionSet.delete();
|
|
157
|
+
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
unhighlight(handles: string[]): this {
|
|
162
|
+
const viewer = this.visualizeJs.getViewer();
|
|
163
|
+
const view = viewer.activeView;
|
|
164
|
+
|
|
165
|
+
const selectionSet = this.getSelectionSetByHandles(handles);
|
|
166
|
+
view.highlightAll(selectionSet, false);
|
|
167
|
+
selectionSet.delete();
|
|
168
|
+
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
explode(scale: 0, coeff = 4): this {
|
|
173
|
+
const viewer = this.visualizeJs.getViewer();
|
|
174
|
+
|
|
175
|
+
viewer.explode(scale);
|
|
176
|
+
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
32
179
|
}
|
|
@@ -26,4 +26,12 @@ import { IModel } from "@inweb/viewer-core";
|
|
|
26
26
|
/**
|
|
27
27
|
* Basic model implementation.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export interface IModelImpl extends IModel {
|
|
30
|
+
initialize(): void;
|
|
31
|
+
|
|
32
|
+
getHandlesByEntityIterator(iterator: any): string[];
|
|
33
|
+
|
|
34
|
+
getHandlesBySelectionSet(selectionSet: any): string[];
|
|
35
|
+
|
|
36
|
+
getSelectionSetByHandles(handles: string[]): any;
|
|
37
|
+
}
|