From 2286da809c0bb678a30bb6fa25e102679fd1598a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Guimmara?= Date: Fri, 20 Dec 2024 10:01:52 +0100 Subject: [PATCH] perf(DebugTilesPlugin): use cheap tree traversal in _initExtremes() We don't need the tiles to be preprocessed in this function, which has a severe performance cost. --- src/plugins/three/DebugTilesPlugin.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/three/DebugTilesPlugin.js b/src/plugins/three/DebugTilesPlugin.js index c1c69e073..f53ed6609 100644 --- a/src/plugins/three/DebugTilesPlugin.js +++ b/src/plugins/three/DebugTilesPlugin.js @@ -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' ); @@ -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 ); } );