Skip to content

Commit

Permalink
perf(DebugTilesPlugin): use cheap tree traversal in _initExtremes()
Browse files Browse the repository at this point in the history
We don't need the tiles to be preprocessed in this function, which has
a severe performance cost.
  • Loading branch information
sguimmara committed Dec 20, 2024
1 parent b24c170 commit b79d5d0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/plugins/three/DebugTilesPlugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box3Helper, Group, MeshStandardMaterial, PointsMaterial, Sphere, Color } from 'three';
import { SphereHelper } from './objects/SphereHelper.js';
import { EllipsoidRegionLineHelper } from './objects/EllipsoidRegionHelper.js';
import { traverseSet } from '../../base/traverseFunctions.js';

const ORIGINAL_MATERIAL = Symbol( 'ORIGINAL_MATERIAL' );
const HAS_RANDOM_COLOR = Symbol( 'HAS_RANDOM_COLOR' );
Expand Down Expand Up @@ -216,15 +217,11 @@ export class DebugTilesPlugin {

// initialize the extreme values of the hierarchy
let maxDepth = - 1;
this.tiles.traverse( tile => {

maxDepth = Math.max( maxDepth, tile.__depth );

} );

let maxError = - 1;
this.tiles.traverse( tile => {

traverseSet( this.tiles.root, null, ( tile, parent, depth ) => {

maxDepth = Math.max( maxDepth, depth );
maxError = Math.max( maxError, tile.geometricError );

} );
Expand Down

0 comments on commit b79d5d0

Please sign in to comment.