ua4192 Posted May 7, 2017 Share Posted May 7, 2017 Dear all. I have a small problem with my code. I want to select one of the multiple invisible but pickable meshes with the mouse. The goal is that I have a big model GLTF (assembly) loaded in the scene, but I also have the boxes of the parts contained loaded in the scene. The idea is that as in a typical CAD program be able to select on of the boxes (the closest one from the coordinates selected with the mouse in the assembly) In the scene I will load the GLTF contained meshes and the boxes (bounding boxes) of the parts in these meshes in a invisible but pickable way. I am using this approach because loading thousand of gltfs of parts is unachievable, the browser gets hang. Instead I load some big GLTFS and I want to be able to get metadata information from the parts contained in this assemblies. When I click with the mouse on the scene, I want to take the coordinates of the big assembly (GLTF) and make visible the box of the closest box of these coordinates. I am trying to use a raycast with camera position and mouse coordinates but it seems that multipick is not able to pick invisible boxes. I have also some problems to set the direction vector of the raycast based on the selected mouse coordinates and camera position. Many thanks in advanced for your support. Quote Link to comment Share on other sites More sharing options...
ua4192 Posted May 7, 2017 Author Share Posted May 7, 2017 Hi. In order to explain my problem I have added a small PG. http://www.babylonjs-playground.com/#KNE0O#29 You can see that when a click on the midle of the big box, the mesh that is make visible is the far away one and not the closest one I want. Many thanks in advanced. Quote Link to comment Share on other sites More sharing options...
ua4192 Posted May 7, 2017 Author Share Posted May 7, 2017 My idea is to make a raycast using the camera position and mouse picked coordinates, then use the multipick function to get all meshes which collide with this coordinates(mouse selected) and finally take the closest one (the last retrieved bounding box before the GLFT mesh). It seems that multipick doesn't work when meshes (my bounding boxes are not visible but pickable). Many thanks Quote Link to comment Share on other sites More sharing options...
ua4192 Posted May 7, 2017 Author Share Posted May 7, 2017 Sorry. This is the PG. I thought that the order got by multipick was depending on the distance of the coordiantes but is seems that is the order of mesh creation in the scene. I need to get the closest one. http://www.babylonjs-playground.com/#KNE0O#30 Many thanks in advanced. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 8, 2017 Share Posted May 8, 2017 Hello you are almost done just check the distance property to find the closest: http://www.babylonjs-playground.com/#KNE0O#31 Quote Link to comment Share on other sites More sharing options...
ua4192 Posted May 8, 2017 Author Share Posted May 8, 2017 Many many thanks. You are the best : ) I will try with this function. Best regards, ans many many thanks again. GameMonetize 1 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.