elkyu Posted June 30, 2015 Share Posted June 30, 2015 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 1, 2015 Share Posted July 1, 2015 Hi,You could use ray tracing for that.Where does the line start? At the mouse click position? Drawing the line can be done even after you already know if there is a collision. Quote Link to comment Share on other sites More sharing options...
elkyu Posted July 1, 2015 Author Share Posted July 1, 2015 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 1, 2015 Share Posted July 1, 2015 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 elkyu 1 Quote Link to comment Share on other sites More sharing options...
elkyu Posted July 1, 2015 Author Share Posted July 1, 2015 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 ! 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.