Make a geometry using points

Hello everyone, I know this question has been answered previously but none of them provide a clear answer to the people other than the author.

I want to create a wall using points, the wall can change its dimension by changing values. I don’t know how I can achieve it but if I get even a little guidance I can do it myself.

I have an example project which I don’t have the code for is passing the points for the wall in this format:

"lines": [
    {
      "p1": {
        "x": -101,
        "y": 203
      },
      "p2": {
        "x": -101,
        "y": -100
      },
      "thickness": 12,
      "wallHeight": 260,
      "selected": false
    },
    {
      "p1": {
        "x": -101,
        "y": -100
      },
      "p2": {
        "x": 100,
        "y": -100
      },
      "thickness": 12,
      "wallHeight": 260,
      "selected": false
    },
    {
      "p1": {
        "x": 100,
        "y": -100
      },
      "p2": {
        "x": 100,
        "y": 202
      },
      "thickness": 12,
      "wallHeight": 260,
      "selected": false
    },
    {
      "p1": {
        "x": 100,
        "y": 202
      },
      "p2": {
        "x": -102,
        "y": 202
      },
      "thickness": 12,
      "wallHeight": 260,
      "selected": false
    }
  ],

which is later on forming a wall.

Thanks for your time and understanding the issue I am facing.

ShapeGeometry usually way easier and cleaner to code than BufferGeometry - just loop through your wall points, draw the shape as-if it was an SVG, then extrude upwards.

2 Likes

What about BufferGeometry cause I later on need to add more advanced stuff, btw thanks for adding the ShapeGeometry example that can help me a lot.

I’d still create the basic shapes using shape geometry - the result will be the same as directly using BufferGeometry, but code is a bit way cleaner.

After you transform shape into a geometry - you are free to push more vertices to position buffer attribute to add fancy stuff (or just add the fancy parts separately as InstancedMeshes, keeping everything in a single BufferGeometry feels a bit rigid and risky.)

1 Like