Extruded mesh rotates with rotation set to 0

So I have been trying to extrude a mesh along a path as can be seen in this playground example:
https://www.babylonjs-playground.com/#165IV6#880

However if you open up the console you can see that although it follows the path, by the end the box has rotated a very slight amount. For example in the path array the first vertex of the last segment is at location
x: 24.98751566374615
y: 25.012453242064886
z: 410
but both x and y should be 25, so as you can see there is a very slight rotation but enough so that if I try to line up extruded meshes end to end such as I am doing, a very obvious gap appears between the meshes. I filed this under the bug section since it seems like incorrect extrusion but if there is a setting I am missing or a way to set it so this small rotation does not happen please let me know.

Hiya 8bit. You are using path in an unusual way.

Try this instead:

function getPathArray(){
	var path = [];
	path.push(new BABYLON.Vector3(0,0,0));
        path.push(new BABYLON.Vector3(0,0,400));
	return path;
}

Just two points in the path… causes a straight-line z-extrude. Give it try… see what ya think. :slight_smile:

Or do you NEED that little bend at the end?

I need the bend, and although I could break it up into multiple extrudes that would be undesirable, also the way I am using the path array is how it is meant to be used, it is good for more than just straight line extrusions.

1 Like

Yeah, sorry, I misunderstood the issue. Pretending that the extrude is “capped”, you need that cap to face perfectly z-ward… even after the bend, no matter the bend angle (within reason).

Crap, I worded that terribly… but yeah. We got that gap thing… and that overlap thing… when trying to connect nicely to perfectly z-ward-facing faces. Might be rough. Let’s ping-in @jerome and @JohnK , a couple of local extrusion extraordinaires.

Actually this rotation is expected because the extrusion process is based on the computation of a Path3D object as for the extrusion axis.
The path3D allows to build smoothly curved geometry from a series of points. we wouldn’t be able to extrude nicely any shape along curved paths without adding rotations in the curves else we get very sharp edges and normals. That’s the way it works.
Your example is just a (reduced) particular case of a how the extrusion works : https://www.babylonjs-playground.com/#165IV6#881
We can see here that the rotations are needed along the curves to avoid some unwanted sharpness.

In your case I would probably build a dedicated ribbon with the required geometry instead of using the extrusion method.

1 Like