Is it possible to pick a point on the mesh when it is not pickable?

Hello everyone

I want to know is it possible to pick point on the surface of the mesh when it isn’t pickable.
I have a glTF model and when I set the isPickable = true , then it effect on the performance of the render while zooming on the mesh. I want to know is it possible without set it as a pickable get the coordinate on it?

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

I suppose: no

Deltakosh said: “You can use scene.pick() but you just need something to pick”

Some more infos:

if all paths are blocked, i would do the following: put invisible large areas around the objects. after the click, detect which area was selected, then make the objects within the area clickable and again determine which object was actually clicked.

1 Like

Hi @Necips
Thanks a lot for helping and answering to my. question.

can I ask another question.
I need to get the thickness of 17 layers with the raycast. and it is work fine with almost 10 layers but when I have 17 layers it didn’t work and freeze, and I think its because all the layers is pickable. I want to know is it any way to optimize the performance when the mesh is pickable.

Is the ray long enough? You can set the length of the ray.

1 Like

Yes when I invisible the layers between the first one and the last one it calculate the thickness of the last layer.

I am working with Chrome.

if you write the command “debugger;” in your code the internal debugger starts and you can set breakpoints to see what happens in your code and what the content of the variables are.

image

you have to use this function declaration “() =>” to access the the variable “model” in the upper context.

image

1 Like

Thanks a lot, it’s so better.
Thank you so much for helping me and your time. :pray: :pray:
But when I put these layers inside my Final model, again I cannot get the thickness of all 17 layers and I have lag.

If you can not understand something you need more data.

If you can not get the result with the ray use pure mathenatics. You have the points if the meshes. So… Write a little for loop and determin the min max points…

1 Like

I found the problem, the problem is in my for loop because instead of getting 17 number for thickness I got much more than that.

https://playground.babylonjs.com/#XB49NT#41

2 Likes

That’s because you don’t pass a specific event to scene.onPointerObservable, so your code ends up being called for all mouse events:

https://playground.babylonjs.com/#XB49NT#44

1 Like

thank you so much for answering to my question. :pray: @Evgeni_Popov

sorry I made a mistake with PG, but again there is a speed issue,
https://playground.babylonjs.com/#XB49NT#46

But when I invisible all the layers except the first one the speed is so good.
and also get the all thickness of the invisible layers.
as can be seen in this PG: https://playground.babylonjs.com/#XB49NT#47

I don’t see a difference on my computer between first and second PG in the time it takes to compute the intersections:

See the console log, it displays the time when you click on a layer. On my computer, it’s around 240ms.

Now, the pick itself can take time because your scene is very heavy in triangles: more than 3.3M. The system finds the picked point by scanning all triangles and looking for intersections with the mouse position. If you display only a single layer (270k triangles with only the blue layer), there are less triangles to check and it’s faster to find this picked point.

You could be interested in some options to make picking / intersecting faster:

1 Like

Thank you so much for your helping :pray: :pray:,
now I tested and it’s about 280ms for both of them.
when I put these layers in my main model which consists of tiled height map and some other model I must turn off the height map to get the result. Thanks a lot for all of your help and your time. :pray:t2: :pray:t2: