Jump to content

Bug in scene.pick ?


Temechon
 Share

Recommended Posts

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, 

Link to comment
Share on other sites

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 :(

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...