3556 Posted October 21, 2016 Share Posted October 21, 2016 I am loading a scene where I'm trying to click on an object using pickResult.pickedMesh. I however get "null" when I check it on console.log. i.e. it is not hitting anything in the scene. Here is the code snippet. Have attached the index.html file as well. I was unable to upload the complete project to the playground, as I'm not sure how to upload the .babylon scene file and the .jpg files. //When pointer down event is raised newScene.onPointerDown = function (evt, pickResult) { // Check if pickResult(); did hit anything by printing it on console.log console.log(pickResult.pickedMesh) // print the info of the clicked object if (pickResult.hit) {console.log(pickResult.pickedMesh)} }; Would appreciate if anyone could help out on what could be possible wrong? Thanks. index.html Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Share Posted October 21, 2016 make sure: mesh.isPickable = true; Quote Link to comment Share on other sites More sharing options...
3556 Posted October 21, 2016 Author Share Posted October 21, 2016 I'm still new to BJS - if you could you possibly refer to an example/demo of mesh.isPickable = true; it would be helpful. Like this Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Share Posted October 21, 2016 http://www.babylonjs-playground.com/#KWTZM Quote Link to comment Share on other sites More sharing options...
3556 Posted October 21, 2016 Author Share Posted October 21, 2016 Thanks. That seems to be a member of a mesh? I am however loading a complete scene via BABYLON.SceneLoader.Load(" ", "Retail.babylon", engine, function (newScene). Do I have to loop through all the meshes in the scene and set each of them to isPickable = true; ? Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Share Posted October 21, 2016 26 minutes ago, 3556 said: Do I have to loop through all the meshes in the scene and set each of them to isPickable = true; If they are set to false and you want to be able to pick them, yes. Quote Link to comment Share on other sites More sharing options...
3556 Posted October 21, 2016 Author Share Posted October 21, 2016 I had taken the scene from the babylon.js samples, so am not sure if the meshes in it are set to false (or true). I loaded the scene in the BJS editor and sandbox, but couldn't see that info in there. Any idea how that info can be viewed/edited? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 21, 2016 Share Posted October 21, 2016 Here : editor.babylonjs.com Quote Link to comment Share on other sites More sharing options...
3556 Posted October 21, 2016 Author Share Posted October 21, 2016 Unable to find that setting in the editor. I think it probably has to do with the manifest file configuration? Trying to again browse the docs & posts on here for a resolution. Quote Link to comment Share on other sites More sharing options...
3556 Posted October 21, 2016 Author Share Posted October 21, 2016 Was able to resolve this using BABYLON.SceneLoader.ImportMesh and then setting individual meshes to isPickable Thanks for all your help. // Import the scene as individual meshes BABYLON.SceneLoader.ImportMesh("", "./", "Retail.babylon", scene, function (newMeshes) { // set isPickable to true, so that mouse clicks can hit objects for (var i = 0; i < newMeshes.length; i++) {newMeshes[i].isPickable = true;} } ) //When pointer down event is raised scene.onPointerDown = function (evt, pickResult) { // print the info of the clicked object if (pickResult.hit){console.log(pickResult.pickedMesh.name)} } 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.