deck.gl
deck.gl copied to clipboard
[Doc] Pixel picking example for `BitmapLayer` uses a deprecated function from `@luma.gl`
Link
https://deck.gl/docs/api-reference/layers/bitmap-layer#pixel-picking
Description
The section for Pixel Picking in the BitmapLayer documentation suggests the following implementation:
new BitmapLayer({
image: './my-image.png',
bounds: [-122.45, 37.75, -122.43, 37.78],
pickable: true,
onClick: ({bitmap, layer}) => {
if (bitmap) {
const {device} = layer.context;
const pixelColor = device.readPixelsToArrayWebGL(layer.props.image, {
sourceX: bitmap.pixel[0],
sourceY: bitmap.pixel[1],
sourceWidth: 1,
sourceHeight: 1
});
console.log('Color at picked pixel:', pixelColor);
}
}
})
Meanwhile, readPixelsToArrayWebGL() is marked as deprecated in @luma.gl. Is this still the recommended way to implement pixel picking, or is there a newer approach?
I see some mention of using CommandEncoders, but can't really find any information on doing so.
Found this that basically says we can ignore until 9.2: https://github.com/visgl/deck.gl/discussions/5241#discussioncomment-10571445
readPixelsToArrayWebGL is marked deprecated because it won't work in WebGPU. It will become an issue in deck.gl 9.2 but you are best off ignoring that for now.