Browse Source

WebGLRenderer: Use correct bounding volume for depth sorting. (#25974)

Michael Herzog 2 years ago
parent
commit
4f397c7837
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/renderers/WebGLRenderer.js

+ 11 - 2
src/renderers/WebGLRenderer.js

@@ -1168,10 +1168,19 @@ class WebGLRenderer {
 
 
 						if ( sortObjects ) {
 						if ( sortObjects ) {
 
 
-							if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+							if ( object.boundingSphere !== undefined ) {
+
+								if ( object.boundingSphere === null ) object.computeBoundingSphere();
+								_vector3.copy( object.boundingSphere.center );
+
+							} else {
+
+								if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+								_vector3.copy( geometry.boundingSphere.center );
+
+							}
 
 
 							_vector3
 							_vector3
-								.copy( geometry.boundingSphere.center )
 								.applyMatrix4( object.matrixWorld )
 								.applyMatrix4( object.matrixWorld )
 								.applyMatrix4( _projScreenMatrix );
 								.applyMatrix4( _projScreenMatrix );