gkjohnson / three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
MIT License
2.53k stars 267 forks source link

Different results when intersect identical triangles. #655

Open ColichevAV opened 7 months ago

ColichevAV commented 7 months ago

Hi! I am having an issue with the intersectTriangle function. I have two triangles that do not intersect visually, but when I call the intersectTriangle function on them, it returns different results. Thank you for your work! image

const triangle1 = new ExtendedTriangle(
        new Vector3(32.22699737548828, 1.2630000114440918, -11.8149995803833),
        new Vector3(31.316997528076172, 1.2630000114440918, -11.739999771118164),
        new Vector3(32.22699737548828, 1.2630000114440918, -11.739999771118164)
)
const triangle2 = new ExtendedTriangle(
        new Vector3(31.316997528076172, 1.933000087738037, -7.585000038146973),
        new Vector3(31.316997528076172, -0.8669999837875366, -7.295000076293945),
        new Vector3(31.316997528076172, -0.8669999837875366, -7.585000038146973)
 )

triangle1.intersectsTriangle(triangle2) is true
triangle2.intersectsTriangle(triangle1) is false
gkjohnson commented 7 months ago

Hello! Thanks for the report. I won't have a lot of time to investigate this but if you'd like to take a look an make a PR, this is the function to take a look at. I'm happy to answer any questions you may have about the implementation.

ColichevAV commented 7 months ago

Ok), I'll take a look at it.