@inweb/viewer-visualize 25.6.7 → 25.7.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/LICENSE +2 -2
- package/dist/viewer-visualize.js +330 -295
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +164 -149
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +4 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +2 -3
- package/lib/Viewer/Markup/IMarkup.d.ts +28 -32
- package/lib/Viewer/Markup/IWorldTransform.d.ts +39 -0
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +11 -6
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +3 -0
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +4 -4
- package/lib/Viewer/Markup/MarkupFactory.d.ts +10 -10
- package/lib/Viewer/Viewer.d.ts +60 -42
- package/lib/index.d.ts +12 -0
- package/package.json +5 -5
- package/src/Viewer/Commands/ApplyModelTransform.ts +2 -2
- package/src/Viewer/Commands/ClearMarkup.ts +2 -2
- package/src/Viewer/Commands/ClearSlices.ts +2 -2
- package/src/Viewer/Commands/CreatePreview.ts +2 -2
- package/src/Viewer/Commands/Explode.ts +2 -2
- package/src/Viewer/Commands/GetDefaultViewPositions.ts +2 -2
- package/src/Viewer/Commands/GetModels.ts +2 -2
- package/src/Viewer/Commands/GetSelected.ts +2 -2
- package/src/Viewer/Commands/HideSelected.ts +2 -2
- package/src/Viewer/Commands/IsolateSelected.ts +2 -2
- package/src/Viewer/Commands/RegenerateAll.ts +2 -2
- package/src/Viewer/Commands/ResetView.ts +2 -2
- package/src/Viewer/Commands/SelectModel.ts +2 -2
- package/src/Viewer/Commands/SetActiveDragger.ts +2 -2
- package/src/Viewer/Commands/SetDefaultViewPosition.ts +2 -2
- package/src/Viewer/Commands/SetMarkupColor.ts +2 -2
- package/src/Viewer/Commands/SetSelected.ts +2 -2
- package/src/Viewer/Commands/ShowAll.ts +2 -2
- package/src/Viewer/Commands/Unselect.ts +2 -2
- package/src/Viewer/Commands/ZoomToExtents.ts +2 -2
- package/src/Viewer/Commands/ZoomToObjects.ts +2 -2
- package/src/Viewer/Commands/ZoomToSelected.ts +2 -2
- package/src/Viewer/Commands/index.ts +2 -2
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +2 -2
- package/src/Viewer/Draggers/Actions/PanAction.ts +2 -2
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +2 -2
- package/src/Viewer/Draggers/Common/Geometry.ts +2 -2
- package/src/Viewer/Draggers/Common/GestureManager.ts +2 -2
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +2 -2
- package/src/Viewer/Draggers/Common/OdaGeAction.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +2 -2
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +2 -2
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +2 -2
- package/src/Viewer/Draggers/OdOrbitDragger.ts +2 -2
- package/src/Viewer/Draggers/OdPanDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +2 -2
- package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +2 -2
- package/src/Viewer/Draggers/OdaLineDragger.ts +2 -2
- package/src/Viewer/Draggers/OdaTextDragger.ts +2 -2
- package/src/Viewer/Draggers/OdaWalkDragger.ts +2 -2
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +2 -2
- package/src/Viewer/Loaders/BaseLoader.ts +2 -2
- package/src/Viewer/Loaders/LoaderFactory.ts +2 -2
- package/src/Viewer/Loaders/TCSLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +2 -2
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +2 -2
- package/src/Viewer/Markup/Api/IMarkupLine.ts +5 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +4 -5
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +1 -1
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +1 -1
- package/src/Viewer/Markup/IMarkup.ts +34 -35
- package/src/Viewer/Markup/IWorldTransform.ts +46 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +85 -161
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +3 -0
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +45 -10
- package/src/Viewer/Markup/MarkupFactory.ts +16 -20
- package/src/Viewer/Viewer.ts +103 -95
- package/src/Viewer/utils.ts +2 -2
- package/src/index.ts +14 -2
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -25,18 +25,20 @@ import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
|
25
25
|
import { Assembly, Client, File, Model } from "@inweb/client";
|
|
26
26
|
import {
|
|
27
27
|
CANVAS_EVENTS,
|
|
28
|
+
CanvasEventMap,
|
|
28
29
|
commands,
|
|
30
|
+
Dragger,
|
|
29
31
|
IClippingPlane,
|
|
30
|
-
|
|
32
|
+
IDragger,
|
|
31
33
|
IOrthogonalCamera,
|
|
32
|
-
|
|
34
|
+
IOptions,
|
|
33
35
|
IViewer,
|
|
36
|
+
IViewpoint,
|
|
34
37
|
Options,
|
|
35
38
|
OptionsEventMap,
|
|
36
39
|
ViewerEventMap,
|
|
37
40
|
} from "@inweb/viewer-core";
|
|
38
41
|
|
|
39
|
-
import { OdBaseDragger } from "./Draggers/Common/OdBaseDragger";
|
|
40
42
|
import { MeasureLineDragger } from "./Draggers/MeasureLineDragger/index";
|
|
41
43
|
import { OdaWalkDragger } from "./Draggers/OdaWalkDragger";
|
|
42
44
|
import { OdCuttingPlaneXAxisDragger } from "./Draggers/OdCuttingPlaneXAxisDragger";
|
|
@@ -52,20 +54,22 @@ import { GestureManager } from "./Draggers/Common/GestureManager";
|
|
|
52
54
|
|
|
53
55
|
import { loadVisualizeJs } from "./utils";
|
|
54
56
|
import { LoaderFactory } from "./Loaders/LoaderFactory";
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
|
|
58
|
-
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
57
|
+
import { IMarkup } from "./Markup/IMarkup";
|
|
58
|
+
import { IWorldTransform } from "./Markup/IWorldTransform";
|
|
59
|
+
import { MarkupFactory, MarkupType } from "./Markup/MarkupFactory";
|
|
59
60
|
|
|
60
61
|
const isExist = (value) => value !== undefined && value !== null;
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* The `Client.js` library class that provides methods to integrate with the
|
|
64
|
-
*
|
|
65
|
+
* {@link https://cloud.opendesign.com/docs/index.html#/visualizejs | VisualizeJS} library.
|
|
65
66
|
*/
|
|
66
67
|
|
|
67
|
-
export class Viewer
|
|
68
|
-
|
|
68
|
+
export class Viewer
|
|
69
|
+
extends EventEmitter2<ViewerEventMap & CanvasEventMap & OptionsEventMap>
|
|
70
|
+
implements IViewer, IWorldTransform
|
|
71
|
+
{
|
|
72
|
+
private _activeDragger: IDragger | null;
|
|
69
73
|
private _zoomWheelDragger: OdZoomWheelDragger | null;
|
|
70
74
|
private _gestureManager: GestureManager | null;
|
|
71
75
|
private _enableAutoUpdate: boolean;
|
|
@@ -79,12 +83,12 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
79
83
|
|
|
80
84
|
private canvaseventlistener: (event: Event) => void;
|
|
81
85
|
|
|
82
|
-
public draggerFactory: Map<string, typeof
|
|
86
|
+
public draggerFactory: Map<string, typeof Dragger>;
|
|
83
87
|
public canvasEvents: string[];
|
|
84
88
|
private frameId = 0;
|
|
85
89
|
private _resizeObserver: ResizeObserver | undefined;
|
|
90
|
+
private _markup: IMarkup;
|
|
86
91
|
public canvas: HTMLCanvasElement | undefined;
|
|
87
|
-
public markup: IMarkup;
|
|
88
92
|
|
|
89
93
|
public _abortController: AbortController | undefined;
|
|
90
94
|
public _abortControllerForRequestMap: Map<string, AbortController> | undefined;
|
|
@@ -102,10 +106,10 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
102
106
|
* _Note: Your own `VisualizeJS` library version must match the version of the `Client.js`
|
|
103
107
|
* you are using._
|
|
104
108
|
* @param params.enableAutoUpdate - Enable auto-update of the viewer after any changes. If
|
|
105
|
-
* the auto-update is disabled, you need to
|
|
106
|
-
*
|
|
107
|
-
* @param params.markupType - Specifies
|
|
108
|
-
*
|
|
109
|
+
* the auto-update is disabled, you need to register the `update` event handler and update
|
|
110
|
+
* the viewer and the active dragger manually. Default is `true`.
|
|
111
|
+
* @param params.markupType - Specifies type of the markup core: `Visualize` (deprecated) or
|
|
112
|
+
* `Konva`. Default is `Konva`.
|
|
109
113
|
*/
|
|
110
114
|
constructor(
|
|
111
115
|
client?: Client,
|
|
@@ -123,9 +127,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
123
127
|
this._gestureManager = null;
|
|
124
128
|
this._renderTime = 0;
|
|
125
129
|
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
this.draggerFactory = new Map<string, typeof OdBaseDragger>();
|
|
130
|
+
this.draggerFactory = new Map<string, typeof Dragger>();
|
|
129
131
|
this.registerDragger("Pan", OdPanDragger);
|
|
130
132
|
this.registerDragger("Orbit", OdOrbitDragger);
|
|
131
133
|
this.registerDragger("Zoom", OdZoomDragger);
|
|
@@ -137,11 +139,6 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
137
139
|
this.registerDragger("CuttingPlaneZAxis", OdCuttingPlaneZAxisDragger);
|
|
138
140
|
this.registerDragger("Walk", OdaWalkDragger);
|
|
139
141
|
|
|
140
|
-
const markupDraggers = this.markup.getDraggers();
|
|
141
|
-
markupDraggers?.forEach((value, key) => {
|
|
142
|
-
this.registerDragger(key, value);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
142
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
146
143
|
this.canvaseventlistener = (event: Event) => this.emit(event);
|
|
147
144
|
|
|
@@ -151,17 +148,19 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
151
148
|
|
|
152
149
|
this.render = this.render.bind(this);
|
|
153
150
|
this.resize = this.resize.bind(this);
|
|
151
|
+
|
|
152
|
+
this._markup = MarkupFactory.createMarkup(params.markupType);
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
/**
|
|
157
|
-
*
|
|
156
|
+
* Viewer options.
|
|
158
157
|
*/
|
|
159
158
|
get options(): Options {
|
|
160
159
|
return this._options;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
/**
|
|
164
|
-
* `VisualizeJS` library URL. Use {@link
|
|
163
|
+
* `VisualizeJS` library URL. Use {@link configure | configure()} to change library URL.
|
|
165
164
|
*
|
|
166
165
|
* @readonly
|
|
167
166
|
*/
|
|
@@ -169,6 +168,15 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
169
168
|
return this._visualizeJsUrl;
|
|
170
169
|
}
|
|
171
170
|
|
|
171
|
+
/**
|
|
172
|
+
* 2D markup core.
|
|
173
|
+
*
|
|
174
|
+
* @readonly
|
|
175
|
+
*/
|
|
176
|
+
get markup(): IMarkup {
|
|
177
|
+
return this._markup;
|
|
178
|
+
}
|
|
179
|
+
|
|
172
180
|
/**
|
|
173
181
|
* Change the viewer configuration parameters.
|
|
174
182
|
*
|
|
@@ -181,26 +189,19 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
181
189
|
return this;
|
|
182
190
|
}
|
|
183
191
|
|
|
184
|
-
/**
|
|
185
|
-
* A [Viewer]{@link Viewer} event measuring progress of loading a `VisualizeJS` library.
|
|
186
|
-
*
|
|
187
|
-
* @property {string} type - `visualizeprogress`
|
|
188
|
-
* @property {number} loaded - A 64-bit unsigned integer value indicating the amount of work
|
|
189
|
-
* already performed by the underlying process. The ratio of work done can be calculated by
|
|
190
|
-
* dividing total by the value of this property.
|
|
191
|
-
* @property {number} total - A 64-bit unsigned integer representing the total amount of work
|
|
192
|
-
* that the underlying process is in the progress of performing.
|
|
193
|
-
* @event visualizeprogress
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
192
|
/**
|
|
197
193
|
* Load `VisualizeJS` module and initialize it with the specified canvas. Call
|
|
198
|
-
* {@link
|
|
194
|
+
* {@link dispose | dispose()} to release allocated resources.
|
|
199
195
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
196
|
+
* Fires:
|
|
197
|
+
*
|
|
198
|
+
* - {@link InitializeProgressEvent | initializeprogress}
|
|
199
|
+
*
|
|
200
|
+
* @param canvas -
|
|
201
|
+
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement}
|
|
202
|
+
* for `VisualizeJS`.
|
|
202
203
|
* @param onProgress - A callback function that handles events measuring progress of loading
|
|
203
|
-
* of the `VisualizeJS` library.
|
|
204
|
+
* of the `VisualizeJS` library.
|
|
204
205
|
*/
|
|
205
206
|
async initialize(canvas: HTMLCanvasElement, onProgress?: (event: ProgressEvent) => void): Promise<this> {
|
|
206
207
|
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
@@ -228,7 +229,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
228
229
|
this.canvas = canvas;
|
|
229
230
|
this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
|
|
230
231
|
|
|
231
|
-
this.
|
|
232
|
+
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
232
233
|
|
|
233
234
|
this._resizeObserver = new ResizeObserver(this.resize);
|
|
234
235
|
this._resizeObserver.observe(canvas.parentElement);
|
|
@@ -275,7 +276,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
275
276
|
if (this._resizeObserver) this._resizeObserver.disconnect();
|
|
276
277
|
this._resizeObserver = undefined;
|
|
277
278
|
|
|
278
|
-
this.
|
|
279
|
+
this._markup.dispose();
|
|
279
280
|
|
|
280
281
|
if (this.canvas) {
|
|
281
282
|
this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
@@ -626,29 +627,28 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
626
627
|
* @param name - Dragger name.
|
|
627
628
|
* @param dragger - Dragger class.
|
|
628
629
|
*/
|
|
629
|
-
public registerDragger(name: string, dragger: typeof
|
|
630
|
+
public registerDragger(name: string, dragger: typeof Dragger): void {
|
|
630
631
|
this.draggerFactory.set(name, dragger);
|
|
631
632
|
}
|
|
632
633
|
|
|
633
634
|
/**
|
|
634
635
|
* Returns active dragger instance or `null` if there is no active dragger.
|
|
635
636
|
*/
|
|
636
|
-
activeDragger():
|
|
637
|
+
activeDragger(): IDragger | null {
|
|
637
638
|
return this._activeDragger;
|
|
638
639
|
}
|
|
639
640
|
|
|
640
641
|
/**
|
|
641
|
-
* Set active dragger. `Viewer` must be
|
|
642
|
-
* dragger or exception is thrown.
|
|
642
|
+
* Set active dragger. `Viewer` must be initialized before enable dragger or exception is thrown.
|
|
643
643
|
*
|
|
644
644
|
* Fires:
|
|
645
645
|
*
|
|
646
646
|
* - {@link ChangeActiveDraggerEvent | changeactivedragger}
|
|
647
647
|
*
|
|
648
|
-
* @param name - Dragger name. Can be one of the {@link
|
|
648
|
+
* @param name - Dragger name. Can be one of the {@link draggers} list.
|
|
649
649
|
* @returns Returns active dragger instance or `null` if there is no dragger with the given name.
|
|
650
650
|
*/
|
|
651
|
-
setActiveDragger(name: string):
|
|
651
|
+
setActiveDragger(name: string): IDragger | null {
|
|
652
652
|
if (this._activeDragger?.name !== name) {
|
|
653
653
|
if (this._activeDragger) {
|
|
654
654
|
this._activeDragger.dispose();
|
|
@@ -703,43 +703,14 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
703
703
|
* Remove markup overlay.
|
|
704
704
|
*/
|
|
705
705
|
clearOverlay(): void {
|
|
706
|
-
this.
|
|
706
|
+
this._markup.clearOverlay();
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
/**
|
|
710
710
|
* Synchronize markup overlay.
|
|
711
711
|
*/
|
|
712
712
|
syncOverlay(): any {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const visViewer = this.visViewer();
|
|
716
|
-
const activeView = visViewer.activeView;
|
|
717
|
-
|
|
718
|
-
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
719
|
-
if (!overlayView) {
|
|
720
|
-
const overlayModel = visViewer.getMarkupModel();
|
|
721
|
-
const pDevice = visViewer.getActiveDevice();
|
|
722
|
-
|
|
723
|
-
overlayView = pDevice.createView(OVERLAY_VIEW_NAME, false);
|
|
724
|
-
overlayView.addModel(overlayModel);
|
|
725
|
-
|
|
726
|
-
activeView.addSibling(overlayView);
|
|
727
|
-
pDevice.addView(overlayView);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
overlayView.viewPosition = activeView.viewPosition;
|
|
731
|
-
overlayView.viewTarget = activeView.viewTarget;
|
|
732
|
-
overlayView.upVector = activeView.upVector;
|
|
733
|
-
overlayView.viewFieldWidth = activeView.viewFieldWidth;
|
|
734
|
-
overlayView.viewFieldHeight = activeView.viewFieldHeight;
|
|
735
|
-
|
|
736
|
-
const viewPort = overlayView.getViewport();
|
|
737
|
-
overlayView.setViewport(viewPort.lowerLeft, viewPort.upperRight);
|
|
738
|
-
overlayView.vportRect = activeView.vportRect;
|
|
739
|
-
|
|
740
|
-
this.update();
|
|
741
|
-
|
|
742
|
-
return overlayView;
|
|
713
|
+
return this._markup.syncOverlay();
|
|
743
714
|
}
|
|
744
715
|
|
|
745
716
|
/**
|
|
@@ -758,6 +729,46 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
758
729
|
//return visViewer.activeView.upVector[1] >= 0.95;
|
|
759
730
|
}
|
|
760
731
|
|
|
732
|
+
screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
|
|
733
|
+
return this.visViewer().screenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
worldToScreen(position: { x: number; y: number; z: number }): { x: number; y: number } {
|
|
737
|
+
if (!this.visualizeJs) return position;
|
|
738
|
+
|
|
739
|
+
const activeView = this.visViewer().activeView;
|
|
740
|
+
const worldMatrix = activeView.worldToDeviceMatrix;
|
|
741
|
+
const worldPoint = this.visLib().Point3d.createFromArray([position.x, position.y, position.z]);
|
|
742
|
+
|
|
743
|
+
const devicePoint = worldPoint.transformBy(worldMatrix);
|
|
744
|
+
const result = { x: devicePoint.x / window.devicePixelRatio, y: devicePoint.y / window.devicePixelRatio };
|
|
745
|
+
|
|
746
|
+
devicePoint.delete();
|
|
747
|
+
worldPoint.delete();
|
|
748
|
+
worldMatrix.delete();
|
|
749
|
+
activeView.delete();
|
|
750
|
+
|
|
751
|
+
return result;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
getScale(): { x: number; y: number; z: number } {
|
|
755
|
+
const result = { x: 1.0, y: 1.0, z: 1.0 };
|
|
756
|
+
|
|
757
|
+
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
758
|
+
const tolerance = 1.0e-6;
|
|
759
|
+
|
|
760
|
+
const x = projMatrix.get(1, 1);
|
|
761
|
+
if (x > tolerance || x < -tolerance) result.x = 1 / result.x;
|
|
762
|
+
|
|
763
|
+
const y = projMatrix.get(1, 1);
|
|
764
|
+
if (y > tolerance || y < -tolerance) result.y = 1 / result.y;
|
|
765
|
+
|
|
766
|
+
const z = projMatrix.get(2, 2);
|
|
767
|
+
if (z > tolerance || z < -tolerance) result.z = 1 / result.z;
|
|
768
|
+
|
|
769
|
+
return result;
|
|
770
|
+
}
|
|
771
|
+
|
|
761
772
|
/**
|
|
762
773
|
* Returns a list of original handles for the selected entities.
|
|
763
774
|
*/
|
|
@@ -784,7 +795,6 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
784
795
|
* Load model references into the viewer. References are images, fonts, or any other files to
|
|
785
796
|
* correct rendering of the model.
|
|
786
797
|
*
|
|
787
|
-
* @async
|
|
788
798
|
* @param model - Instance of model with references. If a `File` instance is specified
|
|
789
799
|
* instead of a model, the file references will be loaded.
|
|
790
800
|
*/
|
|
@@ -839,9 +849,8 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
839
849
|
/**
|
|
840
850
|
* Loads a model of a file or assembly into the viewer.
|
|
841
851
|
*
|
|
842
|
-
* This method requires a
|
|
843
|
-
*
|
|
844
|
-
* {@link Viewer#openVsfxFile | openVsfxFile()}.
|
|
852
|
+
* This method requires a {@link Client} instance to work. For standalone viewer instance use
|
|
853
|
+
* {@link openVsfFile | openVsfFile()} or {@link openVsfxFile | openVsfxFile()}.
|
|
845
854
|
*
|
|
846
855
|
* Fires:
|
|
847
856
|
*
|
|
@@ -853,7 +862,6 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
853
862
|
* - {@link GeometryEndEvent | geometryend}
|
|
854
863
|
* - {@link GeometryErrorEvent | geometryerror}
|
|
855
864
|
*
|
|
856
|
-
* @async
|
|
857
865
|
* @param file - File or Assembly or Model instance to load. If a `File` instance with
|
|
858
866
|
* multiple models is specified, the default model will be loaded. If there is no default
|
|
859
867
|
* model, first availiable model will be loaded.
|
|
@@ -987,7 +995,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
987
995
|
}
|
|
988
996
|
|
|
989
997
|
/**
|
|
990
|
-
* Cancels asynchronous model loading started by {@link
|
|
998
|
+
* Cancels asynchronous model loading started by {@link open | open()}.
|
|
991
999
|
*/
|
|
992
1000
|
cancel(): this {
|
|
993
1001
|
this._abortControllerForReferences?.abort();
|
|
@@ -1033,7 +1041,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
1033
1041
|
* @returns Color with `RGB` values.
|
|
1034
1042
|
*/
|
|
1035
1043
|
getMarkupColor(): { r: number; g: number; b: number } {
|
|
1036
|
-
return this.
|
|
1044
|
+
return this._markup.getMarkupColor();
|
|
1037
1045
|
}
|
|
1038
1046
|
|
|
1039
1047
|
/**
|
|
@@ -1044,7 +1052,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
1044
1052
|
* @param b - `Blue` part of color.
|
|
1045
1053
|
*/
|
|
1046
1054
|
setMarkupColor(r = 255, g = 0, b = 0): void {
|
|
1047
|
-
this.
|
|
1055
|
+
this._markup.setMarkupColor(r, g, b);
|
|
1048
1056
|
const color = { r, g, b };
|
|
1049
1057
|
this.emitEvent({ type: "changemarkupcolor", data: color });
|
|
1050
1058
|
}
|
|
@@ -1057,7 +1065,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
1057
1065
|
* @param b - `Blue` part of color.
|
|
1058
1066
|
*/
|
|
1059
1067
|
colorizeAllMarkup(r = 255, g = 0, b = 0): void {
|
|
1060
|
-
this.
|
|
1068
|
+
this._markup.colorizeAllMarkup(r, g, b);
|
|
1061
1069
|
}
|
|
1062
1070
|
|
|
1063
1071
|
/**
|
|
@@ -1068,7 +1076,7 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
1068
1076
|
* @param b - `Blue` part of color.
|
|
1069
1077
|
*/
|
|
1070
1078
|
colorizeSelectedMarkups(r = 255, g = 0, b = 0): void {
|
|
1071
|
-
this.
|
|
1079
|
+
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
1072
1080
|
}
|
|
1073
1081
|
|
|
1074
1082
|
/**
|
|
@@ -1096,22 +1104,22 @@ export class Viewer extends EventEmitter2<ViewerEventMap & OptionsEventMap> impl
|
|
|
1096
1104
|
|
|
1097
1105
|
/**
|
|
1098
1106
|
* Draw a viewpoint. To get a list of available model viewpoints, use the
|
|
1099
|
-
*
|
|
1107
|
+
* `Model.getViewpoints()` or `File.getViewpoints()` or `Assembly.getViewpoints()`.
|
|
1100
1108
|
*
|
|
1101
1109
|
* @param viewpoint - Viewpoint data.
|
|
1102
1110
|
*/
|
|
1103
1111
|
drawViewpoint(viewpoint: IViewpoint): void {
|
|
1104
1112
|
this.setOrthogonalCameraSettings(viewpoint.orthogonal_camera);
|
|
1105
1113
|
this.setClippingPlanes(viewpoint.clipping_planes);
|
|
1106
|
-
this.
|
|
1114
|
+
this._markup.setViewpoint(viewpoint);
|
|
1107
1115
|
}
|
|
1108
1116
|
|
|
1109
1117
|
/**
|
|
1110
1118
|
* Create a viewpoint. To add a viewpoint to the list of model viewpoints, use the
|
|
1111
|
-
*
|
|
1119
|
+
* `Model.saveViewpoint()` or `File.saveViewpoint()` or . `Assembly.saveViewpoint()`.
|
|
1112
1120
|
*/
|
|
1113
1121
|
createViewpoint(): IViewpoint {
|
|
1114
|
-
const vp = this.
|
|
1122
|
+
const vp = this._markup.getViewpoint();
|
|
1115
1123
|
vp.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
1116
1124
|
vp.clipping_planes = this.getClippingPlanes();
|
|
1117
1125
|
|
package/src/Viewer/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-
|
|
2
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3
3
|
// All rights reserved.
|
|
4
4
|
//
|
|
5
5
|
// This software and its documentation and related materials are owned by
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
//
|
|
15
15
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
16
|
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
18
18
|
// All rights reserved.
|
|
19
19
|
//
|
|
20
20
|
// By use of this software, its documentation or related materials, you
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-
|
|
2
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3
3
|
// All rights reserved.
|
|
4
4
|
//
|
|
5
5
|
// This software and its documentation and related materials are owned by
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
//
|
|
15
15
|
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
16
|
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
18
18
|
// All rights reserved.
|
|
19
19
|
//
|
|
20
20
|
// By use of this software, its documentation or related materials, you
|
|
@@ -26,3 +26,15 @@ import "./Viewer/Commands";
|
|
|
26
26
|
export * from "@inweb/viewer-core";
|
|
27
27
|
export { Viewer } from "./Viewer/Viewer";
|
|
28
28
|
export { OdBaseDragger } from "./Viewer/Draggers/Common/OdBaseDragger";
|
|
29
|
+
export { IMarkup } from "./Viewer/Markup/IMarkup";
|
|
30
|
+
export { IMarkupArrow } from "./Viewer/Markup/Api/IMarkupArrow";
|
|
31
|
+
export { IMarkupCloud } from "./Viewer/Markup/Api/IMarkupCloud";
|
|
32
|
+
export { IMarkupColorable } from "./Viewer/Markup/Api/IMarkupColorable";
|
|
33
|
+
export { IMarkupEllipse } from "./Viewer/Markup/Api/IMarkupEllipse";
|
|
34
|
+
export { IMarkupImage } from "./Viewer/Markup/Api/IMarkupImage";
|
|
35
|
+
export { IMarkupLine, MarkupLineType } from "./Viewer/Markup/Api/IMarkupLine";
|
|
36
|
+
export { IMarkupRectangle } from "./Viewer/Markup/Api/IMarkupRectangle";
|
|
37
|
+
export { IMarkupObject } from "./Viewer/Markup/Api/IMarkupObject";
|
|
38
|
+
export { IMarkupText } from "./Viewer/Markup/Api/IMarkupText";
|
|
39
|
+
export { IWorldTransform } from "./Viewer/Markup/IWorldTransform";
|
|
40
|
+
export { MarkupType } from "./Viewer/Markup/MarkupFactory";
|