WebRenderer.snapshotFramebuffer and by extension, the snapshot methods in Dynamic Textures and Render Textures, has been updated to ensure that the width and height never exceed the framebuffer dimensions, or it'll cause a runtime error. The method snapshotArea has had this limitation removed as a result, allowing you to snapshot areas that are larger than the Canvas. Fix #5707

This commit is contained in:
Richard Davey 2022-10-31 22:17:27 +00:00
parent 49cad2a837
commit 22eae26007

View file

@ -2490,8 +2490,8 @@ var WebGLRenderer = new Class({
state.getPixel = false;
state.x = x;
state.y = y;
state.width = Math.min(width, this.gl.drawingBufferWidth);
state.height = Math.min(height, this.gl.drawingBufferHeight);
state.width = width;
state.height = height;
return this;
},
@ -2561,6 +2561,12 @@ var WebGLRenderer = new Class({
if (width === undefined) { width = bufferWidth; }
if (height === undefined) { height = bufferHeight; }
if (type === 'pixel')
{
getPixel = true;
type = 'image/png';
}
var currentFramebuffer = this.currentFramebuffer;
this.snapshotArea(x, y, width, height, callback, type, encoderOptions);
@ -2573,6 +2579,10 @@ var WebGLRenderer = new Class({
state.bufferWidth = bufferWidth;
state.bufferHeight = bufferHeight;
// Ensure they're not trying to grab an area larger than the framebuffer
state.width = Math.min(state.width, bufferWidth);
state.height = Math.min(state.height, bufferHeight);
this.setFramebuffer(framebuffer);
WebGLSnapshot(this.gl, state);