TerrainProvider and Position of Entities

1. A concise explanation of the problem you're experiencing.

I have a entity and use the position callback to get the position. Starting with ellipsoid after changing the terrainProvider the entity isn't displayed.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

The code is from the forum:

var windowPosition = new Cesium.Cartesian2(viewer.container.clientWidth / 2, viewer.container.clientHeight / 2);

var pickPosition = viewer.camera.pickEllipsoid(windowPosition);
    
var position = pickPosition;
var positionCBP = function(){
  return position;
};

var svgEntityImage = svgDataDeclare + svgString;
myTarget = viewer.entities.add({
  name : 'Target on surface',
  position: new Cesium.CallbackProperty(positionCBP, false),
  billboard: {
    image: svgEntityImage
  }
});

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

It would be good to see the entity independet of the choice of the terrainProvider.

4. The Cesium version you're using, your operating system and browser.
1.40, windows7, chrome

Try using HeightReference.CLAMP_TO_GROUND for the heightReference to lock the height to the terrain surface.

myTarget = viewer.entities.add({
name : ‘Target on surface’,
position: new Cesium.CallbackProperty(positionCBP, false),
billboard: {
image: svgEntityImage,
heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
}
});

``

Thanks,

Gabby