How can I disable raycast for the invisible object?

Hello everyone

In my model I have using raycast to calculate the thickness of the cube. I want to know is it possible to disable raycast when the object is invisible, for example in my model the box3 is invisible and it is right side of the violet box.

here is my PG: https://playground.babylonjs.com/#XB49NT#31

Found this in the documentation Scene | Babylon.js Documentation :slight_smile:
Think this might help:

Optional predicate: (mesh: AbstractMesh) => boolean

Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true

1 Like

your predicate will look like

(m)=>{
   return m.isVisible
}

sense that will return false if the mesh is not visible it will skip that mesh on the picking process.
https://playground.babylonjs.com/#XB49NT#32

Added two different picks to your double click thing so you can see how to do it. Id recommend going with the scene.pick one instead of the pick with ray. Unless its like a gun or something then do a pick with ray using the camera.getForwardRay(range)

2 Likes

@msDestiny14 Thank you so much for your help and your time :pray: :pray: :pray:

@Pryme8
it’s great. Thanks a lot, for your helping and explanation and also for your time. :pray: :pray: :pray: