# ExtrudeShape Caps issue

**URL:** <https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062>\
**Category:** Bugs\
**Created:** [March 11, 2025, 11:52pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062 "2025-03-11T23:52:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 11, 2025, 11:52pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/1 "2025-03-11T23:52:12Z")

</div>

Hi Babylon Masters ,

I have a problem with the caps at the start and the end of the extrudeshape, it’s not well rendered .  
I ve tried the createPolygon to create them after the extrude but the issue is that’s hard to position them and orient them properly since my path is complexe .

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

I want to try an approch where i get the absolute vertecies at the start and end Caps then create a polygon there, but no succes so far . thx for help in advance

Hello and thank you for being a member of the community!  
If you want to report a bug, please make sure to share a repro on the forum:

> **[Babylon.js docs](https://doc.babylonjs.com/divingDeeper/developWithBjs/forum)**

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [March 12, 2025, 10:10am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/2 "2025-03-12T10:10:56Z")

</div>

Hello 🙂

I remember that this had been discussed already in [this topic](https://forum.babylonjs.com/t/extrude-2d-png-image-to-mesh/54230) with @Deltakosh and @Evgeni_Popov , the problem comes from the fact that your “H” shape is not convex.

It seems that the default CAP generator of BabylonJS is a very simplistic “star” caping. It does something like that :  
(Star extrusion toward the center)  
 ![Screencast from 12-03-2025 11:01:43](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/0/d0305c4fd953c5ea799e42ee82022756693f0a52.gif)

While the best would be to have a “smarter” shape closing like that :  
(dividing into convex subparts)  
 ![Screencast from 12-03-2025 11:02:13](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/f/8fca2aacedfcd68b3e1445a28324259e92efcdce.gif)

* * *

I think the best in your case would be to call the extruder without caps, and generate the right caps yourself.

* * *

By the way, I had proposed to add such feature, but still, didn’t took the time to deep dive into it 😛

> [@Extrude 2d PNG image to Mesh](https://forum.babylonjs.com/t/extrude-2d-png-image-to-mesh/54230/41):
>
> As of today I think it’s not possible to customize the CAP of the MeshBuilder.ExtrudeShape @Deltakosh when using the extruder with a closed contour, it would be great to be able to provide a custom triangulation for the CAP of the extrusion, like so : That way we would avoid the artifacts of the default CAP method, with complex NON convex meshes : Don’t you think ? slight_smile

> [@Extrude 2d PNG image to Mesh](https://forum.babylonjs.com/t/extrude-2d-png-image-to-mesh/54230/42):
>
> Happy to merge a PR for that for sure!

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 12, 2025, 11:08am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/3 "2025-03-12T11:08:40Z")

</div>

@Tricotou thanks buddy for the tip

what i did is cheated a bit , instead of one Extrudeshape , i ve done multiple ones to get the result, even if it’s not the best sollution but it solve the issue so far tough

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/6/86769803d5612719ea6308f89cdba1bd6aec937e.png)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/a/3ac1ff835116a47ab4dfc1eb9a368bf9f31bd102.png)

time babylon will fix this old simple issue to solve .

Regards

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 13, 2025, 4:37pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/4 "2025-03-13T16:37:09Z")

</div>

Something weird just happend to the same scene, the extruded segments where parralel to each others , now the extrusion is not that perfect, it like stretching as shown in the picture :

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/7/175cba2df6aa2efbf39c00a3b5662b03202dc74f.png)

And this effect is not occuring on the playground i ve shared … it’s the same function the same scene 🤨

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 13, 2025, 4:55pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/5 "2025-03-13T16:55:51Z")

</div>

Actually what is happenning is that the shape reference is rotating at the corners but not scaling , so this causes this stretching, i am trying to find a way to apply the needed scale to the shape at the corners depending on the Angle … and back to you gys .  
in the mean while if someOne has already face this and fix, i would appreciate to share .

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [March 13, 2025, 6:08pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/6 "2025-03-13T18:08:18Z")

</div>

Do you have a new playground to reproduce your issue so that we can have a look ? 🙂

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 13, 2025, 6:55pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/7 "2025-03-13T18:55:37Z")

