change entity metarial from subscribed event

Hi,

normally i can change metarial by input action.

viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);

   function selectEntity(event) {
                
                var picked = viewer.scene.pick(event.position);
           
                if (Cesium.defined(picked)) {
                   
                var id = Cesium.defaultValue(picked.id, picked.primitive.id);
                
                if (id instanceof Cesium.Entity ) {
                    viewer.selectedEntity = id;
                   
                        id.polygon.metarial = Cesium.Color.RED;
                   
                }
            
            }
        }

but there is performance issues with this way. i have found another way, knockout event.

i subscribed knockout selectentity event.
but it doesnt change metarial.

        var observable = Cesium.knockout.getObservable(viewer, '_selectedEntity');
        observable.subscribe(function (entity) {
                        entity.polygon.metarial = Cesium.Color.RED;
         });

Hello,

We recently added a selectedEntityChanged event to viewer. Here is an example for how to add a listener to the event to change the clicked polygon color:

viewer.selectedEntityChanged.addEventListener(function(entity) {
entity.polygon.material = Cesium.Color.YELLOW;
});

``

Best,

Hannah