fixup more code broken by ai

This commit is contained in:
Stewart Allen 2025-07-05 17:06:38 -04:00
commit 76f9ce2c25
13 changed files with 161 additions and 351 deletions

View file

@ -1,6 +1,6 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { newPolygon } from '../geo/polygon.js';
import { newPolygon, Polygon } from '../geo/polygon.js';
import { polygons as POLY } from '../geo/polygons.js';
export class Layers {
@ -78,7 +78,7 @@ export class Layers {
options.open = true;
const polys = [];
for (let i=0; i<lines.length-1; i += 2) {
polys.push(new base.Polygon()
polys.push(new Polygon()
.append(lines[i])
.append(lines[i+1])
.setOpen());
@ -94,11 +94,14 @@ export class Layers {
// an open or closed polygon
addPoly(poly, options) {
return this.addPolys([poly], options);
return this.addPolys([ poly ], options);
}
// a polygon rendered as a webgl line
addPolys(polys, options) {
if (!Array.isArray(polys)) {
throw "polys must be an array";
}
if (polys.length === 0) {
return this;
}
@ -170,8 +173,7 @@ export class Layers {
p1.setZ(poly.z);
p2.setZ(poly.z);
}
this.addPolys(p1);
this.addPolys(p2);
this.addPolys([ p1, p2 ]);
}
const color = opts.color ?
(typeof(opts.color) === 'number' ? { line: opts.color, face: opts.color } : opts.color) :