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

Adjust camera controls for when the globe is off, and when panning in 3D #11268

Merged
merged 5 commits into from
May 10, 2023

Conversation

ggetz
Copy link
Contributor

@ggetz ggetz commented May 3, 2023

Fixes #7171

Picking for all camera controls had some strange conditions:

  • scene.pickPosition was never used if the globe was undefined (so the ellipsoid was picked instead), which is not a strict requirement. Now, we always go with the scene.pickPosition result if defined and the globe isn't, then fallback to the ellipsoid as needed.
  • The closer of either the globe or the scene position was picked under all scenarios. This is now only the case when underground or when globe translucency is enabled.
  • Since we're not always picking the globe, I renamed the pickGlobe function to pickPosition

Panning formerly did not pick at all and instead used only the ellipsoid. 3D panning now picks a position based off the initial mouse position and moves in worldspace based on the mouse translation. This allows for much better control when panning through 3D tiles such as a cityscape, or other more vertical surfaces.

I did my best to test a variety of scenarios including combinations of the following, but let me know if there are any blind spots:

  • panning, zooming, & orbiting
  • "throwing" the globe or scene when panning with inertia
  • default globe, globe with terrain
  • far away, close to the ellipsoid or terrain, 3/4 views, straight down, steep horizon views, lookup up at the sky
  • translucent globe, underground
  • 3D tiles on the default globe, on a globe with terrain, or with globe: false
  • 3D tiles as terrain (S2 globe example)
  • models and entities on the default globe, on a globe with terrain, or with globe: false
  • perspective and orthographic frustums
  • different aspect ratios and resolutions

@ggetz ggetz requested a review from jjhembd May 3, 2023 18:48
@cesium-concierge
Copy link

Thanks for the pull request @ggetz!

  • ✔️ Signed CLA found.
  • ❔ Unit tests were not updated.
    • Make sure you've updated tests to reflect your changes, added tests for any new code, and ran the code coverage tool.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.

@ggetz ggetz marked this pull request as ready for review May 3, 2023 18:48
Copy link
Contributor

@jjhembd jjhembd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ggetz, this change makes it significantly easier to control the camera!
I'm noticing one issue with panning: If I drag a point in the backround, and a tileset feature crosses my cursor position in the foreground, my cursor is now locked to the foreground feature instead of the point I originally clicked on.

See this screengrab from the Melbourne photogrammetry tileset:
https://user-images.githubusercontent.com/41167620/236309442-f3a4b8b1-aa7f-4177-94c2-b2d0a6068bd5.mp4

Local Sandcastle link.

Would it be possible for pan3D to remember the 3D position of the point I originally clicked on?

@ggetz
Copy link
Contributor Author

ggetz commented May 5, 2023

Thanks @jjhembd! This should now be fixed. Let me know what you think.

@jjhembd
Copy link
Contributor

jjhembd commented May 5, 2023

Thanks @ggetz! That last commit does indeed fix the issue with foreground features, when panning from left to right.

I did notice one more thing: when panning up and down in an oblique view, the picked point doesn't seem to keep up with the cursor. Here's what it looks like on my machine (from this local Sandcastle):

2023-05-05.camera-controls.mp4

For comparison, here is the same up-and-down panning action in v1.105 (on sandcastle.cesium.com):

2023-05-05.main.mp4

@jjhembd
Copy link
Contributor

jjhembd commented May 9, 2023

Could we use the new math only when the globe is off?

The new flow is undeniably better when navigating a tileset with no globe defined. But with a globe and no tileset, the old math is more intuitive.

Compare the current behavior with no tileset. When dragging, the picked point on the globe mostly stays under the cursor.

2023-05-09.main.mp4

With the new math and no tileset (Local Sandcastle), the picked point goes far ahead of the cursor:

2023-05-09.camera-controls.mp4

I have to admit I don't understand the pan3D function well enough to know what is happening.

@ggetz
Copy link
Contributor Author

ggetz commented May 10, 2023

Fair point @jjhembd. I adjusted so that panning only uses the new behavior when the globe is off.

Rotating around a fixed position and zooming will still always use the picked position (whereas before they were using the ellipsoid position), but I think we agree that behavior is a definite improvement.

@jjhembd
Copy link
Contributor

jjhembd commented May 10, 2023

Thanks @ggetz! I think this is good to go. Merging now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Camera picking doesn't work when globe is off
3 participants