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.

Thanks!