Skip to content

fix: clustering with empty entity labels#13365

Open
pandeysambhi wants to merge 2 commits intoCesiumGS:mainfrom
pandeysambhi:issue/13361
Open

fix: clustering with empty entity labels#13365
pandeysambhi wants to merge 2 commits intoCesiumGS:mainfrom
pandeysambhi:issue/13361

Conversation

@pandeysambhi
Copy link
Copy Markdown

Description

Entities that use clustering (for example KML pins with billboards) and also define a label with empty text (label: { text: '' }) stopped forming clusters: only the underlying primitives appeared. EntityCluster unions each billboard’s screen-space bounds with its companion label’s bounds from Label.getScreenSpaceBoundingBox. For empty text, with no background and no glyphs, that function previously left x/y as Infinity and non-finite or negative width/height. BoundingRectangle.union then produced NaN, which broke the spatial index used for clustering.

Change:
After computing width and height from glyphs or background, if any of x, y, width, or height is not finite, or if width or height is negative, the result is reset to a zero-size rectangle at the given screen-space position (center). That keeps clustering stable for “invisible” labels while preserving behavior for normal labels.

Tests:
Regression coverage in LabelCollectionSpec (empty text bounding box) and EntityClusterSpec (two billboards at the same position with empty labels, waiting on billboard collection readiness).

Issue number and link

Fixes #13361Clustering no longer works when assigning a label to datasource entities

Testing plan

  1. Reproduce (pre-fix): Sandcastle clustering example + dataSource.entities.values loop setting entity.label = new Cesium.LabelGraphics({ text: '' }) (or equivalent); clustering fails to show cluster labels / behaves as in the issue.
  2. Verify (post-fix): Same scenario; clusters form as before.
  3. Automated:
    • npm run eslint -- packages/engine/Source/Scene/Label.js packages/engine/Specs/DataSources/EntityClusterSpec.js packages/engine/Specs/Scene/LabelCollectionSpec.js
    • npm run test -- --includeName EntityCluster
    • npm run test -- --includeName "empty text without background"

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

AI acknowledgment

  • I used AI to generate content in this PR
  • If yes, I have reviewed the AI-generated content before submitting

If yes, I used the following Tools(s) and/or Service(s):

Cursor (AI-assisted editing and review)

If yes, I used the following Model(s):

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

Thank you for the pull request, @pandeysambhi! Welcome to the Cesium community!

In order for us to review your PR, please complete the following steps:

Review Pull Request Guidelines to make sure your PR gets accepted quickly.

@pandeysambhi
Copy link
Copy Markdown
Author

Thank you for the pull request, @pandeysambhi! Welcome to the Cesium community!

In order for us to review your PR, please complete the following steps:

Review Pull Request Guidelines to make sure your PR gets accepted quickly.

@lukemckinstry
Copy link
Copy Markdown
Contributor

Thanks for submitting @pandeysambhi to kickoff work on this bug.

I do see some flashing with this implementation as shown in this screen capture. I'm not immediately sure what is happening here but we should aim for a the smoother appearance like we see when label text is applied.

Screencast.from.2026-04-07.16-18-14.mp4

@lukemckinstry lukemckinstry added the needs feedback On hold until additional info is supplied label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs feedback On hold until additional info is supplied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clustering no longer works when assigning a label to datasource entities

2 participants