I have a set of coordinates return from an api. Thereafter, I set camera view with the following codes:
viewer.scene.camera.setView({
destination:
Cesium.Cartesian3.fromDegrees(103.84958233542338,1.3669641300494784, 100),
orientation: new Cesium.HeadingPitchRoll(0, 0, 0),
endTransform: Cesium.Matrix4.IDENTITY
});
Now, I want to get center of the screen and return its coordinates. But I am unable to do so. Any idea why?
var windowPosition = new Cesium.Cartesian2(viewer.container.clientWidth / 2, viewer.container.clientHeight / 2);
var pickRay = viewer.scene.camera.getPickRay(windowPosition);
var pickPosition = viewer.scene.globe.pick(pickRay, viewer.scene);
var pickPositionCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(pickPosition);
var apilon = pickPositionCartographic.longitude * (180 / Math.PI);
var apilat = pickPositionCartographic.latitude * (180 / Math.PI);