Weird behaviour on extrude depending on the direction of the shape polygon


I’m wondering if I’m doing something wrong here, but when using cap on an extrusion reversing the order of points in the shape leads to weird behaviour :

To reproduce in the playground : comment and uncomment the reverse line. Is there a rule that the polygon needs to be direct , or with the path ? I’m trying to make solid filled parts


const createScene = function () {
const scene = new BABYLON.Scene(engine);

const camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 2, Math.PI / 2, 30, BABYLON.Vector3.Zero());
camera.attachControl(canvas, true);

const light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 50, 0));

//Shape profile in XY plane
const myShape = [
	 	new BABYLON.Vector3(0, 5, 0),
		new BABYLON.Vector3(1, 1, 0),
		new BABYLON.Vector3(5, 0, 0),
		new BABYLON.Vector3(1, -1, 0),
		new BABYLON.Vector3(0, -5, 0),
		new BABYLON.Vector3(-1, -1, 0),
		new BABYLON.Vector3(-5, 0, 0),
		new BABYLON.Vector3(-1, 1, 0)

const myPath = [
		new BABYLON.Vector3(0, 0, 0),
		new BABYLON.Vector3(0, 0, -2),
		new BABYLON.Vector3(0, 0, -4),
		new BABYLON.Vector3(0, 0, -6),
		new BABYLON.Vector3(0, 0, -8),
		new BABYLON.Vector3(0, 0, -10)

const scaling = (index, distance) => {
	return 1 / (index + 1);

const extrusion = BABYLON.MeshBuilder.ExtrudeShapeCustom("star", {shape: myShape, closeShape: true, path: myPath, cap: BABYLON.Mesh.CAP_ALL,}, scene);

return scene;


Hi @clemslab and welcome to the community. For future reference it is much easier to answer if you add a playground not just the code. For help on this see

The issue is that the direction of the shape (clockwise or counter clockwise) plus the path direction effects the normals of the extruded sides. This can be easily overcome by ensuring sideOrientation: BABYLON.Mesh.DOUBLESIDE is set as one of the options.

Also this is a special case when capping works with a concave shape. In most cases the cap will not be properly formed with a concave shape.

When you have a concave shape with just a plain extrusion, not a custom one, then I suggest you use