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

3d tiles height reference #11604

Merged
merged 24 commits into from
Jan 31, 2024
Merged

3d tiles height reference #11604

merged 24 commits into from
Jan 31, 2024

Conversation

ggetz
Copy link
Contributor

@ggetz ggetz commented Nov 3, 2023

To be merged after #11581

Fixes #7044
Fixes #9680
CC #11544

Building on this previous PR, this allows more user-friendly APIs for clamping to 3D Tiles as well as or instead of terrain by extending the HeightReference types:

  • CLAMP_TO_GROUND/RELATIVE_TO_GROUND now clamps to or is relative to terrain or 3D Tiles, whichever is higher
  • Added CLAMP_TO_TERRAIN/RELATIVE_TO_TERRAIN to clamp to or position relative to terrain only
  • Added CLAMP_TO_3D_TILE/RELATIVE_TO_3D_TILE to clamp to or position relative to terrain only

This was to align to the possible ClassificationType values, TERRAIN, CESIUM_3D_TILE, or BOTH.

I've replaced the sandcastle for the (now outdated) scene.clampToHeight method of clamping, which is now Clamp Model to Ground. I've also extended this and the Clamp Entities to Ground sandcastle a bit to showcase available options.

Testing Plan:

TODO:

  • Unit tests
  • Update CHANGES.md
  • Confirm 2D/CV mode
  • Sandcastle thumbnails

@cesium-concierge
Copy link

Thanks for the pull request @ggetz!

  • ❕ There was an error checking the CLA! If this is your first contribution, please send in a Contributor License Agreement.
    • Maintainers, this was the error I ran into while attempting to process the CLA check. Please resolve it to continue CLA checking.
    • You'll need to manually check for a submitted CLA
    Error: The service is currently unavailable.
    
  • CHANGES.md was not updated.
    • If this change updates the public API in any way, please add a bullet point to CHANGES.md.
  • ❔ 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.

@ptrgags
Copy link
Contributor

ptrgags commented Dec 22, 2023

In #11655 it was pointed out that this PR might need to account for vertical exaggeration, see #11655 (comment)

@ggetz ggetz marked this pull request as ready for review January 4, 2024 20:31
@ggetz
Copy link
Contributor Author

ggetz commented Jan 12, 2024

@jjspace Would you mind taking a pass on this PR? The 3D-specific work was done in #11581. This mostly wires up a new API for clamping entities to 3D Tiles, and updates or adds Sandcastles showing the functionality.

@jjspace
Copy link
Contributor

jjspace commented Jan 12, 2024

For some reason the "Clamp Entities to Ground" example on the top of the mountain runs at 1-2 fps and even locks up the editor side. I only notice it in that example so far
2024-01-12_16-09

Copy link
Contributor

@jjspace jjspace left a comment

Choose a reason for hiding this comment

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

Had a couple comments in addition to the performance issue above.

I only got about halfway through the code and will finish up the rest on monday but wanted to leave these so you can start on them

CHANGES.md Show resolved Hide resolved
packages/engine/Source/DataSources/ModelVisualizer.js Outdated Show resolved Hide resolved
@ggetz
Copy link
Contributor Author

ggetz commented Jan 16, 2024

For some reason the "Clamp Entities to Ground" example on the top of the mountain runs at 1-2 fps and even locks up the editor side. I only notice it in that example so far

@jjspace This should be addressed. The root of the issue was a missing flag due to a bad merge. Additionally, I further optimized the 3D Tiles picking function by sorting the bounding sphere before reading any mesh data.

Copy link
Contributor

@jjspace jjspace left a comment

Choose a reason for hiding this comment

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

I can confirm that the horrible framerate on the entities sandcastle seems fixed. I reviewed the rest of the code and think it all looks good apart from a few typos I spotted. I would appreciate a second glance through this though as I'm still newer to this area of the code.

I did re-run through the testing plan though and found an issue when changing view types. When switching between 2D and CV there's a "normalized result is not a number" error getting thrown. It doesn't happen when going from 3D to CV, only 2D -> CV

simplescreenrecorder-2024-01-16_17.17.02.mp4

packages/engine/Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Outdated Show resolved Hide resolved
@ggetz
Copy link
Contributor Author

ggetz commented Jan 17, 2024

I did re-run through the testing plan though and found an issue when changing view types. When switching between 2D and CV there's a "normalized result is not a number" error getting thrown. It doesn't happen when going from 3D to CV, only 2D -> CV

Good catch @jjspace. This is because an existing issue in the camera is causing the camera height to be set to NaN. That's outside of the scope of this PR, but we can apply a common workaround by temporarily skipping this scope while the scene is morphing.

Thanks for your review @jjspace!

