Skip to content

Commit

Permalink
Add support rendering the load order of tiles (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson authored Dec 22, 2023
1 parent 12a62e9 commit 7ea052a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
4 changes: 3 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RANDOM_COLOR,
RANDOM_NODE_COLOR,
CUSTOM_COLOR,
LOAD_ORDER,
GLTFCesiumRTCExtension,
} from '../src/index.js';
import {
Expand Down Expand Up @@ -284,7 +285,8 @@ function init() {
IS_LEAF,
RANDOM_COLOR,
RANDOM_NODE_COLOR,
CUSTOM_COLOR
CUSTOM_COLOR,
LOAD_ORDER,

} );
debug.open();
Expand Down
14 changes: 1 addition & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
export {
DebugTilesRenderer,
NONE,
SCREEN_ERROR,
GEOMETRIC_ERROR,
DISTANCE,
DEPTH,
RELATIVE_DEPTH,
IS_LEAF,
RANDOM_COLOR,
RANDOM_NODE_COLOR,
CUSTOM_COLOR,
} from './three/DebugTilesRenderer.js';
export * from './three/DebugTilesRenderer.js';

export { TilesRenderer } from './three/TilesRenderer.js';
export { B3DMLoader } from './three/B3DMLoader.js';
Expand Down
28 changes: 28 additions & 0 deletions src/three/DebugTilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EllipsoidRegionLineHelper } from './objects/EllipsoidRegionHelper.js';
const ORIGINAL_MATERIAL = Symbol( 'ORIGINAL_MATERIAL' );
const HAS_RANDOM_COLOR = Symbol( 'HAS_RANDOM_COLOR' );
const HAS_RANDOM_NODE_COLOR = Symbol( 'HAS_RANDOM_NODE_COLOR' );
const LOAD_TIME = Symbol( 'LOAD_TIME' );

function emptyRaycast() {}

Expand All @@ -20,6 +21,7 @@ export const IS_LEAF = 6;
export const RANDOM_COLOR = 7;
export const RANDOM_NODE_COLOR = 8;
export const CUSTOM_COLOR = 9;
export const LOAD_ORDER = 10;

const _sphere = new Sphere();
export class DebugTilesRenderer extends TilesRenderer {
Expand Down Expand Up @@ -214,6 +216,17 @@ export class DebugTilesRenderer extends TilesRenderer {
const errorTarget = this.errorTarget;
const colorMode = this.colorMode;
const visibleTiles = this.visibleTiles;
let sortedTiles;
if ( colorMode === LOAD_ORDER ) {

sortedTiles = Array.from( visibleTiles ).sort( ( a, b ) => {

return a[ LOAD_TIME ] - b[ LOAD_TIME ];

} );

}

visibleTiles.forEach( tile => {

const scene = tile.cached.scene;
Expand Down Expand Up @@ -377,6 +390,13 @@ export class DebugTilesRenderer extends TilesRenderer {
break;

}
case LOAD_ORDER: {

const value = sortedTiles.indexOf( tile );
this.getDebugColor( value / ( sortedTiles.length - 1 ), c.material.color );
break;

}

}

Expand All @@ -388,6 +408,14 @@ export class DebugTilesRenderer extends TilesRenderer {

}

parseTile( buffer, tile, ext ) {

tile[ LOAD_TIME ] = performance.now();

return super.parseTile( buffer, tile, ext );

}

setTileVisible( tile, visible ) {

super.setTileVisible( tile, visible );
Expand Down

0 comments on commit 7ea052a

Please sign in to comment.