deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Doc] Pixel picking example for `BitmapLayer` uses a deprecated function from `@luma.gl`

Open mz8i opened this issue 8 months ago • 2 comments

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?

mz8i avatar Mar 04 '25 20:03 mz8i

I see some mention of using CommandEncoders, but can't really find any information on doing so.

mohadib avatar Jun 14 '25 15:06 mohadib

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.

mohadib avatar Jun 14 '25 16:06 mohadib