Hello,
I’m using camera computeViewRectangle method.It run properly nearly everywhere. But When I’m looking to avustralia (or near locations )and save cameraviewrectangle and later when I try to fly to this rectangle with it fly to other region like africa.
I’m modified viewRectangle sandcastle to show faulty result .
function viewRectangle() {
Sandcastle.declare(viewRectangle);
var west = -3.1415926;
var south =-1.57079;
var east = 3.1415926;
var north = 1.57079;
var rect=scene.camera.computeViewRectangle(viewer.scene.globe.ellipsoid);
var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);
viewer.camera.flyTo({
destination: rect,
duration:3
});
console.log(rect);
// Show the rectangle. Not required; just for show.
viewer.entities.add({
rectangle : {
coordinates : rect,
fill : false,
outline : true,
outlineColor : Cesium.Color.WHITE
}
});
}
If you are try view rectangle choice when looking australia. You can see faulty result and faulty rectangle drawwing.
I wasn’t able to reproduce the error you were seeing. Here is the example I tested with:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var west = -3.1415926;
var south =-1.57079;
var east = 3.1415926;
var north = 1.57079;
function callback() {
return new Cesium.Rectangle(west, south, east, north);
}
Sandcastle.addToolbarButton(‘Save’, function() {
var rect = viewer.scene.camera.computeViewRectangle();
west = rect.west;
south = rect.south;
east = rect.east;
north = rect.north;
});
viewer.entities.add({
rectangle : {
coordinates : new Cesium.CallbackProperty(callback, false),
fill : false,
outline : true,
outlineColor : Cesium.Color.WHITE
}
});
``
Make sure you are using the latest version of Cesium. I know at one point we had a bug where computeViewRectangle wasn’t working correctly in the southern hemisphere.
computeViewRectangle isn’t the most accurate for certain tilted and zoomed out views. Saving the position/heading/pitch/roll will give you better results.