var pickedFeature = viewer.scene.pick(movement.endPosition);
pickedFeature.color = Cesium.Color.YELLOW;
… the color changes correctly, but when zooming out and dropping to lower LOD-tileset tree level, color is not there anymore. I have confirmed that the batch-id of this feature is the same on each tree level. Is there any way to color accross lod levels?
The ability to color the same batchId across different tiles is not supported right now.
The manual approach would be to store a list of all tiles in the tree (by getting tileset._root and then recursively populating with each tile’s children array), and for each tile calling tile.content.getFeature(pickedFeature._batchId).color = Ceisum.Color.YELLOW. This approach accesses a bunch of private variables though so I wouldn’t recommend it as a long term solution.
I also just realized that in my tiles the batchId is -not- the same accross tiles. Instead it is this way:
“In the Binary glTF section, each vertex has an numeric batchId attribute in the integer range [0, number of models in the batch - 1].”
First of all I quess I would need a custom batchId. It seems to be a float-type parameter in shader code at least, so having an arbitrary id could be possible.
Right now the only option would be to map external id from batchTable to batchId and then somehow set the color using that… but it easily ends up in very costly traversal of every feature in every tile!
There actually was a problem with this approach still. Not all the tiles are in memory when color is applied. I was able to fix this problem by doing this for now:
var features = tile.content.getFeaturesById(coloredFeatureIds[i]);
if (defined(features))
for(var f in features)
applyColor(features[f]);
}
});
… but it seems to fire very often and performance might suffer with lots of colorings. I am looking for a way to fire event in “tile loaded” instead, but was not succesfull yet.
I tried this new event but it does not work. When tileVisible is fired, i quess the batchTable texture etc. are initialized more properly and we can actually get the feature’s properties. At the tileLoad event something still seems uninitialized for the coloring to work.
Hi! Would there be any ideas on this? The new event works as expected, but tile has in-complete state at the time of the event. Would there be some “update” etc. function that I could call for the loaded tile to execute initialization?
I replied to your personal message a few days ago, not sure if you received it.
I’m not sure why the tile state would be incomplete when the event is called since update needs to be called before the tile’s content becomes ready. The code below at least works for me. Do you have some example code that shows the problem you’re having?
The batch table should be updated by the time the promise is resolved, unless I’m missing something. The code below works for me in Sandcastle: