How to update polyline colors dynamically (Cesium 1.4/Master)?


I have a polyline and I need to gradually fade it (or do some other color/alpha manipulations over time)

So for example I have this polyline (can be run in SandCastle)

Nik, the only way to do this is currently is to recreate the primitive for each update. It’s never been possible to do what you describe with per-vertex colors. If the line were a solid color, it would be possible using instance attributes.

It was definitely possible in versions like b10 that we were using before. Based on multiple colours of a line we were able to control opacity of different parts of it in realtime without recreating a line.

Please, refer to this video as an example of the case

Slightly shortened piece of old code that did the thing above (applied for each existing line)

AttacksRendererService.prototype._updateLineAlpha = function (line) {

 var i;

 var len = line._actualLength;

 var ttl = line._death -;

 var age = ttl / this.settings.atkLifetime / 1000;

 var percentage = 1 - age;

 for (i = 0; i < len; i = i + 1) {

   line._colors[i].alpha = 0;

   if (i === parseInt(percentage * len, 10)) {

     line._colors[i].alpha = this.settings.atkMaxAlpha;



 // This is just a hack to call makeDirty since it's a hidden method

 // It doesn't actually update the color

 var c = line.getColor().clone();

 line.setColor({red: 1, green: 1, blue: 1, alpha: Math.random()});



can i see live demo ?thanks?