Convert long/lat/height to screen pixel x,y

Hi, All,
Is there any helper class, which can convert a point from long/lat/height screen pixel x,y ?

Thanks,
-Jonathan

SceneTransforms.wgs84ToWindowCoordinates is what you want. You’ll need to convert the long/lat/height to a Cartesian3 first, which you can do with Ellipsoid.WGS84.cartesianToCartographic

Hi Matthew,
Many thanks to the Cesium Team for such a great product.

I need to translate from window coordinates (x,y) to Cartesian3 coordinates?

I checked the documentation and SceneTransforms doesn’t have such a method?

Looking forward to getting Version 1.0 of Cesium in August! :slight_smile:

scene.camera.pickEllipsoid is what you want to use. That function will return the cartesian position on the earth at the provided x/y or undefined if the xy is not over the globe. This Sandcastle example shows it in action (position under mouse cursor):

http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Picking.html&label=Showcases

The reason it requires the position to be over the globe is simple, when going from Cartesian -> ScreenSpace there is exactly one pixel that the cartesian position maps into (multiple cartesians can map into the same pixel, but that’s okay because we still get the result we want). When going from ScreenSpace->Cartesian, you have an infinite number of positions that each pixel can map into (because of depth). By using the rendered globe as a reference, you are saying the depth you want is the current depth of the globe at that pixel.

Hope that helps,

Matt