From 44f1d9692e58a125bede763f5ecc6e188987e466 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 14 Aug 2024 14:36:13 +0900 Subject: [PATCH 1/5] Traversal: Lazy error calculation --- src/base/traverseFunctions.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/base/traverseFunctions.js b/src/base/traverseFunctions.js index 988c94c4d..f83b8461c 100644 --- a/src/base/traverseFunctions.js +++ b/src/base/traverseFunctions.js @@ -13,6 +13,20 @@ function isUsedThisFrame( tile, frameCount ) { } +// Lazily get error +function getError( tile, renderer ) { + + if ( tile.__errorGeneratedFrame !== renderer.frameCount ) { + + tile.__errorGeneratedFrame = renderer.frameCount; + renderer.calculateError( tile ); + + } + + return tile.__error; + +} + // Resets the frame frame information for the given tile function resetFrameState( tile, renderer ) { @@ -111,7 +125,7 @@ function markUsed( tile, renderer ) { function canTraverse( tile, renderer ) { // If we've met the error requirements then don't load further - if ( tile.__error <= renderer.errorTarget ) { + if ( getError( tile, renderer ) <= renderer.errorTarget ) { return false; @@ -319,7 +333,7 @@ export function markVisibleTiles( tile, renderer ) { const hasContent = tile.__hasContent; const loadedContent = isDownloadFinished( tile.__loadingState ) && hasContent; const errorRequirement = ( renderer.errorTarget + 1 ) * renderer.errorThreshold; - const meetsSSE = tile.__error <= errorRequirement; + const meetsSSE = getError( tile, renderer ) <= errorRequirement; const childrenWereVisible = tile.__childrenWereVisible; // we don't wait for all children tiles to load if this tile set has empty tiles at the root From 8ab3b42a46a163c68b7e72e872b7736b76957ded Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 14 Aug 2024 14:45:22 +0900 Subject: [PATCH 2/5] Remove unneeded lines, ensure error is always generated if a tile is being loaded --- src/base/traverseFunctions.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base/traverseFunctions.js b/src/base/traverseFunctions.js index f83b8461c..ed7c60820 100644 --- a/src/base/traverseFunctions.js +++ b/src/base/traverseFunctions.js @@ -16,9 +16,8 @@ function isUsedThisFrame( tile, frameCount ) { // Lazily get error function getError( tile, renderer ) { - if ( tile.__errorGeneratedFrame !== renderer.frameCount ) { + if ( tile.__error === Infinity ) { - tile.__errorGeneratedFrame = renderer.frameCount; renderer.calculateError( tile ); } @@ -45,7 +44,6 @@ function resetFrameState( tile, renderer ) { // update tile frustum and error state tile.__inFrustum = renderer.tileInView( tile ); - renderer.calculateError( tile ); } @@ -100,6 +98,7 @@ function recursivelyLoadNextRenderableTiles( tile, renderer ) { } else { + getError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -321,6 +320,7 @@ export function markVisibleTiles( tile, renderer ) { } else if ( ! lruCache.isFull() && tile.__hasContent ) { + getError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -344,6 +344,7 @@ export function markVisibleTiles( tile, renderer ) { const includeTile = meetsSSE || tile.refine === 'ADD'; if ( includeTile && ! loadedContent && ! lruCache.isFull() && hasContent ) { + getError( tile, renderer ); renderer.requestTileContents( tile ); } From 22b2c5a3e29851b51fc0ea8270ed56981d8e15db Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 14 Aug 2024 16:35:39 +0900 Subject: [PATCH 3/5] rename function --- src/base/traverseFunctions.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/base/traverseFunctions.js b/src/base/traverseFunctions.js index ed7c60820..86961c911 100644 --- a/src/base/traverseFunctions.js +++ b/src/base/traverseFunctions.js @@ -14,7 +14,7 @@ function isUsedThisFrame( tile, frameCount ) { } // Lazily get error -function getError( tile, renderer ) { +function generateError( tile, renderer ) { if ( tile.__error === Infinity ) { @@ -22,8 +22,6 @@ function getError( tile, renderer ) { } - return tile.__error; - } // Resets the frame frame information for the given tile @@ -98,7 +96,7 @@ function recursivelyLoadNextRenderableTiles( tile, renderer ) { } else { - getError( tile, renderer ); + generateError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -124,7 +122,8 @@ function markUsed( tile, renderer ) { function canTraverse( tile, renderer ) { // If we've met the error requirements then don't load further - if ( getError( tile, renderer ) <= renderer.errorTarget ) { + generateError( tile, renderer ); + if ( tile.__error <= renderer.errorTarget ) { return false; @@ -303,6 +302,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 ) { @@ -320,7 +321,7 @@ export function markVisibleTiles( tile, renderer ) { } else if ( ! lruCache.isFull() && tile.__hasContent ) { - getError( tile, renderer ); + generateError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -333,7 +334,7 @@ export function markVisibleTiles( tile, renderer ) { const hasContent = tile.__hasContent; const loadedContent = isDownloadFinished( tile.__loadingState ) && hasContent; const errorRequirement = ( renderer.errorTarget + 1 ) * renderer.errorThreshold; - const meetsSSE = getError( tile, renderer ) <= errorRequirement; + const meetsSSE = tile.__error <= errorRequirement; const childrenWereVisible = tile.__childrenWereVisible; // we don't wait for all children tiles to load if this tile set has empty tiles at the root @@ -344,7 +345,7 @@ export function markVisibleTiles( tile, renderer ) { const includeTile = meetsSSE || tile.refine === 'ADD'; if ( includeTile && ! loadedContent && ! lruCache.isFull() && hasContent ) { - getError( tile, renderer ); + generateError( tile, renderer ); renderer.requestTileContents( tile ); } From a586f8c17ec40132da0f0e1c6321f1ea77857f79 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 14 Aug 2024 16:41:41 +0900 Subject: [PATCH 4/5] Comment --- src/base/traverseFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/traverseFunctions.js b/src/base/traverseFunctions.js index 86961c911..e6e0ae669 100644 --- a/src/base/traverseFunctions.js +++ b/src/base/traverseFunctions.js @@ -13,7 +13,7 @@ function isUsedThisFrame( tile, frameCount ) { } -// Lazily get error +// Lazily generate error function generateError( tile, renderer ) { if ( tile.__error === Infinity ) { From 444d399b40a5ae48fbb6dde09019ebe1436ecf0f Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Wed, 14 Aug 2024 18:35:40 +0900 Subject: [PATCH 5/5] Remove calls before request --- src/base/traverseFunctions.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/base/traverseFunctions.js b/src/base/traverseFunctions.js index e6e0ae669..129aedcc3 100644 --- a/src/base/traverseFunctions.js +++ b/src/base/traverseFunctions.js @@ -96,7 +96,6 @@ function recursivelyLoadNextRenderableTiles( tile, renderer ) { } else { - generateError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -321,7 +320,6 @@ export function markVisibleTiles( tile, renderer ) { } else if ( ! lruCache.isFull() && tile.__hasContent ) { - generateError( tile, renderer ); renderer.requestTileContents( tile ); } @@ -345,7 +343,6 @@ export function markVisibleTiles( tile, renderer ) { const includeTile = meetsSSE || tile.refine === 'ADD'; if ( includeTile && ! loadedContent && ! lruCache.isFull() && hasContent ) { - generateError( tile, renderer ); renderer.requestTileContents( tile ); }