Hi,
I am trying to highlight features on hover. In order to do that I started from the sandcastle example
and then extracted the part (without silouette).
// Information about the currently highlighted feature
const highlighted = {
feature: undefined,
originalColor: new Cesium.Color(),
};
// Color a feature yellow on hover.
viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
// If a feature was previously highlighted, undo the highlight
if (Cesium.defined(highlighted.feature)) {
highlighted.feature.color = highlighted.originalColor;
highlighted.feature = undefined;
}
// Pick a new feature
const pickedFeature = viewer.scene.pick(movement.endPosition);
// Highlight the feature if it's not already selected.
if (pickedFeature !== selected.feature) {
highlighted.feature = pickedFeature;
console.log(pickedFeature.color);
console.log(highlighted.originalColor);
Cesium.Color.clone(pickedFeature.color, highlighted.originalColor);
pickedFeature.color = Cesium.Color.YELLOW;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
It seems to work, but I receive several errors the console as soon as I have clicked on an entity
Uncaught TypeError: Cannot read properties of undefined (reading 'color')
at onMouseMove (app.js:144:31)
at Ute (Cesium.js:91:118581)
at QRe (Cesium.js:91:122879)
at HTMLCanvasElement.o (Cesium.js:91:116280)
The color of the picked feature is undefined.
I keep looking at the original example, but I am struggling to see what I am missing. Any suggestion?