Skip to content

BVHHelper: Skip nodes with empty bounds - #949

Merged
gkjohnson merged 1 commit into
gkjohnson:masterfrom
Enesuygurs:fix/bvh-helper-empty-bounds
Nov 3, 2026
Merged

gkjohnson merged 1 commit into
gkjohnson:masterfrom
Enesuygurs:fix/bvh-helper-empty-bounds

Conversation

@Enesuygurs

Copy link
Copy Markdown
Contributor

Related to #892

A BVH built from an empty geometry has a root node with empty bounds (min = Infinity, max = -Infinity). BVHHelper still emitted a box for it, so the helper geometry ended up with infinite vertex positions, and three.js logged "Computed radius is NaN" when it computed the bounding sphere for frustum culling.

const geometry = new BufferGeometry();
geometry.setAttribute( 'position', new BufferAttribute( new Float32Array( 0 ), 3 ) );
geometry.boundsTree = new MeshBVH( geometry );

const helper = new BVHHelper( new Mesh( geometry ) );
// before: 8 vertices made of +/-Infinity
// after: an empty position attribute

The helper now skips nodes with empty bounds, both when counting the boxes and when writing their positions, so an empty BVH produces an empty helper geometry. I added a test for the empty case and a basic sanity test for a regular mesh. There were no BVHHelper tests yet.

I wasn't sure whether this covers everything you had in mind for #892, so I referenced the issue instead of closing it.

@gkjohnson gkjohnson added this to the v0.9.18 milestone Nov 3, 2026
@gkjohnson
gkjohnson merged commit bede409 into gkjohnson:master Nov 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants