@inweb/viewer-visualize 27.1.2 → 27.1.4
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 +36 -20
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +1 -1
- package/dist/viewer-visualize.module.js +21 -6
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Commands/GetSnapshot.d.ts +2 -0
- package/lib/Viewer/Markup/Visualize/VisualizeMarkup.d.ts +1 -0
- package/lib/Viewer/Viewer.d.ts +1 -0
- package/package.json +5 -5
- package/src/Viewer/Commands/{CreatePreview.ts → GetSnapshot.ts} +9 -2
- package/src/Viewer/Commands/index.ts +3 -2
- package/src/Viewer/Markup/Visualize/VisualizeMarkup.ts +7 -2
- package/src/Viewer/Viewer.ts +6 -0
- package/lib/Viewer/Commands/CreatePreview.d.ts +0 -2
|
@@ -25,6 +25,7 @@ export declare class VisualizeMarkup implements IMarkup {
|
|
|
25
25
|
colorizeSelectedMarkups(r?: number, g?: number, b?: number): void;
|
|
26
26
|
setViewpoint(viewpoint: IViewpoint): void;
|
|
27
27
|
getViewpoint(viewpoint: IViewpoint): IViewpoint;
|
|
28
|
+
getSnapshot(type?: string, quality?: number): string;
|
|
28
29
|
enableEditMode(mode: MarkupMode | false): this;
|
|
29
30
|
createObject(type: string, params: any): IMarkupObject;
|
|
30
31
|
getObjects(): IMarkupObject[];
|
package/lib/Viewer/Viewer.d.ts
CHANGED
|
@@ -251,6 +251,7 @@ export declare class Viewer extends EventEmitter2<ViewerEventMap & CanvasEventMa
|
|
|
251
251
|
getComponent(name: string): IComponent;
|
|
252
252
|
drawViewpoint(viewpoint: IViewpoint): void;
|
|
253
253
|
createViewpoint(): IViewpoint;
|
|
254
|
+
getSnapshot(type?: string, quality?: number): string;
|
|
254
255
|
screenToWorld(position: {
|
|
255
256
|
x: number;
|
|
256
257
|
y: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/viewer-visualize",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.4",
|
|
4
4
|
"description": "JavaScript library for rendering CAD and BIM files in a browser using VisualizeJS",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"docs": "typedoc"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@inweb/client": "~27.1.
|
|
33
|
-
"@inweb/eventemitter2": "~27.1.
|
|
34
|
-
"@inweb/markup": "~27.1.
|
|
35
|
-
"@inweb/viewer-core": "~27.1.
|
|
32
|
+
"@inweb/client": "~27.1.4",
|
|
33
|
+
"@inweb/eventemitter2": "~27.1.4",
|
|
34
|
+
"@inweb/markup": "~27.1.4",
|
|
35
|
+
"@inweb/viewer-core": "~27.1.4"
|
|
36
36
|
},
|
|
37
37
|
"visualizeJS": "https://public-fhemb7e3embacwec.z02.azurefd.net/libs/visualizejs/master/Visualize.js"
|
|
38
38
|
}
|
|
@@ -23,8 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|
import { Viewer } from "../Viewer";
|
|
25
25
|
|
|
26
|
-
export function
|
|
26
|
+
export function getSnapshot(viewer: Viewer, type?: string, quality?: number): string {
|
|
27
27
|
if (!viewer.visualizeJs) return "";
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const mimeType = type ?? viewer.options.snapshotMimeType ?? "image/jpeg";
|
|
30
|
+
const imageQuality = quality ?? viewer.options.snapshotQuality ?? 0.25;
|
|
31
|
+
|
|
32
|
+
if (viewer.markup) {
|
|
33
|
+
return viewer.markup.getSnapshot(mimeType, imageQuality);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return viewer.canvas?.toDataURL(mimeType, imageQuality) || "";
|
|
30
37
|
}
|
|
@@ -27,7 +27,7 @@ import { applyModelTransform } from "./ApplyModelTransform";
|
|
|
27
27
|
import { clearMarkup } from "./ClearMarkup";
|
|
28
28
|
import { clearSelected } from "./ClearSelected";
|
|
29
29
|
import { clearSlices } from "./ClearSlices";
|
|
30
|
-
import {
|
|
30
|
+
import { getSnapshot } from "./GetSnapshot";
|
|
31
31
|
import { explode, collect } from "./Explode";
|
|
32
32
|
import { getDefaultViewPositions } from "./GetDefaultViewPositions";
|
|
33
33
|
import { getModels } from "./GetModels";
|
|
@@ -83,7 +83,7 @@ commands.registerCommand("applyModelTransform", applyModelTransform);
|
|
|
83
83
|
commands.registerCommand("clearMarkup", clearMarkup);
|
|
84
84
|
commands.registerCommand("clearSelected", clearSelected);
|
|
85
85
|
commands.registerCommand("clearSlices", clearSlices);
|
|
86
|
-
commands.registerCommand("
|
|
86
|
+
commands.registerCommand("getSnapshot", getSnapshot);
|
|
87
87
|
commands.registerCommand("explode", explode);
|
|
88
88
|
commands.registerCommand("collect", collect);
|
|
89
89
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
@@ -119,4 +119,5 @@ commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer,
|
|
|
119
119
|
|
|
120
120
|
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
121
121
|
commands.registerCommandAlias("clearSelected", "unselect");
|
|
122
|
+
commands.registerCommandAlias("getSnapshot", "createPreview");
|
|
122
123
|
commands.registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
@@ -164,7 +164,6 @@ export class VisualizeMarkup implements IMarkup {
|
|
|
164
164
|
return { x: array[0], y: array[1], z: array[2] };
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
const visLib = this._viewer.visLib();
|
|
168
167
|
const visViewer = this._viewer.visViewer();
|
|
169
168
|
|
|
170
169
|
if (!viewpoint) viewpoint = { custom_fields: {} };
|
|
@@ -219,12 +218,18 @@ export class VisualizeMarkup implements IMarkup {
|
|
|
219
218
|
}
|
|
220
219
|
itr.delete();
|
|
221
220
|
|
|
222
|
-
viewpoint.snapshot = { data: visLib.canvas.toDataURL("image/jpeg", 0.25) };
|
|
223
221
|
viewpoint.custom_fields.markup_color = this.getMarkupColor();
|
|
224
222
|
|
|
225
223
|
return viewpoint;
|
|
226
224
|
}
|
|
227
225
|
|
|
226
|
+
getSnapshot(type = "image/jpeg", quality = 0.25): string {
|
|
227
|
+
if (!this._viewer.visualizeJs) return "";
|
|
228
|
+
|
|
229
|
+
const visLib = this._viewer.visLib();
|
|
230
|
+
return visLib.canvas?.toDataURL(type, quality) || "";
|
|
231
|
+
}
|
|
232
|
+
|
|
228
233
|
enableEditMode(mode: MarkupMode | false): this {
|
|
229
234
|
return this;
|
|
230
235
|
}
|
package/src/Viewer/Viewer.ts
CHANGED
|
@@ -1195,6 +1195,8 @@ export class Viewer
|
|
|
1195
1195
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
1196
1196
|
viewpoint.selection = getSelection();
|
|
1197
1197
|
viewpoint.description = new Date().toDateString();
|
|
1198
|
+
viewpoint.snapshot = { data: this.getSnapshot() };
|
|
1199
|
+
|
|
1198
1200
|
this._markup.getViewpoint(viewpoint);
|
|
1199
1201
|
|
|
1200
1202
|
viewpoint.custom_fields.selection2 = getSelection2();
|
|
@@ -1204,6 +1206,10 @@ export class Viewer
|
|
|
1204
1206
|
return viewpoint;
|
|
1205
1207
|
}
|
|
1206
1208
|
|
|
1209
|
+
getSnapshot(type?: string, quality?: number): string {
|
|
1210
|
+
return this.executeCommand("getSnapshot", type, quality);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1207
1213
|
// IWorldTransform
|
|
1208
1214
|
|
|
1209
1215
|
screenToWorld(position: { x: number; y: number }): { x: number; y: number; z: number } {
|