@rulecad/printcheck 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/package.json +1 -1
- package/printcheck.d.mts +37 -2
- package/printcheck.mjs +83 -16
package/README.md
CHANGED
|
@@ -26,10 +26,16 @@ What it checks:
|
|
|
26
26
|
mid-air.
|
|
27
27
|
- **Closed solid**: every edge is matched by a face on the other side. T-junctions count as closed, and so do hairline
|
|
28
28
|
seams narrower than `HAIRLINE` (0.01 mm), which booleans leave and no printer can resolve. Wider gaps are holes.
|
|
29
|
+
- **One piece**: a loose piece would print as a stray bit or fall over. A cavity inside a part (its surface faces in)
|
|
30
|
+
isn't a piece.
|
|
31
|
+
- **Nothing starting in mid-air**: the lowest point of a tip hanging down (an icicle), with nothing below it to print
|
|
32
|
+
on. Its faces point down, and for a millimetre above it the surface stays narrow. The face-by-face overhang check
|
|
33
|
+
misses a tip like this, because each of its faces may slope at 45° or less. A shallow dip in a smoothed underside
|
|
34
|
+
spreads wide, so it doesn't count.
|
|
29
35
|
|
|
30
36
|
Several parts printed together (a keycap with an inlaid legend in another colour): pass
|
|
31
37
|
`{ parts: [{ triangles, role }] }`. Then one part resting on another isn't an overhang, and each part must be closed on
|
|
32
38
|
its own. A part with `role: 'support'` is printed and then removed.
|
|
33
39
|
|
|
34
|
-
Also exported: `bounds(triangles)` (`{ lo, hi, size }`), `seams(triangles)` (`{ gaps, tjunctions, hairlines }`)
|
|
35
|
-
`widest(polys, held, under)` (the bridge measurement).
|
|
40
|
+
Also exported: `bounds(triangles)` (`{ lo, hi, size }`), `seams(triangles)` (`{ gaps, tjunctions, hairlines }`),
|
|
41
|
+
`shape(triangles)` (`{ pieces, tips }`) and `widest(polys, held, under)` (the bridge measurement).
|
package/package.json
CHANGED
package/printcheck.d.mts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
/** @typedef {[number, number, number]} Point a corner in mm, Z up */
|
|
7
7
|
/** @typedef {Point[]} Face a polygon: three or more corners, counter-clockwise seen from outside */
|
|
8
8
|
/** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number }} Printer mm and degrees */
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
11
|
+
* it is when that's known (the box round the faces it's about, in mm).
|
|
12
|
+
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
13
|
+
*/
|
|
10
14
|
export function bounds(polys: any): {
|
|
11
15
|
lo: number[];
|
|
12
16
|
hi: number[];
|
|
@@ -42,6 +46,26 @@ export function seams(polys: Face[], eps?: number): {
|
|
|
42
46
|
tjunctions: number;
|
|
43
47
|
hairlines: number;
|
|
44
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* A model's pieces and the tips hanging down from it. Corners closer than eps are one point. A piece is a set of faces
|
|
51
|
+
* joined by their corners; one enclosing no volume, or a negative one (a cavity's surface, facing in), isn't a piece.
|
|
52
|
+
* Pieces come biggest first. A tip is a corner below every corner it shares a face with, by more than drop, on faces
|
|
53
|
+
* facing down (not a hole's floor), and narrow for hang mm above it (not a dip in an underside): the start of
|
|
54
|
+
* something hanging in the air (corners in a flat underside are level with their neighbours, so they're not tips;
|
|
55
|
+
* nor is the bed, which the caller leaves out). Tips closer than a millimetre are one.
|
|
56
|
+
* @param {Face[]} polys @param {number} [eps] @param {number} [drop] @param {number} [hang] how far a tip must hang, mm
|
|
57
|
+
* @returns {{ pieces: { volume: number, box: { lo: number[], hi: number[] } }[], tips: number[][] }}
|
|
58
|
+
*/
|
|
59
|
+
export function shape(polys: Face[], eps?: number, drop?: number, hang?: number): {
|
|
60
|
+
pieces: {
|
|
61
|
+
volume: number;
|
|
62
|
+
box: {
|
|
63
|
+
lo: number[];
|
|
64
|
+
hi: number[];
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|
67
|
+
tips: number[][];
|
|
68
|
+
};
|
|
45
69
|
export const HAIRLINE: 0.01;
|
|
46
70
|
/**
|
|
47
71
|
* a corner in mm, Z up
|
|
@@ -61,7 +85,18 @@ export type Printer = {
|
|
|
61
85
|
support_gap?: number;
|
|
62
86
|
bridge?: number;
|
|
63
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
90
|
+
* it is when that's known (the box round the faces it's about, in mm).
|
|
91
|
+
*/
|
|
64
92
|
export type Finding = {
|
|
65
|
-
level: "pass" | "warn" | "fail";
|
|
93
|
+
level: "pass" | "warn" | "fail" | "info";
|
|
66
94
|
text: string;
|
|
95
|
+
code?: string;
|
|
96
|
+
values?: Record<string, any>;
|
|
97
|
+
at?: {
|
|
98
|
+
lo: number[];
|
|
99
|
+
hi: number[];
|
|
100
|
+
};
|
|
101
|
+
refs?: Record<string, any>;
|
|
67
102
|
};
|
package/printcheck.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Printability, from the faces and the printer's rules. Each finding is { level: 'fail' | 'warn' | 'pass', text }.
|
|
2
|
-
// fits the bed · sits flat on it · a closed solid (slicers need one) · overhangs past the printer's limit
|
|
2
|
+
// fits the bed · sits flat on it · a closed solid (slicers need one) · one piece · overhangs past the printer's limit
|
|
3
|
+
// · tips hanging down that start in mid-air
|
|
3
4
|
// flat undersides above the bed: on a built-in breakaway support (one support gap above a surface), or bridges no
|
|
4
5
|
// wider than the printer can span: the widest circle that fits in the underside, measured to the edges that are
|
|
5
6
|
// held up by material below. An underside with no such edge starts in mid-air: it needs support.
|
|
@@ -25,7 +26,11 @@ const OVERHANG_SLACK = 0.5; // degrees
|
|
|
25
26
|
/** @typedef {[number, number, number]} Point a corner in mm, Z up */
|
|
26
27
|
/** @typedef {Point[]} Face a polygon: three or more corners, counter-clockwise seen from outside */
|
|
27
28
|
/** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number }} Printer mm and degrees */
|
|
28
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
|
|
31
|
+
* it is when that's known (the box round the faces it's about, in mm).
|
|
32
|
+
* @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
|
|
33
|
+
*/
|
|
29
34
|
|
|
30
35
|
export function bounds(polys) {
|
|
31
36
|
const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity]; // a loop: spreading big models overflows the stack
|
|
@@ -44,7 +49,7 @@ export function bounds(polys) {
|
|
|
44
49
|
* @returns {Finding[]}
|
|
45
50
|
*/
|
|
46
51
|
export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
47
|
-
const out = [], f = (level, text) => out.push({ level, text });
|
|
52
|
+
const out = [], f = (level, text, code, values, at) => out.push({ level, text, code, ...(values && { values }), ...(at && { at }) });
|
|
48
53
|
const solids = (parts || []).filter((p) => p.role !== 'support').map((p) => ({ tris: p.triangles, box: bounds(p.triangles) }));
|
|
49
54
|
// Is the point inside one of the parts? A ray straight up crosses its surface an odd number of times
|
|
50
55
|
const inPart = (pt) => solids.length > 1 && solids.some(({ tris, box }) => {
|
|
@@ -64,10 +69,14 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
64
69
|
const mm = (n) => `${Number(n.toFixed(1))}`;
|
|
65
70
|
|
|
66
71
|
const over = size.filter((s) => s > printer.bed);
|
|
67
|
-
f(over.length ? 'fail' : 'pass', `${size.map(mm).join(' × ')} mm${over.length ? `: bigger than the ${printer.bed} mm bed` : ', fits the bed'}
|
|
72
|
+
f(over.length ? 'fail' : 'pass', `${size.map(mm).join(' × ')} mm${over.length ? `: bigger than the ${printer.bed} mm bed` : ', fits the bed'}`, 'print.bed', { size, bed: printer.bed });
|
|
68
73
|
|
|
69
74
|
// Flat on the bed: the lowest point is z = 0, and faces there point straight down.
|
|
70
75
|
let base = 0, down = 0, support = 0, zs = [];
|
|
76
|
+
// Where a finding is: the box round the faces it's about, { lo, hi } (for a reader to point at)
|
|
77
|
+
const overBox = { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
78
|
+
const grow = (box, p) => { for (const v of p) for (let k = 0; k < 3; k++) { box.lo[k] = Math.min(box.lo[k], v[k]); box.hi[k] = Math.max(box.hi[k], v[k]); } return box; };
|
|
79
|
+
const boxOf = (faces) => faces.reduce((box, p) => grow(box, p), { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] });
|
|
71
80
|
const flatDown = [], flatUp = [];
|
|
72
81
|
// A face overhanging past the limit (measured from vertical) points down by more than its sine; half a degree to
|
|
73
82
|
// spare, since booleans tip a 45° chamfer by hundredths of a degree. (Cosine was used before: the same at 45° only.)
|
|
@@ -80,14 +89,15 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
80
89
|
if (nz < -eps && zmax - lo[2] > eps && rests(p)) continue; // on another part (a legend on its keycap)
|
|
81
90
|
if (nz < -1 + eps && zmax - lo[2] < eps) base += area;
|
|
82
91
|
else if (nz < -1 + eps) flatDown.push({ p, z: zmin, area }); // a flat underside above the bed
|
|
83
|
-
else if (nz < -limit) { support += area; zs.push(zmin); }
|
|
92
|
+
else if (nz < -limit) { support += area; zs.push(zmin); grow(overBox, p); }
|
|
84
93
|
if (nz > 1 - eps) flatUp.push({ p, z: zmax });
|
|
85
94
|
if (nz < 0) down += area;
|
|
86
95
|
}
|
|
87
|
-
if (Math.abs(lo[2]) > eps) f('fail', `lowest point is at z = ${mm(lo[2])} mm, not on the bed (z = 0)
|
|
88
|
-
f(base > 0 ? 'pass' : 'fail', base > 0 ? `${mm(base)} mm² flat on the bed` : 'nothing sits flat on the bed');
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
if (Math.abs(lo[2]) > eps) f('fail', `lowest point is at z = ${mm(lo[2])} mm, not on the bed (z = 0)`, 'print.off-bed', { z: lo[2] });
|
|
97
|
+
f(base > 0 ? 'pass' : 'fail', base > 0 ? `${mm(base)} mm² flat on the bed` : 'nothing sits flat on the bed', 'print.base', { area: base });
|
|
98
|
+
const overAt = support > 0.5 ? overBox : null;
|
|
99
|
+
if (support > 0.5) f('warn', `${mm(support)} mm² overhangs past ${printer.overhang}° (z ${mm(Math.min(...zs))} to ${mm(Math.max(...zs))} mm): needs supports or another orientation`, 'print.overhang', { area: support, angle: printer.overhang, z: [Math.min(...zs), Math.max(...zs)] }, overAt);
|
|
100
|
+
else f('pass', `no overhangs past ${printer.overhang}°`, 'print.overhang', { area: support, angle: printer.overhang });
|
|
91
101
|
|
|
92
102
|
// Flat undersides: on a breakaway support, or bridged
|
|
93
103
|
const gap = printer.support_gap ?? 0.2, inside = (pt, poly) => { // point in the xy footprint of a convex face
|
|
@@ -100,7 +110,7 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
100
110
|
};
|
|
101
111
|
const centroid = (p) => [0, 1].map((k) => p.reduce((s, v) => s + v[k], 0) / p.length);
|
|
102
112
|
const held = flatDown.filter((d) => flatUp.some((u) => d.z - u.z > eps && d.z - u.z <= gap * 1.5 + eps && inside(centroid(d.p), u.p)));
|
|
103
|
-
if (held.length) f('pass', `${mm(held.reduce((s, d) => s + d.area, 0))} mm² rests on a breakaway support (${mm(gap)} mm gap): snip it off after printing
|
|
113
|
+
if (held.length) f('pass', `${mm(held.reduce((s, d) => s + d.area, 0))} mm² rests on a breakaway support (${mm(gap)} mm gap): snip it off after printing`, 'print.breakaway', { area: held.reduce((s, d) => s + d.area, 0), gap });
|
|
104
114
|
const levels = new Map();
|
|
105
115
|
for (const d of flatDown) if (!held.includes(d)) { const k = d.z.toFixed(2); levels.set(k, [...(levels.get(k) || []), d.p]); }
|
|
106
116
|
// Which faces meet at each edge, so an underside's edges can be checked for material below them
|
|
@@ -111,10 +121,21 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
111
121
|
const mine = new Set(group);
|
|
112
122
|
const held = (a, b) => (byEdge.get([vkey(a), vkey(b)].sort().join('|')) || []).some((p) => !mine.has(p) && Math.min(...p.map((v) => v[2])) < Number(z) - eps);
|
|
113
123
|
const under = flatUp.filter((u) => Number(z) - u.z > eps && Number(z) - u.z <= gap * 1.5 + eps).map((u) => u.p); // breakaway supports' tops
|
|
114
|
-
const span = widest(group, held, under);
|
|
115
|
-
if (span == null) f('warn', `an underside at z ${mm(Number(z))} starts in mid-air: needs support (or a built-in breakaway support one ${mm(gap)} mm layer below)
|
|
116
|
-
else if (span > bridgeMax + eps) f('warn', `${mm(span)} mm bridge at z ${mm(Number(z))}: wider than the ${bridgeMax} mm the printer can span, needs supports
|
|
117
|
-
else f('pass', `bridge ${mm(span)} mm at z ${mm(Number(z))} (up to ${bridgeMax} mm)
|
|
124
|
+
const span = widest(group, held, under), at = boxOf(group);
|
|
125
|
+
if (span == null) f('warn', `an underside at z ${mm(Number(z))} starts in mid-air: needs support (or a built-in breakaway support one ${mm(gap)} mm layer below)`, 'print.mid-air', { z: Number(z) }, at);
|
|
126
|
+
else if (span > bridgeMax + eps) f('warn', `${mm(span)} mm bridge at z ${mm(Number(z))}: wider than the ${bridgeMax} mm the printer can span, needs supports`, 'print.bridge', { span, max: bridgeMax, z: Number(z) }, at);
|
|
127
|
+
else f('pass', `bridge ${mm(span)} mm at z ${mm(Number(z))} (up to ${bridgeMax} mm)`, 'print.bridge', { span, max: bridgeMax, z: Number(z) });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// One piece, and nothing starting in mid-air, part by part (an assembly's parts are apart on purpose)
|
|
131
|
+
for (const tris of parts && parts.length > 1 ? parts.filter((p) => p.role !== 'support').map((p) => p.triangles) : [polys]) {
|
|
132
|
+
const { pieces, tips } = shape(tris, eps, (printer.layer ?? 0.2) / 4);
|
|
133
|
+
const loose = pieces.slice(1);
|
|
134
|
+
if (loose.length) f('warn', `${pieces.length} pieces: ${loose.length} loose from the main one (${loose.length === 1 ? mm(loose[0].volume) : `${mm(Math.min(...loose.map((l) => l.volume)))} to ${mm(Math.max(...loose.map((l) => l.volume)))}`} mm³), which would print as stray bits or fall over`, 'print.pieces', { pieces: pieces.length, loose: loose.map((l) => l.volume) }, loose.reduce((b, l) => grow(grow(b, [l.box.lo]), [l.box.hi]), { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] }));
|
|
135
|
+
else if (pieces.length) f('pass', 'one piece', 'print.pieces', { pieces: 1 });
|
|
136
|
+
const hanging = tips.filter((t) => t[2] - lo[2] > eps && !rests([t, t, t]));
|
|
137
|
+
if (hanging.length) f('warn', `${hanging.length === 1 ? 'a point starts' : `${hanging.length} points start`} in mid-air (z ${mm(Math.min(...hanging.map((t) => t[2])))}${hanging.length > 1 ? ` to ${mm(Math.max(...hanging.map((t) => t[2])))}` : ''} mm): the lowest points of tips hanging down, with nothing below to print on`, 'print.island', { points: hanging }, hanging.reduce((b, t) => grow(b, [t]), { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] }));
|
|
138
|
+
else f('pass', 'nothing starts in mid-air', 'print.island', { points: [] });
|
|
118
139
|
}
|
|
119
140
|
|
|
120
141
|
// Closed: every edge is matched by an edge running the other way. An edge that meets the middle of a longer edge
|
|
@@ -122,8 +143,8 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
|
|
|
122
143
|
const { gaps, tjunctions, hairlines } = parts && parts.length > 1
|
|
123
144
|
? parts.map((p) => seams(p.triangles, eps)).reduce((s, x) => ({ gaps: s.gaps + x.gaps, tjunctions: s.tjunctions + x.tjunctions, hairlines: s.hairlines + x.hairlines }), { gaps: 0, tjunctions: 0, hairlines: 0 })
|
|
124
145
|
: seams(polys, eps);
|
|
125
|
-
if (gaps) f('warn', `${gaps} edges with nothing on the other side: holes in the surface (slicers may repair them)
|
|
126
|
-
else f('pass', `closed solid${tjunctions || hairlines ? ` (${[tjunctions && `${tjunctions} T-junction edges`, hairlines && `${hairlines} hairline seams under ${HAIRLINE} mm`].filter(Boolean).join(', ')}: watertight for printing)` : ''}
|
|
146
|
+
if (gaps) f('warn', `${gaps} edges with nothing on the other side: holes in the surface (slicers may repair them)`, 'print.closed', { gaps });
|
|
147
|
+
else f('pass', `closed solid${tjunctions || hairlines ? ` (${[tjunctions && `${tjunctions} T-junction edges`, hairlines && `${hairlines} hairline seams under ${HAIRLINE} mm`].filter(Boolean).join(', ')}: watertight for printing)` : ''}`, 'print.closed', { gaps, tjunctions, hairlines });
|
|
127
148
|
return out;
|
|
128
149
|
}
|
|
129
150
|
|
|
@@ -218,3 +239,49 @@ export function seams(polys, eps = 1e-3) {
|
|
|
218
239
|
}
|
|
219
240
|
return { gaps, tjunctions, hairlines };
|
|
220
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A model's pieces and the tips hanging down from it. Corners closer than eps are one point. A piece is a set of faces
|
|
245
|
+
* joined by their corners; one enclosing no volume, or a negative one (a cavity's surface, facing in), isn't a piece.
|
|
246
|
+
* Pieces come biggest first. A tip is a corner below every corner it shares a face with, by more than drop, on faces
|
|
247
|
+
* facing down (not a hole's floor), and narrow for hang mm above it (not a dip in an underside): the start of
|
|
248
|
+
* something hanging in the air (corners in a flat underside are level with their neighbours, so they're not tips;
|
|
249
|
+
* nor is the bed, which the caller leaves out). Tips closer than a millimetre are one.
|
|
250
|
+
* @param {Face[]} polys @param {number} [eps] @param {number} [drop] @param {number} [hang] how far a tip must hang, mm
|
|
251
|
+
* @returns {{ pieces: { volume: number, box: { lo: number[], hi: number[] } }[], tips: number[][] }}
|
|
252
|
+
*/
|
|
253
|
+
export function shape(polys, eps = 1e-3, drop = 0.05, hang = 1) {
|
|
254
|
+
const ids = new Map(), at = [], key = (v) => v.map((c) => Math.round(c / eps)).join(',');
|
|
255
|
+
const faces = polys.map((p) => p.map((v) => { const k = key(v); if (!ids.has(k)) { ids.set(k, at.length); at.push(v); } return ids.get(k); }));
|
|
256
|
+
const up = at.map((_, i) => i), find = (i) => { while (up[i] !== i) i = up[i] = up[up[i]]; return i; };
|
|
257
|
+
const near = at.map(() => new Set()), facing = at.map(() => 0);
|
|
258
|
+
faces.forEach((f, n) => { const z = areaNormal(polys[n])[2]; for (const v of f) facing[v] += z; });
|
|
259
|
+
for (const f of faces) for (let i = 0; i < f.length; i++) { const a = f[i], b = f[(i + 1) % f.length]; up[find(a)] = find(b); near[a].add(b); near[b].add(a); }
|
|
260
|
+
const by = new Map();
|
|
261
|
+
for (const f of faces) {
|
|
262
|
+
const r = find(f[0]), piece = by.get(r) ?? { volume: 0, box: { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] } };
|
|
263
|
+
for (let i = 1; i < f.length - 1; i++) { const [a, b, c] = [at[f[0]], at[f[i]], at[f[i + 1]]]; piece.volume += vdot(a, cross(b, c)) / 6; }
|
|
264
|
+
for (const v of f) for (let k = 0; k < 3; k++) { piece.box.lo[k] = Math.min(piece.box.lo[k], at[v][k]); piece.box.hi[k] = Math.max(piece.box.hi[k], at[v][k]); }
|
|
265
|
+
by.set(r, piece);
|
|
266
|
+
}
|
|
267
|
+
const pieces = [...by.values()].filter((p) => p.volume > eps).sort((a, b) => b.volume - a.volume);
|
|
268
|
+
const tips = [];
|
|
269
|
+
// A tip hangs: within hang of its point the surface stays narrow (a cone at 45° is as wide as it is tall). A dip in a
|
|
270
|
+
// smoothed underside is shallow: within hang of it, the surface spreads wide, as far as the underside does.
|
|
271
|
+
const narrow = (i) => {
|
|
272
|
+
const seen = new Set([i]), todo = [i], v = at[i];
|
|
273
|
+
while (todo.length) {
|
|
274
|
+
for (const j of near[todo.pop()]) {
|
|
275
|
+
if (seen.has(j) || at[j][2] > v[2] + hang) continue;
|
|
276
|
+
if (Math.hypot(at[j][0] - v[0], at[j][1] - v[1]) > 2 * hang) return false;
|
|
277
|
+
seen.add(j); todo.push(j);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return true;
|
|
281
|
+
};
|
|
282
|
+
at.forEach((v, i) => {
|
|
283
|
+
if (!near[i].size || facing[i] >= 0 || [...near[i]].some((j) => at[j][2] - v[2] <= drop) || !narrow(i)) return;
|
|
284
|
+
if (!tips.some((t) => Math.hypot(t[0] - v[0], t[1] - v[1], t[2] - v[2]) < 1)) tips.push(v);
|
|
285
|
+
});
|
|
286
|
+
return { pieces, tips };
|
|
287
|
+
}
|