Temechon Posted September 30, 2014 Share Posted September 30, 2014 Hello, I'm currently using a lot of picking actions, as described in this playground : http://www.babylonjs.com/playground/#1HCGBN This scene is a simple ground in a biiiiig red sphere (a skydome).A click on the ground creates a box. Try to click on the sphere in front of you : no box.Well, there is a box... Press the 'back' arrow key of your keyboard. Surprise !...What ?The box is behind me ? What the hell ... ? I came to the conclusion there was a bug in the function scene.pick, so I tried to investigate...And here is what I found : Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) { ... var det = Vector3.Dot(this._edge1, this._pvec); if (det === 0) { return null; } ...}In my case, the box is behind the camera because the dot product is negative. I think (but I'm not sure as I'm not a math professional :/ ) that it should never be negative in a picking case...So I added this : if (det <= 0 ) { return null;}And it works... But I don't have any box on my ground now :/ Help me Babylon lovers ! What should I do ? Cheers, Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 30, 2014 Share Posted September 30, 2014 Your problem is that dot < 0 will break the general case You should set sphere.isPickable = false Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 30, 2014 Author Share Posted September 30, 2014 Yes, but the sphere cannot be targeted anymore :/ Actually I want to pick always in front of the camera, not behind it. How can something like this be achieved ? In my mind, it can be if the cos between my two vectors is > 0, thus the dot product > 0... But I don't understand why it does not work with the ground Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 30, 2014 Share Posted September 30, 2014 try with dot >= 0 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 30, 2014 Share Posted September 30, 2014 But btw the problem is that you are INSIDE the sphere with normals pointing outside Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 30, 2014 Author Share Posted September 30, 2014 Ooookkk I think I got it... Thanks Delta I will try to find a workaround for it. 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.