From 22eae26007fe95ac3f09fde6158802e1e3233c11 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 31 Oct 2022 22:17:27 +0000 Subject: [PATCH] `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 --- src/renderer/webgl/WebGLRenderer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 96e21eeb0..a0eb4d14a 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -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);