Detect click to plan with texture

hello ,

i add new plane to my ground with texture but i’m with diffucult do detect the click :
const plane = BABYLON.Mesh.CreatePlane(“text”, 50, scene);
const rectangle = new GUI.Rectangle();
const text = new GUI.TextBlock();
rectangle.addControl(text);
return plane;

this is my plane and i use this methode to detect the click :

case BABYLON.PointerEventTypes.POINTERDOWN:

      if (pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedMesh !== this.ground) {
      
      console.log("clicked);
      }

any help ?
thanks

Hi @Viche

pickInfo.pickedMesh is the picked mesh.
See this PG:
https://playground.babylonjs.com/#0WZNPG

Hope this helps :slight_smile:

1 Like

thanks for your time
in my project i add a rectangle with texture to my plan and i want to check the pick on this texture ?
how i can do that ?

Like getting the texel you just clicked?

sorry don’t understand you :confused: i have texture in my plan and i want to chech to click on it :confused:

In the picking info, you can get the texture coordinates (see bu/bv):

https://doc.babylonjs.com/babylon101/picking_collisions#advanced-picking-features

Then, with the UV, you can compute the texel coordinates and read back the texture pixel using readPixels

https://doc.babylonjs.com/api/classes/babylon.texture#readpixels

2 Likes