Center postion of viewport

Hi,

I am trying to get center position of the viewport.

Let me explain what i am trying to acheive whenever I do drag using mouse pointer or zoom in on the cesium globe it should give center position of the viewport.

Can anyone help?

Thanks in advance.

Tejas

You’d want to pull the viewer.scene.canvas object and get half it’s height and width, then load that into a viewer.scene.camera.getPickray() to return a cartesian3 of the center of the viewport.

You can find a somewhat similar example in Terria.js, shoutout to @NICTA and Kevin for full credit:

https://github.com/TerriaJS/terriajs/blob/e8c46d64e225428265f91f0f9c06bb0bb482855c/lib/ViewModels/DistanceLegendViewModel.js#L100-L104