Jump to content

Problems with picking and orthographic camera


jschwuch
 Share

Recommended Posts

Hi,

I already replied to @faljses post in bugs section (link below) but I'm not sure this really is a bug so I'll try and ask here too if anyone knows a way to do this.

So, I'm trying to use picking with an orthographic camera. My picking code works as long as I use a camera in mode=0 but in orthographic mode it never hits anything.

Here is faljses playground example that shows that as soon as you change the camera mode to 1, the picking stops working.

http://www.babylonjs-playground.com/#XUDHE

I already searched the source for some hours by now to see if I can spot a bug but didn't find one. I suspect that what ever goes wrong (bug or me using the framework wrong) has to do with the cameras projection matrix.

In my own code I use Scene.pick to get my picking information but I suspect, that the problem I experience is the same as the one we see in the Playground, thus I'd like to focus on the Playground first for convenience.

I appreciate any hints I can get, as I need to get this working, so if you have an idea what might go wrong here please tell me.

 

faljses post in Bugs section:

 

Link to comment
Share on other sites

I think I can narrow this down as probably not a bug.  I have a scene where I switch between ortho and perspective (using the 'Use System Camera' checkbox).  All buttons here are meshes.

I am using 2 different cameras, but that shouldn't matter.  Does make it a little complicated to see what is happening.

Looked at your pg.  Even commenting out the othro mode set stuff does not fix, so I think you may be trying to solve the wrong problem.

Link to comment
Share on other sites

Thanks for your answers!


@Pryme8 are there "correct" ratios? I think the picking should work with any ratios. But if it doesn't: Is all I have to take care of, that the aspect doesn't change? I have one camera in my scene that has correct ratios and one that doesn't and am currently testing with the one that doesn't, maybe I should test with  the one with "correct" ratios first...

@JCPalmer thank you for your scene, it looks like this is exactly what I'm searching, I'll take it apart and see what I did wrong :D 

About my PG: When I comment out the line

freeCamera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;

picking works so it is a problem with ortho mode, maybe @Pryme8 is right and it's the ratios.

Link to comment
Share on other sites

Got it working! @Pryme8 Was right, kind of. I actually messed up with rotations and "fixed" it by setting the "ortho parameters" to negative values, which caused my camera to actually look in the wrong direction. The actual ratios don't matter for picking (verified that).

Still doesn't work in the PG though. Guess it's a problem with the alpha like @JCPalmer suggested. Is there any way to use the playground with another version?

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...