Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support rendering the load order of tiles #429

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading