Camera lookAt position in Cartesian3

Dear Cesium-Team,

May I have a question:
How to get or calculate the Coordinate (in form of Cartesian3) of the point on globe ground, that the camera is looking at?

best regards,


If you just want the point on the ground in the center of the screen, you can use camera.pickEllipsoid. In the below snippet, result will be a Cartesian3 if the function succeeds or undefined if the camera was pointing off of the earth.

var canvas = viewer.canvas;

var result = Cesium.Cartesian2(canvas.clientHeight / 2, canvas.clientWidth / 2));

thank you very much. That is exactly what I need.

I tried this out and had success if I reversed the parameter order:

var result = Cesium.Cartesian2( viewer.canvas.clientWidth / 2,viewer.canvas.clientHeight / 2));

cg = Cesium.Ellipsoid.WGS84.cartesianToCartographic(result);

console.log(" l ",cg.latitude180/Math.PI,cg.longitude180/Math.PI);

Copy/Pasting the console output into a geocoder then matches what is in the center of the screen.

Thanks for pointing out the function, this is very useful for matching say the pointer position to a point on the globe!