瀏覽代碼

Merge pull request #108 from NASA-AMMOS/add-refinement

Add refinement
Garrett Johnson 5 年之前
父節點
當前提交
5c39ca7161
共有 4 個文件被更改,包括 46 次插入25 次删除
  1. 11 0
      TESTCASES.md
  2. 1 0
      example/data/tileset-add.json
  3. 2 0
      src/base/TilesRendererBase.js
  4. 32 25
      src/base/traverseFunctions.js

+ 11 - 0
TESTCASES.md

@@ -303,3 +303,14 @@ The next shallowest tiles are visible past the `maxDepth` cutoff.
 #### expected
 
 The tileset renders and loads correctly.
+
+## Verify tileset with missing mid tile content loads and renders correctly
+
+#### steps
+
+1. Open the kitchen sink example with the no root content tileset by navigating [here](https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/#../data/tileset-add.json).
+1. Set `colorMode` to `RANDOM_COLOR`.
+
+#### expected
+
+Verify that all tiles render on top of each other including the root and that setting the error target and threshold to 0 does not change this.

文件差異過大導致無法顯示
+ 1 - 0
example/data/tileset-add.json


+ 2 - 0
src/base/TilesRendererBase.js

@@ -192,10 +192,12 @@ export class TilesRendererBase {
 		if ( parentTile === null ) {
 
 			tile.__depth = 0;
+			tile.refine = tile.refine || 'REPLACE';
 
 		} else {
 
 			tile.__depth = parentTile.__depth + 1;
+			tile.refine = tile.refine || parentTile.refine;
 
 		}
 

+ 32 - 25
src/base/traverseFunctions.js

@@ -282,22 +282,23 @@ export function skipTraversal( tile, renderer ) {
 
 	const errorRequirement = ( renderer.errorTarget + 1 ) * renderer.errorThreshold;
 	const meetsSSE = tile.__error <= errorRequirement;
+	const includeTile = meetsSSE || tile.refine === 'ADD';
 	const hasContent = ! tile.__contentEmpty;
-	const loadedContent = isDownloadFinished( tile.__loadingState ) && ! tile.__contentEmpty;
+	const loadedContent = isDownloadFinished( tile.__loadingState ) && hasContent;
 	const childrenWereVisible = tile.__childrenWereVisible;
 	const children = tile.children;
 	let allChildrenHaveContent = tile.__allChildrenLoaded;
 
 	// Increment the relative depth of the node to the nearest rendered parent if it has content
 	// and is being rendered.
-	if ( meetsSSE && hasContent ) {
+	if ( includeTile && hasContent ) {
 
 		tile.__depthFromRenderedParent ++;
 
 	}
 
 	// If we've met the SSE requirements and we can load content then fire a fetch.
-	if ( meetsSSE && ! loadedContent && ! lruCache.isFull() && hasContent ) {
+	if ( includeTile && ! loadedContent && ! lruCache.isFull() && hasContent ) {
 
 		renderer.requestTileContents( tile );
 
@@ -309,44 +310,50 @@ export function skipTraversal( tile, renderer ) {
 	// load in.
 
 	// Skip the tile entirely if there's no content to load
-	if ( meetsSSE && ! allChildrenHaveContent && ! childrenWereVisible && hasContent ) {
+	if (
+			( meetsSSE && ! allChildrenHaveContent && ! childrenWereVisible && loadedContent )
+			|| ( tile.refine === 'ADD' && loadedContent )
+	) {
 
-		if ( loadedContent ) {
+		if ( tile.__inFrustum ) {
 
-			if ( tile.__inFrustum ) {
+			tile.__visible = true;
+			stats.visible ++;
 
-				tile.__visible = true;
-				stats.visible ++;
+		}
+		tile.__active = true;
+		stats.active ++;
 
-			}
-			tile.__active = true;
-			stats.active ++;
+	}
 
-			// load the child content if we've found that we've been loaded so we can move down to the next tile
-			// layer when the data has loaded.
-			for ( let i = 0, l = children.length; i < l; i ++ ) {
+	// If we're additive then don't stop the traversal here because it doesn't matter whether the children load in
+	// at the same rate.
+	if ( tile.refine !== 'ADD' && meetsSSE && ! allChildrenHaveContent && loadedContent ) {
 
-				const c = children[ i ];
-				if ( isUsedThisFrame( c, frameCount ) && ! lruCache.isFull() ) {
+		// load the child content if we've found that we've been loaded so we can move down to the next tile
+		// layer when the data has loaded.
+		for ( let i = 0, l = children.length; i < l; i ++ ) {
 
-					c.__depthFromRenderedParent = tile.__depthFromRenderedParent + 1;
-					recursivelyLoadTiles( c, c.__depthFromRenderedParent, renderer );
+			const c = children[ i ];
+			if ( isUsedThisFrame( c, frameCount ) && ! lruCache.isFull() ) {
 
-				}
+				c.__depthFromRenderedParent = tile.__depthFromRenderedParent + 1;
+				recursivelyLoadTiles( c, c.__depthFromRenderedParent, renderer );
 
 			}
 
 		}
-		return;
 
-	}
+	} else {
 
-	for ( let i = 0, l = children.length; i < l; i ++ ) {
+		for ( let i = 0, l = children.length; i < l; i ++ ) {
 
-		const c = children[ i ];
-		if ( isUsedThisFrame( c, frameCount ) ) {
+			const c = children[ i ];
+			if ( isUsedThisFrame( c, frameCount ) ) {
 
-			skipTraversal( c, renderer );
+				skipTraversal( c, renderer );
+
+			}
 
 		}