Skip to content

Commit

Permalink
Merge pull request #1722 from xeokit/XCD-153-2nd-attempt-conpensate-o…
Browse files Browse the repository at this point in the history
…ffset-only-for-first-plugin

XCD-153 Reset snapshotCanvas transformation applied by html2canvas
  • Loading branch information
xeolabs authored Nov 5, 2024
2 parents 8bfb3a3 + 6ebdf62 commit 198d1be
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,19 +493,15 @@ class Viewer {

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
//only calculate the scale for first plugin
//for all others keep the scale 1 otherwise it will keep multiplying the scale with the base scale of canvas
//resulting in increase/decreased size for the the canvas that is being overlapped
const scale = i == 0 ? snapshotCanvas.width / containerElement.clientWidth : 1;
const off = math.vec2([ 0, 0 ]);
transformToNode(canvas, containerElement, off);
await html2canvas(containerElement, {
canvas: snapshotCanvas,
backgroundColor: null,
x: off[0],
y: off[1],
scale
scale: snapshotCanvas.width / containerElement.clientWidth
});
// Reverts translation and scaling applied to the snapshotCanvas's context
// by the html2canvas call (inside the ForeignObjectRenderer's constructor)
// (implemented to compensate XCD-153 issue)
snapshotCanvas.getContext("2d").resetTransform();
}
if (!params.includeGizmos) {
this.sendToPlugins("snapshotFinished");
Expand Down

0 comments on commit 198d1be

Please sign in to comment.