@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.
@@ -2396,11 +2396,16 @@ function clearSlices(viewer) {
2396
2396
  viewer.clearSlices();
2397
2397
  }
2398
2398
 
2399
- function createPreview(viewer, type = "image/jpeg", encoderOptions = 0.25) {
2400
- var _a;
2399
+ function getSnapshot(viewer, type, quality) {
2400
+ var _a, _b, _c;
2401
2401
  if (!viewer.visualizeJs)
2402
2402
  return "";
2403
- return ((_a = viewer.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, encoderOptions)) || "";
2403
+ const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
2404
+ const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
2405
+ if (viewer.markup) {
2406
+ return viewer.markup.getSnapshot(mimeType, imageQuality);
2407
+ }
2408
+ return ((_c = viewer.canvas) === null || _c === void 0 ? void 0 : _c.toDataURL(mimeType, imageQuality)) || "";
2404
2409
  }
2405
2410
 
2406
2411
  function explode(viewer, index = 0) {
@@ -2705,7 +2710,7 @@ commands.registerCommand("applyModelTransform", applyModelTransform);
2705
2710
  commands.registerCommand("clearMarkup", clearMarkup);
2706
2711
  commands.registerCommand("clearSelected", clearSelected);
2707
2712
  commands.registerCommand("clearSlices", clearSlices);
2708
- commands.registerCommand("createPreview", createPreview);
2713
+ commands.registerCommand("getSnapshot", getSnapshot);
2709
2714
  commands.registerCommand("explode", explode);
2710
2715
  commands.registerCommand("collect", collect);
2711
2716
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
@@ -2739,6 +2744,7 @@ commands.registerCommand("k3DViewNE", (viewer) => setDefaultViewPosition(viewer,
2739
2744
  commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
2740
2745
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
2741
2746
  commands.registerCommandAlias("clearSelected", "unselect");
2747
+ commands.registerCommandAlias("getSnapshot", "createPreview");
2742
2748
  commands.registerCommandAlias("zoomToExtents", "zoomExtents");
2743
2749
 
2744
2750
  class CameraComponent {
@@ -3916,7 +3922,6 @@ class VisualizeMarkup {
3916
3922
  function getLogicalPoint3dFromArray(array) {
3917
3923
  return { x: array[0], y: array[1], z: array[2] };
3918
3924
  }
3919
- const visLib = this._viewer.visLib();
3920
3925
  const visViewer = this._viewer.visViewer();
3921
3926
  if (!viewpoint)
3922
3927
  viewpoint = { custom_fields: {} };
@@ -3961,10 +3966,16 @@ class VisualizeMarkup {
3961
3966
  entityPtr.delete();
3962
3967
  }
3963
3968
  itr.delete();
3964
- viewpoint.snapshot = { data: visLib.canvas.toDataURL("image/jpeg", 0.25) };
3965
3969
  viewpoint.custom_fields.markup_color = this.getMarkupColor();
3966
3970
  return viewpoint;
3967
3971
  }
3972
+ getSnapshot(type = "image/jpeg", quality = 0.25) {
3973
+ var _a;
3974
+ if (!this._viewer.visualizeJs)
3975
+ return "";
3976
+ const visLib = this._viewer.visLib();
3977
+ return ((_a = visLib.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, quality)) || "";
3978
+ }
3968
3979
  enableEditMode(mode) {
3969
3980
  return this;
3970
3981
  }
@@ -4681,11 +4692,15 @@ class Viewer extends EventEmitter2 {
4681
4692
  viewpoint.clipping_planes = getClippingPlanes();
4682
4693
  viewpoint.selection = getSelection();
4683
4694
  viewpoint.description = new Date().toDateString();
4695
+ viewpoint.snapshot = { data: this.getSnapshot() };
4684
4696
  this._markup.getViewpoint(viewpoint);
4685
4697
  viewpoint.custom_fields.selection2 = getSelection2();
4686
4698
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
4687
4699
  return viewpoint;
4688
4700
  }
4701
+ getSnapshot(type, quality) {
4702
+ return this.executeCommand("getSnapshot", type, quality);
4703
+ }
4689
4704
  screenToWorld(position) {
4690
4705
  if (!this.visualizeJs)
4691
4706
  return { x: position.x, y: position.y, z: 0 };