# Concave polyhedron face

**URL:** <https://forum.babylonjs.com/t/concave-polyhedron-face/41717>\
**Category:** Bugs\
**Created:** [June 19, 2023, 10:02am UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717 "2023-06-19T10:02:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [June 19, 2023, 10:02am UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/1 "2023-06-19T10:02:54Z")

</div>

Hi,

In some cases, when i try to create a concave polyhedron, some faces doesn’t render as expected.

> **[Babylon.js Playground](https://playground.babylonjs.com/#5XGGIC%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 19, 2023, 10:27am UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/2 "2023-06-19T10:27:21Z")

</div>

That’s probably that the winding of these faces is wrong: you will have to reverse the order of the vertex indices for these faces (instead of being (index1,index2,index3), it should be (index1,index3,index2)).

---

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [June 19, 2023, 3:43pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/3 "2023-06-19T15:43:24Z")

</div>

In reference to [this answer](https://forum.babylonjs.com/t/face-vertex-order-in-custom-polyhedron/41033/5) you provided, how can i do to create a “U” polyhedron like on [this PG](https://playground.babylonjs.com/#5XGGIC#3)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 19, 2023, 4:29pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/4 "2023-06-19T16:29:00Z")

</div>

I tried using `ExtrudeShapeCustom`, which mostly works, but there are some rotations where the U turns:

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

I don’t know if this is fixable or a by-product of the method…

---

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [June 23, 2023, 1:05pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/5 "2023-06-23T13:05:30Z")

</div>

The algorithm proposed in [this video](https://www.youtube.com/watch?v=QAdfkylpYwc&themeRefresh=1) is, perhaps, a good replacement for the current calculation method?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 23, 2023, 2:13pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/6 "2023-06-23T14:13:54Z")

</div>

Actually, it happens that the existing `ExtrudePolygon` method can be used:

> **[Babylon.js Playground](https://playground.babylonjs.com/#5XGGIC%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [June 26, 2023, 9:47am UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/7 "2023-06-26T09:47:48Z")

</div>

Yes but the ExtrudePolygon works only in a XZ plane with Y extrusion.

It works for my needs with a simple “if the plane is horizontal use Extrude else use Polyhedron” : [https://playground.babylonjs.com/#5XGGIC#5](https://playground.babylonjs.com/#5XGGIC#5), but it still particular

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 26, 2023, 11:07am UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/8 "2023-06-26T11:07:38Z")

</div>

You can also rotate the mesh after extrusion if it’s not in the right orientation.

---

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [June 26, 2023, 12:03pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/9 "2023-06-26T12:03:02Z")

</div>

Not really cause my points are not always in the XZ plane, I could do something like project them on the XZ plane but I don’t know if BABYLON propose that and if not I think that I’ll have to do a lot of calcul

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 26, 2023, 1:13pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/10 "2023-06-26T13:13:42Z")

</div>

If your points aren’t in a plan, I don’t think we have a solution in Babylon indeed.

---

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [June 26, 2023, 1:34pm UTC](https://forum.babylonjs.com/t/concave-polyhedron-face/41717/11 "2023-06-26T13:34:08Z")

</div>

Hi everyone,

I answer to this post because i’ve the same problem as @VerandaLouis .

I mean, it is really difficult to build a polygon in space in BabylonJS because there are probably too many ways to do but each way has restrictions.

Today, i think that there are 3 methods :

BABYLON.MeshBuilder.ExtrudePolygon : shape has to be done in the XZ plane, doesn’t allow arcs in the shape

BABYLON.PolygonMeshBuilder : shape has to be done in the XY plane, allows arcs

BABYLON.MeshBuilder.CreatePolyhedron : the plane of the shape can be anywhere but the concave shapes are not well done.

For instance, we are not able to draw a concave shape which is in a plane different from XY or XZ. Projecting points on the XZ or XY plane is not as easy as it appears first especially if you don’t have only segments but also arcs.

May be a new feature should be to have only one general method to draw a polygon if it is possible. What could be done is to define a shape which is in a plane (but not XY or XZ) and extrude it along its normal.

Thks.
