distraub Posted June 13, 2018 Share Posted June 13, 2018 I am hoping someone can take a look at this, and let me know if I am using it wrong. I have 2 spheres that I have attached Rays to, they are both shooting at a target, and there is a large sphere in the way, called earth. When I change the position of the spheres, the pickedPoint that is returned by hitInfo on the Ray.intersectsMesh function seems to be giving me an incorrect Picked Point if my source has a negative Y position. The "source" ray is just fine, but the "alternate" ray seems to be getting a picked point that is on the wrong side of the earth. Any help would be appreciated, I put this in a playground so you can see what I mean. https://www.babylonjs-playground.com/#KNB069 Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted June 13, 2018 Share Posted June 13, 2018 Hello Distraub ! I did some test with your PG. First thing I can say is that even with a negative Y position, the picked point may be the one you are looking for : https://www.babylonjs-playground.com/#KNB069#1 When using pickWithRay method instead of intersectWithMesh, even with not-working-Y-position on your alternate sphere, it is working as expected. I think it is because pickWithRay get the first hit from source to target while intersectWithMesh has another behaviour : https://www.babylonjs-playground.com/#KNB069#2 Hope it will help distraub 1 Quote Link to comment Share on other sites More sharing options...
distraub Posted June 13, 2018 Author Share Posted June 13, 2018 Thank you @Amarth2Estel This does solve my issue, if I use multiPickWithRay and then check for the id of my mesh, then it works as expected. I was hoping intersectsMesh would work the same way. Here is an example https://www.babylonjs-playground.com/#KNB069#3 If you intersectsMesh with those coordinates it seems to use the other end, which almost looks like it is shooting the ray from the target to the source and using that picked point. Amarth2Estel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.