Here is a playground: https://playground.babylonjs.com/#2UR29J
The scene contains a box and a sphere. These two meshes are separate and do not intersect.
I have a function called “detect” that I have added to the window object. This function does the following:
window.detect = () => {
// first move sphere to box
sphere.position.copyFrom(box.position);
return sphere.intersectsMesh(box)
}
First it moves the sphere to the box by copying the position vector from the box to the sphere. Then we test to see if the sphere intersects the box.
I expect that running detect() in the browser’s dev console would return true right away. But it takes a second run of detect() to return true.
Why does the function return false on the initial run?