Skip to content

Return pick ray in world coordinates with orthographic frustum #12500

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

Merged
merged 7 commits into from
Mar 10, 2025

Conversation

andrewda
Copy link
Contributor

@andrewda andrewda commented Feb 28, 2025

Description

Currently, Camera.getPickRay returns results in different coordinate systems depending on whether a perspective or orthographic frustum is used. With a perspective frustum, getPickRay returns a ray in world coordinates, which is correct per the getPickRay docs. With an orthographic frustum (both 2D and 3D), on the other hand, getPickRay returns the ray in camera coordinates, which differs from the documentation. This also results in weird zooming behavior in 3D orthographic mode with a tracked entity.

CleanShot.2025-02-27.at.19.24.42.mp4

Note that this could be a breaking change if users have depended on getPickRay incorrectly returning results in camera coordinates.

Issue number and link

#12498
#11743

Testing plan

Added four additional tests to cover:

  1. get pick ray with lookAt in perspective 3D
  2. get pick ray with lookAt in orthographic 3D
  3. get pick ray with lookAt in orthographic 2D
  4. get pick ray with lookAt in orthographic Columbus view

Only test 1 (perspective 3D) currently passes on main. This PR resolves the remaining 3 tests.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code
Copy link

Thank you for the pull request, @andrewda!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Mar 10, 2025

Thanks for the fix here @andrewda! The camera behavior is so much better.

I pushed a small fix to CHANGES.md with update instructions in case any users were relying on the previous behavior.

I'm surprised but happy to see that this fix was quite isolated. I tested out camera and picking behavior in both 3D orthographic and 2D scene modes. Everything appears to be working great.

@ggetz ggetz added this pull request to the merge queue Mar 10, 2025
Merged via the queue into CesiumGS:main with commit 01a163f Mar 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants