Reputation: 2211
I have a few entities, who's positions are being set using a CallbackProperty function.
cesium.renderPolygon = function(mapContext, polygon, existingEntity) {
var p;
if (existingEntity) {
p = existingEntity;
} else {
var polOpts = getStyleOptions(polygon.style);
// function for getting location
polygon.getHierarachy = new Cesium.CallbackProperty(function(time, result) {
var hierarchy = [];
for (var i = 0; i < polygon.coordinates.length; i++) {
var coordinate = polygon.coordinates[i];
hierarchy.push(Cesium.Cartesian3.fromDegrees(coordinate.longitude, coordinate.latitude, coordinate.altitude));
}
return hierarchy;
}, false);
polOpts.hierarchy = polygon.getHierarachy;
p = mapContext.entities.add({
name: polygon.name,
polygon: polOpts
});
}
return p;
};
If I add a single entity, it seems to work great. As I add more there is a delay (1-3 seconds) and then all entities do not update nicely. It looks really bad.
Is there a way to limit the number of times this updates the entities. I have been reading the Cesium documentation, but cannot find anything on this.
Or is there a better way to dynamically and consistently update entities?
Upvotes: 3
Views: 5506
Reputation: 647
The Cesium guide claims that the Entity API is able to provide flexible, high-performance visualization while exposing a consistent, easy to learn, and easy to use interface. I have the experience to tell you that updating from outside of cesium works faster. You can also utilize the EntitiCollection (https://cesiumjs.org/Cesium/Build/Documentation/EntityCollection.html?classFilter=EntityCol) to getByID, suspendEvents and removeEvents to orchestrate cesium to update only when you are ready. We were able to update 1000 entities every 200ms that way without hurting performance at all. We figured out that if you want better results (like 10k entities every 200ms) you will need to implement your own shader.
Upvotes: 1