Tainder Posted January 24, 2014 Share Posted January 24, 2014 Hey guys, I'm actually trying to put the picking tutorial and I want to increment a result variable while i click on some meshes. in my scene. With this tutorial : https://github.com/BabylonJS/Babylon.js/wiki/11---Picking-collisions Exemple : If I click on a mesh name BOX To increment my variable after hit the BOX i should do something like that ? if (pickResult.hit = BOX) { Result += 1 } Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 24, 2014 Share Posted January 24, 2014 I fact as this : pickResult = scene.pick(event.clientX, event.clientY - tbl.offsetTop); if (pickResult.pickedMesh) { if(pickResult.pickedMesh.name == "BoxName") { Result += 1; } }or If you have several models : for(a=0; a < mesh.length; a++) { if(pickResult.pickedMesh.name == mesh[a].name) { Result += 1 } } Quote Link to comment Share on other sites More sharing options...
Tainder Posted January 24, 2014 Author Share Posted January 24, 2014 Thanks for the answer, but i've a problem while implating your code in my js file. This making it crash. I should put the code after creating my picking animation or at the begining of the code ? Quote Link to comment Share on other sites More sharing options...
Tainder Posted January 25, 2014 Author Share Posted January 25, 2014 Up. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 25, 2014 Share Posted January 25, 2014 Look how I made here.Exemple scene pick Quote Link to comment Share on other sites More sharing options...
Tainder Posted January 26, 2014 Author Share Posted January 26, 2014 Thanks dude you're just an expert ! I put this topic as solved. Cheers, Tainder. 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.