Jump to content

How to trace a line between 2 mesh and check for a collision ?


elkyu
 Share

Recommended Posts

Hi again ! :)

 

I have a plane with an other mesh behind.

 

I would like, when I click on the plane, trace a line directed to the back of the plane, and verify if there is a collision or not with the other mesh. 

 

I think I can create a line mesh, and update its size and check for a collision on each frame. No ? Maybe there is an other way ? 

 

Thanks

Link to comment
Share on other sites

Yes the line should start at the mouse click position.

 

I want to know if at the mouse click position on the plane there is a match(collision) at the same coordinate somewhere behind the plane. Trace a line is just an idea 

 

But, I forgot an important detail ... Between my plane and my other mesh I have an other plane which I want to ignore

Link to comment
Share on other sites

That's simple -  the scene.pick function accepts a predicate - this is a function that defines which meshes shouzld be picked and which shouldn't.
so (for example):

scene.pick(scene.pointerX,scene.pointerY, function(mesh) { return mesh.id == "idOfMeshToBePicked" })

You could also use the scene.onPointerDown and set the isPickable value to false to unpickable meshes and true to the pickables.

Like this - http://www.babylonjs-playground.com/#3TCRC

Link to comment
Share on other sites

I can set true just to the pickable mesh behind the plane because I need a pickinginfo on the plane too.

 

Your first solution works very well ! I defines the mesh behind the plane "pickables" with its ID and it works !

 

Thanks !

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