Hello. My company has been using Cesium for about a year now to develop a viewer for Wide Area Motion Imagery (WAMI). Part of our functionality in the viewer is a region of interest query. This feature calculates the geographic area that the user is viewing, and sends it to our master application, so the master application can trim the imagery and only send the portion that the user is viewing. To do accomplish this is cesium, we have been using the camera.computeViewRectangle function to find the range of geographic bounds that the camera has been viewing, and it has worked great. Unfortunately, a couple weeks ago, our company purchased a subscription of Cesium Ion so that we could view 3d terrain in our application. However, enabling terrain made the computeViewRectangle no longer work as expected. Now, the rectangle that this function provides is very incorrect to what we are actually viewing.
Here is the relevant code
CesiumViewer = new Cesium.Viewer("cesiumContainer", {
imageryProvider: USGSProvider,
terrainProvider: Cesium.createWorldTerrain({
requestWaterMask : true
}),
//terrainProvider: arcGisProvider,
baseLayerPicker: false,
geocoder: false,
timeline: false,
animation: false,
homeButton: false,
fullscreenButton: false,
selectionIndicator: false,
infoBox: false,
useDefaultRenderLoop: true,
orderIndependentTranslucency: true,
scene3DOnly: true,
automaticallyTrackDataSourceClocks: false,
dataSources: null,
clock: null,
targetFrameRate: 60,
resolutionScale: 0.1,
terrainShadows: Cesium.ShadowMode.ENABLED,
infoBox: false,
navigationHelpButton: false,
contextOptions: {
webgl: {
alpha: false,
antialias: true,
preserveDrawingBuffer: true,
failIfMajorPerformanceCaveat: false,
depth: true,
stencil: false,
antialias: false,
},
},
});
CesiumViewer.camera.moveEnd.addEventListener(function () {
if (updateRoi) {
var rect = CesiumViewer.camera.computeViewRectangle();
var east = String(Cesium.Math.toDegrees(rect.east));
var south = String(Cesium.Math.toDegrees(rect.south));
var west = String(Cesium.Math.toDegrees(rect.west));
var north = String(Cesium.Math.toDegrees(rect.north));
var coords = south + " " + west + " " + north + " " + east;
window.CallNativeWithJSON(
JSON.stringify({ func: "updateROI", args: [coords] })
);
}
});