formacad 0.0.0-stage → 0.2.0

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.
Files changed (97) hide show
  1. package/LICENSE +200 -0
  2. package/README.md +98 -2
  3. package/build/cli/src/forma.d.ts +2 -0
  4. package/build/cli/src/forma.js +546 -0
  5. package/build/cli/src/forma.js.map +1 -0
  6. package/build/cli/src/mcp.d.ts +1 -0
  7. package/build/cli/src/mcp.js +495 -0
  8. package/build/cli/src/mcp.js.map +1 -0
  9. package/build/cli/src/preview.d.ts +31 -0
  10. package/build/cli/src/preview.js +427 -0
  11. package/build/cli/src/preview.js.map +1 -0
  12. package/build/core/fonts/Roboto-Bold.ttf +0 -0
  13. package/build/core/fonts/Roboto-Regular.ttf +0 -0
  14. package/build/core/src/bevel.d.ts +41 -0
  15. package/build/core/src/bevel.js +548 -0
  16. package/build/core/src/bevel.js.map +1 -0
  17. package/build/core/src/difflib.d.ts +3 -0
  18. package/build/core/src/difflib.js +94 -0
  19. package/build/core/src/difflib.js.map +1 -0
  20. package/build/core/src/errors.d.ts +9 -0
  21. package/build/core/src/errors.js +14 -0
  22. package/build/core/src/errors.js.map +1 -0
  23. package/build/core/src/export2d.d.ts +10 -0
  24. package/build/core/src/export2d.js +127 -0
  25. package/build/core/src/export2d.js.map +1 -0
  26. package/build/core/src/geometry.d.ts +93 -0
  27. package/build/core/src/geometry.js +946 -0
  28. package/build/core/src/geometry.js.map +1 -0
  29. package/build/core/src/gltf.d.ts +6 -0
  30. package/build/core/src/gltf.js +154 -0
  31. package/build/core/src/gltf.js.map +1 -0
  32. package/build/core/src/host.d.ts +28 -0
  33. package/build/core/src/host.js +113 -0
  34. package/build/core/src/host.js.map +1 -0
  35. package/build/core/src/importers.d.ts +12 -0
  36. package/build/core/src/importers.js +1025 -0
  37. package/build/core/src/importers.js.map +1 -0
  38. package/build/core/src/index.d.ts +92 -0
  39. package/build/core/src/index.js +227 -0
  40. package/build/core/src/index.js.map +1 -0
  41. package/build/core/src/inflate.d.ts +15 -0
  42. package/build/core/src/inflate.js +230 -0
  43. package/build/core/src/inflate.js.map +1 -0
  44. package/build/core/src/interp.d.ts +178 -0
  45. package/build/core/src/interp.js +3012 -0
  46. package/build/core/src/interp.js.map +1 -0
  47. package/build/core/src/lexer.d.ts +14 -0
  48. package/build/core/src/lexer.js +217 -0
  49. package/build/core/src/lexer.js.map +1 -0
  50. package/build/core/src/manifold.d.ts +26 -0
  51. package/build/core/src/manifold.js +687 -0
  52. package/build/core/src/manifold.js.map +1 -0
  53. package/build/core/src/modeling.d.ts +18 -0
  54. package/build/core/src/modeling.js +483 -0
  55. package/build/core/src/modeling.js.map +1 -0
  56. package/build/core/src/parser.d.ts +46 -0
  57. package/build/core/src/parser.js +478 -0
  58. package/build/core/src/parser.js.map +1 -0
  59. package/build/core/src/scad/colors.d.ts +1 -0
  60. package/build/core/src/scad/colors.js +37 -0
  61. package/build/core/src/scad/colors.js.map +1 -0
  62. package/build/core/src/scad/convert.d.ts +33 -0
  63. package/build/core/src/scad/convert.js +2842 -0
  64. package/build/core/src/scad/convert.js.map +1 -0
  65. package/build/core/src/scad/parser.d.ts +239 -0
  66. package/build/core/src/scad/parser.js +578 -0
  67. package/build/core/src/scad/parser.js.map +1 -0
  68. package/build/core/src/scad/sources.d.ts +39 -0
  69. package/build/core/src/scad/sources.js +171 -0
  70. package/build/core/src/scad/sources.js.map +1 -0
  71. package/build/core/src/std.d.ts +3 -0
  72. package/build/core/src/std.js +47 -0
  73. package/build/core/src/std.js.map +1 -0
  74. package/build/core/src/surface.d.ts +21 -0
  75. package/build/core/src/surface.js +253 -0
  76. package/build/core/src/surface.js.map +1 -0
  77. package/build/core/src/threemf.d.ts +4 -0
  78. package/build/core/src/threemf.js +127 -0
  79. package/build/core/src/threemf.js.map +1 -0
  80. package/build/core/src/ttf.d.ts +39 -0
  81. package/build/core/src/ttf.js +473 -0
  82. package/build/core/src/ttf.js.map +1 -0
  83. package/build/core/src/values.d.ts +146 -0
  84. package/build/core/src/values.js +365 -0
  85. package/build/core/src/values.js.map +1 -0
  86. package/build/core/src/xml.d.ts +13 -0
  87. package/build/core/src/xml.js +152 -0
  88. package/build/core/src/xml.js.map +1 -0
  89. package/build/core/std/electronics.forma +120 -0
  90. package/build/core/std/enclosures.forma +76 -0
  91. package/build/core/std/fasteners.forma +170 -0
  92. package/build/core/std/gridfinity.forma +182 -0
  93. package/build/core/std/joints.forma +120 -0
  94. package/build/core/std/mechanics.forma +276 -0
  95. package/build/core/std/patterns.forma +138 -0
  96. package/build/core/std/threads.forma +152 -0
  97. package/package.json +59 -4
