Too much polygons causes lags?

Hello Cesium,

Currently I’m drawing 5000 polygons onto the globe and noticed that it is causing my cesium project to lag a lot. Is there a way to handle this better? Each one of these polygons are being added like this:

scene.primitives.add(new Cesium.Polygon({

});

and each are stored onto a global array (to keep track of all of them). Am I doing this wrong? Thanks!

Katone

Cesium can handle way more polygons than that (up to whatever the underlying video card can handle). The Polygon object is an old class that will eventually go away, try switching your code to use the newer Entity API, which will provide automatic batching and other optimizations to make everything much faster. Here’s a tutorial that should tell you what you need to know: http://cesiumjs.org/2015/02/02/Visualizing-Spatial-Data/

Lol thanks Matthew. Yes, I’ve checked on previous old post of mine and you mentioned this before. I apologize for not checking it before posting this. Again, thank you. =)

Matthew. I have just performed the changes and WOW! The differences in performance is crazy. Thank you for the advice. =)

Katone

Matthew, I must ask you this as well.

You say to use the newer Entity API, which will provide automatic batching and other optimization. Would this include using Entities for Billboards? I am currently using Billboards instead of the Entity (BillboardGraphic). Is it wise to swap this out too? Because from what I’m getting from the message, Entity is the ideal way.

Thanks!

Ultimately yes, but if you are happy with your current code, you probably won’t see as much as a speed up as you did with polygons. The one caveat would be if you have a large amount of static billboards ( > 10000), then I would wait a release or two, since that’s one situation that Entity billboards still need to be optimized. Of course if you switch now, you’ll get those optimizations “for free” as soon as they are ready without any code changes on your end.

There’s also other reasons to use entities as well (camera helpers, infobox, easily aggregates visualization into a single object, etc…). For anyone writing new code, I would recommend using the Entity API as much as possible and only fall back to primitives if there’s something you can’t do with entities (and then tell us about it so we can add it to the Entity API as well)

Matthew,

Can the same be said about Entity -> Polylines? I’ve done it with polygon 13,000 and its performance is magnificent. But doing it with polylines, it froze on me. Lol. So is this on the next release? Or perhaps it’s already here but I’m doing something wrong?

Thanks Matthew!

Polylines should be just as fast as polygons, can you post a Sandcastle example that is slow for you?

Sandcastle doesn’t freeze up, but mine does so it’s on my end. Thanks! =) I’m just making sure Polyline is already optimized! So the problem is on my end.