question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Globe picking is very slow

See original GitHub issue

The current approach for globe picking is intersect the ray against all rendered tiles (using their bounding spheres) and sort the intersected tiles by closeness to ray. Then, for the closest tile do ray-triangle intersection tests against all of its triangles and return the closest. If there was none, test the next tile. And repeat.

This could be optimized some more. ScreenSpaceCameraController does one or two globe picks per frame and that alone can slow down Cesium severely with detailed terrain providers like ArcGIS.

Some ideas on how to improve this:

  • Custom intersection test for heightmap providers since we know their triangles are on a grid
  • Per-tile octree for non-heightmap providers (too slow to generate?)
  • Remove TerrainEncoding quantization for faster position decode from vertex buffer (only affects nearby tiles)
  • Cache recently used triangles in a form that makes future picks faster, maybe by pre-calculating some of the math from IntersectionTests.rayTriangleParametric.
  • Unroll picking math

Sandcastle (console prints how long each pick takes with left click). Select ArcGIS from the dropdown for some seriously slow speeds.

WIP branch

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
IanLilleyTcommented, Aug 4, 2020

Those two optimization ideas are good. I agree with the plan to optimize the JS version first, and then convert to WebAssembly if necessary. And yeah, draco is the only one so far. So then it’s a matter of deciding what programming language to use, etc, etc and may involve input from other team members. So that’s more for the distant future, even though I think it could speed things up a decent amount.

Make a different version of addTriangles that is faster for heightmaps (and doesn’t need triangleVerticesCallback.

I’d like to avoid calling triangleVerticesCallback for every triangle by instead passing a vertex grid directly to a new function called addTrianglesFromHeightmap. Currently triangleVerticesCallback inside HeightmapTessellator figures out the vertex index from the triangle index, but it’s not very optimized.

I’m in the same situation as you, only able to work on this in my spare time. I want to get back to this in around 2-3 weeks, but even then I’m not positive. I’ll give an update then.

1reaction
OmarShehatacommented, Dec 20, 2019

This actually came up twice this week on the forum:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Arcgis tile terrain make my globe is super slow
When i use ArcGIS Tiled Terrain my globe is being super slow. Super low frame almost 2~3 fps. But just change terrain to...
Read more >
Speeding up pickables, lots and lots of ... - WorldWind Forum
I have been analyzing ways to speed up performance and the biggest slow down right now is picking. If I disable picking on...
Read more >
Why Your Internet Slows Down at Night (and How to Fix It)
Slower internet speeds at night are often the due to network congestion. Just like rush hour traffic, when everyone uses the internet at...
Read more >
how to use watering globes (we tested for ourselves)
As the water trickles out, a weak vacuum is formed within the globe, stopping too much water from escaping at once. As the...
Read more >
Everything I know about slow and steady living, I learned ...
Have a story to tell? See our guidelines at tgam.ca/essayguide. The Globe and Mail.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found