NASA-AMMOS / 3DTilesRendererJS

Renderer for 3D Tiles in Javascript using three.js
https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/mars.html
Apache License 2.0
1.62k stars 288 forks source link

Re-add children-in-frustum optimization #741

Open gkjohnson opened 1 month ago

gkjohnson commented 1 month ago

In d316413 the check for child visibility has been disabled because it can cause unused children to be added to the lru cache. We should understand why and see if we can add an easy way to check frustum visibility without marking a child as used.

The fundamental issue is that external tile sets are being marked as unused because the children aren't visible, being unloaded, then being marked as used again because there are no children and loading.

Related to #740

gkjohnson commented 1 month ago

Cesium's implementation updates all child frustum and error metrics before marking children as "used":

https://github.com/CesiumGS/cesium/blob/165e0fb4fcc9a448b15de6a2df46db23c71fffda/packages/engine/Source/Scene/Cesium3DTilesetBaseTraversal.js#L111-L126

It's also the case that Cesium does not unload external tile sets: https://github.com/CesiumGS/cesium/blob/165e0fb4fcc9a448b15de6a2df46db23c71fffda/packages/engine/Source/Scene/Cesium3DTile.js#L1423-L1425

gkjohnson commented 1 month ago

In a test the frustum optimization improves the tile visibility from 350 to 323 so it can have quite an impact. With a more shallow approach this loads ~340 tiles on google earth tiles.

The limited approach may be "good" enough - otherwise this requires keeping all tile sub trees in memory.

gkjohnson commented 1 month ago

It's possible we could keep the tile marked as "used" but mark "in frustum" to be false and account for that in the subsequent traversals. This would cause the tiles to still load but at least not be rendered.