Polyline Geometry Question

Hello all,

I have been working with cesium for close to 2 months now and the majority of my work has been done with the Primitive class. The reason for this is because I have a very large amount of data that needs to be visualized so I really needed to optimize performance over just visualization.

My question pertains directly to the PolylineGeometry class and how exactly would I go about using it currently I've tried a few approaches all of which are very similar to this one, note: the beginning code is taken from the cesium documentation

var polyline = new Cesium.PolylineGeometry({
    positions: Cesium.Cartesian3.fromDegreesArray([
    0.0, 0.0,
    5.0, 0.0,
    0.0, 5.0
    ]),
    width: 5.0
});

var geometry = Cesium.PolylineGeometry.createGeometry(polyline);

I then created an instance

var newInstance = new Cesium.GeometryInstance({
   id: "1",
   geometry,
   attributes: {
      color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED)
   }
});

I then add it to a primitive and try to add it to the scene

var targetPrimitive = new Cesium.Primitive({
   geometryInstances: newInstance
});

var scene = viewer.scene;
scene.primitives.add(targetPrimitive);

With this method I keep getting an error that says "DeveloperError: _workerName must be defined for asynchronous geometry"

My question really lies in if I'm using PolylineGeometry is this not the proper way to put it into the scene?

Looks like you can avoid this by passing the asynchronous as false to the Primitive constructor.

With that said, the entity API does primitives under the hood and it combines many entities into one primitive when possible for performance. So I would try using polyline entities and see if it produces the performance you need. The Entity layer should be a lot more straightforward to use.

Let me know what you end up finding to be the best workflow!