|
@@ -3762,7 +3762,13 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {
|
|
|
|
|
|
- _gl.readPixels( x, y, width, height, paramThreeToGL( texture.format ), paramThreeToGL( texture.type ), buffer );
|
|
|
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
|
|
|
+
|
|
|
+ if ( ( x > 0 && x <= ( renderTarget.width - width ) ) && ( y > 0 && y <= ( renderTarget.height - height ) ) ) {
|
|
|
+
|
|
|
+ _gl.readPixels( x, y, width, height, paramThreeToGL( texture.format ), paramThreeToGL( texture.type ), buffer );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|