Kaynağa Gözat

Merge pull request #106 from NASA-AMMOS/adjust-max-depth-logic

Adjust max depth logic
Garrett Johnson 5 yıl önce
ebeveyn
işleme
973bad11ba

+ 2 - 0
CHANGELOG.md

@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 ### Fixed
 
 - `CMPTLoader` not importing `I3DMLoader`.
+- A case where if the tile at depth `maxDepth` was empty nothing would be rendered.
+- A case where an error was thrown if a mid tile had no content.
 
 ## [0.1.4] - 2020-07-17
 ### Added

+ 1 - 1
README.md

@@ -172,7 +172,7 @@ If `errorThreshold` is set to `Infinity` then all parent tiles will be loaded an
 maxDepth = Infinity : Number
 ```
 
-The max depth to which tiles will be loaded and rendered. Setting it to `1` will only render the root tile.
+The max depth to which tiles will be loaded and rendered. Setting it to `1` will only render the root tile. If the tile at depth `maxDepth` is an empty tile then the next set of visible children will be rendered.
 
 ### .loadSiblings
 

+ 30 - 0
TESTCASES.md

@@ -273,3 +273,33 @@ Verify no errors are logged.
 #### expected
 
 Verify that the stats display 125 geometries, 126 textures, and 1 programs.
+
+## Verify maxDepth limit does not stop at empty tiles
+
+#### steps
+
+1. Open the kitchen sink example by navigating [here](https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/).
+1. Set `maxDepth` to 1.
+1. Verify that only 1 tile is visible.
+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-no-root-content.json).
+1. Set `maxDepth` to 1.
+1. Verify that 4 tiles are visible.
+
+#### expected
+
+The next shallowest tiles are visible past the `maxDepth` cutoff.
+
+## 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-no-midtile-content.json).
+1. Zoom in slowly and verify the tiles load correctly and completely.
+1. Set `errorTarget` to 0.
+1. Set `maxDepth` to 3.
+1. Set `colorMode` to `RANDOM_COLOR`.
+1. Verify that there are four smaller tiles compared to the rest of the tileset where the missing midtile with content is.
+
+#### expected
+
+The tileset renders and loads correctly.

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 0
example/data/tileset-no-midtile-content.json


+ 29 - 5
src/base/traverseFunctions.js

@@ -52,6 +52,30 @@ function recursivelyMarkUsed( tile, frameCount, lruCache ) {
 
 }
 
+function recursivelyLoadTiles( tile, depthFromRenderedParent, renderer ) {
+
+	if ( tile.__contentEmpty ) {
+
+		const children = tile.children;
+		for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+			// don't increment depth to rendered parent here because we should treat
+			// the next layer of rendered children as just a single depth away for the
+			// sake of sorting.
+			const child = children[ i ];
+			child.__depthFromRenderedParent = depthFromRenderedParent;
+			recursivelyLoadTiles( child, depthFromRenderedParent, renderer );
+
+		}
+
+	} else {
+
+		renderer.requestTileContents( tile );
+
+	}
+
+}
+
 // Helper function for recursively traversing a tileset. If `beforeCb` returns `true` then the
 // traversal will end early.
 export function traverseSet( tile, beforeCb = null, afterCb = null, parent = null, depth = 0 ) {
@@ -121,12 +145,12 @@ export function determineFrustumSet( tile, renderer ) {
 
 		}
 
-	}
+		// Early out if we've reached the maximum allowed depth.
+		if ( renderer.maxDepth > 0 && tile.__depth + 1 >= maxDepth ) {
 
-	// Early out if we've reached the maximum allowed depth.
-	if ( renderer.maxDepth > 0 && tile.__depth + 1 >= maxDepth ) {
+			return true;
 
-		return true;
+		}
 
 	}
 
@@ -306,7 +330,7 @@ export function skipTraversal( tile, renderer ) {
 				if ( isUsedThisFrame( c, frameCount ) && ! lruCache.isFull() ) {
 
 					c.__depthFromRenderedParent = tile.__depthFromRenderedParent + 1;
-					renderer.requestTileContents( c );
+					recursivelyLoadTiles( c, c.__depthFromRenderedParent, renderer );
 
 				}