Hello,
I was looking at the Picking Sandcastle example, and I noticed that in the ‘Show Cartographic Position on Mouse Over’ example that if I ‘turned on’ terrain, STK World Terrain meshes, the label would not stay above the terrain and would be hidden depending on the mouse position.
I’m also seeing a similar issue in a cesium app I’m working on.
What is your recommendation for solving this issue?
It’s not part of the entity API yet, but we recently added a heightReference property to labels and billboards. Setting heightReference: Cesium.HeightReference.CLAMP_TO_GROUND will clamp the label to the terrain. Here is an example:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var scene = viewer.scene;
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : ‘//assets.agi.com/stk-terrain/world’
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
viewer.scene.globe.depthTestAgainstTerrain = true;
var labels = scene.primitives.add(new Cesium.LabelCollection({
scene : viewer.scene
}));
var label = labels.add({
text: ‘My Label’,
position: Cesium.Cartesian3.fromDegrees(-120, 40),
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER
});