Переглянути джерело

Allow the files to gracefully fail

Garrett Johnson 5 роки тому
батько
коміт
11064d2dd0
2 змінених файлів з 20 додано та 3 видалено
  1. 16 0
      src/base/TilesRendererBase.js
  2. 4 3
      src/base/traverseFunctions.js

+ 16 - 0
src/base/TilesRendererBase.js

@@ -55,6 +55,7 @@ export class TilesRendererBase {
 		this.stats = {
 			parsing: 0,
 			downloading: 0,
+			failed: 0,
 			inFrustum: 0,
 			used: 0,
 			active: 0,
@@ -426,6 +427,21 @@ export class TilesRendererBase {
 
 				if ( e.name !== 'AbortError' ) {
 
+					parseQueue.remove( tile );
+					downloadQueue.remove( tile );
+
+					if ( tile.__loadingState === PARSING ) {
+
+						stats.parsing --;
+
+					} else if ( tile.__loadingState === LOADING ) {
+
+						stats.downloading --;
+
+					}
+
+					stats.failed ++;
+
 					console.error( 'TilesRenderer : Failed to load tile.' );
 					console.error( e );
 					tile.__loadingState = FAILED;

+ 4 - 3
src/base/traverseFunctions.js

@@ -1,4 +1,4 @@
-import { LOADED } from './constants.js';
+import { LOADED, FAILED } from './constants.js';
 
 // Checks whether this tile was last used on the given frame.
 function isUsedThisFrame( tile, frameCount ) {
@@ -195,7 +195,8 @@ export function markUsedSetLeaves( tile, renderer ) {
 
 			if ( isUsedThisFrame( c, frameCount ) ) {
 
-				const childLoaded = ( ! c.__contentEmpty && c.__loadingState === LOADED ) || c.__allChildrenLoaded;
+				const childContentLoaded = c.__loadingState === LOADED || c.__loadingState === FAILED;
+				const childLoaded = ( ! c.__contentEmpty && childContentLoaded ) || c.__allChildrenLoaded;
 				allChildrenLoaded = allChildrenLoaded && childLoaded;
 
 			}
@@ -253,7 +254,7 @@ export function skipTraversal( tile, renderer ) {
 	const errorRequirement = ( renderer.errorTarget + 1 ) * renderer.errorThreshold;
 	const meetsSSE = tile.__error <= errorRequirement;
 	const hasContent = ! tile.__contentEmpty;
-	const loadedContent = tile.__loadingState === LOADED && ! tile.__contentEmpty;
+	const loadedContent = ( tile.__loadingState === LOADED || tile.__loadingState === FAILED ) && ! tile.__contentEmpty;
 	const childrenWereVisible = tile.__childrenWereVisible;
 	const children = tile.children;
 	let allChildrenHaveContent = tile.__allChildrenLoaded;