Changin entity properties on event tick

var viewer = new Cesium.Viewer(‘cesiumContainer’, {});
function computeCircle(radius) {

    var positions = [];

    for (var i = 0; i < 360; i++) {

        var radians = Cesium.Math.toRadians(i);

        positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians)));

    }

    return positions;

}

var line = viewer.entities.add({

    polylineVolume : {

        positions : Cesium.Cartesian3.fromDegreesArrayHeights([49.1641293, -5.3639241, 50,

                                                            3.535853, 9.809184 ,50]),

        shape : computeCircle(20),

        material : Cesium.Color.GREEN.withAlpha(0.3)

    }

});

viewer.clock.onTick.addEventListener(function() {

                    line.material = new Cesium.Color.RED.withAlpha(0.3);

});

I am trying to change the color of the line on every tick but i can not do it.

Why this code is not working?

It actually is changing, but since entities are creating asynchronously by default, it takes a few frames to recreate the geometry when you change the material. So if you’re changing it every frame, it will just always disappear.

Here’s a Sandcastle example where you can verify it changes when you click the button in the top left.