Polyline removeAll Collection bug?

Hi Cesium team,

I have encounted some issues when working with Polyline collections. The following code will throw an error when using either kind of removeAll when removing more than one polyline at a time.

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var scene = viewer.scene;

scene.primitives.add(new Cesium.PolylineCollection());

scene.primitives.add(new Cesium.LabelCollection());

var material3 = Cesium.Material.fromType(‘Color’);

var polylines = scene.primitives.get(0);

var poly;

var labels = scene.primitives.get(1);

var index=0;

for (index = 0; index < 5; index++) {

var positions = [ -96+index, 30+index, -98+index, 32+index ];

positions = Cesium.Cartesian3.fromDegreesArray(positions);


positions : positions,

width : 2,

material: material3


poly.material.uniforms.color = Cesium.Color.AQUA;


position : Cesium.Cartesian3.fromDegrees(-96+index, 30+index),

text : ‘A label’+index





Changing the polylines.add material parameter to the following fixed the issue.

material: Cesium.Material.fromType(‘Color’)

So I assume that this has something to do with passing a material by reference or something. Will things stay this way? On a side note I noticed a syntax error in the PolylineCollection documentation in the first example. the ‘positions’ property is spelled ‘position’ for the first polyline.


Another question I had was whether there were plans to bring back the Geometry and Appearances SandCastle back to using Geometries instead of entities. It has some great examples that I used.



Thanks for the heads up. You are probably running into this bug: https://github.com/AnalyticalGraphicsInc/cesium/issues/1567
The workaround is to just create a material per line. In your example, get rid of material3 and replace it with Cesium.Material.fromType(‘Color’); in your add call.