@inweb/viewer-three 25.12.1 → 26.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/viewer-three.js +52994 -52727
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -3
- package/dist/viewer-three.module.js +1571 -1444
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +4 -4
- package/lib/Viewer/commands/ApplyModelTransform.d.ts +3 -1
- package/lib/Viewer/commands/ClearMarkup.d.ts +2 -1
- package/lib/Viewer/commands/ClearSelected.d.ts +2 -1
- package/lib/Viewer/commands/ClearSlices.d.ts +2 -1
- package/lib/Viewer/commands/CreatePreview.d.ts +2 -1
- package/lib/Viewer/commands/Explode.d.ts +3 -1
- package/lib/Viewer/commands/GetDefaultViewPositions.d.ts +1 -1
- package/lib/Viewer/commands/GetModels.d.ts +2 -1
- package/lib/Viewer/commands/GetSelected.d.ts +2 -1
- package/lib/Viewer/commands/HideSelected.d.ts +2 -1
- package/lib/Viewer/commands/IsolateSelected.d.ts +2 -1
- package/lib/Viewer/commands/RegenerateAll.d.ts +2 -1
- package/lib/Viewer/commands/ResetView.d.ts +2 -1
- package/lib/Viewer/commands/SelectModel.d.ts +2 -1
- package/lib/Viewer/commands/SetActiveDragger.d.ts +2 -1
- package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +2 -0
- package/lib/Viewer/commands/SetMarkupColor.d.ts +2 -1
- package/lib/Viewer/commands/SetSelected.d.ts +2 -1
- package/lib/Viewer/commands/ShowAll.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToExtents.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToObjects.d.ts +2 -1
- package/lib/Viewer/commands/ZoomToSelected.d.ts +2 -1
- package/lib/Viewer/commands/index.d.ts +22 -22
- package/lib/Viewer/components/AxesHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/BackgroundComponent.d.ts +2 -2
- package/lib/Viewer/components/DefaultPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/ExtentsComponent.d.ts +2 -2
- package/lib/Viewer/components/ExtentsHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/LightComponent.d.ts +2 -2
- package/lib/Viewer/components/RenderLoopComponent.d.ts +2 -2
- package/lib/Viewer/components/ResizeCanvasComponent.d.ts +2 -2
- package/lib/Viewer/components/SelectionComponent.d.ts +2 -2
- package/lib/Viewer/components/ViewPositionComponent.d.ts +2 -3
- package/lib/Viewer/components/WCSHelperComponent.d.ts +2 -2
- package/lib/Viewer/components/index.d.ts +40 -0
- package/lib/Viewer/draggers/OrbitDragger.d.ts +2 -2
- package/lib/Viewer/draggers/WalkDragger.d.ts +2 -1
- package/lib/Viewer/draggers/index.d.ts +39 -0
- package/lib/index.d.ts +4 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +37 -68
- package/src/Viewer/commands/ApplyModelTransform.ts +2 -6
- package/src/Viewer/commands/ClearMarkup.ts +3 -3
- package/src/Viewer/commands/ClearSelected.ts +1 -5
- package/src/Viewer/commands/ClearSlices.ts +3 -2
- package/src/Viewer/commands/CreatePreview.ts +1 -4
- package/src/Viewer/commands/Explode.ts +4 -5
- package/src/Viewer/commands/GetDefaultViewPositions.ts +1 -4
- package/src/Viewer/commands/GetModels.ts +2 -6
- package/src/Viewer/commands/GetSelected.ts +1 -4
- package/src/Viewer/commands/HideSelected.ts +1 -4
- package/src/Viewer/commands/IsolateSelected.ts +1 -5
- package/src/Viewer/commands/RegenerateAll.ts +1 -5
- package/src/Viewer/commands/ResetView.ts +1 -4
- package/src/Viewer/commands/SelectModel.ts +1 -4
- package/src/Viewer/commands/SetActiveDragger.ts +2 -3
- package/src/Viewer/commands/SetDefaultViewPosition.ts +1 -26
- package/src/Viewer/commands/SetMarkupColor.ts +3 -5
- package/src/Viewer/commands/SetSelected.ts +1 -4
- package/src/Viewer/commands/ShowAll.ts +1 -4
- package/src/Viewer/commands/ZoomToExtents.ts +1 -6
- package/src/Viewer/commands/ZoomToObjects.ts +1 -5
- package/src/Viewer/commands/ZoomToSelected.ts +1 -5
- package/src/Viewer/commands/index.ts +98 -22
- package/src/Viewer/components/AxesHelperComponent.ts +2 -2
- package/src/Viewer/components/BackgroundComponent.ts +2 -2
- package/src/Viewer/components/DefaultPositionComponent.ts +2 -3
- package/src/Viewer/components/ExtentsComponent.ts +2 -2
- package/src/Viewer/components/ExtentsHelperComponent.ts +2 -2
- package/src/Viewer/components/LightComponent.ts +2 -2
- package/src/Viewer/components/RenderLoopComponent.ts +2 -2
- package/src/Viewer/components/ResizeCanvasComponent.ts +2 -2
- package/src/Viewer/components/SelectionComponent.ts +2 -2
- package/src/Viewer/components/ViewPositionComponent.ts +2 -3
- package/src/Viewer/components/WCSHelperComponent.ts +2 -2
- package/src/Viewer/components/index.ts +91 -0
- package/src/Viewer/draggers/OrbitDragger.ts +3 -2
- package/src/Viewer/draggers/WalkDragger.ts +2 -1
- package/src/Viewer/draggers/index.ts +83 -0
- package/src/index.ts +5 -2
- package/lib/Viewer/IDisposable.d.ts +0 -6
- package/src/Viewer/IDisposable.ts +0 -29
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -30,9 +30,9 @@ import { Assembly, Client, Model, File } from "@inweb/client";
|
|
|
30
30
|
import {
|
|
31
31
|
CANVAS_EVENTS,
|
|
32
32
|
CanvasEventMap,
|
|
33
|
-
commands,
|
|
34
33
|
IClippingPlane,
|
|
35
34
|
IComponent,
|
|
35
|
+
IEntity,
|
|
36
36
|
IDragger,
|
|
37
37
|
IOptions,
|
|
38
38
|
IPerspectiveCamera,
|
|
@@ -45,27 +45,10 @@ import {
|
|
|
45
45
|
} from "@inweb/viewer-core";
|
|
46
46
|
import { IMarkup, IWorldTransform, Markup } from "@inweb/markup";
|
|
47
47
|
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
import {
|
|
52
|
-
import { CuttingPlaneXAxisDragger } from "./draggers/CuttingPlaneXAxis";
|
|
53
|
-
import { CuttingPlaneYAxisDragger } from "./draggers/CuttingPlaneYAxis";
|
|
54
|
-
import { CuttingPlaneZAxisDragger } from "./draggers/CuttingPlaneZAxis";
|
|
55
|
-
import { MeasureLineDragger } from "./draggers/MeasureLineDragger";
|
|
56
|
-
|
|
57
|
-
import { IDisposable } from "./IDisposable";
|
|
58
|
-
import { ExtentsComponent } from "./components/ExtentsComponent";
|
|
59
|
-
import { LightComponent } from "./components/LightComponent";
|
|
60
|
-
import { BackgroundComponent } from "./components/BackgroundComponent";
|
|
61
|
-
import { DefaultPositionComponent } from "./components/DefaultPositionComponent";
|
|
62
|
-
import { ResizeCanvasComponent } from "./components/ResizeCanvasComponent";
|
|
63
|
-
import { RenderLoopComponent } from "./components/RenderLoopComponent";
|
|
64
|
-
import { SelectionComponent } from "./components/SelectionComponent";
|
|
65
|
-
// import { ViewPositionComponent } from "./components/ViewPositionComponent";
|
|
66
|
-
import { WCSHelperComponent } from "./components/WCSHelperComponent";
|
|
67
|
-
// import { AxesHelperComponent } from "./components/AxesHelperComponent";
|
|
68
|
-
// import { ExtentsHelperComponent } from "./components/ExtentsHelperComponent";
|
|
48
|
+
import { draggers } from "./draggers";
|
|
49
|
+
import { commands } from "./commands";
|
|
50
|
+
|
|
51
|
+
import { components } from "./components";
|
|
69
52
|
|
|
70
53
|
/**
|
|
71
54
|
* 3D viewer powered by {@link https://threejs.org/ | Three.js}.
|
|
@@ -91,10 +74,8 @@ export class Viewer
|
|
|
91
74
|
public extents: Box3;
|
|
92
75
|
public target: Vector3;
|
|
93
76
|
|
|
94
|
-
private draggerFactory: Record<string, any>;
|
|
95
77
|
private _activeDragger: IDragger | null;
|
|
96
|
-
|
|
97
|
-
private components: Array<IDisposable>;
|
|
78
|
+
private _components: Array<IComponent>;
|
|
98
79
|
|
|
99
80
|
private renderNeeded: boolean;
|
|
100
81
|
private renderTime: DOMHighResTimeStamp;
|
|
@@ -115,24 +96,13 @@ export class Viewer
|
|
|
115
96
|
this.canvasEvents = CANVAS_EVENTS;
|
|
116
97
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
117
98
|
|
|
99
|
+
this.models = [];
|
|
100
|
+
this.selected = [];
|
|
118
101
|
this.extents = new Box3();
|
|
119
102
|
this.target = new Vector3();
|
|
120
103
|
|
|
121
|
-
this.draggerFactory = {
|
|
122
|
-
Pan: PanDragger,
|
|
123
|
-
Zoom: ZoomDragger,
|
|
124
|
-
Orbit: OrbitDragger,
|
|
125
|
-
Walk: WalkDragger,
|
|
126
|
-
CuttingPlaneXAxis: CuttingPlaneXAxisDragger,
|
|
127
|
-
CuttingPlaneYAxis: CuttingPlaneYAxisDragger,
|
|
128
|
-
CuttingPlaneZAxis: CuttingPlaneZAxisDragger,
|
|
129
|
-
MeasureLine: MeasureLineDragger,
|
|
130
|
-
};
|
|
131
104
|
this._activeDragger = null;
|
|
132
|
-
|
|
133
|
-
this.models = [];
|
|
134
|
-
this.components = [];
|
|
135
|
-
this.selected = [];
|
|
105
|
+
this._components = [];
|
|
136
106
|
|
|
137
107
|
this.renderTime = 0;
|
|
138
108
|
|
|
@@ -147,7 +117,11 @@ export class Viewer
|
|
|
147
117
|
}
|
|
148
118
|
|
|
149
119
|
get draggers(): string[] {
|
|
150
|
-
return
|
|
120
|
+
return [...draggers.getDraggers().keys()];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get components(): string[] {
|
|
124
|
+
return [...components.getComponents().keys()];
|
|
151
125
|
}
|
|
152
126
|
|
|
153
127
|
/**
|
|
@@ -181,17 +155,9 @@ export class Viewer
|
|
|
181
155
|
|
|
182
156
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
183
157
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// this.components.push(new ViewPositionComponent(this));
|
|
188
|
-
this.components.push(new DefaultPositionComponent(this));
|
|
189
|
-
this.components.push(new ResizeCanvasComponent(this));
|
|
190
|
-
this.components.push(new RenderLoopComponent(this));
|
|
191
|
-
this.components.push(new SelectionComponent(this));
|
|
192
|
-
this.components.push(new WCSHelperComponent(this));
|
|
193
|
-
// this.components.push(new AxesHelperComponent(this));
|
|
194
|
-
// this.components.push(new ExtentsHelperComponent(this));
|
|
158
|
+
for (let name of components.getComponents().keys()) {
|
|
159
|
+
this._components.push(components.createComponent(name, this));
|
|
160
|
+
}
|
|
195
161
|
|
|
196
162
|
this.syncOptions();
|
|
197
163
|
this.syncOverlay();
|
|
@@ -212,8 +178,8 @@ export class Viewer
|
|
|
212
178
|
this.cancel();
|
|
213
179
|
this.emitEvent({ type: "dispose" });
|
|
214
180
|
|
|
215
|
-
this.
|
|
216
|
-
this.
|
|
181
|
+
this._components.forEach((component: IComponent) => component.dispose());
|
|
182
|
+
this._components = [];
|
|
217
183
|
|
|
218
184
|
this.setActiveDragger();
|
|
219
185
|
this.removeAllListeners();
|
|
@@ -257,6 +223,8 @@ export class Viewer
|
|
|
257
223
|
this.renderer.render(this.helpers, this.camera);
|
|
258
224
|
this.renderer.clippingPlanes = clippingPlanes;
|
|
259
225
|
|
|
226
|
+
this._activeDragger?.updatePreview?.();
|
|
227
|
+
|
|
260
228
|
const deltaTime = (time - this.renderTime) / 1000;
|
|
261
229
|
this.renderTime = time;
|
|
262
230
|
this.emitEvent({ type: "render", time, deltaTime });
|
|
@@ -566,26 +534,27 @@ export class Viewer
|
|
|
566
534
|
|
|
567
535
|
setActiveDragger(name = ""): IDragger | null {
|
|
568
536
|
if (!this._activeDragger || this._activeDragger.name !== name) {
|
|
537
|
+
const oldDragger = this._activeDragger;
|
|
538
|
+
let newDragger = null;
|
|
539
|
+
|
|
569
540
|
if (this._activeDragger) {
|
|
570
541
|
this._activeDragger.dispose();
|
|
571
542
|
this._activeDragger = null;
|
|
572
543
|
}
|
|
573
544
|
if (this.isInitialized()) {
|
|
574
|
-
|
|
575
|
-
if (
|
|
576
|
-
this._activeDragger =
|
|
577
|
-
this._activeDragger.
|
|
545
|
+
newDragger = draggers.createDragger(name, this);
|
|
546
|
+
if (newDragger) {
|
|
547
|
+
this._activeDragger = newDragger;
|
|
548
|
+
this._activeDragger.initialize?.();
|
|
578
549
|
}
|
|
579
550
|
}
|
|
551
|
+
|
|
580
552
|
const canvas = this.canvas;
|
|
581
553
|
if (canvas) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
.filter((x) => !x.startsWith("oda-cursor-"))
|
|
585
|
-
.filter((x) => x)
|
|
586
|
-
.concat(`oda-cursor-${name.toLowerCase()}`)
|
|
587
|
-
.join(" ");
|
|
554
|
+
if (oldDragger) canvas.classList.remove(`oda-cursor-${oldDragger.name.toLowerCase()}`);
|
|
555
|
+
if (newDragger) canvas.classList.add(`oda-cursor-${newDragger.name.toLowerCase()}`);
|
|
588
556
|
}
|
|
557
|
+
|
|
589
558
|
this.emitEvent({ type: "changeactivedragger", data: name });
|
|
590
559
|
this.update();
|
|
591
560
|
}
|
|
@@ -635,11 +604,11 @@ export class Viewer
|
|
|
635
604
|
}
|
|
636
605
|
|
|
637
606
|
executeCommand(id: string, ...args: any[]): any {
|
|
638
|
-
return commands
|
|
607
|
+
return commands.executeCommand(id, this, ...args);
|
|
639
608
|
}
|
|
640
609
|
|
|
641
|
-
getComponent(
|
|
642
|
-
return this.
|
|
610
|
+
getComponent(name: string): IComponent {
|
|
611
|
+
return this._components.find((component) => component.name === name);
|
|
643
612
|
}
|
|
644
613
|
|
|
645
614
|
drawViewpoint(viewpoint: IViewpoint): void {
|
|
@@ -670,7 +639,7 @@ export class Viewer
|
|
|
670
639
|
});
|
|
671
640
|
};
|
|
672
641
|
|
|
673
|
-
const setSelection = (selection:
|
|
642
|
+
const setSelection = (selection: IEntity[]) => {
|
|
674
643
|
this.setSelected(selection?.map((component) => component.handle));
|
|
675
644
|
};
|
|
676
645
|
|
|
@@ -722,7 +691,7 @@ export class Viewer
|
|
|
722
691
|
return clipping_planes;
|
|
723
692
|
};
|
|
724
693
|
|
|
725
|
-
const getSelection = ():
|
|
694
|
+
const getSelection = (): IEntity[] => {
|
|
726
695
|
return this.getSelected().map((handle) => ({ handle }));
|
|
727
696
|
};
|
|
728
697
|
|
|
@@ -21,13 +21,9 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Model, File, Assembly } from "@inweb/client";
|
|
25
|
-
import { commands } from "@inweb/viewer-core";
|
|
24
|
+
import type { Model, File, Assembly } from "@inweb/client";
|
|
26
25
|
import type { Viewer } from "../Viewer";
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
function applyModelTransform(viewer: Viewer, model: Model | File | Assembly) {
|
|
27
|
+
export function applyModelTransform(viewer: Viewer, model: Model | File | Assembly) {
|
|
30
28
|
console.warn("applyModelTransform not implemented");
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
commands("ThreeJS").registerCommand("applyModelTransform", applyModelTransform);
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export function clearMarkup(viewer: Viewer) {
|
|
27
|
+
viewer.clearOverlay();
|
|
28
|
+
}
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
import { SelectionComponent } from "../components/SelectionComponent";
|
|
27
26
|
|
|
28
|
-
function clearSelected(viewer: Viewer): void {
|
|
27
|
+
export function clearSelected(viewer: Viewer): void {
|
|
29
28
|
const selection = new SelectionComponent(viewer);
|
|
30
29
|
selection.clearSelection();
|
|
31
30
|
selection.dispose();
|
|
@@ -33,6 +32,3 @@ function clearSelected(viewer: Viewer): void {
|
|
|
33
32
|
viewer.update();
|
|
34
33
|
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
commands("ThreeJS").registerCommand("clearSelected", clearSelected);
|
|
38
|
-
commands("ThreeJS").registerCommandAlias("clearSelected", "unselect");
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
export function clearSlices(viewer: Viewer) {
|
|
27
|
+
viewer.clearSlices();
|
|
28
|
+
}
|
|
@@ -21,12 +21,9 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function createPreview(viewer: Viewer, type = "image/jpeg", encoderOptions = 0.25): string {
|
|
26
|
+
export function createPreview(viewer: Viewer, type = "image/jpeg", encoderOptions = 0.25): string {
|
|
28
27
|
viewer.update(true);
|
|
29
28
|
return viewer.canvas.toDataURL(type, encoderOptions);
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
commands("ThreeJS").registerCommand("createPreview", createPreview);
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Box3, Object3D, Vector3 } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
27
|
function calcObjectDepth(object: Object3D, depth: number) {
|
|
@@ -72,12 +70,13 @@ function explodeScene(scene: Object3D, scale = 0) {
|
|
|
72
70
|
explodeObject(scene, 0, sceneCenter, new Vector3(0, 0, 0));
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
function explode(viewer: Viewer, index = 0): void {
|
|
73
|
+
export function explode(viewer: Viewer, index = 0): void {
|
|
76
74
|
viewer.models.forEach((gltf) => explodeScene(gltf.scene, index));
|
|
77
75
|
|
|
78
76
|
viewer.update();
|
|
79
77
|
viewer.emitEvent({ type: "explode", data: index });
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
export function collect(viewer: Viewer) {
|
|
81
|
+
explode(viewer, 0);
|
|
82
|
+
}
|
|
@@ -21,11 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import { defaultViewPositions } from "./SetDefaultViewPosition";
|
|
26
25
|
|
|
27
|
-
function getDefaultViewPositions(): string[] {
|
|
26
|
+
export function getDefaultViewPositions(): string[] {
|
|
28
27
|
return Object.keys(defaultViewPositions);
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
commands("ThreeJS").registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
@@ -21,12 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function getModels(viewer: Viewer): string[] {
|
|
28
|
-
|
|
29
|
-
return handles;
|
|
26
|
+
export function getModels(viewer: Viewer): string[] {
|
|
27
|
+
return viewer.models.map((model) => model.userData?.handle || "").filter((handle) => handle);
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
commands("ThreeJS").registerCommand("getModels", getModels);
|
|
@@ -21,11 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function getSelected(viewer: Viewer): string[] {
|
|
26
|
+
export function getSelected(viewer: Viewer): string[] {
|
|
28
27
|
return viewer.selected.map((object) => object.userData?.handle).filter((handle) => handle);
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
commands("ThreeJS").registerCommand("getSelected", getSelected);
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
import { SelectionComponent } from "../components/SelectionComponent";
|
|
27
26
|
|
|
28
|
-
function hideSelected(viewer: Viewer): void {
|
|
27
|
+
export function hideSelected(viewer: Viewer): void {
|
|
29
28
|
viewer.selected.forEach((object) => (object.visible = false));
|
|
30
29
|
|
|
31
30
|
const selection = new SelectionComponent(viewer);
|
|
@@ -36,5 +35,3 @@ function hideSelected(viewer: Viewer): void {
|
|
|
36
35
|
viewer.emitEvent({ type: "hide" });
|
|
37
36
|
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
commands("ThreeJS").registerCommand("hideSelected", hideSelected);
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Object3D } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
|
-
function isolateSelected(viewer: Viewer): void {
|
|
27
|
+
export function isolateSelected(viewer: Viewer): void {
|
|
30
28
|
const selectedSet = new Set(viewer.selected);
|
|
31
29
|
|
|
32
30
|
function isolateObject(object: Object3D, depth: number): boolean {
|
|
@@ -46,5 +44,3 @@ function isolateSelected(viewer: Viewer): void {
|
|
|
46
44
|
viewer.update();
|
|
47
45
|
viewer.emitEvent({ type: "isolate" });
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
commands("ThreeJS").registerCommand("isolateSelected", isolateSelected);
|
|
@@ -21,12 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function regenerateAll(viewer: Viewer): void {
|
|
28
|
-
console.warn("regenerateAll not implemented");
|
|
26
|
+
export function regenerateAll(viewer: Viewer): void {
|
|
29
27
|
viewer.emit({ type: "regenerateall" });
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
commands("ThreeJS").registerCommand("regenerateAll", regenerateAll);
|
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function resetView(viewer: Viewer): void {
|
|
26
|
+
export function resetView(viewer: Viewer): void {
|
|
28
27
|
viewer.executeCommand("setActiveDragger");
|
|
29
28
|
viewer.executeCommand("clearSlices");
|
|
30
29
|
viewer.executeCommand("clearOverlay");
|
|
@@ -37,5 +36,3 @@ function resetView(viewer: Viewer): void {
|
|
|
37
36
|
|
|
38
37
|
viewer.emit({ type: "resetview" });
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
commands("ThreeJS").registerCommand("resetView", resetView);
|
|
@@ -21,12 +21,9 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function selectModel(viewer: Viewer, handle: string): void {
|
|
26
|
+
export function selectModel(viewer: Viewer, handle: string): void {
|
|
28
27
|
console.warn("selectModel not implemented");
|
|
29
28
|
viewer.emit({ type: "select", data: [] });
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
commands("ThreeJS").registerCommand("selectModel", selectModel);
|
|
@@ -21,9 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
export function setActiveDragger(viewer: Viewer, dragger = "") {
|
|
28
27
|
viewer.setActiveDragger(dragger);
|
|
29
|
-
}
|
|
28
|
+
}
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Sphere, Vector3 } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
27
|
export const defaultViewPositions = {
|
|
@@ -39,7 +37,7 @@ export const defaultViewPositions = {
|
|
|
39
37
|
nw: new Vector3(-0.5, 0.5, 1.0).normalize(),
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
function setDefaultViewPosition(viewer: Viewer, position: string): void {
|
|
40
|
+
export function setDefaultViewPosition(viewer: Viewer, position: string): void {
|
|
43
41
|
const direction = defaultViewPositions[position] || defaultViewPositions["sw"];
|
|
44
42
|
|
|
45
43
|
const center = viewer.extents.getCenter(new Vector3());
|
|
@@ -59,26 +57,3 @@ function setDefaultViewPosition(viewer: Viewer, position: string): void {
|
|
|
59
57
|
|
|
60
58
|
viewer.executeCommand("zoomToExtents");
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
commands("ThreeJS").registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
64
|
-
commands("ThreeJS").registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "top"));
|
|
65
|
-
commands("ThreeJS").registerCommand("bottom", (viewer) => setDefaultViewPosition(viewer, "bottom"));
|
|
66
|
-
commands("ThreeJS").registerCommand("left", (viewer) => setDefaultViewPosition(viewer, "left"));
|
|
67
|
-
commands("ThreeJS").registerCommand("right", (viewer) => setDefaultViewPosition(viewer, "right"));
|
|
68
|
-
commands("ThreeJS").registerCommand("front", (viewer) => setDefaultViewPosition(viewer, "front"));
|
|
69
|
-
commands("ThreeJS").registerCommand("back", (viewer) => setDefaultViewPosition(viewer, "back"));
|
|
70
|
-
commands("ThreeJS").registerCommand("sw", (viewer) => setDefaultViewPosition(viewer, "sw"));
|
|
71
|
-
commands("ThreeJS").registerCommand("se", (viewer) => setDefaultViewPosition(viewer, "se"));
|
|
72
|
-
commands("ThreeJS").registerCommand("ne", (viewer) => setDefaultViewPosition(viewer, "ne"));
|
|
73
|
-
commands("ThreeJS").registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"));
|
|
74
|
-
|
|
75
|
-
commands("ThreeJS").registerCommandAlias("top", "k3DViewTop");
|
|
76
|
-
commands("ThreeJS").registerCommandAlias("bottom", "k3DViewBottom");
|
|
77
|
-
commands("ThreeJS").registerCommandAlias("left", "k3DViewLeft");
|
|
78
|
-
commands("ThreeJS").registerCommandAlias("right", "k3DViewRight");
|
|
79
|
-
commands("ThreeJS").registerCommandAlias("front", "k3DViewFront");
|
|
80
|
-
commands("ThreeJS").registerCommandAlias("back", "k3DViewBack");
|
|
81
|
-
commands("ThreeJS").registerCommandAlias("se", "k3DViewSE");
|
|
82
|
-
commands("ThreeJS").registerCommandAlias("sw", "k3DViewSW");
|
|
83
|
-
commands("ThreeJS").registerCommandAlias("ne", "k3DViewNE");
|
|
84
|
-
commands("ThreeJS").registerCommandAlias("nw", "k3DViewNW");
|
|
@@ -21,10 +21,8 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
26
|
+
export function setMarkupColor(viewer: Viewer, r = 255, g = 0, b = 0) {
|
|
27
|
+
viewer.markup.setMarkupColor(r, g, b);
|
|
28
|
+
}
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
import { SelectionComponent } from "../components/SelectionComponent";
|
|
27
26
|
|
|
28
|
-
function setSelected(viewer: Viewer, handles: string[] = []): void {
|
|
27
|
+
export function setSelected(viewer: Viewer, handles: string[] = []): void {
|
|
29
28
|
const handleSet = new Set(handles);
|
|
30
29
|
const objects = [];
|
|
31
30
|
viewer.scene.traverseVisible((child) => {
|
|
@@ -40,5 +39,3 @@ function setSelected(viewer: Viewer, handles: string[] = []): void {
|
|
|
40
39
|
viewer.update();
|
|
41
40
|
viewer.emitEvent({ type: "select", data: undefined, handles });
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
commands("ThreeJS").registerCommand("setSelected", setSelected);
|
|
@@ -21,14 +21,11 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { commands } from "@inweb/viewer-core";
|
|
25
24
|
import type { Viewer } from "../Viewer";
|
|
26
25
|
|
|
27
|
-
function showAll(viewer: Viewer): void {
|
|
26
|
+
export function showAll(viewer: Viewer): void {
|
|
28
27
|
viewer.scene.traverse((object) => (object.visible = true));
|
|
29
28
|
|
|
30
29
|
viewer.update();
|
|
31
30
|
viewer.emitEvent({ type: "showall" });
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
commands("ThreeJS").registerCommand("showAll", showAll);
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Sphere, Vector3 } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
|
-
function zoomToExtents(viewer: Viewer): void {
|
|
27
|
+
export function zoomToExtents(viewer: Viewer): void {
|
|
30
28
|
if (viewer.extents.isEmpty()) return;
|
|
31
29
|
|
|
32
30
|
const center = viewer.extents.getCenter(new Vector3());
|
|
@@ -42,6 +40,3 @@ function zoomToExtents(viewer: Viewer): void {
|
|
|
42
40
|
viewer.update();
|
|
43
41
|
viewer.emitEvent({ type: "zoom" });
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
commands("ThreeJS").registerCommand("zoomToExtents", zoomToExtents);
|
|
47
|
-
commands("ThreeJS").registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Box3, Sphere, Vector3 } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
|
-
function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
|
|
27
|
+
export function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
|
|
30
28
|
const handleSet = new Set(handles);
|
|
31
29
|
const objects = [];
|
|
32
30
|
viewer.scene.traverseVisible((child) => {
|
|
@@ -47,5 +45,3 @@ function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
|
|
|
47
45
|
viewer.update();
|
|
48
46
|
viewer.emitEvent({ type: "zoom" });
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
commands("ThreeJS").registerCommand("zoomToObjects", zoomToObjects);
|
|
@@ -22,11 +22,9 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { Box3, Sphere, Vector3 } from "three";
|
|
25
|
-
|
|
26
|
-
import { commands } from "@inweb/viewer-core";
|
|
27
25
|
import type { Viewer } from "../Viewer";
|
|
28
26
|
|
|
29
|
-
function zoomToSelected(viewer: Viewer): void {
|
|
27
|
+
export function zoomToSelected(viewer: Viewer): void {
|
|
30
28
|
const extents = viewer.selected.reduce((result: Box3, object) => result.expandByObject(object), new Box3());
|
|
31
29
|
|
|
32
30
|
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
@@ -44,5 +42,3 @@ function zoomToSelected(viewer: Viewer): void {
|
|
|
44
42
|
viewer.update();
|
|
45
43
|
viewer.emitEvent({ type: "zoom" });
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
commands("ThreeJS").registerCommand("zoomToSelected", zoomToSelected);
|