Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the empty traversal algorithm to match CesiumJS, possible fix for low-res flickering #2847

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions modules/tiles/src/tileset/tileset-traverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,38 +335,35 @@ export class TilesetTraverser {
executeEmptyTraversal(root: Tile3D, frameState: FrameState): boolean {
let allDescendantsLoaded = true;
const stack = this._emptyTraversalStack;

stack.push(root);

while (stack.length > 0 && allDescendantsLoaded) {
while (stack.length > 0) {
const tile = stack.pop();

const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, false);
const emptyLeaf = !tile.hasRenderableContent && tile.children.length === 0;

// Traversal stops but the tile does not have content yet
// There will be holes if the parent tries to refine to its children, so don't refine
// One exception: a parent may refine even if one of its descendants is an empty leaf
if (!traverse && !tile.contentAvailable && !emptyLeaf) {
allDescendantsLoaded = false;
}

this.updateTile(tile, frameState);

if (!tile.isVisibleAndInRequestVolume) {
// Load tiles that aren't visible since they are still needed for the parent to refine
this.loadTile(tile, frameState);
this.touchTile(tile, frameState);
}

this.touchTile(tile, frameState);

// Only traverse if the tile is empty - traversal stop at descendants with content
const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);

if (traverse) {
const children = tile.children;
for (const child of children) {
// eslint-disable-next-line max-depth
if (stack.find(child)) {
stack.delete(child);
}
stack.push(child);
}
} else if (!tile.contentAvailable && !tile.hasEmptyContent) {
allDescendantsLoaded = false;
}
}

return allDescendantsLoaded;
}
}
Loading