Jump to content



Recommended Posts


all in all I just want to have a round boundingBox for my sphere mesh .. and .. as just having the space to ask .. a customizedBox for irregular formed meshes.

After reading some of the babylon tutorial sides and topics and web, I want to know if my understanding in correct:


For intersections between meshes I can use the bounding boxes that are available for every mesh in a scene.

.. and as to see in http://playground.babylonjs.com/#CTHIE#1 the means real boxes!

.. furthermore the boxes are take if I uses the actionManager functions to detect mesh intersection between meshes 

mesh1.actionManager.registerAction(new BABYLON.ExecuteCodeAction(

{ trigger: BABYLON.ActionManager.OnIntersectionExitTrigger, parameter: mesh2 } , function () {

  mesh1.position.x = 0.0;



So if I have two spheres then it can happen that in the worst case both bounding boxes will hit on there edges with each other ..   without any intersections of the spheres.


In https://doc.babylonjs.com/tutorials/Intersect_Collisions_-_mesh there is the statement: " But this bounding box can be more or less precise, and that’s why we have our second parameter. In short, if this parameter is set to true (false by default), then the bounding box is closer to the mesh (OBB bounding type), but it’s a more costly calculation." .. 


Having the corresponding PG http://playground.babylonjs.com/?10 and trying  "intersectsMesh(sphere, true)" still delivers a box (?) 


On the other hand there seems to be a boundingSphere but only for the camera?



How to have a round BoundingSphere or assign a custom mesh as a boundingBox?

Did I have to write a detection on my own by looping though sphere vertices of a mesh instead? :huh:

(sorry for that questions)

With best regards

Link to comment
Share on other sites

in short,

all mesh intersections are computed with bounding boxes AND bounding spheres that way :

if the two bounding spheres don't intersect, return false

else it the two bounding boxes don't intersect return false

This means that for spherical meshes, the bounding sphere is similar to the mesh and the intersection is really fast and accurate !

The debug layer only shows the bounding boxes. If you force the parameter precise to true, you only force the bounding boxes to be rotated in the space like their embedded mesh. So instead of having a simple axis aligned process (direct coordinate comparison = AABB), this needs some more complex computation with oriented bounding boxes (OBB what implies some SAT or Separate Axis Theorem application https://en.wikipedia.org/wiki/Hyperplane_separation_theorem )

Having other "impostors" than boxes or spheres is even more complex and requires far more CPU. This is what the physics engines provide out-of-the-box ;)

Link to comment
Share on other sites

you can access a mesh bounding sphere via its boundingInfo object :



var bSphere = mesh._boundingInfo.boundingSphere;

You can test if two bounding spheres intersect with the static method : http://doc.babylonjs.com/classes/2.4/BoundingSphere#static-intersects-sphere0-sphere1-rarr-boolean

BABYLON.BoundingSphere.Intersects(bSphere1, bSphere2); // returns a boolean


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...