function getExtentView(){ var c2 = new Cesium.Cartesian2(0,0); var leftTop = scene.getCamera().controller.pickEllipsoid(c2, ellipsoid); c2 = new Cesium.Cartesian2(scene.getCanvas().width, scene.getCanvas().height); var rightDown = scene.getCamera().controller.pickEllipsoid(c2, ellipsoid); if(leftTop != null && rightDown != null){ leftTop = ellipsoid.cartesianToCartographic(leftTop); rightDown = ellipsoid.cartesianToCartographic(rightDown); return new Cesium.Extent(leftTop.longitude, rightDown.latitude, rightDown.longitude, leftTop.latitude); }else{//The sky is visible in 3D return null; } }
function getExtentView() { var cl2 = new Cesium.Cartesian2(0, 0); var leftTop = viewer.scene.camera.pickEllipsoid(cl2, ellipsoid);
cr2 = new Cesium.Cartesian2(viewer.scene.canvas.width, viewer.scene.canvas.height); var rightDown = viewer.scene.camera.pickEllipsoid(cr2, ellipsoid);
if (leftTop != null && rightDown != null) {
leftTop = ellipsoid.cartesianToCartographic(leftTop); rightDown = ellipsoid.cartesianToCartographic(rightDown);
return new Cesium.Rectangle(leftTop.longitude, rightDown.latitude, rightDown.longitude, leftTop.latitude);
} else {//The sky is visible in 3D
console.log("Sky is visible"); return null; }}