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

Traversal: Lazily compute error #688

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
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
15 changes: 14 additions & 1 deletion src/base/traverseFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ function isUsedThisFrame( tile, frameCount ) {

}

// Lazily generate error
function generateError( tile, renderer ) {

if ( tile.__error === Infinity ) {

renderer.calculateError( tile );

}

}

// Resets the frame frame information for the given tile
function resetFrameState( tile, renderer ) {

Expand All @@ -31,7 +42,6 @@ function resetFrameState( tile, renderer ) {

// update tile frustum and error state
tile.__inFrustum = renderer.tileInView( tile );
renderer.calculateError( tile );

}

Expand Down Expand Up @@ -111,6 +121,7 @@ function markUsed( tile, renderer ) {
function canTraverse( tile, renderer ) {

// If we've met the error requirements then don't load further
generateError( tile, renderer );
if ( tile.__error <= renderer.errorTarget ) {

return false;
Expand Down Expand Up @@ -290,6 +301,8 @@ export function markVisibleTiles( tile, renderer ) {

}

generateError( tile, renderer );

// Request the tile contents or mark it as visible if we've found a leaf.
const lruCache = renderer.lruCache;
if ( tile.__isLeaf ) {
Expand Down
Loading