@ptrgags Would you mind doing a final pass and merge if everything is good?

@ptrgags
Copy link
Contributor

ptrgags commented Jan 17, 2024

@ggetz I'm trying out the Sandcastles first before I look at the code. I'm noticing a couple things in the Clamp Entities to Ground Sandcastle:

  1. When I switch the first dropdown from 3D Tiles -> Terrain, the drawn entity disappears. When I adjust the second dropdown, then it works again.
    image
  2. (a little tricky to reproduce) When I switch to Terrain, then select something else in the second dropdown (e.g. Draw Polyline), then slowly cycle through the dropdown options quickly (I was using the up arrow key), when I get back to "Draw Point with Label", the text doesn't line up with the bilboard, but then when I zoom out it lines up again. I'm guessing it's a race condition due to swapping assets in/out of the scene while they are still partially loaded?
    2024-01-17_RaceCondition
    2024-01-17_TheCuriousFloatingText.

@ptrgags
Copy link
Contributor

ptrgags commented Jan 17, 2024

I also tried using Terrain Exaggeration (Sandcastle)

It works, though the scene is very slow until everything loads.

Copy link
Contributor

@ptrgags ptrgags left a comment

Choose a reason for hiding this comment

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

@ggetz I had some minor comments and questions, but overall this is looking good

packages/engine/Source/Scene/HeightReference.js Outdated Show resolved Hide resolved
});

it("changing height reference works", function () {
return loadAndZoomToModelAsync(
it("changing height reference works", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test and another one in this file is failing locally:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I'm not able to reproduce this locally in the command line or in the browser.

packages/engine/Source/Scene/Model/Model.js Show resolved Hide resolved
packages/engine/Source/Scene/Model/Model.js Show resolved Hide resolved
packages/engine/Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
packages/engine/Source/Scene/Scene.js Show resolved Hide resolved
@ggetz
Copy link
Contributor Author

ggetz commented Jan 19, 2024

Thanks @ptrgags! Your comments should be addressed.

(a little tricky to reproduce) When I switch to Terrain, then select something else in the second dropdown (e.g. Draw Polyline), then slowly cycle through the dropdown options quickly (I was using the up arrow key), when I get back to "Draw Point with Label", the text doesn't line up with the bilboard, but then when I zoom out it lines up again. I'm guessing it's a race condition due to swapping assets in/out of the scene while they are still partially loaded?

From what I can tell, this is an existing issue with clamping to terrain and would be outside of the scope of this PR

@ggetz
Copy link
Contributor Author

ggetz commented Jan 22, 2024

@jjspace I believe all the feedback here has been addressed. OK to merge?

@ggetz
Copy link
Contributor Author

ggetz commented Jan 29, 2024

@jjspace Bump?

@jjspace
Copy link
Contributor

jjspace commented Jan 29, 2024

@ggetz It mostly looks good, I did spot a small issue in the sandcastles

The Clamp Entities sandcastle isn't loading the google tiles correctly it seems. This then prevents switching between terrain and 3d tiles in the viewer.

2024-01-29_14-45

Actually it seems like something else weird is going on here and all sandcastles seem to be running twice every time...? note the double options

2024-01-29_14-51

I'm observing this on main too so maybe something on my end?

@ggetz
Copy link
Contributor Author

ggetz commented Jan 29, 2024

@jjspace In this example?

@ggetz
Copy link
Contributor Author

ggetz commented Jan 29, 2024

image

I'm also not seeing the double options.

@jjspace
Copy link
Contributor

jjspace commented Jan 29, 2024

@ggetz it seems like the double run might be a problem with my extensions because running in the chrome guest profile doesn't make it happen. I have no idea why any of them would cause that but I'll have to investigate later. interestingly it only happens locally and in that ci link, not the deployed version of sandcastle...
(Edit: super weird but it seems to be a Bitwarden issue, will try and follow up with them)

I am seeing some test errors when running locally though. Not sure why CI didn't catch them.

2024-01-29_15-57

I confirmed I see the fog one in main too so that's not related to this branch but the height reference one is only on this branch.
The tests also ran into that "error in afterAll" error after switching branches until I ran npm i again, not sure what that's about but will have to keep an eye on it

@ggetz
Copy link
Contributor Author

ggetz commented Jan 31, 2024

Thanks @jjspace, that should fix the failing spec. I'll make sure an issue is open for the others, but there's no need for those to hold up this PR.

@jjspace
Copy link
Contributor

jjspace commented Jan 31, 2024

Confirmed that test no longer fails on my system, thanks

@jjspace jjspace merged commit 8273efc into main Jan 31, 2024
9 checks passed
@jjspace jjspace deleted the 3d-tiles-height-reference branch January 31, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants