Error in obtaining height value

Hello! I obtained the correct ECEF according to the following code, and then used the EarthCenteredEarthFixedToLongitudeLatitudeHeight method to obtain the correct longitude and latitude while the incorrect height (as shown in the code below)

Camera camera = Camera.main;
RaycastHit hit;

    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
  
    if (Physics.Raycast(ray, out hit))
    {
        Transform objectHit = hit.transform;
        double3 hitPition = new double3(objectHit.position);
        //   TransformUnityPosition

       double3  value =  cesiumGeoreference.TransformUnityPositionToEarthCenteredEarthFixed(hitPition);

        //  TransformUnityPositionToEarthCenteredEarthFixedCesiumGeoreference
       double3 xyz = 
       CesiumWgs84Ellipsoid.EarthCenteredEarthFixedToLongitudeLatitudeHeight(value);
        txt.text = xyz.x.ToString()+","+ xyz.y.ToString()+","+xyz.z.ToString();
        txt1.text = value.x.ToString() + "," + value.y.ToString() + "," + value.z.ToString();
    }

What makes you say the height is incorrect? It’s true that those height values are different, but they’re at different horizontal locations so it’s not surprising. Plus, there’s no reason to think that the georeference origin is exactly on the terrain surface.

The right side is the height of the camera, and the left side is the height of the mouse position, which is basically at a uniform height, with a significant difference

You have to remember that the “height” of the CesiumGeoreference refers to the height above the WGS84 ellipsoid model. This is often unequal to the actual height of the terrain above mean sea level.

If you want the height above the terrain, you’ll have to use Physics.Raycast. If you want the height above mean sea level, see Kevin’s post on this thread: The height of the sea is not 0 - #8 by Kevin_Ring

How to conveniently detect the height of EGM96 Geoid in unity? Since the longitude and latitude data are sent from the back end, it is necessary to calculate the corresponding approximate height of EGM96 Geoid on unity to give the target object. Is there a corresponding solution

Hello! What I mean is, Cesium Georeference and double3 xyz=

Is CesiumWgs84Ellipsoid. EarthCenteredEarthFixedToLongitudeLatitudeHeight (value) the height of the wgs84 ellipsoid and the same benchmark