Browse Source

Improve frustum culling performance (#27219)

Garrett Johnson 1 year ago
parent
commit
7551b234e1
1 changed files with 4 additions and 11 deletions
  1. 4 11
      src/objects/BatchedMesh.js

+ 4 - 11
src/objects/BatchedMesh.js

@@ -948,6 +948,7 @@ class BatchedMesh extends Mesh {
 
 				if ( visibility[ i ] ) {
 
+					// get the bounds in world space
 					this.getMatrixAt( i, _matrix );
 					this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
 
@@ -955,12 +956,7 @@ class BatchedMesh extends Mesh {
 					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 );
 
 					}
 
@@ -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 );
 
 					}