cesium
cesium copied to clipboard
Supporting picking properties from property textures
Unlike Feature ID attributes and Feature ID textures, Feature Textures present a challenge for implementing picking because both the attribution and the metadata is on the GPU side, in the texture.
An initial, and admittedly flawed, approach to picking certain values from feature textures was accomplished by exploiting how the pickColor
is generated, with the rgba
channels populated from left-to-right, with each channel accounting for 32768 pickable objects. The feature ID texture values were sampled (by modifying the pickId
) and encoded in the unused (arbitrarily set to b
and a
) channels, and PickFramebuffer.js
was modified to extract those values.
A more stable approach would be to add a pickFeatureTexture()
function to Scene.js
:
- This function would first call
pick
, check if the object returned has the requested feature texture. - The primitive's
pickId
would be modified to sample the values from the feature texture. - The draw commands would be updated.
-
pick
would be called again, and values would be read from the channels specified by the feature texture - The
pickId
would be reset back toczm_pickColor
- The draw commands would be updated
CC: @lilleyse @ptrgags