I am trying to detect the intersection of a mesh created in Babylonjs with a mesh from an imported GLB.
It doesn’t detect intersections, as seen here:
I tried looking up information on this and this is the closest I could find, but I couldn’t find a solution.
Here I just changed your PG to pass the cube mesh to intersectsMesh (instead of passing its root mesh) and it seems to be working. I also removed the false parameter to dispose() so that the cube mesh is disposed too, not just its root mesh.
EDIT: Well if you end up removing the root meshes for physics then this answer wont be relevant anymore but I’ll leave it up anyway in case it helps.
Does anyone have any insight into this and can explain?
Hey there, intersectsMesh() relies on the world matrices being up-to-date. So since the positions of sphere and sphere2 were changed I called computeWorldMatrix(true) on those meshes to update their world matrices and then both intersections are detected.
Ah thank you!
I tried computerWorldMatrix, but I didn’t pass in true so it didn’t work.