# Get picked face (not triangle)

**URL:** <https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820>\
**Category:** Questions\
**Created:** [January 7, 2025, 5:39pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820 "2025-01-07T17:39:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kristofer\_Gafvert](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kristofer_gafvert/32/35003_2.png) [@Kristofer\_Gafvert](https://forum.babylonjs.com/u/Kristofer_Gafvert)\
**Post date:** [January 7, 2025, 5:39pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820/1 "2025-01-07T17:39:25Z")

</div>

Hi!

I am new to BabylonJS och 3D in general, so I have started reading to make sure I go in the right direction. So bear with me.

My situation is that I have data in the form of an array with vertices, and an array with faces. For example, imagine a house with a triangle-formed roof, I will have 10 vertices and 7 faces (4 walls, 2 for the roof and 1 for the floor). The data is not triangulated. Each face may have data associated to it, for example an id, name, and much more.

I have read up on MeshBuilder.CreatePolyhedron and I can create a custom polyhedron by passing my vertices and faces as custom data.

```auto
const data = {
   "name":"abc",
   "category":["b"],
   "vertex": myVertices,
    "face": myFaces
};
const r= BABYLON.MeshBuilder.CreatePolyhedron("h" + i, {custom: data, faceColors: faceColors});

```

It seems that CreatePolyhedron do the triangulation, since I can pass a face with four vertices (I have not tried any more vertices).

But then it comes to identifying what face a user has clicked on.I played with the examples at: [Babylon.js docs](https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions) and tried PickingInfo.faceId. It did however return the id of the triangle, which is not useful for me. I want to know which one of the 7 faces was picked, so I can present the information about the face.

Is there any way to know which face (not triangle) a user has clicked on? Or am I going in the wrong direction by creating a Polyhedron, and I should instead be creating surfaces?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 7, 2025, 9:59pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820/2 "2025-01-07T21:59:41Z")

</div>

The only way would be to store the info in the face as well and for this you could maybe rely on the uv channel so then you could request .`getTextureCoordinates` on pickInfo to read the data back ?

---

<div class="post-metadata">

**Author:** ![Kristofer\_Gafvert](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kristofer_gafvert/32/35003_2.png) [@Kristofer\_Gafvert](https://forum.babylonjs.com/u/Kristofer_Gafvert)\
**Post date:** [January 8, 2025, 4:16pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820/3 "2025-01-08T16:16:01Z")

</div>

Thanks for the insight! I am not sure right now how to do it, but I will investigate this as a viable solution.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 8, 2025, 4:54pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820/4 "2025-01-08T16:54:22Z")

</div>

You can do you your own triangulation, set the references, create a custom mesh and you are good to go!

Click on faces of the mesh a watch the console.

> **[Babylon.js Playground](https://playground.babylonjs.com/#W2H9BH)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/a/5a22222f0745ecd8d7b6885bb15972d581e3c260.png)

First column `pickInfo.faceId`, second one the `id` of the original face the triangle was created from.

---

<div class="post-metadata">

**Author:** ![Kristofer\_Gafvert](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kristofer_gafvert/32/35003_2.png) [@Kristofer\_Gafvert](https://forum.babylonjs.com/u/Kristofer_Gafvert)\
**Post date:** [January 8, 2025, 7:49pm UTC](https://forum.babylonjs.com/t/get-picked-face-not-triangle/55820/5 "2025-01-08T19:49:54Z")

</div>

Wow! Thanks! I have so much to learn. This was very helpful.
