I have below PG where when camera intersect with mesh I am capturing it using
I am using thin instances, so also enabled
thinInstanceEnablePicking, But the issue is it doesn’t always trigger my event, if you move camera forward in PG, it will output in console.log when camera intersect with mesh but not with thin instances, but when you walk back it will work with thininstance but not with main mesh, I would like to always trigger
OnIntersectionEnterTrigger whenever I am above those white meshes and thin instances.
what am I missing again?
Seems to be working for me. Note that you need to leave the mesh if you want the enter event to trigger again. Your meshes look like this (each mesh has a different color):
What exactly doesn’t work?
@RaananW If you keep moving forward as is in your image, when you are on first 3 meshes (first blue-red-green in your image ), those trigger events when you walk straight, but last 3 doesn’t trigger any event, and when you walk back last 3 are triggering event but not the first 3. please see this video of the issue, I write in console when it doesn’t trigger: Screen Recording 2021-01-28 at 3.26.53 PM.mov - Google Drive
This is because they are considered to be the same mesh. Notice what happens when you enable the bounding box on one of them - it shows both together. The inspector will also not show you any other instance. Thin instances are a wonderful way of achieving a sort of cloning, with some down sides.
It’s described here - Thin Instances | Babylon.js Documentation
If you want to achieve that, you will have to use instance meshes instead
@RaananW thanks, but is there something else I can do while using thininstance? Here I simplified an example using just one mesh,
you see I am able to capture PickTriggerEvent on click and event does work with thininstance , easily able to capture which thininstance was clicked,
may @Evgeni_Popov have some work around?
This is because the thin instance picking mechanism is implemented.
But maybe someone else has a better answer, that’s true
Thanks @RaananW , I actually have learned all the thininstance stuff from @Evgeni_Popov and he actually did some PR’s too for some stuff which was not working so thought maybe he know some other trick , I admire your XR stuff, have been reading those… and once I start there I will definitely bug you more xD
hey @RaananW , as per your suggestion I am trying to create instances in my loop instead thininstance but encountering issue of instance position,
I am creating thininstance and auto adjusting z position in the loop (line 34)
startZ += 20;
Now I need to replace thininstance with instance in above PG, but not able to adjust properly X/Z position, I have to manually adjust X position in the loop with
m.position.x = 122;
if I try to set
m.position.x = obj.position.x; it doesn’t work
how could I make it work properly without setting x position manually, like I am doing with thininstance PG? in my real project I also have rotationQuaternion which is creating issues.
Edit: I even tried to use metrix which looks similar to my thiinstance approach but still position issue https://playground.babylonjs.com/#NB9U03#10
Edit: clone made it work correct position. xD