Two ways to create primitive, which to choose?

Hello,

I want to create primitive polyline(or any other primitive).
There two ways:

  1. Create a primitive with PolylineGeometry.
  2. Create a PolylineCollection, and add polyline.

Which is better? which to choose? (also consider performance, and memory)

Second question.
Primitive has a property called: asynchronous : Boolean
Which says: “Determines if the geometry instances will be created and batched on a web worker.”

So if i assign: asynchronous =false; it means it will run on the main thread and drawn synchronously, right? maybe its a reason to use the first way above?

Thanks in advance

Hello @Baruch_Levin,

Unless you have a reason not to, i would recommend using the Entity API to draw your polylines: Cesium Sandcastle
It provides a more user-friendly API while managing lower level primitives/geometry optimally behind the scenes.

If you wanted to dig into using these lower level primitives directly- PolylineCollection and PolylineGeometry are very similar, but have slightly different feature support. PolylineCollection tends to be the better choice if you have a polyline that is updating frequently, and PolylineGeometry is faster for static polylines.

And yes, setting asynchronous: false will force the geometry to compute it’s attributes as part of the main thread. If you have a large number of complex geometry, computing them in the main thread will keep the cesium viewer from rendering new frames while they are computing, making it appear frozen.

Best regards,

Hannah
Cesium Staff

1 Like