Skip to content

Commit

Permalink
add snapshot quality
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings committed Oct 10, 2024
1 parent f7fe820 commit 1697aad
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/RenderWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class RenderWebGL extends EventEmitter {

this.dirty = true;

this.snapshotQuality = undefined;

Check failure on line 262 in src/RenderWebGL.js

View workflow job for this annotation

GitHub Actions / build

Unexpected use of undefined

/**
* Element that contains all overlays.
* @type {HTMLElement}
Expand Down Expand Up @@ -1049,12 +1051,14 @@ class RenderWebGL extends EventEmitter {
skipPrivateSkins: snapshotRequested
});
if (snapshotRequested) {
const snapshot = gl.canvas.toDataURL();
const quality = this.snapshotQuality;
const snapshot = gl.canvas.toDataURL(quality ? "image/jpeg" : "image/png", quality);
this._snapshotCallbacks.forEach(cb => cb(snapshot));
this._snapshotCallbacks = [];
// We need to make sure to always render next frame so that private skins
// that were skipped this frame will become visible again shortly.
this.dirty = true;
this.snapshotQuality = undefined;
}
}

Expand Down

0 comments on commit 1697aad

Please sign in to comment.