I am trying to determine the best way to compute collisions in Cesium. As far as I can tell, only Camera collision detection is built in. I need to determine when two entities are colliding (seems easy), when an particle system is colliding with an entity (seems okay) and when a particle system is colliding with a terrain (no idea).
One basic thing that I can't figure out is how to alter the material on a chunk of terrain. Assuming I have a simple radial particle system, what is the best way to determine which terrain chunks it intersects and how do I then swap the material on that chunk of terrain?
Right now my particle system is being drawn as a custom primitive but I would be open to using any part of the API to get this working.
Thanks muchly,
Nick
function selectTile(cartesian) { var selectedTile;
if (Cesium.defined(cartesian)) { var cartographic = ellipsoid.cartesianToCartographic(cartesian); var tilesRendered = globe._surface.tileProvider._tilesToRenderByTextureCount; for (var textureCount = 0; !selectedTile && textureCount < tilesRendered.length; ++textureCount) { var tilesRenderedByTextureCount = tilesRendered[textureCount]; if (!Cesium.defined(tilesRenderedByTextureCount)) { continue; }
for (var tileIndex = 0; !selectedTile && tileIndex < tilesRenderedByTextureCount.length; ++tileIndex) { var tile = tilesRenderedByTextureCount[tileIndex]; if (Cesium.Rectangle.contains(tile.rectangle, cartographic)) { selectedTile = tile; } } } }
return selectedTile;}