Jump to content

How to perform pick on LinesMesh


Recommended Posts

oh !

We are planning to develop a component where in user should be able select edges for welding operation.

I was thinking that all edges would be rendered as line and then ask the user to pick whatever is needed.

If lines are not pickable, what is the alternative for my case ?

Should I create small planes instead of lines ?  Wont this have performance issues ?

Kindly suggest a way to achieve this effect.




Link to comment
Share on other sites

  • 2 weeks later...

Friggin' Noxy (Nockawa), sneakin' around doing excellent contribs.  He also did http://doc.babylonjs.com/tutorials/Using_parallax_mapping

Did he think we wouldn't notice?  :)

*sigh*  The Gods make it look SO easy.  (drooool)  Someday.  Someday I'll walk with the Gods, or at least be allowed to sweep their floors and wash their laundry.  heh  

Link to comment
Share on other sites

@Nockawa  , thank you for your quick support.

I would like to pick the lines mesh even though mouse is not very precisely over the mesh.

looks like intersectionThreshold should take care of this, however I think I am missing something.

please refer


What should be done to pick with some tolerance ?


Link to comment
Share on other sites

@Rajkumar I've got some time to spend on your issue, here's what happens, there're two things:

1) The boundingInfo of you line mesh exactly fits the line, there's no "additional margin" so your mesh is rejected if the mouse pointer is too far. In another words, the engine doesn't make the linesMesh intersection because the ray corresponding to the mouse cursor is outside the boundingInfo of the lineMesh. That is why I've created a boundingBias property in the Geometry class: to "extend" the bounding info using a 2D vector with the formulae described in the doc:

The Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y

2) Unfortunately I've discovered a bug when trying to fix your issue, the boundingInfo is not updated when you change the boundingBias after the linesMesh is created. I've just fixed the bug and will submit a PR right away. Hoping @Deltakosh will integrate it and update the playground quickly.

The only line you'll need to add is:

xaxis.geometry.boundingBias = new Vector2(0, 100);

btw, you'll see that 100 is overkill, setting 1 is totaly acceptable in your case.

Best, Nockawa

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.

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.


  • Recently Browsing   0 members

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