Skip to content

Commit

Permalink
WebGLRenderer: Sort on bounding sphere center, not origin (#25913)
Browse files Browse the repository at this point in the history
* WebGLRenderer: Sort on bounding sphere center.

* Update screenshot for webgl_buffergeometry_drawrange.
  • Loading branch information
donmccurdy authored Apr 24, 2023
1 parent f39297c commit fab4ed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Binary file modified examples/screenshots/webgl_buffergeometry_drawrange.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,16 +1163,20 @@ class WebGLRenderer {

if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {

const geometry = objects.update( object );
const material = object.material;

if ( sortObjects ) {

_vector3.setFromMatrixPosition( object.matrixWorld )
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();

_vector3
.copy( geometry.boundingSphere.center )
.applyMatrix4( object.matrixWorld )
.applyMatrix4( _projScreenMatrix );

}

const geometry = objects.update( object );
const material = object.material;

if ( Array.isArray( material ) ) {

const groups = geometry.groups;
Expand Down

0 comments on commit fab4ed4

Please sign in to comment.