@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.
@@ -251,6 +251,8 @@
251
251
  rulerUnit: "Default",
252
252
  rulerPrecision: 2,
253
253
  cameraMode: "perspective",
254
+ snapshotMimeType: "image/jpeg",
255
+ snapshotQuality: 0.25,
254
256
  };
255
257
  }
256
258
  class Options {
@@ -2956,11 +2958,16 @@
2956
2958
  viewer.clearSlices();
2957
2959
  }
2958
2960
 
2959
- function createPreview(viewer, type = "image/jpeg", encoderOptions = 0.25) {
2960
- var _a;
2961
+ function getSnapshot(viewer, type, quality) {
2962
+ var _a, _b, _c;
2961
2963
  if (!viewer.visualizeJs)
2962
2964
  return "";
2963
- return ((_a = viewer.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, encoderOptions)) || "";
2965
+ const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
2966
+ const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
2967
+ if (viewer.markup) {
2968
+ return viewer.markup.getSnapshot(mimeType, imageQuality);
2969
+ }
2970
+ return ((_c = viewer.canvas) === null || _c === void 0 ? void 0 : _c.toDataURL(mimeType, imageQuality)) || "";
2964
2971
  }
2965
2972
 
2966
2973
  function explode(viewer, index = 0) {
@@ -3265,7 +3272,7 @@
3265
3272
  commands.registerCommand("clearMarkup", clearMarkup);
3266
3273
  commands.registerCommand("clearSelected", clearSelected);
3267
3274
  commands.registerCommand("clearSlices", clearSlices);
3268
- commands.registerCommand("createPreview", createPreview);
3275
+ commands.registerCommand("getSnapshot", getSnapshot);
3269
3276
  commands.registerCommand("explode", explode);
3270
3277
  commands.registerCommand("collect", collect);
3271
3278
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
@@ -3299,6 +3306,7 @@
3299
3306
  commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
3300
3307
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
3301
3308
  commands.registerCommandAlias("clearSelected", "unselect");
3309
+ commands.registerCommandAlias("getSnapshot", "createPreview");
3302
3310
  commands.registerCommandAlias("zoomToExtents", "zoomExtents");
3303
3311
 
3304
3312
  class CameraComponent {
@@ -17128,10 +17136,22 @@ js: import "konva/skia-backend";
17128
17136
  viewpoint.ellipses = this.getMarkupEllipses();
17129
17137
  viewpoint.images = this.getMarkupImages();
17130
17138
  viewpoint.rectangles = this.getMarkupRectangles();
17131
- viewpoint.snapshot = { data: this.combineMarkupWithDrawing() };
17132
17139
  viewpoint.custom_fields.markup_color = this.getMarkupColor();
17133
17140
  return viewpoint;
17134
17141
  }
17142
+ getSnapshot(type = "image/jpeg", quality = 0.25) {
17143
+ this.clearSelected();
17144
+ const tempCanvas = document.createElement("canvas");
17145
+ if (this._konvaStage) {
17146
+ tempCanvas.width = this._konvaStage.width();
17147
+ tempCanvas.height = this._konvaStage.height();
17148
+ const ctx = tempCanvas.getContext("2d");
17149
+ if (this._container instanceof HTMLCanvasElement)
17150
+ ctx.drawImage(this._container, 0, 0);
17151
+ ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
17152
+ }
17153
+ return tempCanvas.toDataURL(type, quality);
17154
+ }
17135
17155
  enableEditMode(mode) {
17136
17156
  if (!mode || !MarkupMode2Konva[mode]) {
17137
17157
  this.clearSelected();
@@ -17568,19 +17588,6 @@ js: import "konva/skia-backend";
17568
17588
  });
17569
17589
  return clouds;
17570
17590
  }
17571
- combineMarkupWithDrawing() {
17572
- this.clearSelected();
17573
- const tempCanvas = document.createElement("canvas");
17574
- if (this._konvaStage) {
17575
- tempCanvas.width = this._konvaStage.width();
17576
- tempCanvas.height = this._konvaStage.height();
17577
- const ctx = tempCanvas.getContext("2d");
17578
- if (this._container instanceof HTMLCanvasElement)
17579
- ctx.drawImage(this._container, 0, 0);
17580
- ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
17581
- }
17582
- return tempCanvas.toDataURL("image/jpeg", 0.25);
17583
- }
17584
17591
  addLine(linePoints, color, type, width, id) {
17585
17592
  if (!linePoints || linePoints.length === 0)
17586
17593
  return;
@@ -18008,7 +18015,6 @@ js: import "konva/skia-backend";
18008
18015
  function getLogicalPoint3dFromArray(array) {
18009
18016
  return { x: array[0], y: array[1], z: array[2] };
18010
18017
  }
18011
- const visLib = this._viewer.visLib();
18012
18018
  const visViewer = this._viewer.visViewer();
18013
18019
  if (!viewpoint)
18014
18020
  viewpoint = { custom_fields: {} };
@@ -18053,10 +18059,16 @@ js: import "konva/skia-backend";
18053
18059
  entityPtr.delete();
18054
18060
  }
18055
18061
  itr.delete();
18056
- viewpoint.snapshot = { data: visLib.canvas.toDataURL("image/jpeg", 0.25) };
18057
18062
  viewpoint.custom_fields.markup_color = this.getMarkupColor();
18058
18063
  return viewpoint;
18059
18064
  }
18065
+ getSnapshot(type = "image/jpeg", quality = 0.25) {
18066
+ var _a;
18067
+ if (!this._viewer.visualizeJs)
18068
+ return "";
18069
+ const visLib = this._viewer.visLib();
18070
+ return ((_a = visLib.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, quality)) || "";
18071
+ }
18060
18072
  enableEditMode(mode) {
18061
18073
  return this;
18062
18074
  }
@@ -18773,11 +18785,15 @@ js: import "konva/skia-backend";
18773
18785
  viewpoint.clipping_planes = getClippingPlanes();
18774
18786
  viewpoint.selection = getSelection();
18775
18787
  viewpoint.description = new Date().toDateString();
18788
+ viewpoint.snapshot = { data: this.getSnapshot() };
18776
18789
  this._markup.getViewpoint(viewpoint);
18777
18790
  viewpoint.custom_fields.selection2 = getSelection2();
18778
18791
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
18779
18792
  return viewpoint;
18780
18793
  }
18794
+ getSnapshot(type, quality) {
18795
+ return this.executeCommand("getSnapshot", type, quality);
18796
+ }
18781
18797
  screenToWorld(position) {
18782
18798
  if (!this.visualizeJs)
18783
18799
  return { x: position.x, y: position.y, z: 0 };