Skip to content
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

Prevent camera from going underground during mouse navigation #8504

Merged
merged 6 commits into from
Jan 6, 2020

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Jan 2, 2020

Fixes #5837
Fixes #5999 (I think)

Since #4105 the camera has been allowed to underground if globe tiles are loading in order to prevent unwanted shifts during camera flights or setView calls. However this leads to poor user experience when manually navigating around terrain and accidentally slipping underground, especially on slower internet connections where it happens much more frequently.

This PR undoes #4105 and moves the onus to adjust height back to ScreenSpaceCameraController, but only if the camera has moved during the controller's update. Camera flyTo and setView are not affected because terrain adjustment only happens when the user interacts with the camera which cannot occur during these two operations. This behavior can be confirmed in this sandcastle.

This method also removes some pretty bad coupling between Camera, ScreenSpaceCameraController, and Globe. Especially lines in Camera like:

var globeFinishedUpdating = !defined(globe) || (globe._surface.tileProvider.ready && globe._surface._tileLoadQueueHigh.length === 0 && globe._surface._tileLoadQueueMedium.length === 0 && globe._surface._tileLoadQueueLow.length === 0 && globe._surface._debug.tilesWaitingForChildren === 0);

@mramato @gberaudo @IanLilleyT

@lilleyse lilleyse requested review from IanLilleyT and mramato January 2, 2020 02:14
@cesium-concierge
Copy link

Thanks for the pull request @lilleyse!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@lilleyse lilleyse force-pushed the fix-camera-underground branch from 1c077ac to 587ce95 Compare January 2, 2020 02:15
@mramato
Copy link
Contributor

mramato commented Jan 2, 2020

This sounds like a good fix to me. I retested the initial issue (#4075) and it still works as of this PR.

@mramato
Copy link
Contributor

mramato commented Jan 2, 2020

There seem to still be some cases where you can go underground:

image

To recreate the above, I modified http://localhost:8080/Apps/Sandcastle/index.html?src=KML.html&label=DataSources and enabled clampToGround for the facilities KML and turned on terrain.

Assuming this isn't a trivial fix or is an unrelated issue, I'm okay with this going in as-is and having another issue written up, just wanted to bring it to your attention.

@mramato
Copy link
Contributor

mramato commented Jan 2, 2020

It's actually even easier to reproduce with just the stock example: http://localhost:8080/Apps/Sandcastle/index.html?src=GeoJSON%20simplestyle.html&label=DataSources using the ellipsoid provider

image

@lilleyse lilleyse force-pushed the fix-camera-underground branch from e203392 to 648b10a Compare January 2, 2020 16:56
@lilleyse
Copy link
Contributor Author

lilleyse commented Jan 2, 2020

@mramato I pushed a commit that should fix that. I actually had this fix on underground-camera but didn't think to move it over here.

The problem was globe.getHeight would return undefined if the deepest tile didn't have a rendered mesh, which would result in frames where the camera could go underground. The fix was to keep track of the deepest tile with a rendered mesh instead of just the deepest tile.

The GeoJSON demo now works much smoother. Any remaining flicker problems are due to log-depth.

@mramato
Copy link
Contributor

mramato commented Jan 2, 2020

Looks awesome @lilleyse this is a huge improvement. I couldn't get the camera to go permanently underground at all and only saw very rare flashes as tiles were loading in high-detail terrain areas.

@IanLilleyT please review and merge if you're satisfied.

@lilleyse any reason this can't make Monday's release? Seems like a huge win and a relatively minor change, but if you're not comfortable with putting it in just yet, I'm happy to have us hold off until Feb 1st.

@lilleyse
Copy link
Contributor Author

lilleyse commented Jan 2, 2020

@lilleyse any reason this can't make Monday's release?

I'd prefer to wait for February in case this change has some unintended side affect that we're not aware of yet. I'm going to be working in the camera system a lot in January so there will be plenty of opportunity to catch any mistakes.

@IanLilleyT
Copy link
Contributor

This looks good. It fixes both the linked issues. Going to merge after the January release.

Future work: Adjusting the height only when the camera moves is not always enough. For example: If you pivot the camera and release before all the high detail tiles are loaded, the camera can get stuck underground and does not recover until you move the camera again. Or if, in the future, terrain is dynamic and goes above the camera, the camera won't snap upwards.

Not sure what the best fix is. It has to play nicely with camera.setView which wants to preserve the camera location.

@IanLilleyT IanLilleyT merged commit 4a44e0e into master Jan 6, 2020
@IanLilleyT IanLilleyT deleted the fix-camera-underground branch January 6, 2020 19:48
Williangalvani added a commit to ArduPilot/UAVLogViewer that referenced this pull request Dec 1, 2020
Williangalvani added a commit to ArduPilot/UAVLogViewer that referenced this pull request Dec 1, 2020
Williangalvani added a commit to ArduPilot/UAVLogViewer that referenced this pull request Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants