CesiumGS / CesiumGS/cesium

Polyline `clampToGround` performance penalty when idle, unnecessary

Open
#9,533 6 comments 0 reactions 0 assignees View on GitHub
category - graphics category - polygons/geometry
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

[Sandcastle example](https://sandcastle.cesium.com/#c=vZRLj9owEMe/yiinpOwa0IoLL3ULbS9bdVVQL80eTDKAqWMj2wGyFd+9NgnBsAi1qlRFih/zm4c9/2RDFWwYblHBAARuYYSa5Rn5ftgL4yA5rEdSGMoEqjiIerEoPYhOUCBJcZYvJku5/aRohvoZ1QQTKVIb0KgcLe6eeS4Sw6SAVNHts+QFt+F0mHCarSP4FQuAuVQQcjTArGurZ4c+dNzYaFSEx6xKZlUxK48BcMDOAaTVasM7YD3fUniWVW2pzoTCMMNQE5qmYR0QYF2V3AVv021r5o6lu8ebG1Fl7IyKBzJXMhvjQiHqR6VoEf7wXQHu2+0WNGB3Bw8dOxZ3V83hzr4O9UZ/C4bFaedm6j8Gz1O/nNNblpplFzpnmxk1qBjlpwuSXCry7eP4DDsIYSo/K5mLtFsuPWBfz/dR1bK9G+xrXwpsQkWaUG04utaNcU5zbqZS8hlVX1DkocOrBtQtNLgzXYiDsRVlmRNTqNUZB3VW22HkmFi4FnIY+VK4lI/CTG7wkfMw6p2oc/G7z8O3VjFepcymMryIeAKPd3Ecr58mF/f//UBzyvW/n+glFlHvoqUKtf1yB2+LvV3m/hAnuAv62hQch8eE71m2lspArnhISNNgtuZWp7o5y5OfaEii6+r6Td+1n7INsHRw5cfo9KO1tcxzzifsFeNg2G9a/o0rlzRlYvF1g4rTwmHL9vCp3CSE9Jt2ed3TlHq2LseTeDa0/xgmnNYvMvuUa8WH3Bjb/xuUkYsFxye2WBpb0w1QW4VxvB7Qn/8G)

Browser: Chrome latest

Operating System: Win10

I'm manually creating polygon entities from some external data sources, and am using polylines to draw separate outlines for them because of https://github.com/CesiumGS/cesium/issues/8577 et al. This means I wind up with hundreds to thousands of polylines with ~10-30 points. Performance was getting bad, then I noticed that for some reason when I switched from 3D to 2D, the apparent lag was completely fixed.

The linked example creates a grid of 2500 squares. If you pick "un-clamped" from the menu, performance should dip briefly while the initial geometry is computed, then stay at or around 60fps on decent hardware. It might dip down a bit when panning and zooming, but generally is good in both 2D and 3D modes. Pick "clamped", though, and stay in 3D mode, and you're lucky to reach double digits, even when totally idle. Switching to 2D fixes the problem -- maybe the `clampToGround` property is ignored?

I'm not sure exactly what I'm asking to fix here. Of course, with terrain turned off (as in my example), `clampToGround` isn't actually necessary, but I don't want to have to re-declare my entities, or go around updating properties, every time the user toggles terrain on or off. Maybe the "clamping logic" could be disabled when the default (WGS84) terrain provider is in use? The continued penalty strongly suggests that clamping must be performed again on each frame, maybe clamping results could be cached somehow? Alternately, clamping could be event-driven, where collections that own entities with clamped graphics recompute heights only when the containing terrain tile's height data is updated?

Contributor guide

Open the contributing guide

Research direction

Run the linked Sandcastle example in Chrome and compare idle performance for clamped and unclamped polylines in 3D, then check the relevant polyline clamping and terrain-update path. Done means that thousands of clamped polylines no longer impose a persistent idle frame-rate penalty when terrain is disabled or unchanged, while still responding correctly when terrain data changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.