</div>

Yes bro with great pleasure, my 1st approche is to use scalefunction that take the returned value and apply it to the shape at each step of the extrude. The issue was that the return value apply a global scale to the shape there is no straight way to apply it only on x for example which we need actually.

So no the next approch i ll try is to modify the shape by updating its verticies which is possible in babylone 6 and above …  
I will give a try this night and share with you the result

Regards matesss

---

<div class="post-metadata">

**Author:** ![Pe443](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pe443/32/22675_2.png) [@Pe443](https://forum.babylonjs.com/u/Pe443)\
**Post date:** [March 19, 2025, 8:45am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/8 "2025-03-19T08:45:35Z")

</div>

Yes it would be very helpfull if the scalefunction could be seperated into X-/Y-Scaling 🙂

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 24, 2025, 6:01am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/9 "2025-03-24T06:01:13Z")

</div>

I ve put this beside for a while now I am back guys to try to fix this issue .  
I am using now extrudeShapeCustom that offer rotationFunction and scaleFunction to have more control on the shape on each point from the Path …

however I am stuck on something I can’t find it logic if someOne can help . when i apply a simple rotation using rotationFunction ,the shape is well rotated but only arround the Path direction Axe … if i want to rotate along the vertical Axe regardless the Path orientation , the hole Extrude process get stuck .

Where i am suppose to have the right rotation by returning Quaternion instead of Angle . here’s the playground .

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

uncomment rotationFunction:rotationFunction, to see the bug.

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 26, 2025, 4:29pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/10 "2025-03-26T16:29:36Z")

</div>

@Tricotou🤨

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [March 26, 2025, 4:39pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/11 "2025-03-26T16:39:58Z")

</div>

Hello @sachou_sachou

