Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer Picking #32

Open
kylebarron opened this issue Aug 16, 2020 · 4 comments
Open

Layer Picking #32

kylebarron opened this issue Aug 16, 2020 · 4 comments

Comments

@kylebarron
Copy link
Owner

Trying to pick from rendered layers gives color: null and picked: false.

@kylebarron
Copy link
Owner Author

Note that this is "fixed" by just setting pickable: true on the layer. However this still gives object: undefined in the picked result because deck.gl is focused on vector picking. So when you pick it gives you the tile, not a pixel within the tile.

So you'll probably need to dig into deck.gl's picking to figure out how to pick the pixel value itself.

@kylebarron
Copy link
Owner Author

Debug using drawPickingColors: https://github.com/visgl/deck.gl/blob/8ed7b8e535c7867724bd9ba9a0f35f89bfbb325d/modules/core/src/lib/deck.js#L89

When you call deck.pickObject, it delegates to this.deckPicker, which is defined in deck-picker.js. That calls DeckPicker.pickObject, which calls DeckPicker. _pickClosestObject.

It looks like then DeckPicker._drawAndSample is called

  // returns pickedColor or null if no pickable layers found.

which internally calls this.pickLayersPass.render. That's defined in pick-layers-pass.js.

At a low level, you should read the Luma picking dev docs and the luma picking module code.

@kylebarron
Copy link
Owner Author

If you don't supply the picking module in the layer, then "color" picking will be correct. I.e. it will pick the actual color rendered to the screen.

That said, the color attribute is always a Uint8ClampedArray unless pickZ is true, in which case it's a Float32Array then? The easiest way for pickZ to be true is to have unproject3D to be true

@kylebarron
Copy link
Owner Author

kylebarron commented Sep 17, 2020

Therefore, the best next try is to create a custom picking module that takes the same uniforms, and breaks out of computation at that point (hence stopping modification of color) if picking is active. Something like

if (picking_uActive) {
  return color;
}

top-level in main? And then would return e.g. the NDVI computed value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant