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

Merge pull request #119 from liberostelios/feature/calculate-errors-empty

Add option to show empty tiles
Garrett Johnson 4 роки тому
батько
коміт
963208cffe

+ 17 - 1
TESTCASES.md

@@ -274,7 +274,7 @@ Verify no errors are logged.
 
 Verify that the stats display 125 geometries, 126 textures, and 1 programs.
 
-## Verify maxDepth limit does not stop at empty tiles
+## Verify stopAtEmptyTiles works
 
 #### steps
 
@@ -283,6 +283,20 @@ Verify that the stats display 125 geometries, 126 textures, and 1 programs.
 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 all tiles disappear.
+
+#### expected
+
+No tiles are visible when the active leafs have no content.
+
+## Verify maxDepth limit does not stop at empty tiles when stopAtEmptyTiles = false
+
+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. Disable `stopAtEmptyTiles`.
+1. Set `maxDepth` to 1.
 1. Verify that 4 tiles are visible.
 
 #### expected
@@ -298,6 +312,8 @@ The next shallowest tiles are visible past the `maxDepth` cutoff.
 1. Set `errorTarget` to 0.
 1. Set `maxDepth` to 3.
 1. Set `colorMode` to `RANDOM_COLOR`.
+1. Verify that one tile is missing.
+1. Disable `stopAtEmptyTiles`.
 1. Verify that there are four smaller tiles compared to the rest of the tileset where the missing midtile with content is.
 
 #### expected

+ 3 - 0
example/index.js

@@ -58,6 +58,7 @@ let params = {
 	'errorThreshold': 60,
 	'maxDepth': 15,
 	'loadSiblings': true,
+	'stopAtEmptyTiles': true,
 	'displayActiveTiles': false,
 	'resolutionScale': 1.0,
 
@@ -231,6 +232,7 @@ function init() {
 
 	const tileOptions = gui.addFolder( 'Tiles Options' );
 	tileOptions.add( params, 'loadSiblings' );
+	tileOptions.add( params, 'stopAtEmptyTiles' );
 	tileOptions.add( params, 'displayActiveTiles' );
 	tileOptions.add( params, 'errorTarget' ).min( 0 ).max( 50 );
 	tileOptions.add( params, 'errorThreshold' ).min( 0 ).max( 1000 );
@@ -442,6 +444,7 @@ function animate() {
 	tiles.errorTarget = params.errorTarget;
 	tiles.errorThreshold = params.errorThreshold;
 	tiles.loadSiblings = params.loadSiblings;
+	tiles.stopAtEmptyTiles = params.stopAtEmptyTiles;
 	tiles.displayActiveTiles = params.displayActiveTiles;
 	tiles.maxDepth = params.maxDepth;
 	tiles.displayBoxBounds = params.displayBoxBounds;

+ 1 - 0
src/base/TilesRendererBase.d.ts

@@ -11,6 +11,7 @@ export class TilesRendererBase {
 	loadSiblings : Boolean;
 	displayActiveTiles : Boolean;
 	maxDepth : Number;
+	stopAtEmptyTiles : Boolean;
 
 	fetchOptions : Object;
 

+ 1 - 0
src/base/TilesRendererBase.js

@@ -70,6 +70,7 @@ export class TilesRendererBase {
 		this.loadSiblings = true;
 		this.displayActiveTiles = false;
 		this.maxDepth = Infinity;
+		this.stopAtEmptyTiles = true;
 
 	}
 

+ 2 - 1
src/base/traverseFunctions.js

@@ -118,6 +118,7 @@ export function determineFrustumSet( tile, renderer ) {
 	const maxDepth = renderer.maxDepth;
 	const loadSiblings = renderer.loadSiblings;
 	const lruCache = renderer.lruCache;
+	const stopAtEmptyTiles = renderer.stopAtEmptyTiles;
 	resetFrameState( tile, frameCount );
 
 	// Early out if this tile is not within view.
@@ -135,7 +136,7 @@ export function determineFrustumSet( tile, renderer ) {
 	stats.inFrustum ++;
 
 	// Early out if this tile has less error than we're targeting.
-	if ( ! tile.__contentEmpty ) {
+	if ( stopAtEmptyTiles || ! tile.__contentEmpty ) {
 
 		const error = renderer.calculateError( tile );
 		tile.__error = error;

+ 1 - 1
src/utilities/FeatureTable.js

@@ -55,7 +55,7 @@ export class FeatureTable {
 			const featureType = feature.type || defaultType;
 			const featureComponentType = feature.componentType || defaultComponentType;
 
-			if ( 'type' in feature && defaultType && feature.type !== defaultType) {
+			if ( 'type' in feature && defaultType && feature.type !== defaultType ) {
 
 				throw new Error( 'FeatureTable: Specified type does not match expected type.' );