Please have a look at the [DOC](https://doc.babylonjs.com/typedoc/functions/BABYLON.ExtrudeShapeCustom) 🙂 :  
`rotationFunction?: Nullable<(i: number, distance: number) => number>;`  
`scaleFunction?: Nullable<(i: number, distance: number) => number>;`

`rotationFunction` and `scaleFunction` return a `number` not anything like a quaternion

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

Also, please note that I remove the last (doubled) point from your shape. There is the `closeShape` param for that 🙂

`EDIT`

> [@sachou\_sachou](#):
>
> if i want to rotate along the vertical Axe regardless the Path orientation , the hole Extrude process get stuck .
> 
> Where i am suppose to have the right rotation by returning Quaternion instead of Angle . here’s the playground .

I think this function is not meant to rotate the loop vertically, but only in the axe of the path, indeed

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [March 26, 2025, 5:03pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/12 "2025-03-26T17:03:03Z")

</div>

> [@Tricotou](#):
>
> vertically

Does this mean you’re saying there’s no way to fix this controversy? 😭

---

<div class="post-metadata">

**Author:** ![Tricotou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tricotou/32/5844_2.png) [@Tricotou](https://forum.babylonjs.com/u/Tricotou)\
**Post date:** [March 26, 2025, 5:04pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/13 "2025-03-26T17:04:11Z")

</div>

> [@sachou\_sachou](#):
>
> Does this mean you’re saying there’s no way to fix this controversy? 😭

I do think there is an issue 🤔  
@Evgeni_Popov don’t you think that this behavior is weird ?

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/8/e8db252a6bd8aaedc91fc54f7fe4bcd772abeef4.png)  
I’m just editing the points before build :

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

Like if we were missing a shrink in the inmiddle sections, necessary to keep the section shape constant…

---

<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:** [March 26, 2025, 6:11pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/14 "2025-03-26T18:11:53Z")

</div>

Yes it looks a bit strange…

I think you should create an issue in [GitHub · Where software is built](https://github.com/BabylonJS/Babylon.js/issues) so that we can take a look as soon as we get the chance.

---

<div class="post-metadata">

**Author:** ![tibotiber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tibotiber/32/26735_2.png) [@tibotiber](https://forum.babylonjs.com/u/tibotiber)\
**Post date:** [January 29, 2026, 7:57am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/15 "2026-01-29T07:57:02Z")

</div>

Hi folks, I’m facing the same stretching issue in my app when using `ExtrudeShapeCustom`. I was wondering if anyone eventually managed to fix it?

@sachou_sachou any solution for you?

@Evgeni_Popov was an issue created eventually? Did anyone look into this?

---

<div class="post-metadata">

**Author:** ![sachou\_sachou](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sachou_sachou/32/44493_2.png) [@sachou\_sachou](https://forum.babylonjs.com/u/sachou_sachou)\
**Post date:** [January 29, 2026, 9:01am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/16 "2026-01-29T09:01:35Z")

</div>

No unfortunately, my solution was to build my object with multi combined object to look as i want (cheating 🙂 )

---

<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:** [January 29, 2026, 10:04am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/17 "2026-01-29T10:04:11Z")

</div>

In fact, this is the expected behavior from `ExtrudeShapeCustom`.

Here’s an updated PG where I added some extra path points to make sure we turn with a 45° angle:

[https://playground.babylonjs.com/#F82TBJ#3](https://playground.babylonjs.com/#F82TBJ#3)

Now, the top has always the same thickness, but we don’t rotate it at a right angle because once the (square) shape is rotated, its length is too small for that: we would have to scale it by sqrt(2), but only in the X and Y dimensions, not in Z. This is something that `ExtrudeShapeCustom` cannot know. This function simply takes the shape, makes it follow the path, and connects the points.

---

<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:** [January 29, 2026, 10:35am UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/18 "2026-01-29T10:35:22Z")

</div>

Ok, I did a PR to be able to apply a non-uniform scaling when using `ExtrudeShapeCustom`:

> <https://github.com/BabylonJS/Babylon.js/pull/17752>
>
> See https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/17

When this PR is merged, [this PG](http://playground.babylonjs.com/?inspectorv2=true#F82TBJ#6) will display:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/4/14a15bb157a896906ad93a0f94cd886523f1a3cf.png)

instead of:

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

---

<div class="post-metadata">

**Author:** ![tibotiber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tibotiber/32/26735_2.png) [@tibotiber](https://forum.babylonjs.com/u/tibotiber)\
**Post date:** [February 2, 2026, 2:49pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/19 "2026-02-02T14:49:01Z")

</div>

> [@Evgeni\_Popov](#):
>
> In fact, this is the expected behavior from `ExtrudeShapeCustom`.

Thanks so much for clarifying that @Evgeni_Popov! I’ve gone another round through the docs and understand it more in depth now. It’s indeed not intending to solve the issue I thought it solved. And I now discovered the Mitred utility which is closer to what I thought, although it doesn’t include scaling and rotation: [Babylon.js docs](https://doc.babylonjs.com/toolsAndResources/utilities/Mitred/).

Are there downsides to using the Mitred utility I should be aware of, besides no scaling, no rotation, and potentially weird joins at very sharp angles?

And I’m curious, what’s the rationale behind having a utility like this (copy the code to my repo) versus a proper feature like `ExtrudeShapeCustom` (import from BJS)?

Thanks again ☺

---

<div class="post-metadata">

**Author:** ![tibotiber](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tibotiber/32/26735_2.png) [@tibotiber](https://forum.babylonjs.com/u/tibotiber)\
**Post date:** [February 2, 2026, 2:54pm UTC](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062/20 "2026-02-02T14:54:50Z")

</div>

One more question: do you think it’s viable to attempt to generalize your approach with the additional points before/after each path angle and a calculated scale at the angle? I’m guessing the scale would depend on the angle, the distance of the points before/after might depend on the shape dimensions. Maybe we would run into issues with angles over 90° since a proper “mitre” would require a scale smaller on one side and longer on the other? I’m keen to look into it but I’m guessing some of you might have thought this through already and know the issues I might encounter. Maybe it’s not even generalizable?

(I hope i’m somewhat clear with this description 😬)

[Next page](https://forum.babylonjs.com/t/extrudeshape-caps-issue/57062.md?page=2)
