Skip to content

Commit 7551b23

Browse files
authored
Improve frustum culling performance (#27219)
1 parent 05fa47e commit 7551b23

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/objects/BatchedMesh.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,19 +948,15 @@ class BatchedMesh extends Mesh {
948948

949949
if ( visibility[ i ] ) {
950950

951+
// get the bounds in world space
951952
this.getMatrixAt( i, _matrix );
952953
this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
953954

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

958-
// get the bounds in camera space
959-
this.getMatrixAt( i, _matrix );
960-
961-
// get the bounds
962-
this.getBoundingBoxAt( i, _box ).applyMatrix4( _matrix );
963-
culled = ! _frustum.intersectsBox( _box ) || ! _frustum.intersectsSphere( _sphere );
959+
culled = ! _frustum.intersectsSphere( _sphere );
964960

965961
}
966962

@@ -1001,13 +997,10 @@ class BatchedMesh extends Mesh {
1001997
let culled = false;
1002998
if ( perObjectFrustumCulled ) {
1003999

1004-
// get the bounds in camera space
1000+
// get the bounds in world space
10051001
this.getMatrixAt( i, _matrix );
1006-
1007-
// get the bounds
1008-
this.getBoundingBoxAt( i, _box ).applyMatrix4( _matrix );
10091002
this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
1010-
culled = ! _frustum.intersectsBox( _box ) || ! _frustum.intersectsSphere( _sphere );
1003+
culled = ! _frustum.intersectsSphere( _sphere );
10111004

10121005
}
10131006

0 commit comments

Comments
 (0)