-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve position selected for camera in viewRectangle in 3D. #2764
Conversation
@bagnell you might want to look at this for 1.10, since it looks like a good small-impact change. |
Good catch, Dan. My system (Ubuntu 15.04 / Chrome / NVidia Quadro 4000) has a number of test failures under normal circumstances so I missed this. The problem is that my new code works very poorly when the east and west boundaries are coplanar (e.g. west: -180 degrees and east: 0 degrees). To correct this, I have a new version that uses In addition to avoiding problems with coplanar longitudes, this also yields a slightly better result for my test numbers above: |
This turned out to be a lot more complicated than I expected, but I'm pretty happy with it now. After calling It's still possible for part of the extent to be outside the view frustum when the side bulge out from the corners (the coordinates above will exhibit this behavior). I don't think it's easy to important to fix this. The camera also now looks down the ellipsoid surface normal rather than toward the center of the Earth after viewing a rectangle. One thing I noticed while working on this is that the So we may want to change it now that viewing big rectangles is more reliable. Another weird thing I noticed is that Sandcastle and Cesium Viewer (at least) don't actually use the |
I made another small change to this because I realized I was computing the camera position displacement along the geodetic surface normal, but then actually displacing it along the geocentric normal. Oops. This changes the camera position by a couple of pixels for big rectangles. |
@kring This looks good to me. Is it ready to be merged or were there other changes you wanted to make? |
It's ready as far as I'm concerned. |
Conflicts: CHANGES.md
I updated CHANGES.md by moving what you added to the 1.11 section. Merging. |
Improve position selected for camera in viewRectangle in 3D.
For
Camera.viewRectangle
in 3D, Cesium places the camera by selecting a position halfway along a Cartesian line between the southwest and northeast corners, and then computing its height. This works when extents are approximately rectangles, but it yields total garbage for rectangles where the top and bottom are at very different latitudes.This change has the Camera instead select the position that is the average of the four corners of the extent. This isn't perfect (the perfect solution I guess would find the barycenter of the projection of the extent onto the globe) but it's drastically better.
For example,
90, -62, 174, -4
(WSEN) looks like this:Before this change:
After this change: