Webgl / return 0 if doing renderTarget.read outside of data width/height
This would happen when WebGLPointsLayerRenderer.forEachFeatureAtCoordinate is called on "warped" worlds at -360/+360 degrees, and may produce false positives.
This commit is contained in:
@@ -115,12 +115,18 @@ class WebGLRenderTarget {
|
||||
/**
|
||||
* Reads one pixel of the frame buffer as an array of r, g, b, a components
|
||||
* in the 0-255 range (unsigned byte).
|
||||
* If x and/or y are outside of existing data, an array filled with 0 is returned.
|
||||
* @param {number} x Pixel coordinate
|
||||
* @param {number} y Pixel coordinate
|
||||
* @returns {Uint8Array} Integer array with one color value (4 components)
|
||||
* @api
|
||||
*/
|
||||
readPixel(x, y) {
|
||||
if (x < 0 || y < 0 || x > this.size_[0] || y >= this.size_[1]) {
|
||||
tmpArray4[0] = tmpArray4[1] = tmpArray4[2] = tmpArray4[3] = 0;
|
||||
return tmpArray4;
|
||||
}
|
||||
|
||||
this.readAll();
|
||||
const index = Math.floor(x) + (this.size_[1] - Math.floor(y) - 1) * this.size_[0];
|
||||
tmpArray4[0] = this.data_[index * 4];
|
||||
|
||||
Reference in New Issue
Block a user