@inweb/viewer-three 27.1.3 → 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 {
@@ -35796,9 +35798,15 @@ void main() {
35796
35798
  viewer.clearSlices();
35797
35799
  }
35798
35800
 
35799
- function createPreview(viewer, type = "image/jpeg", quality = 0.25) {
35801
+ function getSnapshot(viewer, type, quality) {
35802
+ var _a, _b;
35800
35803
  viewer.update(true);
35801
- return viewer.canvas.toDataURL(type, quality);
35804
+ const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
35805
+ const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
35806
+ if (viewer.markup) {
35807
+ return viewer.markup.getSnapshot(mimeType, imageQuality);
35808
+ }
35809
+ return viewer.canvas.toDataURL(mimeType, imageQuality);
35802
35810
  }
35803
35811
 
35804
35812
  function explode(viewer, index = 0) {
@@ -36007,7 +36015,7 @@ void main() {
36007
36015
  commands.registerCommand("clearSelected", clearSelected);
36008
36016
  commands.registerCommand("clearSlices", clearSlices);
36009
36017
  commands.registerCommand("collect", collect);
36010
- commands.registerCommand("createPreview", createPreview);
36018
+ commands.registerCommand("getSnapshot", getSnapshot);
36011
36019
  commands.registerCommand("explode", explode);
36012
36020
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
36013
36021
  commands.registerCommand("getModels", getModels);
@@ -36039,6 +36047,7 @@ void main() {
36039
36047
  commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"));
36040
36048
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
36041
36049
  commands.registerCommandAlias("clearSelected", "unselect");
36050
+ commands.registerCommandAlias("getSnapshot", "createPreview");
36042
36051
  commands.registerCommandAlias("zoomToExtents", "zoomExtents");
36043
36052
  commands.registerCommandAlias("top", "k3DViewTop");
36044
36053
  commands.registerCommandAlias("bottom", "k3DViewBottom");
@@ -56591,10 +56600,22 @@ js: import "konva/skia-backend";
56591
56600
  viewpoint.ellipses = this.getMarkupEllipses();
56592
56601
  viewpoint.images = this.getMarkupImages();
56593
56602
  viewpoint.rectangles = this.getMarkupRectangles();
56594
- viewpoint.snapshot = { data: this.combineMarkupWithDrawing() };
56595
56603
  viewpoint.custom_fields.markup_color = this.getMarkupColor();
56596
56604
  return viewpoint;
56597
56605
  }
56606
+ getSnapshot(type = "image/jpeg", quality = 0.25) {
56607
+ this.clearSelected();
56608
+ const tempCanvas = document.createElement("canvas");
56609
+ if (this._konvaStage) {
56610
+ tempCanvas.width = this._konvaStage.width();
56611
+ tempCanvas.height = this._konvaStage.height();
56612
+ const ctx = tempCanvas.getContext("2d");
56613
+ if (this._container instanceof HTMLCanvasElement)
56614
+ ctx.drawImage(this._container, 0, 0);
56615
+ ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
56616
+ }
56617
+ return tempCanvas.toDataURL(type, quality);
56618
+ }
56598
56619
  enableEditMode(mode) {
56599
56620
  if (!mode || !MarkupMode2Konva[mode]) {
56600
56621
  this.clearSelected();
@@ -57031,19 +57052,6 @@ js: import "konva/skia-backend";
57031
57052
  });
57032
57053
  return clouds;
57033
57054
  }
57034
- combineMarkupWithDrawing() {
57035
- this.clearSelected();
57036
- const tempCanvas = document.createElement("canvas");
57037
- if (this._konvaStage) {
57038
- tempCanvas.width = this._konvaStage.width();
57039
- tempCanvas.height = this._konvaStage.height();
57040
- const ctx = tempCanvas.getContext("2d");
57041
- if (this._container instanceof HTMLCanvasElement)
57042
- ctx.drawImage(this._container, 0, 0);
57043
- ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
57044
- }
57045
- return tempCanvas.toDataURL("image/jpeg", 0.25);
57046
- }
57047
57055
  addLine(linePoints, color, type, width, id) {
57048
57056
  if (!linePoints || linePoints.length === 0)
57049
57057
  return;
@@ -57765,12 +57773,16 @@ js: import "konva/skia-backend";
57765
57773
  viewpoint.clipping_planes = getClippingPlanes();
57766
57774
  viewpoint.selection = getSelection();
57767
57775
  viewpoint.description = new Date().toDateString();
57776
+ viewpoint.snapshot = { data: this.getSnapshot() };
57768
57777
  this._markup.getViewpoint(viewpoint);
57769
57778
  viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
57770
57779
  viewpoint.custom_fields.selection2 = getSelection2();
57771
57780
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
57772
57781
  return viewpoint;
57773
57782
  }
57783
+ getSnapshot(type, quality) {
57784
+ return this.executeCommand("getSnapshot", type, quality);
57785
+ }
57774
57786
  screenToWorld(position) {
57775
57787
  if (!this.renderer)
57776
57788
  return { x: position.x, y: position.y, z: 0 };