I am relatively new to Three.JS and tried to implement something to build polygons in 3D space. I tried using earcut library to triangulate points - did not help that much, tried to use Hull.js, which did work, but only with convex shapes.

After a while I found solution that was provided by @prisoner849 and for some sets of points it worked perfectly, but for some not.

Live code example

As far as I understand this solution, there should be a rectangle here, not a triangle.

For this set of points it build rectangle as expected:

```
[
{
"x": 2.6443464756011963,
"y": 1.637024998664856,
"z": -3.753018856048584
},
{
"x": -2.3420379161834717,
"y": 1.637024998664856,
"z": -3.2846970558166504
},
{
"x": -3.70695424079895,
"y": 1.637024998664856,
"z": -6.309837818145752
},
{
"x": 0.8760173916816711,
"y": 1.637024998664856,
"z": -8.244649887084961
}
]
```

How to change the code so example in the fiddle would build a rectangle?