Highlight an entity

I am struggling to highlight an entity (created with viewer.entities.add) when hovering over it. I followed the example in the sandcastle about picking and modified it

This is the sandcastle with my attempt.

It works well with 3dtiles, but it flickers and randomly changes color when I hover over the entity I have created (in cyan).
I have read several posts with partial answers, but I must be missing something because I can’t get it to work.

Is there some clear example somewhere? It seems to be a quite common feature.


Hi there,

It’s a bit obfuscated for simplicity’s sake, but entities actually use a property system to detect when something has changed. I would suggest creating a MaterialProperty with a nested CallabckProperty:

const colorProperty = new Cesium.ColorMaterialProperty();
let  color = normalColor;
colorProperty.color = new Cesium.CallbackProperty(function(time, result){
  return color;
}, false);

In your entity, set material to this property:

    material: colorProperty

Then set color to either Cesium.Color.YELLOW or normalColor in your mouse handlers.

1 Like

Thanks @Gabby_Getz
From my initial test, this is working much better!