Primitive vs Entity vs DataSource Performance?

I have a polylinecollection, each representing a different entity that I can add to primitives.
Alternatively, I can create a separate entity for each of the polylines.

Alternatively, I can have a GeoJsonData source that I add that contains a polyline?

Which one will give me better performance if I want to draw a high volume of polylines? Is it the polylinecollection, the entity, or the geojson data source? Or do they all perform about the same?

If you already have GeoJsonData, loading that is the way to go. It will create Entities that you can further modify or customize if you like. Since it just creates entities, GeoJSON and the Entity API will have the exact same performance with the same data. If you don’t have GeoJSON data already, then entities are the way to go.

99 times out of 100, there is no reason to use PolylineCollection directly anymore. It has a very specific use case (time-dynamic lines) and will be used under the hood by the Entity system for that specific use case. You definitely wouldn’t want to use it for static data (because that’s what PoylineGeometry is for.)

The general rules are:

  1. Do you have data in a standard format Cesium supports? Use the corresponding DataSource.

  2. Loading custom data? Use Entity API.

  3. Doing something very custom that isn’t supported by the Entity API? Use primitives (and tell us about it so we can improve the Entity API)

I recommend you check out the Visualizing Spatial Data tutorial: which will help get you up in running with the Entity API.

Hi Matthew,

I came across this board and it’s inline with what I am trying to do, which is, to investigate which performs better, Entity or Primitive. Basically, I am optimizing my page that loads thousands of Entities (5 thousands - 7 thousands) where each entity contains a PointGraphics and ModelGraphics and these 2 are toggled depending on the Camera’s height relative to the surface of the earth. I am currently using the Entity API system (latest version of Cesium) and surprisingly Cesium can take it. I am wondering if using the primitive (model), would it give me better performance? I am guessing NO, because in theory Primitive (model) has overhead since it’s lower level compared to the Entity counterpart.

What do you think?

Also, it would be nice if Cesium supports sharing the Geometry info/data of a certain Model across entities. Meaning, if I have 1000 entities pointing to just 1 instance of a ModelGraphics. I think in theory this would give better performance and memory consumption.



Please to show me example of code how you doing this :frowning:
Just I before use primitive as I think that they productively, but I ran into a problem with "distanceDisplayCondition" of Primitive object and I had to remodel everything to entities.
And I want up the perfomance through show/hide objects from map