0

I have faced with an issue. when I set the cubes' visible property to false. It is hiding the mesh from the user, but it is actual place is staying there and preventing from clicking the another mesh that is behind.

enter image description here

I want to hide the cube and make the circle mesh hoverable and clickable.

I have tried mesh.visible property of the mesh, it is hiding the mesh, but the actual place stays there and preventing to click another meshes behind of it.

1 Answer 1

1

You forgot to tell us how you handle clicking. If you are casting a ray using THREE.Raycaster, then yes it will indeed hit also invisible objects.

The simplest option would be to manually filter out from the raycast result those hits that are not visible.

Alternatively, you can look into Raycaster.layers, which lets you raycast only a subset of the scene.

1
  • 1
    I have solved this issue with layers. const visible = true; mesh.visible = visible; visible ? mesh.layers.enable(0) : mesh.layers.disable(0); these line of code helped me to solve the issue. thanks) Commented Mar 17, 2023 at 10:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.