Dimensions of boundingSphere of sphere mesh don't match

The engine does not know that your mesh is a sphere or any other shape: it’s only a triangle soup.

The bounding sphere is computed thanks to the bounding box: the center of the sphere is the center of the bounding box and the radius is the half of the diagonal. With a unit sphere centered on the origin, the min and max of the bounding box are (-1,-1,-1) and (+1,+1,+1), the diagonal is Math.sqrt(2²+2²+2²)=3.461 and half the diagonal = radius of the bounding sphere = 1.732.

You can do better than the engine if you know the shape of your mesh and provide a more fitting bounding sphere (as you did with the 0.33333333 scale).

If you want to use intersectsPoint yourself, you must make sure the world center/radius are up to date given the world coordinates of the underlying mesh: you need to call _update() with the world matrix of the mesh:

https://playground.babylonjs.com/#KU7GBX#4

Your last example does not work because the world matrix of the sphere is not up to date: call sphere.computeWorldMatrix(true); before calling intersectsPoint.

2 Likes