I’ve been looking closer at this issue, and it seems that all the values are strange.
For example, the vertices coming from the loaded tile are (very) large numbers. These are the first 10 vertices of some random tile coming in from the Unity mesh:
x |
y |
z |
693706.30 |
1033791.00 |
-6232509.00 |
1436441.00 |
591030.30 |
-6164443.00 |
409.85 |
-3651.96 |
-6355296.00 |
439.89 |
623047.60 |
-6324991.00 |
1248052.00 |
-3651.96 |
-6231827.00 |
409.85 |
-3651.96 |
-6355296.00 |
1586733.00 |
2134956.00 |
-5774282.00 |
1965603.00 |
1046561.00 |
-5954476.00 |
659585.70 |
1587470.00 |
-6120762.00 |
2896741.00 |
786249.20 |
-5607043.00 |
2400065.00 |
473444.90 |
-5867085.00 |
And these are the resulting longitude, latitude, and height values computed from these vertices:
Longitude |
Latitude |
Height |
14.88 |
23.28 |
3332429.00 |
19.86 |
21.63 |
3038246.00 |
10.42 |
18.47 |
2625713.00 |
10.42 |
21.30 |
3059041.00 |
18.84 |
18.84 |
2625757.00 |
10.42 |
18.47 |
2625713.00 |
20.44 |
28.90 |
4031120.00 |
23.22 |
24.13 |
3341595.00 |
14.59 |
25.81 |
3690489.00 |
29.82 |
24.08 |
3170757.00 |
26.51 |
22.01 |
2957681.00 |
For reference, this is the function I’m using to convert the vertices of the mesh to long/lat/height:
for (int i = 0; i < verts.Length; i++)
{
var d3 = double3(verts[i]);
// Convert vertex to ECEF.
d3 = Georeference.TransformUnityPositionToEarthCenteredEarthFixed(d3);
// Convert to Longitude, Latitude, and Height.
d3 = CesiumWgs84Ellipsoid.EarthCenteredEarthFixedToLongitudeLatitudeHeight(d3);
// Store Lon, Lat, Height values.
lonLatHeight[i] = new Vector3((float)d3.x, (float)d3.y, (float)d3.z);
}
I believe that the Longitude and Latitude values could be correct (despite my current view being centered around (10.4, 63.4, 547)), the height is clearly not (if this is indeed supposed to be the height (in meters) above (or below) the WGS84 ellipsoid).
But if I try to visualize the longitude (normalized the range [-180 … 180] and output in the red channel) and latitude (normalized in the range [-90 … 90] and output in the green channel), and zoom out a bit, it looks like this:
Which clearly doesn’t look correct. It should be black at the south pole (-180, -90) and yellow at the north pole (180, 90) and a smooth gradient from 50% green to yellow(ish) around the equator.
For reference, this is the orientation of the globe using the default material:
I’m really not sure if my assumptions are correct about how the mesh vertices are really in Unity’s local space (or another space) (or if I’m flipping lon/lat or lat/lon values again?)