# How to create a irregular plane using a vector3 points array?

I checked the document and there is relative chapter “irregular polygon”, it’s using vector 2D array. what I want to approach is to create a surface of a terrain with a vector3 (x,y,z) array of points, the surface also can be styled like give color, texture etc. I am not babylon expert (yet ^_^), hopefully get taught here - thanks.

You could use `GreasedLine`

or build the mesh yourself manually:

https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/custom/custom

Thank you very much roland!

in my previous post (you also help me with ):

I am trying to use the vector3 array (sortedPoints) get from the sample above to create the irregular plane, but getting error “Cannot read properties of undefined (reading ‘length’)”, what I am doing is replace the “points” with “sortedPoints” in the PG above:
const ribbonLine = BABYLON.CreateGreasedLine(“ribbon-line-paths”, {
sortedPoints,
ribbonOptions: {
pointsMode: BABYLON.GreasedLineRibbonPointsMode.POINTS_MODE_PATHS
},
}, {
color: BABYLON.Color3.Gray(),
colorMode: BABYLON.GreasedLineMeshColorMode.COLOR_MODE_ADD,
width: 4,
});
maybe the sortedPoints is not the vector3 array as required? or need to convert it to?

Sorry about my poor knowledge of babylon but eager to learn more.

Would you create a PG please?

Look at the documentation for CreateGreasedLine again. The expected parameters are well documented there.

2 Likes

``````const corners = sortedPoints.map(sv3 => new BABYLON.Vector2(sv3.x, sv3.z))
const polygonTemp = new BABYLON.PolygonMeshBuilder("polytri", corners);
const polygon = polygonTemp.build();
``````
3 Likes

Nice sample - Thanks.

1 Like

Can you mark the solution please?

1 Like

@haiyaya

You marked your guestion as a solution?

Sorry - mismarked.

Please create a new topic. Thanks!

will do. thanks