@@ -0,0 +1,94 @@
1
+ // A faithful port of the parts of Python's difflib used for "did you mean ...?" suggestions,
2
+ // so every Forma implementation suggests exactly the same names.
3
+ function matchingBlocksSize(a, b) {
4
+ const b2j = new Map();
5
+ b.forEach((ch, j) => {
6
+ const list = b2j.get(ch);
7
+ if (list)
8
+ list.push(j);
9
+ else
10
+ b2j.set(ch, [j]);
11
+ });
12
+ const longest = (alo, ahi, blo, bhi) => {
13
+ let besti = alo, bestj = blo, bestsize = 0;
14
+ let j2len = new Map();
15
+ for (let i = alo; i < ahi; i++) {
16
+ const newj2len = new Map();
17
+ for (const j of b2j.get(a[i]) ?? []) {
18
+ if (j < blo)
19
+ continue;
20
+ if (j >= bhi)
21
+ break;
22
+ const k = (j2len.get(j - 1) ?? 0) + 1;
23
+ newj2len.set(j, k);
24
+ if (k > bestsize) {
25
+ besti = i - k + 1;
26
+ bestj = j - k + 1;
27
+ bestsize = k;
28
+ }
29
+ }
30
+ j2len = newj2len;
31
+ }
32
+ while (besti > alo && bestj > blo && a[besti - 1] === b[bestj - 1]) {
33
+ besti--;
34
+ bestj--;
35
+ bestsize++;
36
+ }
37
+ while (besti + bestsize < ahi && bestj + bestsize < bhi && a[besti + bestsize] === b[bestj + bestsize]) {
38
+ bestsize++;
39
+ }
40
+ return [besti, bestj, bestsize];
41
+ };
42
+ let total = 0;
43
+ const queue = [[0, a.length, 0, b.length]];
44
+ while (queue.length) {
45
+ const [alo, ahi, blo, bhi] = queue.pop();
46
+ const [i, j, k] = longest(alo, ahi, blo, bhi);
47
+ if (k) {
48
+ total += k;
49
+ if (alo < i && blo < j)
50
+ queue.push([alo, i, blo, j]);
51
+ if (i + k < ahi && j + k < bhi)
52
+ queue.push([i + k, ahi, j + k, bhi]);
53
+ }
54
+ }
55
+ return total;
56
+ }
57
+ function ratio(len, matches) {
58
+ return len ? (2 * matches) / len : 1;
59
+ }
60
+ /** Python's difflib.get_close_matches(word, options, n=1, cutoff=0.6)[0], or null. */
61
+ export function closeMatch(word, options, cutoff = 0.6) {
62
+ const b = Array.from(word);
63
+ let best = null;
64
+ for (const x of options) {
65
+ const a = Array.from(x);
66
+ const total = a.length + b.length;
67
+ if (ratio(total, Math.min(a.length, b.length)) < cutoff)
68
+ continue; // real_quick_ratio
69
+ const avail = new Map();
70
+ for (const ch of b)
71
+ avail.set(ch, (avail.get(ch) ?? 0) + 1);
72
+ let common = 0;
73
+ for (const ch of a) {
74
+ const n = avail.get(ch) ?? 0;
75
+ if (n > 0) {
76
+ common++;
77
+ avail.set(ch, n - 1);
78
+ }
79
+ }
80
+ if (ratio(total, common) < cutoff)
81
+ continue; // quick_ratio
82
+ const score = ratio(total, matchingBlocksSize(a, b));
83
+ if (score < cutoff)
84
+ continue;
85
+ if (!best || score > best[0] || (score === best[0] && x > best[1]))
86
+ best = [score, x];
87
+ }
88
+ return best ? best[1] : null;
89
+ }
90
+ export function suggest(name, options) {
91
+ const m = closeMatch(name, options);
92
+ return m !== null ? ` (did you mean '${m}'?)` : '';
93
+ }
94
+ //# sourceMappingURL=difflib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"difflib.js","sourceRoot":"","sources":["../../../packages/core/src/difflib.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iEAAiE;AAEjE,SAAS,kBAAkB,CAAC,CAAW,EAAE,CAAW;IAClD,MAAM,GAAG,GAAG,IAA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AAE,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACV,MAAM,EAAE,CAAC;gBACT,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM;YAAE,SAAS,CAAC,cAAc;QAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,KAAK,GAAG,MAAM;YAAE,SAAS;QAC7B,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAAE,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,OAAyB;IAC7D,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Position in a source file: [line, column, file]. Lines and columns start at 1. */
2
+ export type Pos = [number, number, string | null];
3
+ export declare class FormaError extends Error {
4
+ msg: string;
5
+ line: number | null;
6
+ col: number | null;
7
+ file: string | null;
8
+ constructor(msg: string, pos?: Pos | null);
9
+ }
@@ -0,0 +1,14 @@
1
+ export class FormaError extends Error {
2
+ msg;
3
+ line;
4
+ col;
5
+ file;
6
+ constructor(msg, pos) {
7
+ super(msg);
8
+ this.msg = msg;
9
+ this.line = pos ? pos[0] : null;
10
+ this.col = pos ? pos[1] : null;
11
+ this.file = pos && pos.length > 2 ? pos[2] : null;
12
+ }
13
+ }
14
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../packages/core/src/errors.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,GAAG,CAAS;IACZ,IAAI,CAAgB;IACpB,GAAG,CAAgB;IACnB,IAAI,CAAgB;IAEpB,YAAY,GAAW,EAAE,GAAgB;QACvC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { Poly } from './geometry.js';
2
+ /** Export 2D contours as an SVG document in millimetres (1:1 scale, Y-flipped to SVG coords, holes via evenodd). */
3
+ export declare function svgText(polys: Poly[], is2d?: boolean): string;
4
+ export declare function svgBytes(polys: Poly[], is2d?: boolean): Uint8Array;
5
+ /** Export 2D contours as an ASCII AutoCAD R12 DXF document in millimetres (closed POLYLINE entities). */
6
+ export declare function dxfText(polys: Poly[], is2d?: boolean): string;
7
+ export declare function dxfBytes(polys: Poly[], is2d?: boolean): Uint8Array;
8
+ /** Export 2D contours as a 1:1 millimetre-scale PDF 1.4 vector template (10mm margin, even-odd fill + hairline stroke). */
9
+ export declare function pdfText(polys: Poly[], is2d?: boolean): string;
10
+ export declare function pdfBytes(polys: Poly[], is2d?: boolean): Uint8Array;
@@ -0,0 +1,127 @@
1
+ // 2D SVG and DXF exporters (for laser cutters, CNC, and 2D CAD).
2
+ // Extracts exact 2D contours (with holes) via Manifold CrossSection (slice for 2D shapes, XY projection for 3D).
3
+ import { FormaError } from './errors.js';
4
+ import { manifoldContours2d } from './manifold.js';
5
+ const fmt = (n) => {
6
+ const r = Math.round(n * 1e4) / 1e4;
7
+ return Object.is(r, -0) ? '0' : String(r);
8
+ };
9
+ function getContours(polys, is2d) {
10
+ const contours = manifoldContours2d(polys, is2d);
11
+ if (contours === null)
12
+ throw new FormaError('2D export requires a closed (manifold) shape');
13
+ const nonEmpty = contours.filter((c) => c.length >= 3);
14
+ if (!nonEmpty.length)
15
+ throw new FormaError('2D export produced an empty outline');
16
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
17
+ for (const ring of nonEmpty) {
18
+ for (const [x, y] of ring) {
19
+ if (x < minX)
20
+ minX = x;
21
+ if (y < minY)
22
+ minY = y;
23
+ if (x > maxX)
24
+ maxX = x;
25
+ if (y > maxY)
26
+ maxY = y;
27
+ }
28
+ }
29
+ return { contours: nonEmpty, minX, minY, maxX, maxY };
30
+ }
31
+ /** Export 2D contours as an SVG document in millimetres (1:1 scale, Y-flipped to SVG coords, holes via evenodd). */
32
+ export function svgText(polys, is2d = false) {
33
+ const { contours, minX, minY, maxX, maxY } = getContours(polys, is2d);
34
+ const w = Math.max(maxX - minX, 1e-4);
35
+ const h = Math.max(maxY - minY, 1e-4);
36
+ const parts = [];
37
+ for (const ring of contours) {
38
+ const cmds = ring.map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${fmt(x - minX)} ${fmt(maxY - y)}`);
39
+ parts.push(cmds.join(' ') + ' Z');
40
+ }
41
+ return [
42
+ '<?xml version="1.0" encoding="UTF-8"?>',
43
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${fmt(w)}mm" height="${fmt(h)}mm" viewBox="0 0 ${fmt(w)} ${fmt(h)}">`,
44
+ ` <path d="${parts.join(' ')}" fill="#1d1f22" fill-rule="evenodd" stroke="#000000" stroke-width="0.2"/>`,
45
+ '</svg>',
46
+ '',
47
+ ].join('\n');
48
+ }
49
+ export function svgBytes(polys, is2d = false) {
50
+ return new TextEncoder().encode(svgText(polys, is2d));
51
+ }
52
+ /** Export 2D contours as an ASCII AutoCAD R12 DXF document in millimetres (closed POLYLINE entities). */
53
+ export function dxfText(polys, is2d = false) {
54
+ const { contours, minX, minY, maxX, maxY } = getContours(polys, is2d);
55
+ const lines = [
56
+ '0', 'SECTION',
57
+ '2', 'HEADER',
58
+ '9', '$ACADVER', '1', 'AC1009',
59
+ '9', '$INSUNITS', '70', '4',
60
+ '9', '$EXTMIN', '10', fmt(minX), '20', fmt(minY), '30', '0',
61
+ '9', '$EXTMAX', '10', fmt(maxX), '20', fmt(maxY), '30', '0',
62
+ '0', 'ENDSEC',
63
+ '0', 'SECTION',
64
+ '2', 'ENTITIES',
65
+ ];
66
+ for (const ring of contours) {
67
+ lines.push('0', 'POLYLINE', '8', '0', '66', '1', '70', '1', '10', '0', '20', '0', '30', '0');
68
+ for (const [x, y] of ring) {
69
+ lines.push('0', 'VERTEX', '8', '0', '10', fmt(x), '20', fmt(y), '30', '0');
70
+ }
71
+ lines.push('0', 'SEQEND', '8', '0');
72
+ }
73
+ lines.push('0', 'ENDSEC', '0', 'EOF', '');
74
+ return lines.join('\n');
75
+ }
76
+ export function dxfBytes(polys, is2d = false) {
77
+ return new TextEncoder().encode(dxfText(polys, is2d));
78
+ }
79
+ const MM_TO_PT = 72 / 25.4;
80
+ /** Export 2D contours as a 1:1 millimetre-scale PDF 1.4 vector template (10mm margin, even-odd fill + hairline stroke). */
81
+ export function pdfText(polys, is2d = false) {
82
+ const { contours, minX, minY, maxX, maxY } = getContours(polys, is2d);
83
+ const marginMm = 10;
84
+ const pageW = Math.max(maxX - minX, 1e-4) + marginMm * 2;
85
+ const pageH = Math.max(maxY - minY, 1e-4) + marginMm * 2;
86
+ const wPt = fmt(pageW * MM_TO_PT);
87
+ const hPt = fmt(pageH * MM_TO_PT);
88
+ const ops = [
89
+ '0.567 w',
90
+ '0 0 0 RG',
91
+ '0.94 0.95 0.96 rg',
92
+ ];
93
+ for (const ring of contours) {
94
+ ring.forEach(([x, y], i) => {
95
+ const px = fmt((x - minX + marginMm) * MM_TO_PT);
96
+ const py = fmt((y - minY + marginMm) * MM_TO_PT);
97
+ ops.push(`${px} ${py} ${i === 0 ? 'm' : 'l'}`);
98
+ });
99
+ ops.push('h');
100
+ }
101
+ ops.push('B*');
102
+ const stream = ops.join('\n') + '\n';
103
+ const objects = [
104
+ '1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n',
105
+ '2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n',
106
+ `3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${wPt} ${hPt}] /Contents 4 0 R /Resources << >> >>\nendobj\n`,
107
+ `4 0 obj\n<< /Length ${stream.length} >>\nstream\n${stream}endstream\nendobj\n`,
108
+ ];
109
+ let out = '%PDF-1.4\n';
110
+ const offsets = [0];
111
+ for (const obj of objects) {
112
+ offsets.push(out.length);
113
+ out += obj;
114
+ }
115
+ const xrefPos = out.length;
116
+ out += `xref\n0 ${objects.length + 1}\n`;
117
+ out += '0000000000 65535 f \n';
118
+ for (let i = 1; i < offsets.length; i++) {
119
+ out += `${String(offsets[i]).padStart(10, '0')} 00000 n \n`;
120
+ }
121
+ out += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xrefPos}\n%%EOF\n`;
122
+ return out;
123
+ }
124
+ export function pdfBytes(polys, is2d = false) {
125
+ return new TextEncoder().encode(pdfText(polys, is2d));
126
+ }
127
+ //# sourceMappingURL=export2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export2d.js","sourceRoot":"","sources":["../../../packages/core/src/export2d.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,iHAAiH;AAEjH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE;IAChC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACpC,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,SAAS,WAAW,CAAC,KAAa,EAAE,IAAa;IAC/C,MAAM,QAAQ,GAAG,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjD,IAAI,QAAQ,KAAK,IAAI;QAAE,MAAM,IAAI,UAAU,CAAC,8CAA8C,CAAC,CAAC;IAC5F,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,UAAU,CAAC,qCAAqC,CAAC,CAAC;IAClF,IAAI,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC;IACzE,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,CAAC,EAAE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AAI,GAAG,iDAAiD;QACnH,uBAAuB,MAAM,CAAC,MAAM,gBAAgB,MAAM,qBAAqB;KAChF,CAAC;IAEF,IAAI,GAAG,GAAG,YAAY,CAAC;IACvB,MAAM,OAAO,GAAa,CAAC,CAAC,CAAC,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,GAAG,IAAI,GAAG,CAAC;IACb,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC;IAC3B,GAAG,IAAI,WAAW,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC;IACzC,GAAG,IAAI,uBAAuB,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,GAAG,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC;IAC9D,CAAC;IACD,GAAG,IAAI,qBAAqB,OAAO,CAAC,MAAM,GAAG,CAAC,+BAA+B,OAAO,WAAW,CAAC;IAChG,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,IAAI,GAAG,KAAK;IAClD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { Pos } from './errors.js';
2
+ export type Vec3 = [number, number, number];
3
+ export type Vec2 = [number, number];
4
+ export type Mat3 = [Vec3, Vec3, Vec3];
5
+ export declare const EPS = 0.00001;
6
+ /** Python's round(x, nd) for keys: correctly rounded decimal, as a string (−0 folded into 0). */
7
+ export declare function roundKey(x: number, nd: number): string;
8
+ /** Python's round(x, nd) as a number. */
9
+ export declare function pyRoundTo(x: number, nd: number): number;
10
+ /** Python's round(x) for integers: halves go to the even neighbour. */
11
+ export declare function pyRound(x: number): number;
12
+ export declare function newell(v: Vec3[]): [Vec3 | null, number];
13
+ export declare class Poly {
14
+ v: Vec3[];
15
+ n: Vec3;
16
+ w: number;
17
+ c: string | null;
18
+ constructor(v: Vec3[], c?: string | null, n?: Vec3 | null, w?: number);
19
+ flipped(): Poly;
20
+ }
21
+ export declare function makePoly(v: Vec3[], c?: string | null): Poly | null;
22
+ export declare function split(n: Vec3, w: number, p: Poly, cf: Poly[], cb: Poly[], f: Poly[], b: Poly[]): void;
23
+ export declare class BspNode {
24
+ n: Vec3 | null;
25
+ w: number;
26
+ front: BspNode | null;
27
+ back: BspNode | null;
28
+ polys: Poly[];
29
+ constructor(polys?: Poly[]);
30
+ nodes(): BspNode[];
31
+ build(polys: Poly[]): void;
32
+ clipPolygons(polys: Poly[]): Poly[];
33
+ clipTo(bsp: BspNode): void;
34
+ invert(): void;
35
+ allPolys(): Poly[];
36
+ }
37
+ export type BBox3 = [Vec3, Vec3];
38
+ export declare function bboxOf(polys: Poly[]): BBox3 | null;
39
+ export declare function boxesOverlap(a: BBox3 | null, b: BBox3 | null): boolean;
40
+ /** n-way union: uses Manifold WASM when possible, falling back to BSP for non-manifold inputs. */
41
+ export declare function csgUnion(input: Poly[][]): Poly[];
42
+ export declare function csgSubtract(A: Poly[], B: Poly[]): Poly[];
43
+ /** Subtract multiple cutters from A in a single Manifold pass (skipping non-overlapping cutters). */
44
+ export declare function csgSubtractMany(A: Poly[], cutters: Poly[][]): Poly[];
45
+ export declare function csgIntersect(A: Poly[], B: Poly[]): Poly[];
46
+ /** N-way intersection in a single Manifold pass. */
47
+ export declare function csgIntersectMany(sets: Poly[][]): Poly[];
48
+ export type QualityName = 'draft' | 'normal' | 'fine';
49
+ export declare const QUALITY: Record<QualityName, [number, number, number]>;
50
+ export declare const quality: {
51
+ name: QualityName;
52
+ fs: number;
53
+ lo: number;
54
+ hi: number;
55
+ };
56
+ export declare function setQuality(name: QualityName): void;
57
+ export declare function segmentsFor(r: number, override?: number | null): number;
58
+ export declare function primSphere(r: number, seg: number): Poly[];
59
+ export declare function primCone(r1: number, r2: number, h: number, seg: number, z0?: number): Poly[];
60
+ export declare function primBox(sx: number, sy: number, sz: number, z0: number): Poly[];
61
+ export declare function primTorus(R: number, t: number, seg: number, tseg: number): Poly[];
62
+ export declare const I3: Mat3;
63
+ export declare function matMul(a: Mat3, b: Mat3): Mat3;
64
+ export declare function matDet(m: Mat3): number;
65
+ export declare function rotX(a: number): Mat3;
66
+ export declare function rotY(a: number): Mat3;
67
+ export declare function rotZ(a: number): Mat3;
68
+ export declare function rotAxis(axis: Vec3, ang: number): Mat3;
69
+ /** 2D shapes are thin prisms (z = 0..1); cutters are stretched to z = -1..2 so caps never coincide. */
70
+ export declare function stretchZ(polys: Poly[]): Poly[];
71
+ export declare function cross2(o: Vec2, a: Vec2, b: Vec2): number;
72
+ export declare function cleanOutline(pts: Vec2[]): Vec2[];
73
+ export declare function earClip(pts: Vec2[]): Vec2[][] | null;
74
+ export declare function signedArea(o: Vec2[]): number;
75
+ export declare function prism2d(input: Vec2[], what: string, pos: Pos | null): Poly[];
76
+ export declare function sliceZ(polys: Poly[], n: number): Poly[];
77
+ export declare function fan<T>(v: T[]): T[][];
78
+ export declare function pointInOutline(p: Vec2, poly: Vec2[]): boolean;
79
+ /** Quickhull. Returns outward triangles, or null if the points are flat. */
80
+ export declare function convexHull3d(points: Vec3[]): Vec3[][] | null;
81
+ export declare function convexHull2d(points: Vec2[]): Vec2[];
82
+ /** How many edges have no matching opposite edge (0 for a closed, printable mesh). */
83
+ export declare function openEdges(polys: Poly[]): number;
84
+ /**
85
+ * After booleans a vertex of one face can sit in the middle of a neighbour's edge (a T-junction).
86
+ * Every vertex lying on an edge is inserted into that edge; changed faces are re-triangulated
87
+ * around their centre so no zero-area triangles appear.
88
+ */
89
+ export declare function fixTJunctions(polys: Poly[]): Poly[];
90
+ export declare function volume(polys: Poly[]): number;
91
+ export declare function triangleCount(polys: Poly[]): number;
92
+ /** Binary STL. */
93
+ export declare function stlBytes(polys: Poly[]): Uint8Array;