How to calculate the vertical distance and horizontal distance between two points

The horizontal and vertical distances that I draw on the cesium are weird, the same for X and Y, and the two points for different Z values ​​are not on a vertical line, I don't know how to set parameter,thank you!

Are you maybe mixing Cartesian3 and Cartographic coordinates?

For reference, Cartesian3 objects are (x, y, z) coordinates in world space. Cartographic objects are (lat, long, height) coordinates. You can convert between them, see the linked documentation.

Thanks,

Gabby