Picking sprites and event not triggering

Hello

First of all, BabylonJS is awesome, the API is so intuitive, it’s so easy to create a scene. But I think I’ve found a bug between Sprite and event triggering.

The minimalist playground that reproduce the bug :

I have a simple ground. I have a simple pickable sprite. The sprite is above the ground and it is in the foreground for the camera.

Problem : If I click on the upper section of the sprite (the 3 squares red, yellow and cyan of the picture), the event is triggered and the alert box is shown.
If I click on the lower part of the sprite, no event is triggered (but the cursor is correct : it is pickable).
If you move the camera, it feels like the ground far behind is occluding the sprite in the foreground, but only regarding event triggering.

Did I miss something ? Is there a “z-index” to move sprite foreground ? Is it a bug from Firefox ?

Thanks in advance

Though you cant see it the ground plane was covering the sprite. They are technically rendered in different sorting spaces so what was happening was though the sprite was visually covering the ground mesh as far as the picking system sees it was obfuscating the pick. That is why the initial top corner worked because the plane was not being picked up in the pick pass.

Simple solution is to just turn the plane non pickable, you can also sort the elements to ensure that there is not a depth discrepancy or you can use a GPU pick method.

3 Likes

The sprite is above the ground.
Its size is 0.5 and it is at y=1 (the ground is at y=0)

If you only move the camera (another point of view) :

In this view, all parts of the sprite are pickable

I gave you the awnser… It’s not a bug, it’s a sampling space thing.

Due to the way things are sorted and rendered the spirtes are sorted ina different depth, so the ground plane is eating the pick when there is overlap. Reference the above post for solutions.

I’ve made another playground with Arc Camera :

It’s more obvious.

Al parts of the sprite are pickable :

No part of the sprite are pickable :

Bro read my posts… Absorb what is being said… You keep posting proofs of what I said to be true and are not taking a second to understand why.

I’ve read

The ground is not pickable

Then why did it work when I turned isPickable off?

I posted a working pg…

They are in different coordinate spaces the way that the picking system works makes it so the ground blocks the pick. You can sort them different to ensure it works, turn the picking off on the ground, use predicates, or a GPU picking method.

This is not a bug. I’m not trying to be rude either, mad love hope you figure this out. :heart:

Ok my bad, it works now. Unlike sprites, meshes are pickable by default, I didn’t know that.

Thanks.

2 Likes