Hey there,
I'm trying to draw static polylines and i'm getting performance issues.
Started with entities, then moved to PolylineCollection with primitives,
then tried polylineGeometry and then combined instances with polylineGeometry.
The combining of instances realy improved the performance issues but i have a big problem that i need to remove and add polylines in interval, and after adding 1 primitive with the geometryInstances, it can't be change.
That means if you want to add/remove polylines u have to remove the primitive and add a new one with the new geometryInstances - that's a problem.
Here's the code - copy paste to the Cesium Sandcastle.
var viewer = new Cesium.Viewer('cesiumContainer');
var collection = new Cesium.PrimitiveCollection();
for (var lon = -180.0; lon < 180.0; lon += 5.0) {
for (var lat = -85.0; lat < 85.0; lat += 5.0) {
var instance = new Cesium.GeometryInstance({
geometry : new Cesium.PolylineGeometry({
positions : Cesium.Cartesian3.fromDegreesArray(calcCirclePos(lon, lat)),
width: 1.0,
vertexFormat : Cesium.PolylineColorAppearance.VERTEX_FORMAT
}),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromRandom({alpha : 0.5}))
}
});
collection.add(new Cesium.Primitive({
geometryInstances : instance,
appearance : new Cesium.PolylineColorAppearance({
translucent : false
})
}));
}
}
viewer.scene.primitives.add(collection);
function calcCirclePos(x, y) {
var positions = ;
for(var i = 0; i < 30; i++) {
var currX = x + 2 * Math.cos(2 * Math.PI * i / 30);
var currY = y + 2 * Math.sin(2 * Math.PI * i / 30);
positions.push(currX, currY);
}
positions.push(positions[0], positions[1]);
return positions;
}
So best performance i succeed to get is primitiveCollecion with polylineGeometry, but still its really bad performance, im getting 15FPS when im zoomed out.
I hope u have solution to my problem, the context that i need static polylines with abillity to add/remove with good performance.
Thank you.