You can get the distance in meters between the camera and the ellipsoid surface like this:
var cameraPosition = viewer.scene.camera.positionWC;
var ellipsoidPosition = viewer.scene.globe.ellipsoid.scaleToGeodeticSurface(cameraPosition);
var distance = Cesium.Cartesian3.magnitude(Cesium.Cartesian3.subtract(cameraPosition, ellipsoidPosition, new Cesium.Cartesian3()));
The code works great in 3D scene mode, but in SCENE2D return invalid results.
Should i use different calculation for geting the camera's heigth in this case?
Finally i want to calculate the map's scale represented in 2D view.
For example, i have the zoom level range from 10 - 18 along with 10:20000m - 18:1000m of distance, so now if the camera is currently on 6000m of height, please help me to compute the zoom level of this height and what algorithm to compute it?