8000
Skip to content

Conversation

@plainheart
Copy link
Contributor
@plainheart plainheart commented Dec 15, 2025

Description

Fix the bug that sampleHeightMostDetailed can not get height from a tileset that is added to the scene.primitives by a primitive collection. This bug was originally reported in the community 4 years ago.

Possible Cause:

if (tileset.show && scene.primitives.contains(tileset)) {

Here we can know scene.primitives.contains(tileset) will return false when the tileset is added by primitive collection - That is not expected, and causes the height sample to fail.

Here is a comment that says:

// Only update tilesets that are still contained in the scene's primitive collection and are still visible
// Update tilesets continually until all tilesets are ready. This way tiles are never removed from the cache.

But we can know the tilesets are already collected from the scene.primitives from the following function (Line 1070):

function launchMostDetailedRayPick(
picking,
scene,
ray,
objectsToExclude,
width,
callback,
) {
const tilesets = [];
getTilesets(scene.primitives, objectsToExclude, tilesets);
if (tilesets.length === 0) {
return Promise.resolve(callback());
}
const rayPick = new MostDetailedRayPick(ray, width, tilesets);
picking._mostDetailedRayPicks.push(rayPick);
return rayPick.promise.then(function () {
return callback();
});
}

So I think we can remove the scene.primitives.contains(tileset) check to make the sample work, or consider adding a new function to check whether a tileset is in scene.primitives to replace this check?

Comparison

Before After
After Before

Issue number and link

Fix https://community.cesium.com/t/clamptoheightmostdetailed-get-the-elevation-problem/15056

Sandcastle

https://sandcastle.cesium.com/#c=7VVRa9swEP4rh5/cEeSV9KVdElbSwQodC7SsD/MeFPsSi8mSkWSHrOS/72xZTUIcBmNjL/OLrdN9d999d4dFWWnj4A1wC3O0oi5hZXQJaZR1pzR6l6pUZVpZB43ADRqYgsJN782+dLY4+M+1clwoNGl00SGTBJ65ywpwBQLdWi0RdO2q2qXK1Cr2btxuVQarWmVOaAXdBbykCoBvuHDA8/xJSLToOsCp+Vm4YmFEKZxocK6lxC5S570byHAY0Cfy1TGboUJWhVCWGSx1g7dS9lQBvBrOw0kOz6UXxL/Gd3101sp5r9WtpcN9Ho+vrsbXl9e+iHMpiVzchz9yXMntkw43I3iBvDa8LecG3sIu0PN02h4tKLewGMcGSfcGL2A688VCoM+EoqRcdnQfNM8xb9N/aFC5B2EdMTOx1y4+hAcVKpF9X2grOlGnryJw4/Ta8KoQWadAa6ArruIA3zNY6lrlQq0fqwINMhLDoRkFPy9A+/i6jjSzvKwkfkSxLtwnbd0d0vRJzOOvh7y+7WNkfgKZ1OsDJmm0IHfMoegiwYaGCSxRolkNbX5tz00ajfbQwzzMwweo9/rHwbLzH7tfT+fZuf69oa1OQx3v87kd+oNTP8Dh7MQPrsZAgP9r8q/W5GQ/CBy68hdWJRpFE+u2Emet9b3w/6/ayJixxCHVyUnBZFkTUccya1vcJAmQSS4aEPl04H8FmeTW0s2qlvJR/MA0mk0S8j+CSeo9NeFzg0bybetSXM4evJExNknoeIpyWsslNwcRfwI

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

@github-actions
Copy link

Thank you for the pull request, @plainheart!

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

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.

1 participant

0