Skip to content

Commit

Permalink
Improve frustum culling performance (mrdoob#27219)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson authored and AdaRoseCannon committed Jan 15, 2024
1 parent da5cf06 commit 56d7d26
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/objects/BatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,19 +948,15 @@ class BatchedMesh extends Mesh {

if ( visibility[ i ] ) {

// get the bounds in world space
this.getMatrixAt( i, _matrix );
this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );

// determine whether the batched geometry is within the frustum
let culled = false;
if ( perObjectFrustumCulled ) {

// get the bounds in camera space
this.getMatrixAt( i, _matrix );

// get the bounds
this.getBoundingBoxAt( i, _box ).applyMatrix4( _matrix );
culled = ! _frustum.intersectsBox( _box ) || ! _frustum.intersectsSphere( _sphere );
culled = ! _frustum.intersectsSphere( _sphere );

}

Expand Down Expand Up @@ -1001,13 +997,10 @@ class BatchedMesh extends Mesh {
let culled = false;
if ( perObjectFrustumCulled ) {

// get the bounds in camera space
// get the bounds in world space
this.getMatrixAt( i, _matrix );

// get the bounds
this.getBoundingBoxAt( i, _box ).applyMatrix4( _matrix );
this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
culled = ! _frustum.intersectsBox( _box ) || ! _frustum.intersectsSphere( _sphere );
culled = ! _frustum.intersectsSphere( _sphere );

}

Expand Down

0 comments on commit 56d7d26

Please sign in to comment.