Skip to content

Commit

Permalink
example: add toggle to enable/disable DebugTilesPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sguimmara committed Dec 21, 2024
1 parent 7e6ae37 commit cb23fdc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
3 changes: 3 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const params = {
resolutionScale: 1.0,

up: hashUrl ? '+Z' : '+Y',
enableDebug: true,
displayBoxBounds: false,
displaySphereBounds: false,
displayRegionBounds: false,
Expand Down Expand Up @@ -271,6 +272,7 @@ function init() {
tileOptions.open();

const debug = gui.addFolder( 'Debug Options' );
debug.add( params, 'enableDebug' );
debug.add( params, 'displayBoxBounds' );
debug.add( params, 'displaySphereBounds' );
debug.add( params, 'displayRegionBounds' );
Expand Down Expand Up @@ -485,6 +487,7 @@ function animate() {

// update plugin
const plugin = tiles.getPluginByName( 'DEBUG_TILES_PLUGIN' );
plugin.enabled = params.enableDebug;
plugin.displayBoxBounds = params.displayBoxBounds;
plugin.displaySphereBounds = params.displaySphereBounds;
plugin.displayRegionBounds = params.displayRegionBounds;
Expand Down
33 changes: 19 additions & 14 deletions src/plugins/three/DebugTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,25 +708,30 @@ export class DebugTilesPlugin {
dispose() {

const tiles = this.tiles;
tiles.removeEventListener( 'load-tile-set', this._onLoadTileSetCB );
tiles.removeEventListener( 'load-model', this._onLoadModelCB );
tiles.removeEventListener( 'dispose-model', this._onDisposeModelCB );
tiles.removeEventListener( 'update-after', this._onUpdateAfterCB );

// reset all materials
this.colorMode = NONE;
this._onUpdateAfter();
if ( tiles ) {

// dispose of all helper objects
tiles.traverse( tile => {
tiles.removeEventListener( 'load-tile-set', this._onLoadTileSetCB );
tiles.removeEventListener( 'load-model', this._onLoadModelCB );
tiles.removeEventListener( 'dispose-model', this._onDisposeModelCB );
tiles.removeEventListener( 'update-after', this._onUpdateAfterCB );

this._onDisposeModel( tile );
// reset all materials
this.colorMode = NONE;
this._onUpdateAfter();

} );
// dispose of all helper objects
tiles.traverse( tile => {

this._onDisposeModel( tile );

} );

}

this.boxGroup.removeFromParent();
this.sphereGroup.removeFromParent();
this.regionGroup.removeFromParent();
this.boxGroup?.removeFromParent();
this.sphereGroup?.removeFromParent();
this.regionGroup?.removeFromParent();

}

Expand Down

0 comments on commit cb23fdc

Please sign in to comment.