How does one update/change the altitude of a billboard with respect to the terrain? I'd like a user to click a point and eventually update/change altitude above the ground/terrain. I know how to clamp to ground, but relative to ground doesn't seem to work as expected.
I've tried the following:
var terrainModels = Cesium.createDefaultTerrainProviderViewModels();
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProviderViewModels: terrainModels,
selectedTerrainProviderViewModel: terrainModels[1] // Select STK High-res terrain
});
var scene = viewer.scene;
viewer.scene.globe.depthTestAgainstTerrain = true;
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
var buildboardCollection = scene.primitives.add(new Cesium.BillboardCollection({
scene: viewer.scene
}));
handler.setInputAction(createPointEventHandler, Cesium.ScreenSpaceEventType.LEFT_CLICK);
function createPointEventHandler(event)
{
var ray = viewer.camera.getPickRay(event.position);
var position = viewer.scene.globe.pick(ray, viewer.scene);
var pinBuilder = new Cesium.PinBuilder();
if (Cesium.defined(position)) {
// I'd like to change the position's height
buildboardCollection.add({
position: position,
image: pinBuilder.fromText("P", Cesium.Color.YELLOW, 30).toDataURL(),
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM
});
}
} // end if hit globe
Thanks in advance for any help.