Mesh detection issue

HI,
I m facing a mesh detection issue, when I m very close to mesh it’s fine but if I little back, its detecting mesh which is backface culling TRUE, is there any solution to detect mesh that is visible when they click.

scene.onPointerDown = function (event, pickResultx) {
if (pickResultx.hit) {
meshCliked = pickResultx.pickedMesh.id;
}
}

In the below picture when I like to select floor mesh its showing mesh id of the roof mesh which are not visible from top view, if I go close to floor mesh then it will detect the floor mesh, The same thing from all sides. if i do click from outside of room, it will detect mesh which are in front ( but which is not visible)

So just because you can’t see the ceiling it doesn’t mean it isn’t there… I guess that is the issue. Probably means the ceiling needs to be non-selectable if facing the ‘wrong’ way.

1 Like

Thanks for your time, Planes hide default on rotation. and It’s common. I m asking any solution to avoid/disable non-visible meshes. which are hidden on rotation

Hi,
@Deltakosh , @Evgeni_Popov can you guys help on this

Can you check the isPickable or isVisible and exclude those which aren’t pickable or visible?

i.e. https://www.html5gamedevs.com/topic/38520-solved-meshispickable-is-not-working/?do=findComment&comment=219967

You can define your own predicate when picking, so you can decide which meshes go into the list from which to choose from, and which don’t. You could calculate this list yourself when the camera rotates and provide it to the predicate whenever changed. This way you will only get the meshes you want to allow to pick (and on the way you will have better performance :slight_smile: )

A mesh will be selected even if it is backfaced, as it is still there. the normal is not being used to calculate the picked mesh. You can know after a mesh was picked if it is reversed to you by calling the getNormal() function on the pickInfo returned from the pick function. This is, however, not a very good way of doing things, as it will be provided to you only after the user has already picked the mesh.