BoundingSphere and BoundingBox


I have a large pointcloud that consists of a grid of smaller cube shaped pointclouds (each of them is a separate bufferGeometry) that I load progressively using DynamicDrawUsage. That may not be important but mentioning for context.

My question is simple, I am not able to fully understand when does my Points based BufferGeometry need to have a boundingBox computed and when does it need to have a boundingSphere computed.

If I don’t do any of them, the rendering doesn’t show up properly (may be somehow not detected in the Camera’s Frustum).

If these bounds information is used to detect what should be visible in Camera, then why only one of them is not sufficient?

ThreeJS documentation is really light on this boundingSphere and boundingBox stuff. I mean, we do understand what it means really. But the docs doesn’t explain why is it needed, and in what scenarios I could skip them. Only reason I am asking for this, is because I know that there is a cost to computing this stuff.
Another question I have is: What part of ThreeJs actually refers to the boundingBox and boundingSphere and for what purpose? I tried looking in the ThreeJS code on github, but not able to parse out an answer for myself.

Any explanation would be greatly appreciated.

Bounding volumes are used in many components of three.js. If you properly setup a geometry (e.g. by defining a position attribute), bounding volumes can be automatically computed by the engine.

BufferGeometry.boundingSphere is used for view frustum culling. If the bounding sphere is not yet defined, the logic will perform the computation, see:

The bounding sphere is also computed automatically when doing raycasting. The bounding box is optional. If you define it, the raycasting logic will test it too before doing the more expensive ray/triangle intersection tests.

BTW: The docs do not explain these details since they are somewhat internal stuff. Especially since the bounding sphere is automatically computed. If this does not work in your app, you might have problems with your geometry setup.

1 Like

Thanks, this is very helpful.

I am actually setting my own bounding sphere because I know its dimensions. I don’t want threeJS to calculate it because it would have to go through all the points, and I know that center and radius information already.
And that works for me, but it seems I also have to set boundingBox manually too without that rendering doesn’t work.

Is it possible that if automatic boundingSphere calculation also takes care of boundingBox calculation?

Can you please point out what part of the code in WebGLRenderer is failing?

I can’t comment on the part of code failing, because the end result is nothing being rendered as if the frustum culling process detected that nothing is being intersected.

View frustum culling does not need a bounding box.

Is that any analogue of the BoundingBox, but for the Triangular prism?

I’m not sure I understand what you are asking. But there are no bounding volumes in form of a tetrahedron.

for example, if you have triangle on the scene, it is enabled to see BoundingSphere, or Bounding Box for triangle, but what if I need Bounding Triangle. Actually I have Point Cloud, where the figure will be drawn by /mouse click, and I am gonna to change the color of the points inside the area by dividing the figure on triangles. And I need to get intersection points with my triangles, not only point of intersection. Is it possible to get it by Volume intersection of Bounding Triangular Prism, or another object?