I don’t understand what I’m doing wrong here…could someone from Cesium team help me debug. In my Unreal Engine 5.6 project I simply have an Actor spawner that:
-
Spawns a bunch of simple cube-actors (scaled by 10) scattered randomly around a lat/lon box roughly covering the Falkland Islands.
-
For each spawn, I treat altitude = 0 m as “sea level (MSL)”. I run it through GeographicLib’s geoid model (using “egm2008-2_5”) to convert to ellipsoidal height via
geoid(lat, lon), then feed that into the actor’s CesiumGlobeAnchorComponent — so that should put the cube flush with actual sea-surface.
The problem: some cubes appear roughly at sea surface (as expected), but some are floating ~10–40 m above water.
I recorded a quick video of this to show what I mean.
CesiumForUnreal Demo MSL to Ellipsoidal height
here’s the code I use for the conversion and the spawning:
void AFalklandsSpawner::SpawnAt(double Lat, double Lon, double AltMSL)
{
double geoidN = QueryGeoidHeight(Lat, Lon);
double ellipsoidH = AltMSL + geoidN;
FActorSpawnParameters spawnParams;
AActor* newActor = GetWorld()->SpawnActor<AActor>(ActorToSpawn, FTransform::Identity, spawnParams);
if (!newActor) return;
// Add Cesium anchor
UCesiumGlobeAnchorComponent* anchor = NewObject<UCesiumGlobeAnchorComponent>(newActor);
anchor->RegisterComponent();
newActor->AddInstanceComponent(anchor);
FVector lonLatH = FVector(Lon, Lat, ellipsoidH);
anchor->MoveToLongitudeLatitudeHeight(lonLatH);
anchor->SnapLocalUpToEllipsoidNormal();
// make actor big so it's visible
newActor->SetActorScale3D(FVector(10.0, 10.0, 10.0));
}
double AFalklandsSpawner::QueryGeoidHeight(double Lat, double Lon) const
{
using namespace GeographicLib;
const std::string geoidModel = "egm2008-2_5";
const Geoid geoid(geoidModel, /*dirname=*/"", /*threadsafe=*/true);
return geoid(Lat, Lon);
}
double AFalklandsSpawner::RandomRange(double Min, double Max) const
{
return FMath::Lerp(Min, Max, UKismetMathLibrary::RandomFloat());
}
Why are some cubes significantly above the “sea level plane”? Is this expected geoid-to-ellipsoid height variation around Falklands, or am I doing something wrong?
Any pointers what I should check next — or is this a known caveat when placing objects at MSL = 0 with geoid conversion in Cesium for Unreal?
@Kevin_Ring Sorry to ping you like this, but I noticed your name popping up in replies to similar posts, so I thought I’d ask the best person for the job ![]()
Thanks in advance ![]()