Adem Posted December 24, 2016 Share Posted December 24, 2016 I put some mesh into my imported 3D scene, i tried to register a pick function on the mesh but it's not working. newScene.onPointerDown = function (evt, pr) { var width = newScene.getEngine().getRenderWidth(); var height = newScene.getEngine().getRenderHeight(); var pickInfo = newScene.pick(width / 2, height / 2); if (pickInfo.hit) { pickInfo.pickedMesh.dispose(); } }; Quote Link to comment Share on other sites More sharing options...
jpdev Posted December 24, 2016 Share Posted December 24, 2016 I have two ideas what might be wrong: 1) You code always picks the center of the scene, is that intended? I mean, you do not reference the pointer position. 2) Also is your mesh pickable? mesh.isPickable = true; If it's not it gets ignored. Here is a playground that uses your pick code, that picks the sphere and disposes it. http://babylonjs-playground.com/#1YFKMO#0 But there is something weird going on here, because disposing the sphere in the click event also removes the ground from the scene. This seems to me like a bug. Maybe @Deltakosh can have a look, at this. If you replace the dispose with anything else, for example "pickInfo.pickedMesh.visibility -= 0.1" only the sphere is affected. So the picking works, but dispose called from a pointer event does something strange. Quote Link to comment Share on other sites More sharing options...
Visam Posted December 24, 2016 Share Posted December 24, 2016 One more question about meshes picking. I can get one mesh (top one) under cursor using the method: var pickResult = scene.pick............ But how can I get a list of meshes under a cursor position? I mean all meshes under a cursor position. Quote Link to comment Share on other sites More sharing options...
Visam Posted December 24, 2016 Share Posted December 24, 2016 17 minutes ago, iTekVR said: One more question about meshes picking. I can get one mesh (top one) under cursor using the method: var pickResult = scene.pick............ But how can I get a list of meshes under a cursor position? I mean all meshes under a cursor position. I found the solution: scene.multiPick jpdev 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.