ExtrudeShape Caps issue

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 .

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:

Hello :slight_smile:

I remember that this had been discussed already in this topic 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

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


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 :face_with_tongue:

1 Like

@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


time babylon will fix this old simple issue to solve .

Regards

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 :

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

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 .

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

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

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

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 .

uncomment rotationFunction:rotationFunction, to see the bug.

@Tricotou :face_with_raised_eyebrow:

Hello @sachou_sachou

Please have a look at the DOC :slight_smile: :
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

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

EDIT

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

1 Like

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

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


I’m just editing the points before build :

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

Yes it looks a bit strange…

I think you should create an issue in GitHub · Where software is built so that we can take a look as soon as we get the chance.