surfcad-mcp 0.2.4 → 0.3.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.
- package/README.md +14 -3
- package/data/commands.json +11252 -4296
- package/data/helpers.json +1765 -0
- package/package.json +1 -1
- package/src/helpers.mjs +209 -0
- package/src/prompt/buildGuidance.mjs +21 -0
- package/src/prompt/errorHints.mjs +288 -0
- package/src/prompt/guide.mjs +285 -0
- package/src/prompt/promptSession.mjs +94 -11
- package/src/prompt/promptTools.mjs +31 -3
- package/src/relay.mjs +9 -3
- package/src/server.mjs +107 -19
|
@@ -0,0 +1,1765 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatedFrom": "src/lib/surfcad/runtime.js HELPER_FUNCTIONS",
|
|
3
|
+
"count": 79,
|
|
4
|
+
"helpers": [
|
|
5
|
+
{
|
|
6
|
+
"name": "shell",
|
|
7
|
+
"signature": "shell(manifold, thickness, opening = 'z')",
|
|
8
|
+
"params": [
|
|
9
|
+
{
|
|
10
|
+
"name": "manifold",
|
|
11
|
+
"text": "manifold"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "thickness",
|
|
15
|
+
"text": "thickness"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "opening",
|
|
19
|
+
"text": "opening = 'z'",
|
|
20
|
+
"default": "'z'"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"description": "shell(manifold, thickness, opening) — the CAVITY tool. ",
|
|
24
|
+
"doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.)\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
|
|
25
|
+
"examples": [
|
|
26
|
+
"// Uniform 2mm wall, open at the top\nconst box = Manifold.cube([50, 30, 40], true);\nreturn hollow(box, 2, 'z');\n\n// Opening on a face you picked in the viewport, or queried\nlet part = Manifold.cylinder(40, 20, 20, 64);\npart = hollow(part, 2.5, facesByNormal(part, [0, 0, 1])[0]);\n\n// Closed hollow (a sealed void), and two openings at once\nconst sealed = hollow(Manifold.cube([30, 30, 30], true), 3, 'none');\nconst openBoth = hollow(Manifold.cube([30, 30, 30], true), 3, ['z', '-z']);"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "hollow",
|
|
31
|
+
"signature": "hollow(manifold, thickness, opening = 'z')",
|
|
32
|
+
"params": [
|
|
33
|
+
{
|
|
34
|
+
"name": "manifold",
|
|
35
|
+
"text": "manifold"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "thickness",
|
|
39
|
+
"text": "thickness"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "opening",
|
|
43
|
+
"text": "opening = 'z'",
|
|
44
|
+
"default": "'z'"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"description": "hollow(manifold, thickness, opening) — the shelled SOLID (walls only).",
|
|
48
|
+
"doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.)\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
|
|
49
|
+
"examples": [
|
|
50
|
+
"// Uniform 2mm wall, open at the top\nconst box = Manifold.cube([50, 30, 40], true);\nreturn hollow(box, 2, 'z');\n\n// Opening on a face you picked in the viewport, or queried\nlet part = Manifold.cylinder(40, 20, 20, 64);\npart = hollow(part, 2.5, facesByNormal(part, [0, 0, 1])[0]);\n\n// Closed hollow (a sealed void), and two openings at once\nconst sealed = hollow(Manifold.cube([30, 30, 30], true), 3, 'none');\nconst openBoth = hollow(Manifold.cube([30, 30, 30], true), 3, ['z', '-z']);"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "getScaleRatio",
|
|
55
|
+
"signature": "getScaleRatio(manifold, axis, thickness)",
|
|
56
|
+
"params": [
|
|
57
|
+
{
|
|
58
|
+
"name": "manifold",
|
|
59
|
+
"text": "manifold"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "axis",
|
|
63
|
+
"text": "axis"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "thickness",
|
|
67
|
+
"text": "thickness"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"description": "Helper to compute uniform scale ratio based on min perpendicular dimension LEGACY: this is the math the pre-uniform-wall `shell()` used. ",
|
|
71
|
+
"doc": "Legacy. Computes the uniform scale ratio the old scale-based `shell()` used.\nNothing calls it any more — `shell()` offsets each face instead, because one\nscale ratio cannot give a non-cubic part a uniform wall. Kept so existing\nscripts that call it still run.\n\n**Parameters:**\n- `manifold` - The input manifold\n- `axis` - Axis index (0=x, 1=y, 2=z)\n- `thickness` - Desired wall thickness\n\n**Returns:** Scale ratio (0-1)\n\n---\n\n## Selection & Feature Helpers (C4)\n\nThese helpers add a geometric **selector layer** (Manifold has no native\nface/edge API) plus parametric **features** (holes, counterbores,\ncountersinks, chamfers). They read a manifold's mesh via `getMesh()` and\noperate in local 2D face frames, so a script can reason about \"the top\nface\", \"vertical edges\", or \"a hole pattern on this wall\" the way a CAD\nuser does.\n\nAll of them take and return standard `Manifold` objects and validate the\nresult (`status() === 'NoError'`), throwing on failure.",
|
|
72
|
+
"examples": []
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "roundedBox",
|
|
76
|
+
"signature": "roundedBox(size, radius, segments = 16)",
|
|
77
|
+
"params": [
|
|
78
|
+
{
|
|
79
|
+
"name": "size",
|
|
80
|
+
"text": "size"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "radius",
|
|
84
|
+
"text": "radius"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "segments",
|
|
88
|
+
"text": "segments = 16",
|
|
89
|
+
"default": "16"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"description": "Create a rounded box (box with filleted edges)",
|
|
93
|
+
"doc": "Create a rounded box (box with filleted edges)",
|
|
94
|
+
"examples": []
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "tube",
|
|
98
|
+
"signature": "tube(outerRadius, innerRadius, height, segments = 32)",
|
|
99
|
+
"params": [
|
|
100
|
+
{
|
|
101
|
+
"name": "outerRadius",
|
|
102
|
+
"text": "outerRadius"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "innerRadius",
|
|
106
|
+
"text": "innerRadius"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "height",
|
|
110
|
+
"text": "height"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "segments",
|
|
114
|
+
"text": "segments = 32",
|
|
115
|
+
"default": "32"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"description": "Create a tube/pipe shape — round or rectangular. ",
|
|
119
|
+
"doc": "Creates a tube/pipe shape — round or **rectangular**. Passing an array as the\nfirst argument switches to the rectangular form (and the 4th argument becomes its\noptions object rather than a segment count).\n\n\n\n**Parameters:**\n- `outerRadius` - Outer radius, or `[width, depth]` for a rectangle (a single\n number in `rectTube` means a square)\n- `innerRadius` - Inner radius. For a rectangle: a **number** is read as a\n uniform wall thickness, `[width, depth]` as an explicit inner size.\n- `height` - Height of the tube (z = 0 .. height)\n- `segments` - Number of circular segments (default: 32). For a rectangle this\n slot is the options object instead:\n - `cornerRadius` - outer corner radius (default 0, i.e. sharp)\n - `innerCornerRadius` - defaults to `cornerRadius - wall`, keeping the wall\n uniform around the corner\n - `segments` - segments per full circle for the corner arcs (default 32)\n - `center` - center the extrusion on z instead of starting at z = 0\n\n---",
|
|
120
|
+
"examples": [
|
|
121
|
+
"// Round: 10mm outer radius, 8mm inner radius, 30mm tall\nconst pipe = tube(10, 8, 30, 32);\n\n// Rectangular 40 x 20, uniform 2.5mm wall, 60mm tall\nconst box = tube([40, 20], 2.5, 60);\n\n// Explicit inner size, and rounded corners (the wall stays uniform round them)\nconst a = tube([40, 20], [30, 10], 60);\nconst b = tube([40, 20], 2.5, 60, { cornerRadius: 4 });\n\n// Square tube, 3mm wall\nconst sq = rectTube(30, 3, 20);"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "rectTube",
|
|
126
|
+
"signature": "rectTube(outer, inner, height, opts = {})",
|
|
127
|
+
"params": [
|
|
128
|
+
{
|
|
129
|
+
"name": "outer",
|
|
130
|
+
"text": "outer"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "inner",
|
|
134
|
+
"text": "inner"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "height",
|
|
138
|
+
"text": "height"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "opts",
|
|
142
|
+
"text": "opts = {}",
|
|
143
|
+
"default": "{}"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"description": "rectTube(outer, inner, height, opts) — rectangular (square) tube.",
|
|
147
|
+
"doc": "Creates a tube/pipe shape — round or **rectangular**. Passing an array as the\nfirst argument switches to the rectangular form (and the 4th argument becomes its\noptions object rather than a segment count).\n\n\n\n**Parameters:**\n- `outerRadius` - Outer radius, or `[width, depth]` for a rectangle (a single\n number in `rectTube` means a square)\n- `innerRadius` - Inner radius. For a rectangle: a **number** is read as a\n uniform wall thickness, `[width, depth]` as an explicit inner size.\n- `height` - Height of the tube (z = 0 .. height)\n- `segments` - Number of circular segments (default: 32). For a rectangle this\n slot is the options object instead:\n - `cornerRadius` - outer corner radius (default 0, i.e. sharp)\n - `innerCornerRadius` - defaults to `cornerRadius - wall`, keeping the wall\n uniform around the corner\n - `segments` - segments per full circle for the corner arcs (default 32)\n - `center` - center the extrusion on z instead of starting at z = 0\n\n---",
|
|
148
|
+
"examples": [
|
|
149
|
+
"// Round: 10mm outer radius, 8mm inner radius, 30mm tall\nconst pipe = tube(10, 8, 30, 32);\n\n// Rectangular 40 x 20, uniform 2.5mm wall, 60mm tall\nconst box = tube([40, 20], 2.5, 60);\n\n// Explicit inner size, and rounded corners (the wall stays uniform round them)\nconst a = tube([40, 20], [30, 10], 60);\nconst b = tube([40, 20], 2.5, 60, { cornerRadius: 4 });\n\n// Square tube, 3mm wall\nconst sq = rectTube(30, 3, 20);"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "hexPrism",
|
|
154
|
+
"signature": "hexPrism(radius, height)",
|
|
155
|
+
"params": [
|
|
156
|
+
{
|
|
157
|
+
"name": "radius",
|
|
158
|
+
"text": "radius"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "height",
|
|
162
|
+
"text": "height"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"description": "Create a hexagonal prism",
|
|
166
|
+
"doc": "Creates a hexagonal prism (6-sided cylinder).\n\n\n\n**Parameters:**\n- `radius` - Circumradius (center to vertex)\n- `height` - Height\n\n---",
|
|
167
|
+
"examples": [
|
|
168
|
+
"// Create a hex nut shape\nconst hex = hexPrism(10, 5);\nreturn hex;"
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "mirror",
|
|
173
|
+
"signature": "mirror(manifold, plane = 'xy', keepOriginal = true)",
|
|
174
|
+
"params": [
|
|
175
|
+
{
|
|
176
|
+
"name": "manifold",
|
|
177
|
+
"text": "manifold"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "plane",
|
|
181
|
+
"text": "plane = 'xy'",
|
|
182
|
+
"default": "'xy'"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "keepOriginal",
|
|
186
|
+
"text": "keepOriginal = true",
|
|
187
|
+
"default": "true"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"description": "Mirror a manifold across a plane",
|
|
191
|
+
"doc": "Mirrors a manifold across a plane.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to mirror\n- `plane` - Mirror plane: 'xy', 'xz', or 'yz'\n- `keepOriginal` - If true, unions with original (default: true)\n\n---",
|
|
192
|
+
"examples": [
|
|
193
|
+
"// Create a symmetric part\nconst half = Manifold.cube([20, 10, 10]);\nconst full = mirror(half, 'yz', true);\nreturn full;"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "array3D",
|
|
198
|
+
"signature": "array3D(manifold, counts, spacing)",
|
|
199
|
+
"params": [
|
|
200
|
+
{
|
|
201
|
+
"name": "manifold",
|
|
202
|
+
"text": "manifold"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"name": "counts",
|
|
206
|
+
"text": "counts"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "spacing",
|
|
210
|
+
"text": "spacing"
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"description": "Create an array/grid of manifolds",
|
|
214
|
+
"doc": "Creates a 3D rectangular array of copies.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to array\n- `counts` - [nx, ny, nz] number of copies in each direction\n- `spacing` - [dx, dy, dz] spacing between copies\n\n---",
|
|
215
|
+
"examples": [
|
|
216
|
+
"// Create a 3x3x2 grid of cubes\nconst cube = Manifold.cube([5, 5, 5], true);\nconst grid = array3D(cube, [3, 3, 2], [10, 10, 10]);\nreturn grid;"
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"name": "polarArray",
|
|
221
|
+
"signature": "polarArray(manifold, count, radius = 0, axis = 'z')",
|
|
222
|
+
"params": [
|
|
223
|
+
{
|
|
224
|
+
"name": "manifold",
|
|
225
|
+
"text": "manifold"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "count",
|
|
229
|
+
"text": "count"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "radius",
|
|
233
|
+
"text": "radius = 0",
|
|
234
|
+
"default": "0"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "axis",
|
|
238
|
+
"text": "axis = 'z'",
|
|
239
|
+
"default": "'z'"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"description": "Create a polar array (copies around an axis)",
|
|
243
|
+
"doc": "Creates a circular/polar array of copies around an axis.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to array\n- `count` - Number of copies\n- `radius` - Radius from center (optional offset)\n- `axis` - Rotation axis: 'x', 'y', or 'z' (default: 'z')\n\n---",
|
|
244
|
+
"examples": [
|
|
245
|
+
"// Create 6 cylinders in a circle\nconst cylinder = Manifold.cylinder(20, 5, 5, 32);\nconst circle = polarArray(cylinder, 6, 30, 'z');\nreturn circle;"
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"name": "patternOnPoints",
|
|
250
|
+
"signature": "patternOnPoints(manifold, points, opts = {})",
|
|
251
|
+
"params": [
|
|
252
|
+
{
|
|
253
|
+
"name": "manifold",
|
|
254
|
+
"text": "manifold"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "points",
|
|
258
|
+
"text": "points"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "opts",
|
|
262
|
+
"text": "opts = {}",
|
|
263
|
+
"default": "{}"
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
"description": "Pattern on points: one copy of `manifold` at every point, turned so its `up` axis follows the point's `axis` when the point has one. ",
|
|
267
|
+
"doc": "One copy of the body at every point, turned so its `up` axis follows the point's `axis` when the point has one. The hardware helper: a bolt onto the hole centers and axes of the part it fastens.\n\n\n\n**Parameters:**\n- `manifold` - The body to copy (one instance)\n- `points` - Array of `[x, y, z]` or `{ at: [x, y, z], axis?: [nx, ny, nz] }` in mm; a point with no axis is a plain translate\n- `opts.up` - The body axis that follows each point's axis (default `[0, 0, 1]`)\n- `opts.keepOriginal` - Also keep the source where it is (default `false`)\n- `opts.merge` - Union the copies (default `true`); `false` composes them as separate bodies\n\nThrows a plain error on an empty list, a point that is not three numbers, or a zero axis. The palette item is **Points** (`patternPoints`, Build); the agent tool is `insert_pattern_points { points, up?, keepOriginal?, merge? }`.\n\n---",
|
|
268
|
+
"examples": [
|
|
269
|
+
"// Four bolts, one per hole; each hole gives its center and axis\nconst bolt = Manifold.cylinder(12, 2.5, 2.5, 24);\nlet part = patternOnPoints(bolt, [\n { at: [-20, -15, 6], axis: [0, 0, 1] },\n { at: [20, -15, 6], axis: [0, 0, 1] },\n { at: [-20, 15, 6], axis: [0, 0, 1] },\n { at: [20, 15, 6], axis: [0, 0, 1] },\n], { up: [0, 0, 1] });\nreturn part;"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"name": "center",
|
|
274
|
+
"signature": "center(manifold, axes = [true, true, true])",
|
|
275
|
+
"params": [
|
|
276
|
+
{
|
|
277
|
+
"name": "manifold",
|
|
278
|
+
"text": "manifold"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"name": "axes",
|
|
282
|
+
"text": "axes = [true, true, true]",
|
|
283
|
+
"default": "[true, true, true]"
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"description": "Center a manifold at origin",
|
|
287
|
+
"doc": "Centers a manifold at the origin.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to center\n- `axes` - [centerX, centerY, centerZ] which axes to center (default: all true)\n\n---",
|
|
288
|
+
"examples": [
|
|
289
|
+
"// Center on all axes\nconst box = Manifold.cube([20, 30, 10]);\nconst centered = center(box, [true, true, true]);\nreturn centered;\n\n// Center only on X and Y\nconst partCentered = center(box, [true, true, false]);"
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "align",
|
|
294
|
+
"signature": "align(manifold, options = {})",
|
|
295
|
+
"params": [
|
|
296
|
+
{
|
|
297
|
+
"name": "manifold",
|
|
298
|
+
"text": "manifold"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"name": "options",
|
|
302
|
+
"text": "options = {}",
|
|
303
|
+
"default": "{}"
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
"description": "Align a manifold to a specific position",
|
|
307
|
+
"doc": "Aligns a manifold to a specific position.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to align\n- `options.min` - [x, y, z] align min bounds (use undefined to skip)\n- `options.max` - [x, y, z] align max bounds\n- `options.center` - [x, y, z] align center\n\n---",
|
|
308
|
+
"examples": [
|
|
309
|
+
"// Align min-Z to the origin\nconst box = Manifold.cube([20, 20, 20], true);\nconst aligned = align(box, { min: [undefined, undefined, 0] });\nreturn aligned;\n\n// Center on X, align max-Y to 50\nconst positioned = align(box, { \n center: [0, undefined, undefined],\n max: [undefined, 50, undefined]\n});"
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "getDimensions",
|
|
314
|
+
"signature": "getDimensions(manifold)",
|
|
315
|
+
"params": [
|
|
316
|
+
{
|
|
317
|
+
"name": "manifold",
|
|
318
|
+
"text": "manifold"
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"description": "Get the dimensions of a manifold",
|
|
322
|
+
"doc": "Gets the dimensions and bounding box of a manifold.\n\n\n\n**Returns:**\n\n\n---",
|
|
323
|
+
"examples": [
|
|
324
|
+
"const box = Manifold.cube([20, 30, 10]);\nconst dims = getDimensions(box);\nconsole.log(dims.size); // [20, 30, 10]\nconsole.log(dims.center); // [10, 15, 5]\nconsole.log(dims.min); // [0, 0, 0]\nconsole.log(dims.max); // [20, 30, 10]",
|
|
325
|
+
"{\n size: [x, y, z], // Dimensions\n min: [x, y, z], // Minimum corner\n max: [x, y, z], // Maximum corner\n center: [x, y, z] // Center point\n}"
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "addDraft",
|
|
330
|
+
"signature": "addDraft(manifold, draftDeg, axis = \"z\")",
|
|
331
|
+
"params": [
|
|
332
|
+
{
|
|
333
|
+
"name": "manifold",
|
|
334
|
+
"text": "manifold"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "draftDeg",
|
|
338
|
+
"text": "draftDeg"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "axis",
|
|
342
|
+
"text": "axis = \"z\"",
|
|
343
|
+
"default": "\"z\""
|
|
344
|
+
}
|
|
345
|
+
],
|
|
346
|
+
"description": "Add draft angle to a manifold — every side wall, true constant angle. ",
|
|
347
|
+
"doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n\n---",
|
|
348
|
+
"examples": [
|
|
349
|
+
"// Whole part: 2° on every side wall, bottom fixed\nconst box = Manifold.cube([60, 20, 30], false);\nreturn addDraft(hollow(box, 2, 'z'), 2, 'z');\n\n// One picked face, pivoting about the top instead of the bottom\nlet part = Manifold.cube([60, 20, 30], false);\npart = draftFaces(part, facesByNormal(part, [1, 0, 0])[0], 3,\n { pull: 'z', reference: 'max' });\n\n// Several faces at once (what a shift-click multi-pick emits), flaring outward\npart = draftFaces(part, [\n { center: [60, 10, 15], normal: [1, 0, 0] },\n { center: [0, 10, 15], normal: [-1, 0, 0] },\n], -3, { pull: 'z', reference: 'min' });"
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"name": "draftFaces",
|
|
354
|
+
"signature": "draftFaces(manifold, faces, angleDeg, opts = {})",
|
|
355
|
+
"params": [
|
|
356
|
+
{
|
|
357
|
+
"name": "manifold",
|
|
358
|
+
"text": "manifold"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "faces",
|
|
362
|
+
"text": "faces"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "angleDeg",
|
|
366
|
+
"text": "angleDeg"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"name": "opts",
|
|
370
|
+
"text": "opts = {}",
|
|
371
|
+
"default": "{}"
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
"description": "draftFaces(manifold, faces, angleDeg, opts) — tilt the selected faces by a true constant angle about their intersection with a reference plane. ",
|
|
375
|
+
"doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n\n---",
|
|
376
|
+
"examples": [
|
|
377
|
+
"// Whole part: 2° on every side wall, bottom fixed\nconst box = Manifold.cube([60, 20, 30], false);\nreturn addDraft(hollow(box, 2, 'z'), 2, 'z');\n\n// One picked face, pivoting about the top instead of the bottom\nlet part = Manifold.cube([60, 20, 30], false);\npart = draftFaces(part, facesByNormal(part, [1, 0, 0])[0], 3,\n { pull: 'z', reference: 'max' });\n\n// Several faces at once (what a shift-click multi-pick emits), flaring outward\npart = draftFaces(part, [\n { center: [60, 10, 15], normal: [1, 0, 0] },\n { center: [0, 10, 15], normal: [-1, 0, 0] },\n], -3, { pull: 'z', reference: 'min' });"
|
|
378
|
+
]
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "cut",
|
|
382
|
+
"signature": "cut(manifold, plane, opts = {})",
|
|
383
|
+
"params": [
|
|
384
|
+
{
|
|
385
|
+
"name": "manifold",
|
|
386
|
+
"text": "manifold"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"name": "plane",
|
|
390
|
+
"text": "plane"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "opts",
|
|
394
|
+
"text": "opts = {}",
|
|
395
|
+
"default": "{}"
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
"description": "cut(manifold, plane, opts) — split one or more bodies with a plane, then optionally delete pieces. ",
|
|
399
|
+
"doc": "Splits every selected body with a plane, then optionally deletes pieces. The\ncut is Manifold's `splitByPlane`: the `'+'` piece is the side the normal\npoints to, and `'-'` is the other side. Pieces you keep stay separate bodies\n(`decompose()` returns them one by one). A body that does not cross the plane\nis left alone — same solid, same volume, still one body.\n\n\n\n**Parameters:**\n- `manifold` - The solid, or several solids grouped by `Manifold.compose`\n- `plane` - a face `{ center, normal }`, or an explicit `{ normal, originOffset }`.\n `offset` on a face is added along the normal (positive in the normal\n direction). Offset 0 is omitted and the call stays `{ center, normal }`.\n A world-axis name such as `'z'` is rejected.\n- `opts.keep` - `'both'` (default), `'+'`, or `'-'`\n- `opts.bodies` - which bodies to cut, each `{ at }` near that body's centroid.\n Omit to cut every body. Bodies you skip are unchanged.\n- `opts.drop` - pieces to delete when you are not dropping a whole side:\n `{ at, side: '+' | '-' }`\n\n**Returns:** The kept pieces. One piece is that solid. Several pieces are one\ncomposed manifold whose `decompose()` length is the number of pieces.\n\n**Notes:**\n- A body that only touches the plane is not cut.\n- Deleting every piece throws.\n- Pass `keep` or `drop`, not both.\n\n---",
|
|
400
|
+
"examples": [
|
|
401
|
+
"// Mid plane z = 0, keep both halves\nlet part = Manifold.cube([40, 30, 20], true);\npart = cut(part, { normal: [0, 0, 1], originOffset: 0 });\n\n// Same cut, keep only the +Z half\npart = cut(part, { normal: [0, 0, 1], originOffset: 0 }, { keep: '+' });\n\n// The plane is the face you picked — not a guessed world axis.\n// Offset 0 keeps this shape. A nonzero offset is along the face normal.\npart = cut(part, { center: [0, 0, 10], normal: [0, 0, 1] });\npart = cut(part, { center: [0, 0, 10], normal: [0, 0, 1], offset: -10 });"
|
|
402
|
+
]
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"name": "booleanBodies",
|
|
406
|
+
"signature": "booleanBodies(manifold, opts = {})",
|
|
407
|
+
"params": [
|
|
408
|
+
{
|
|
409
|
+
"name": "manifold",
|
|
410
|
+
"text": "manifold"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"name": "opts",
|
|
414
|
+
"text": "opts = {}",
|
|
415
|
+
"default": "{}"
|
|
416
|
+
}
|
|
417
|
+
],
|
|
418
|
+
"description": "booleanBodies(manifold, { op, bodies, drop }) — union, difference, or intersect of named bodies. ",
|
|
419
|
+
"doc": "booleanBodies(manifold, { op, bodies, drop }) — union, difference, or\nintersect of named bodies. The first { at } is the target. Later entries\nare tools, unioned together, then subtracted from or intersected with the\ntarget. Bodies that were not named stay in the solid.\n\nop: 'union' | 'difference' | 'intersect'.\nbodies: [{ at }] near each body's vertex centroid, in pick order.\n Omit to use every body, in decompose order.\ndrop: intersect only. [{ at }] centroids of leftover pieces to delete.\n A piece that is not listed stays. Deleting every piece throws.",
|
|
420
|
+
"examples": [
|
|
421
|
+
"part = booleanBodies(part, { op: 'difference', bodies: [{ at: [0, 0, 5] }, { at: [0, 0, -5] }] });"
|
|
422
|
+
]
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "externalBody",
|
|
426
|
+
"signature": "externalBody(source, opts = {})",
|
|
427
|
+
"params": [
|
|
428
|
+
{
|
|
429
|
+
"name": "source",
|
|
430
|
+
"text": "source"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "opts",
|
|
434
|
+
"text": "opts = {}",
|
|
435
|
+
"default": "{}"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"description": "externalBody(source, { bodies, offset }) — a frozen copy of geometry from another part. `source` is a function holding that part's script text as it was at Accept (or a Manifold). ",
|
|
439
|
+
"doc": "externalBody(source, { bodies, offset }) — a frozen copy of geometry from\nanother part. `source` is a function holding that part's script text as\nit was at Accept (or a Manifold). It is not linked: editing the source part\nlater does not change this copy. `bodies` picks bodies by vertex centroid\nin the source frame; `offset` poses the copy into this part's frame.",
|
|
440
|
+
"examples": [
|
|
441
|
+
"const copy = externalBody(() => otherScript(), { offset: [40, 0, 0] });"
|
|
442
|
+
]
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "move",
|
|
446
|
+
"signature": "move(manifold, delta, opts = {})",
|
|
447
|
+
"params": [
|
|
448
|
+
{
|
|
449
|
+
"name": "manifold",
|
|
450
|
+
"text": "manifold"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"name": "delta",
|
|
454
|
+
"text": "delta"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"name": "opts",
|
|
458
|
+
"text": "opts = {}",
|
|
459
|
+
"default": "{}"
|
|
460
|
+
}
|
|
461
|
+
],
|
|
462
|
+
"description": "move(manifold, [dx, dy, dz], { bodies: [{ at }] }) — translate one body. ",
|
|
463
|
+
"doc": "move(manifold, [dx, dy, dz], { bodies: [{ at }] }) — translate one body.\nSame Manifold.translate center() already uses, and the same decompose /\ncentroid / compose split cut() uses. Not a second kernel. The named body\nmoves; every other body stays. A zero delta returns the input solid.\n\nThe { at } point is that body's vertex centroid. cut() requires squared\ndistance ≤ 1e-4. A fillet does not retessellate the same way on the next\nrun, so that average can move by a few hundredths and a valid pick would\nmiss the tight gate. move() still takes the exact match, and otherwise\nthe nearest body within 1% of its radius (at least 0.05) when the next\nbody is farther than that. A point that is not near a centroid throws.",
|
|
464
|
+
"examples": [
|
|
465
|
+
"part = move(part, [10, 0, 0], { bodies: [{ at: [0, 0, 0] }] });"
|
|
466
|
+
]
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"name": "rotateAbout",
|
|
470
|
+
"signature": "rotateAbout(manifold, axis, angleDeg, center = null, opts = {})",
|
|
471
|
+
"params": [
|
|
472
|
+
{
|
|
473
|
+
"name": "manifold",
|
|
474
|
+
"text": "manifold"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"name": "axis",
|
|
478
|
+
"text": "axis"
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
"name": "angleDeg",
|
|
482
|
+
"text": "angleDeg"
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"name": "center",
|
|
486
|
+
"text": "center = null",
|
|
487
|
+
"default": "null"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"name": "opts",
|
|
491
|
+
"text": "opts = {}",
|
|
492
|
+
"default": "{}"
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
"description": "rotateAbout(manifold, axis, angleDeg, center, { bodies: [{ at }] }) — turn one body. ",
|
|
496
|
+
"doc": "Turns one body by `angleDeg` degrees (right-hand rule) about the line through `center` along `axis`. `axis` is `'x'`, `'y'`, `'z'` (a leading `-` flips it) or a vector `[ax, ay, az]`. `center` is `[x, y, z]` in mm, or `null` for that body's own vertex centroid. The body is named the way `move()` names it: `{ bodies: [{ at }] }` with the centroid from the Rotate card's double-click or `list_bodies`. The named body turns; every other body stays. Volume is unchanged and the bounding box follows the turn. A zero angle returns the input. The Rotate button (below Move) writes this call inside `// --- rotate begin --- / end ---` markers, so the strip shows a Rotate chip with edit, delete, and undo.\n\n\n\nA point that is not a body centroid, a zero-length axis, or a missing `bodies` entry throws with a `rotateAbout:` message.",
|
|
497
|
+
"examples": [
|
|
498
|
+
"part = rotateAbout(part, 'z', 90, null, { bodies: [{ at: [40, 0, 0] }] }); // quarter turn about its own centre\npart = rotateAbout(part, [0, 1, 0], -15, [0, 0, 10], { bodies: [{ at: [40, 0, 0] }] }); // about a line through [0, 0, 10]"
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"name": "moveFace",
|
|
503
|
+
"signature": "moveFace(manifold, faces, distance, opts = {})",
|
|
504
|
+
"params": [
|
|
505
|
+
{
|
|
506
|
+
"name": "manifold",
|
|
507
|
+
"text": "manifold"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
"name": "faces",
|
|
511
|
+
"text": "faces"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
"name": "distance",
|
|
515
|
+
"text": "distance"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"name": "opts",
|
|
519
|
+
"text": "opts = {}",
|
|
520
|
+
"default": "{}"
|
|
521
|
+
}
|
|
522
|
+
],
|
|
523
|
+
"description": "Offsets each selected face along its own normal by `distance`. ",
|
|
524
|
+
"doc": "Offsets each selected face along its own normal by `distance`. Adjacent faces stay on their planes, so they extend or trim and the solid stays closed. This is not `move()`, which translates a whole body.\n\n\n\n**Parameters:**\n- `manifold` - The solid\n- `faces` - a viewport pick `{ center, normal }`, a face from `facesByNormal()`, or an array of those\n- `distance` - millimetres along each selected face normal\n- `opts.flip` - reverse each face normal\n\n**Returns:** The solid with those faces offset.\n\n**Notes:**\n- A distance the walls cannot absorb throws. It does not return a folded mesh.\n- A picked face that is no longer on the body throws.\n\n---",
|
|
525
|
+
"examples": [
|
|
526
|
+
"let part = Manifold.cube([40, 30, 20], true);\npart = moveFace(part, [{ center: [0, 0, 10], normal: [0, 0, 1] }], 5);\npart = moveFace(part, [{ center: [0, 0, 10], normal: [0, 0, 1] }], 5, { flip: true });"
|
|
527
|
+
]
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"name": "deleteFace",
|
|
531
|
+
"signature": "deleteFace(manifold, faces)",
|
|
532
|
+
"params": [
|
|
533
|
+
{
|
|
534
|
+
"name": "manifold",
|
|
535
|
+
"text": "manifold"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"name": "faces",
|
|
539
|
+
"text": "faces"
|
|
540
|
+
}
|
|
541
|
+
],
|
|
542
|
+
"description": "deleteFace(manifold, faces) — remove the selected faces and heal by extending or trimming the neighboring faces. ",
|
|
543
|
+
"doc": "Removes the selected faces and heals the solid by extending or trimming the neighboring faces. A face is `{ center, normal }`, the same pick `moveFace` uses. If the neighbors cannot meet in a closed solid, this throws. It does not return an open or non-manifold mesh.\n\n\n\n**Parameters:**\n- `manifold` - The solid\n- `faces` - a viewport pick `{ center, normal }`, a face from `facesByNormal()`, or an array of those\n\n**Returns:** The healed solid.\n\n**Notes:**\n- Deleting one face of a cube throws: the side walls do not meet.\n- A planar chamfer whose two neighbors can meet is healed back to the sharp edge.\n\n---",
|
|
544
|
+
"examples": [
|
|
545
|
+
"let part = Manifold.cube([10, 10, 10], true);\npart = deleteFace(part, [{ center: [0, 0, 5], normal: [0, 0, 1] }]);"
|
|
546
|
+
]
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"name": "loft",
|
|
550
|
+
"signature": "loft({ topCS, bottomCS, height = 30, twistDeg = 0, topScale = 1.0, align = true, resolution = 1024 } = {})",
|
|
551
|
+
"params": [
|
|
552
|
+
{
|
|
553
|
+
"name": "{ topCS, bottomCS, height = 30, twistDeg = 0, topScale = 1.0, align = true, resolution = 1024 }",
|
|
554
|
+
"text": "{ topCS, bottomCS, height = 30, twistDeg = 0, topScale = 1.0, align = true, resolution = 1024 } = {}",
|
|
555
|
+
"default": "{}",
|
|
556
|
+
"destructured": true
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
"description": "Legacy two-section loft from a bottom and a top cross section, with height, twist, and top scale. Prefer makeLoft for contour-mode lofts.",
|
|
560
|
+
"doc": "Legacy two-section loft from a bottom and a top cross section, with height, twist, and top scale. Prefer makeLoft for contour-mode lofts.",
|
|
561
|
+
"examples": [
|
|
562
|
+
"const cup = loft({ bottomCS, topCS, height: 30 });"
|
|
563
|
+
]
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"name": "sumSqDist",
|
|
567
|
+
"signature": "sumSqDist(cont1, cont2)",
|
|
568
|
+
"params": [
|
|
569
|
+
{
|
|
570
|
+
"name": "cont1",
|
|
571
|
+
"text": "cont1"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"name": "cont2",
|
|
575
|
+
"text": "cont2"
|
|
576
|
+
}
|
|
577
|
+
],
|
|
578
|
+
"description": "Sum of squared distances between matched points of two loft contours.",
|
|
579
|
+
"doc": "Sum of squared distances between matched points of two loft contours.",
|
|
580
|
+
"examples": [
|
|
581
|
+
"const err = sumSqDist(a, b);"
|
|
582
|
+
]
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
"name": "rotateContour",
|
|
586
|
+
"signature": "rotateContour(contour, deg)",
|
|
587
|
+
"params": [
|
|
588
|
+
{
|
|
589
|
+
"name": "contour",
|
|
590
|
+
"text": "contour"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
"name": "deg",
|
|
594
|
+
"text": "deg"
|
|
595
|
+
}
|
|
596
|
+
],
|
|
597
|
+
"description": "Rotate a loft contour so its start point best matches the previous section.",
|
|
598
|
+
"doc": "Rotate a loft contour so its start point best matches the previous section.",
|
|
599
|
+
"examples": [
|
|
600
|
+
"const turned = rotateContour(contour, pivot);"
|
|
601
|
+
]
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"name": "sweep",
|
|
605
|
+
"signature": "sweep(profile, path, options = {})",
|
|
606
|
+
"params": [
|
|
607
|
+
{
|
|
608
|
+
"name": "profile",
|
|
609
|
+
"text": "profile"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"name": "path",
|
|
613
|
+
"text": "path"
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"name": "options",
|
|
617
|
+
"text": "options = {}",
|
|
618
|
+
"default": "{}"
|
|
619
|
+
}
|
|
620
|
+
],
|
|
621
|
+
"description": "Sweep a 2D profile along a 3D path Creates a 3D manifold by extruding a cross-section profile along a parametric path curve. ",
|
|
622
|
+
"doc": "Sweeps a 2D cross-section along a parametric 3D path using Frenet-Serret frames.\n\n\n**Parameters:**\n- `profile` - CrossSection to sweep (should be centered at origin)\n- `path` - Parametric path object:\n - `position(t)` - Function returning [x, y, z] at parameter t (required)\n - `derivative(t)` - Function returning first derivative (optional, computed numerically if omitted)\n - `secondDerivative(t)` - Function returning second derivative (optional)\n - `tMin` - Start parameter (default: 0)\n - `tMax` - End parameter (default: 1)\n- `options` - Optional settings:\n - `arcSamples` - Samples for arc-length table (default: 1000)\n - `extrudeSegments` - Segments along extrusion (default: 64)\n - `epsilon` - Delta for numerical derivatives (default: 1e-5)\n\n**Example - Trefoil Knot:**\n\n\n---",
|
|
623
|
+
"examples": [
|
|
624
|
+
"// Sweep a circle along a helix\nconst profile = CrossSection.circle(2, 32);\nconst helix = {\n position: (t) => [20 * Math.cos(t), 20 * Math.sin(t), 5 * t],\n tMin: 0,\n tMax: 4 * Math.PI\n};\nreturn sweep(profile, helix);",
|
|
625
|
+
"const scale = 5;\nconst profile = CrossSection.circle(1, 32);\nconst trefoil = {\n position: (t) => [\n scale * (Math.sin(t) + 2 * Math.sin(2 * t)),\n scale * (Math.cos(t) - 2 * Math.cos(2 * t)),\n scale * (-Math.sin(3 * t))\n ],\n derivative: (t) => [\n scale * (Math.cos(t) + 4 * Math.cos(2 * t)),\n scale * (-Math.sin(t) + 4 * Math.sin(2 * t)),\n scale * (-3 * Math.cos(3 * t))\n ],\n tMin: 0,\n tMax: 2 * Math.PI\n};\nreturn sweep(profile, trefoil, { arcSamples: 2000, extrudeSegments: 128 });"
|
|
626
|
+
]
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
"name": "sweepPoints",
|
|
630
|
+
"signature": "sweepPoints(profile, points, options = {})",
|
|
631
|
+
"params": [
|
|
632
|
+
{
|
|
633
|
+
"name": "profile",
|
|
634
|
+
"text": "profile"
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"name": "points",
|
|
638
|
+
"text": "points"
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"name": "options",
|
|
642
|
+
"text": "options = {}",
|
|
643
|
+
"default": "{}"
|
|
644
|
+
}
|
|
645
|
+
],
|
|
646
|
+
"description": "Sweep a profile along a path defined by an array of points Convenience wrapper for sweep() that accepts a polyline path. ",
|
|
647
|
+
"doc": "Sweeps a profile along a path defined by an array of points using Catmull-Rom spline interpolation.\n\n\n**Parameters:**\n- `profile` - CrossSection to sweep\n- `points` - Array of [x, y, z] coordinates defining the path (minimum 2 points)\n- `options` - Optional settings:\n - `closed` - If true, creates a closed loop (default: false)\n - Plus all options from `sweep()`\n\n**Example - Closed Loop:**\n\n\n---",
|
|
648
|
+
"examples": [
|
|
649
|
+
"// Sweep along a curved path\nconst profile = CrossSection.circle(2, 16);\nconst points = [\n [0, 0, 0],\n [20, 10, 0],\n [40, 0, 20],\n [60, -10, 20],\n [80, 0, 0]\n];\nreturn sweepPoints(profile, points);",
|
|
650
|
+
"const profile = CrossSection.square([3, 3], true);\nconst ring = [\n [30, 0, 0],\n [0, 30, 10],\n [-30, 0, 0],\n [0, -30, 10]\n];\nreturn sweepPoints(profile, ring, { closed: true });"
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "vecAdd",
|
|
655
|
+
"signature": "vecAdd(a, b)",
|
|
656
|
+
"params": [
|
|
657
|
+
{
|
|
658
|
+
"name": "a",
|
|
659
|
+
"text": "a"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"name": "b",
|
|
663
|
+
"text": "b"
|
|
664
|
+
}
|
|
665
|
+
],
|
|
666
|
+
"description": "Add two 3-vectors.",
|
|
667
|
+
"doc": "Add two 3-vectors.",
|
|
668
|
+
"examples": [
|
|
669
|
+
"const p = vecAdd(a, b);"
|
|
670
|
+
]
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"name": "vecSub",
|
|
674
|
+
"signature": "vecSub(a, b)",
|
|
675
|
+
"params": [
|
|
676
|
+
{
|
|
677
|
+
"name": "a",
|
|
678
|
+
"text": "a"
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
"name": "b",
|
|
682
|
+
"text": "b"
|
|
683
|
+
}
|
|
684
|
+
],
|
|
685
|
+
"description": "Subtract two 3-vectors.",
|
|
686
|
+
"doc": "Subtract two 3-vectors.",
|
|
687
|
+
"examples": [
|
|
688
|
+
"const d = vecSub(a, b);"
|
|
689
|
+
]
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
"name": "vecMul",
|
|
693
|
+
"signature": "vecMul(s, v)",
|
|
694
|
+
"params": [
|
|
695
|
+
{
|
|
696
|
+
"name": "s",
|
|
697
|
+
"text": "s"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
"name": "v",
|
|
701
|
+
"text": "v"
|
|
702
|
+
}
|
|
703
|
+
],
|
|
704
|
+
"description": "Scale a 3-vector by a number.",
|
|
705
|
+
"doc": "Scale a 3-vector by a number.",
|
|
706
|
+
"examples": [
|
|
707
|
+
"const p = vecMul(v, 2);"
|
|
708
|
+
]
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"name": "vecDot",
|
|
712
|
+
"signature": "vecDot(a, b)",
|
|
713
|
+
"params": [
|
|
714
|
+
{
|
|
715
|
+
"name": "a",
|
|
716
|
+
"text": "a"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"name": "b",
|
|
720
|
+
"text": "b"
|
|
721
|
+
}
|
|
722
|
+
],
|
|
723
|
+
"description": "Dot product of two 3-vectors.",
|
|
724
|
+
"doc": "Dot product of two 3-vectors.",
|
|
725
|
+
"examples": [
|
|
726
|
+
"const s = vecDot(a, b);"
|
|
727
|
+
]
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"name": "vecCross",
|
|
731
|
+
"signature": "vecCross(a, b)",
|
|
732
|
+
"params": [
|
|
733
|
+
{
|
|
734
|
+
"name": "a",
|
|
735
|
+
"text": "a"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"name": "b",
|
|
739
|
+
"text": "b"
|
|
740
|
+
}
|
|
741
|
+
],
|
|
742
|
+
"description": "Cross product of two 3-vectors.",
|
|
743
|
+
"doc": "Cross product of two 3-vectors.",
|
|
744
|
+
"examples": [
|
|
745
|
+
"const n = vecCross(a, b);"
|
|
746
|
+
]
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
"name": "vecNorm",
|
|
750
|
+
"signature": "vecNorm(v)",
|
|
751
|
+
"params": [
|
|
752
|
+
{
|
|
753
|
+
"name": "v",
|
|
754
|
+
"text": "v"
|
|
755
|
+
}
|
|
756
|
+
],
|
|
757
|
+
"description": "Euclidean length of a 3-vector.",
|
|
758
|
+
"doc": "Euclidean length of a 3-vector.",
|
|
759
|
+
"examples": [
|
|
760
|
+
"const len = vecNorm(v);"
|
|
761
|
+
]
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
"name": "vecNormalize",
|
|
765
|
+
"signature": "vecNormalize(v)",
|
|
766
|
+
"params": [
|
|
767
|
+
{
|
|
768
|
+
"name": "v",
|
|
769
|
+
"text": "v"
|
|
770
|
+
}
|
|
771
|
+
],
|
|
772
|
+
"description": "Return the unit-length copy of a 3-vector.",
|
|
773
|
+
"doc": "Return the unit-length copy of a 3-vector.",
|
|
774
|
+
"examples": [
|
|
775
|
+
"const u = vecNormalize(v);"
|
|
776
|
+
]
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"name": "facesByNormal",
|
|
780
|
+
"signature": "facesByNormal(m, dir, tolDeg = 1)",
|
|
781
|
+
"params": [
|
|
782
|
+
{
|
|
783
|
+
"name": "m",
|
|
784
|
+
"text": "m"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"name": "dir",
|
|
788
|
+
"text": "dir"
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
"name": "tolDeg",
|
|
792
|
+
"text": "tolDeg = 1",
|
|
793
|
+
"default": "1"
|
|
794
|
+
}
|
|
795
|
+
],
|
|
796
|
+
"description": "facesByNormal(m, dir, tolDeg=1) — faces whose normal is within tolDeg of dir. dir e.g. [0,0,1] (>Z) or [0,0,-1] (<Z).",
|
|
797
|
+
"doc": "**Parameters:**\n- `m` - The input manifold\n- `dir` - Target normal as `[x,y,z]` (e.g. `[0,0,1]` for `>Z`, `[0,0,-1]` for `<Z`)\n- `tolDeg` - Angular tolerance in degrees (default 1)\n\n**Returns:** Array of face objects `{ id, tris, normal, center, verts }`.",
|
|
798
|
+
"examples": [
|
|
799
|
+
"const topFaces = facesByNormal(part, [0, 0, 1]); // all upward faces\nconst wall = facesByNormal(part, [1, 0, 0])[0]; // a +X face"
|
|
800
|
+
]
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"name": "planarFaceAt",
|
|
804
|
+
"signature": "planarFaceAt(m, axis, value, tol = 1e-3)",
|
|
805
|
+
"params": [
|
|
806
|
+
{
|
|
807
|
+
"name": "m",
|
|
808
|
+
"text": "m"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
"name": "axis",
|
|
812
|
+
"text": "axis"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"name": "value",
|
|
816
|
+
"text": "value"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"name": "tol",
|
|
820
|
+
"text": "tol = 1e-3",
|
|
821
|
+
"default": "1e-3"
|
|
822
|
+
}
|
|
823
|
+
],
|
|
824
|
+
"description": "planarFaceAt(m, axis, value, tol=1e-3) — the face lying in plane axis==value (axis 'x'|'y'|'z'). ",
|
|
825
|
+
"doc": "planarFaceAt(m, axis, value, tol=1e-3) — the face lying in plane axis==value\n(axis 'x'|'y'|'z'). Returns null if absent, throws if ambiguous.",
|
|
826
|
+
"examples": [
|
|
827
|
+
"const top = planarFaceAt(part, 'z', 30); // the face at z=30"
|
|
828
|
+
]
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"name": "edgesByOrientation",
|
|
832
|
+
"signature": "edgesByOrientation(m, axis, dir = null, tolDeg = 5)",
|
|
833
|
+
"params": [
|
|
834
|
+
{
|
|
835
|
+
"name": "m",
|
|
836
|
+
"text": "m"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"name": "axis",
|
|
840
|
+
"text": "axis"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
"name": "dir",
|
|
844
|
+
"text": "dir = null",
|
|
845
|
+
"default": "null"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"name": "tolDeg",
|
|
849
|
+
"text": "tolDeg = 5",
|
|
850
|
+
"default": "5"
|
|
851
|
+
}
|
|
852
|
+
],
|
|
853
|
+
"description": "edgesByOrientation(m, axis, dir, tolDeg=5) axis 'x'|'y'|'z' -> edges parallel to that axis dir 1 | -1 | null -> one-sided / both",
|
|
854
|
+
"doc": "edgesByOrientation(m, axis, dir, tolDeg=5)\n axis 'x'|'y'|'z' -> edges parallel to that axis\n dir 1 | -1 | null -> one-sided / both",
|
|
855
|
+
"examples": [
|
|
856
|
+
"const vEdges = edgesByOrientation(part, 'z'); // all vertical edges"
|
|
857
|
+
]
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"name": "workplaneFromFace",
|
|
861
|
+
"signature": "workplaneFromFace(m, face)",
|
|
862
|
+
"params": [
|
|
863
|
+
{
|
|
864
|
+
"name": "m",
|
|
865
|
+
"text": "m"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
"name": "face",
|
|
869
|
+
"text": "face"
|
|
870
|
+
}
|
|
871
|
+
],
|
|
872
|
+
"description": "workplaneFromFace(m, face) -> { center, normal, x, y } Local 2D frame on the face. center = face centroid, normal = outward face normal, and the in-plane axes x,y are DETERMINISTIC + AXIS-ALIGNED so (u,v) map to predictable world directions (a transpiler/LLM can reason about t...",
|
|
873
|
+
"doc": "workplaneFromFace(m, face) -> { center, normal, x, y }\nLocal 2D frame on the face. center = face centroid, normal = outward face\nnormal, and the in-plane axes x,y are DETERMINISTIC + AXIS-ALIGNED so\n(u,v) map to predictable world directions (a transpiler/LLM can reason\nabout them):\n x = the world axis most in-plane with the face (smallest |n·axis|),\n ties broken by axis index (X > Y > Z); y = normal × x.\nSo: +Z face -> u→+X, v→+Y ; -Z -> u→+X, v→-Y ; +X -> u→+Y, v→+Z ;\n -X -> u→+Y, v→-Z ; +Y -> u→+X, v→-Z ; -Y -> u→+X, v→+Z.\n(Non-axis-aligned faces, e.g. a 45° chamfer, fall back to the\nfirst-vertex direction.)\n(pass a face object from facesByNormal/planarFaceAt, or a face index into m)",
|
|
874
|
+
"examples": [
|
|
875
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\n// fr.center, fr.normal, fr.x, fr.y"
|
|
876
|
+
]
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
"name": "placeInFrame",
|
|
880
|
+
"signature": "placeInFrame(frame, solid, uvw = [0, 0, 0])",
|
|
881
|
+
"params": [
|
|
882
|
+
{
|
|
883
|
+
"name": "frame",
|
|
884
|
+
"text": "frame"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"name": "solid",
|
|
888
|
+
"text": "solid"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"name": "uvw",
|
|
892
|
+
"text": "uvw = [0, 0, 0]",
|
|
893
|
+
"default": "[0, 0, 0]"
|
|
894
|
+
}
|
|
895
|
+
],
|
|
896
|
+
"description": "placeInFrame(frame, solid, uvw = [0, 0, 0]) Transform `solid` so its local origin lands at center + u·x + v·y + w·normal, axes aligned to (x, y, normal). `frame` is a PlaneFrame { center, normal, x, y } — never a Manifold. ",
|
|
897
|
+
"doc": "Places a solid on a **PlaneFrame** `{ center, normal, x, y }` (from\n`workplaneFromFace` / `makeCrossSection.plane` / default +Z). The solid's\nlocal origin lands at `center + u·x + v·y + w·normal`, axes aligned to\n`(x, y, normal)`. **Frame-only** — never a Manifold / cube / scaffold.\nDoes not take a host part. A first body assigns `let part = placeInFrame(…)`.\nAdvanced Confirm (Extrude / Revolve / Sweep / Loft), when `part` already\nexists, unions instead: `part = part.add(placeInFrame(…))`.\n`transformByFrame` is the same helper.",
|
|
898
|
+
"examples": [
|
|
899
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs = makeCrossSection(fr, profileCircle(5, 32));\npart = placeInFrame(xs.plane, makeExtrude(xs.contours, 10), [0, 0, 0]);"
|
|
900
|
+
]
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"name": "transformByFrame",
|
|
904
|
+
"signature": "transformByFrame(frame, solid, uvw = [0, 0, 0])",
|
|
905
|
+
"params": [
|
|
906
|
+
{
|
|
907
|
+
"name": "frame",
|
|
908
|
+
"text": "frame"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"name": "solid",
|
|
912
|
+
"text": "solid"
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
"name": "uvw",
|
|
916
|
+
"text": "uvw = [0, 0, 0]",
|
|
917
|
+
"default": "[0, 0, 0]"
|
|
918
|
+
}
|
|
919
|
+
],
|
|
920
|
+
"description": "Alias — same frame-only replace transform as placeInFrame.",
|
|
921
|
+
"doc": "Places a solid on a **PlaneFrame** `{ center, normal, x, y }` (from\n`workplaneFromFace` / `makeCrossSection.plane` / default +Z). The solid's\nlocal origin lands at `center + u·x + v·y + w·normal`, axes aligned to\n`(x, y, normal)`. **Frame-only** — never a Manifold / cube / scaffold.\nDoes not take a host part. A first body assigns `let part = placeInFrame(…)`.\nAdvanced Confirm (Extrude / Revolve / Sweep / Loft), when `part` already\nexists, unions instead: `part = part.add(placeInFrame(…))`.\n`transformByFrame` is the same helper.",
|
|
922
|
+
"examples": [
|
|
923
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs = makeCrossSection(fr, profileCircle(5, 32));\npart = placeInFrame(xs.plane, makeExtrude(xs.contours, 10), [0, 0, 0]);"
|
|
924
|
+
]
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
"name": "placeOnFace",
|
|
928
|
+
"signature": "placeOnFace(part, frame, builder)",
|
|
929
|
+
"params": [
|
|
930
|
+
{
|
|
931
|
+
"name": "part",
|
|
932
|
+
"text": "part"
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
"name": "frame",
|
|
936
|
+
"text": "frame"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"name": "builder",
|
|
940
|
+
"text": "builder"
|
|
941
|
+
}
|
|
942
|
+
],
|
|
943
|
+
"description": "placeOnFace(part, frame, builder) — run builder in the face's local frame. builder receives { Manifold: statics, frame, put } where put(m, [u,v,w]) returns m transformed so its local origin lands at center + u·x + v·y + w·normal (w is along the outward normal), with its local ...",
|
|
944
|
+
"doc": "placeOnFace(part, frame, builder) — run builder in the face's local frame.\nbuilder receives { Manifold: statics, frame, put } where put(m, [u,v,w])\nreturns m transformed so its local origin lands at\ncenter + u·x + v·y + w·normal (w is along the outward normal), with its\nlocal axes aligned to (x, y, normal). Lets scripts write axis-aligned\ngeometry for arbitrary face normals.\n\n`part` is unused (legacy host arg). New-body Confirm should assign\nplaceInFrame/transformByFrame instead of placeOnFace + part.add.",
|
|
945
|
+
"examples": [
|
|
946
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\nconst rib = placeOnFace(part, fr, ({ put, Manifold }) =>\n put(Manifold.cube([40, 4, 6], true), [0, 0, -3]));\nreturn Manifold.union(part, rib);"
|
|
947
|
+
]
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"name": "hole",
|
|
951
|
+
"signature": "hole(part, frame, u, v, dia, span)",
|
|
952
|
+
"params": [
|
|
953
|
+
{
|
|
954
|
+
"name": "part",
|
|
955
|
+
"text": "part"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
"name": "frame",
|
|
959
|
+
"text": "frame"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"name": "u",
|
|
963
|
+
"text": "u"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
"name": "v",
|
|
967
|
+
"text": "v"
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
"name": "dia",
|
|
971
|
+
"text": "dia"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
"name": "span",
|
|
975
|
+
"text": "span"
|
|
976
|
+
}
|
|
977
|
+
],
|
|
978
|
+
"description": "hole(part, frame, u, v, dia, span) — cut a round hole through `part`. frame from workplaneFromFace; (u,v) local coords (mm), span = cut length along the outward normal from the face (use holeSpan() for full thickness). ",
|
|
979
|
+
"doc": "hole(part, frame, u, v, dia, span) — cut a round hole through `part`.\nframe from workplaneFromFace; (u,v) local coords (mm), span = cut length\nalong the outward normal from the face (use holeSpan() for full thickness).\nReturns the cut part.",
|
|
980
|
+
"examples": [
|
|
981
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\npart = hole(part, fr, 10, 5, 6, holeSpan(part, fr));"
|
|
982
|
+
]
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"name": "holeSpan",
|
|
986
|
+
"signature": "holeSpan(part, frame)",
|
|
987
|
+
"params": [
|
|
988
|
+
{
|
|
989
|
+
"name": "part",
|
|
990
|
+
"text": "part"
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
"name": "frame",
|
|
994
|
+
"text": "frame"
|
|
995
|
+
}
|
|
996
|
+
],
|
|
997
|
+
"description": "holeSpan(part, frame) — full extent of the part measured along the frame normal (both directions from the face plane) + 2mm overshoot. ",
|
|
998
|
+
"doc": "holeSpan(part, frame) — full extent of the part measured along the frame\nnormal (both directions from the face plane) + 2mm overshoot. A safe\nfull-through cut length from that face.",
|
|
999
|
+
"examples": []
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
"name": "cboreHole",
|
|
1003
|
+
"signature": "cboreHole(part, frame, u, v, diaThru, diaCbore, cboreDepth, span)",
|
|
1004
|
+
"params": [
|
|
1005
|
+
{
|
|
1006
|
+
"name": "part",
|
|
1007
|
+
"text": "part"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"name": "frame",
|
|
1011
|
+
"text": "frame"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
"name": "u",
|
|
1015
|
+
"text": "u"
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
"name": "v",
|
|
1019
|
+
"text": "v"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"name": "diaThru",
|
|
1023
|
+
"text": "diaThru"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
"name": "diaCbore",
|
|
1027
|
+
"text": "diaCbore"
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
"name": "cboreDepth",
|
|
1031
|
+
"text": "cboreDepth"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
"name": "span",
|
|
1035
|
+
"text": "span"
|
|
1036
|
+
}
|
|
1037
|
+
],
|
|
1038
|
+
"description": "cboreHole(part, frame, u, v, diaThru, diaCbore, cboreDepth, span) — through hole + larger counterbore from the face. ",
|
|
1039
|
+
"doc": "cboreHole(part, frame, u, v, diaThru, diaCbore, cboreDepth, span)\n— through hole + larger counterbore from the face. (CadQuery cboreHole)",
|
|
1040
|
+
"examples": []
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
"name": "cskHole",
|
|
1044
|
+
"signature": "cskHole(part, frame, u, v, diaThru, diaCsk, cskDepth, span)",
|
|
1045
|
+
"params": [
|
|
1046
|
+
{
|
|
1047
|
+
"name": "part",
|
|
1048
|
+
"text": "part"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"name": "frame",
|
|
1052
|
+
"text": "frame"
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
"name": "u",
|
|
1056
|
+
"text": "u"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
"name": "v",
|
|
1060
|
+
"text": "v"
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"name": "diaThru",
|
|
1064
|
+
"text": "diaThru"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"name": "diaCsk",
|
|
1068
|
+
"text": "diaCsk"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"name": "cskDepth",
|
|
1072
|
+
"text": "cskDepth"
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
"name": "span",
|
|
1076
|
+
"text": "span"
|
|
1077
|
+
}
|
|
1078
|
+
],
|
|
1079
|
+
"description": "cskHole(part, frame, u, v, diaThru, diaCsk, cskDepth, span) — through hole + cone countersink: the cone spans diaThru→diaCsk over cskDepth (118° style for cskDepth ≈ 1.17·(diaCsk−diaThru)/2). ",
|
|
1080
|
+
"doc": "cskHole(part, frame, u, v, diaThru, diaCsk, cskDepth, span)\n— through hole + cone countersink: the cone spans diaThru→diaCsk over\ncskDepth (118° style for cskDepth ≈ 1.17·(diaCsk−diaThru)/2).\n(CadQuery cskHole)",
|
|
1081
|
+
"examples": []
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
"name": "chamferEdges",
|
|
1085
|
+
"signature": "chamferEdges(part, edges, c)",
|
|
1086
|
+
"params": [
|
|
1087
|
+
{
|
|
1088
|
+
"name": "part",
|
|
1089
|
+
"text": "part"
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
"name": "edges",
|
|
1093
|
+
"text": "edges"
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
"name": "c",
|
|
1097
|
+
"text": "c"
|
|
1098
|
+
}
|
|
1099
|
+
],
|
|
1100
|
+
"description": "chamferEdges(part, edges, c) — equal-leg 45° chamfer c on a SET of straight convex edges. ",
|
|
1101
|
+
"doc": "chamferEdges(part, edges, c) — equal-leg 45° chamfer c on a SET of straight\nconvex edges. Edges = objects from c4MeshData/convexEdges, or a plain\n[{va, vb, n0, n1}] array. n0/n1 (outward normals of the two adjacent faces\nat that edge) are REQUIRED for hand-built edges, but are AUTO-DERIVED from\nthe current mesh when the edge object carries {faces: [i0, i1]} (as all\nc4MeshData-based selectors do: convexEdges, edgesByOrientation,\nedgesByNormal, planarFaceAt-derived selections) — no more\n\"Cannot read properties of undefined (reading '0')\" when mixing selectors\nwith chamferEdges.\n\nConstruction (verified, C2 pilot + C4): per edge, cutter = hull of the two\nedge endpoints plus four corner points pulled c into each adjacent face\ninterior. c IS THE LEG LENGTH along each adjacent face (CAD \"C2\" = 2 mm\non both legs), NOT the perpendicular face offset — the perpendicular\noffset is derived from the face-to-face angle (offset = c·tan(θ/2), θ =\nangle between n0/n1; at a 90° corner they coincide, at a 120° hex-nut\ncorner C2 → 1.155 mm offset / 2 mm legs). CUTTERS ARE APPLIED SEQUENTIALLY (one difference per edge) and\neach intermediate result is checked: a single degenerate cutter (e.g. at\na triple-junction rib-base edge where the two \"adjacent faces\" are coplanar\nor the cutter self-intersects) must not be allowed to wedge the batch\nunion into a wasm out-of-bounds trap (observed: chamfering ALL convex\nedges of a ribbed plate — one subset crashes the kernel while the rest\nbuild fine). The first bad edge throws a named, actionable error instead.\nCost: n differences instead of 1 — fine for the edge counts these parts\nactually use (≤ ~30); the C8 timeout guard catches anything pathological.",
|
|
1102
|
+
"examples": [
|
|
1103
|
+
"part = chamferEdges(part, convexEdges(part), 2);"
|
|
1104
|
+
]
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
"name": "convexEdges",
|
|
1108
|
+
"signature": "convexEdges(m, minAngleDeg = FEATURE_EDGE_MIN_DEG)",
|
|
1109
|
+
"params": [
|
|
1110
|
+
{
|
|
1111
|
+
"name": "m",
|
|
1112
|
+
"text": "m"
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
"name": "minAngleDeg",
|
|
1116
|
+
"text": "minAngleDeg = FEATURE_EDGE_MIN_DEG",
|
|
1117
|
+
"default": "FEATURE_EDGE_MIN_DEG"
|
|
1118
|
+
}
|
|
1119
|
+
],
|
|
1120
|
+
"description": "convexEdges(m, minAngleDeg) — genuine convex feature edges. ",
|
|
1121
|
+
"doc": "Genuine straight convex edges: dihedral angle > `minAngleDeg` (filters\ncurved-face tessellation seams) and a ball-probe confirms the corner is\nconvex (not concave). Returns edge objects `{ va, vb, a, b, tris, tangent,\nfaces: [i0, i1], n0, n1 }` — `n0`/`n1` are the adjacent face normals and\n`faces` the face indices, so the result is ready for `chamferEdges`\n(normals auto-derived) and `filletEdges` as-is.",
|
|
1122
|
+
"examples": [
|
|
1123
|
+
"const vConvex = convexEdges(part).filter(e => Math.abs(e.tangent[2]) > 0.99);\npart = chamferEdges(part, vConvex, 0.5); // chamfer only the vertical corners"
|
|
1124
|
+
]
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
"name": "concaveEdges",
|
|
1128
|
+
"signature": "concaveEdges(m, minAngleDeg = FEATURE_EDGE_MIN_DEG)",
|
|
1129
|
+
"params": [
|
|
1130
|
+
{
|
|
1131
|
+
"name": "m",
|
|
1132
|
+
"text": "m"
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
"name": "minAngleDeg",
|
|
1136
|
+
"text": "minAngleDeg = FEATURE_EDGE_MIN_DEG",
|
|
1137
|
+
"default": "FEATURE_EDGE_MIN_DEG"
|
|
1138
|
+
}
|
|
1139
|
+
],
|
|
1140
|
+
"description": "concaveEdges(m, minAngleDeg) — genuine concave (interior) feature edges. ",
|
|
1141
|
+
"doc": "concaveEdges(m, minAngleDeg) — genuine concave (interior) feature edges.\nRounding these is material ADD, not remove; see filletAlongPath.",
|
|
1142
|
+
"examples": [
|
|
1143
|
+
"const inner = concaveEdges(part);"
|
|
1144
|
+
]
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"name": "signedFeatureEdges",
|
|
1148
|
+
"signature": "signedFeatureEdges(m, minAngleDeg = FEATURE_EDGE_MIN_DEG)",
|
|
1149
|
+
"params": [
|
|
1150
|
+
{
|
|
1151
|
+
"name": "m",
|
|
1152
|
+
"text": "m"
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
"name": "minAngleDeg",
|
|
1156
|
+
"text": "minAngleDeg = FEATURE_EDGE_MIN_DEG",
|
|
1157
|
+
"default": "FEATURE_EDGE_MIN_DEG"
|
|
1158
|
+
}
|
|
1159
|
+
],
|
|
1160
|
+
"description": "Signed feature edges — convex AND concave, by a local winding test. ",
|
|
1161
|
+
"doc": "Signed feature edges — convex AND concave, by a local winding test.\n\nSign: `dot(cross(n0, n1), dir) > 0` is convex, `< 0` is concave, where `dir`\nis the edge as wound in the triangle whose normal is n0. Winding is what\ncarries the inside/outside information; a dot product alone cannot tell a 90°\nconvex edge from a 270° concave one (they share the same normal angle).\n\nNormals come from the adjacent TRIANGLES, not the face groups: a face group's\nnormal is an area-weighted average, and on a curved group (a fillet sail) it\npoints nowhere near the local surface, which flips the cross product. Where a\ntriangle is a degenerate sliver — tessellated lofts carry hundreds — its\nnormal is meaningless, so the face-group normal stands in for it instead.\n\n`e.tris[i]` is the triangle belonging to face group `e.faces[i]`, so the\nsubstitution always pairs a triangle with its own group.",
|
|
1162
|
+
"examples": [
|
|
1163
|
+
"const edges = signedFeatureEdges(part);"
|
|
1164
|
+
]
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
"name": "holePattern",
|
|
1168
|
+
"signature": "holePattern(part, frame, opts)",
|
|
1169
|
+
"params": [
|
|
1170
|
+
{
|
|
1171
|
+
"name": "part",
|
|
1172
|
+
"text": "part"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"name": "frame",
|
|
1176
|
+
"text": "frame"
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
"name": "opts",
|
|
1180
|
+
"text": "opts"
|
|
1181
|
+
}
|
|
1182
|
+
],
|
|
1183
|
+
"description": "holePattern(part, frame, { n, m, spacingU, spacingV, dia, span, u0=0, v0=0 }) — linear grid of through holes (CadQuery rarray idiom). ",
|
|
1184
|
+
"doc": "holePattern(part, frame, { n, m, spacingU, spacingV, dia, span, u0=0, v0=0 })\n— linear grid of through holes (CadQuery rarray idiom).\nGrid centered on the face center + (u0, v0) offset.",
|
|
1185
|
+
"examples": [
|
|
1186
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\npart = holePattern(part, fr, { n: 3, m: 2, spacingU: 12, spacingV: 10, dia: 4 });"
|
|
1187
|
+
]
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
"name": "clearanceHole",
|
|
1191
|
+
"signature": "clearanceHole(part, frame, u, v, size, spanOrOpts, fitArg)",
|
|
1192
|
+
"params": [
|
|
1193
|
+
{
|
|
1194
|
+
"name": "part",
|
|
1195
|
+
"text": "part"
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
"name": "frame",
|
|
1199
|
+
"text": "frame"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"name": "u",
|
|
1203
|
+
"text": "u"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
"name": "v",
|
|
1207
|
+
"text": "v"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"name": "size",
|
|
1211
|
+
"text": "size"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
"name": "spanOrOpts",
|
|
1215
|
+
"text": "spanOrOpts"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
"name": "fitArg",
|
|
1219
|
+
"text": "fitArg"
|
|
1220
|
+
}
|
|
1221
|
+
],
|
|
1222
|
+
"description": "clearanceHole(part, frame, u, v, size, spanOrOpts?, fit?) Cut a clearance hole for fastener `size` ('M3', 3, '#8-32', …). fit: 'close'|'normal'|'loose' (default 'normal'). span defaults to holeSpan(). ",
|
|
1223
|
+
"doc": "Cut a **clearance** hole sized for fastener `size`. `size` accepts `'M3'`,\n`3`, `'M2.5'`, `'#8-32'`, `'1/4-20'`, etc. `fit` is `'close'|'normal'|'loose'`\n(aliases: tight/medium/coarse). `span` defaults to `holeSpan(part, frame)`.\nYou can also pass an options object as the 6th argument:\n`{ fit: 'close', span: 12 }`.\n\n\n\nThrows on unknown size/fit, non-positive derived diameter, bad frame, or empty /\nnon-manifold result.",
|
|
1224
|
+
"examples": [
|
|
1225
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\npart = clearanceHole(part, fr, 10, 8, 'M3'); // normal fit\npart = clearanceHole(part, fr, -10, 8, 'M4', undefined, 'close');\npart = clearanceHole(part, fr, 0, 0, 'M5', { fit: 'loose' });"
|
|
1226
|
+
]
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"name": "tapDrillHole",
|
|
1230
|
+
"signature": "tapDrillHole(part, frame, u, v, size, span)",
|
|
1231
|
+
"params": [
|
|
1232
|
+
{
|
|
1233
|
+
"name": "part",
|
|
1234
|
+
"text": "part"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"name": "frame",
|
|
1238
|
+
"text": "frame"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
"name": "u",
|
|
1242
|
+
"text": "u"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
"name": "v",
|
|
1246
|
+
"text": "v"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
"name": "size",
|
|
1250
|
+
"text": "size"
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
"name": "span",
|
|
1254
|
+
"text": "span"
|
|
1255
|
+
}
|
|
1256
|
+
],
|
|
1257
|
+
"description": "tapDrillHole(part, frame, u, v, size, span?) Cut a tap-drill hole for fastener `size` (for subsequent tapping). span defaults to holeSpan().",
|
|
1258
|
+
"doc": "tapDrillHole(part, frame, u, v, size, span?)\nCut a tap-drill hole for fastener `size` (for subsequent tapping).\nspan defaults to holeSpan().",
|
|
1259
|
+
"examples": [
|
|
1260
|
+
"const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\npart = tapDrillHole(part, fr, 0, 0, 'M3'); // Ø2.5 for M3 coarse\npart = tapDrillHole(part, fr, 12, 0, '#8-32');"
|
|
1261
|
+
]
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
"name": "holesOnContour",
|
|
1265
|
+
"signature": "holesOnContour(part, section, spec)",
|
|
1266
|
+
"params": [
|
|
1267
|
+
{
|
|
1268
|
+
"name": "part",
|
|
1269
|
+
"text": "part"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
"name": "section",
|
|
1273
|
+
"text": "section"
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
"name": "spec",
|
|
1277
|
+
"text": "spec"
|
|
1278
|
+
}
|
|
1279
|
+
],
|
|
1280
|
+
"description": "holesOnContour(part, section, spec) — one hole at every sketch point of a centres contour, including arc centres. `section` is a makeCrossSection (plane + profile). ",
|
|
1281
|
+
"doc": "holesOnContour(part, section, spec) — one hole at every sketch point of a\ncentres contour, including arc centres. `section` is a makeCrossSection\n(plane + profile). Construction lines are not centres. No centres returns\n`part`. `dia` is a raw millimetre diameter and wins over `size` + `fit`.\nWithout `dia`, `type: 'tapDrill'` uses the tap drill and anything else uses\nthe clearance diameter. `side: 1` cuts toward −normal (the same way as\nhole()); `side: -1` or `flip: true` cuts the other way. `depth` is how far\nthe hole enters that side; `through: true` uses holeSpan. A far c-bore or\nc-sink needs a through hole. Two calls may share one section.",
|
|
1282
|
+
"examples": [
|
|
1283
|
+
"const c1 = makeCrossSection(plane, solveContour({\n centers: true,\n points: [{ id: 'p0', at: [10, 0] }, { id: 'c0', at: [0, 0] }],\n arcs: [{ id: 'a0', center: 'c0', radius: 10, full: true, sweep: 'ccw' }],\n}));\npart = holesOnContour(part, c1, { dia: 4, through: false, depth: 6, side: 1 });\npart = holesOnContour(part, c1, { type: 'clearance', size: 'M3', fit: 'normal', through: true, side: -1 });"
|
|
1284
|
+
]
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
"name": "fastenerClearanceDia",
|
|
1288
|
+
"signature": "fastenerClearanceDia(size, fit = 'normal')",
|
|
1289
|
+
"params": [
|
|
1290
|
+
{
|
|
1291
|
+
"name": "size",
|
|
1292
|
+
"text": "size"
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
"name": "fit",
|
|
1296
|
+
"text": "fit = 'normal'",
|
|
1297
|
+
"default": "'normal'"
|
|
1298
|
+
}
|
|
1299
|
+
],
|
|
1300
|
+
"description": "Clearance diameter (mm) for a fastener size + fit.",
|
|
1301
|
+
"doc": "Return the clearance or tap-drill diameter in **mm** without cutting. Useful\nfor custom patterns:\n\n\n\n`listFastenerSizes()` → `{ metric: ['M1.6','M2',…], unc: ['#4-40',…] }`.\n\n---\n\n## Fillet Helper (C6)",
|
|
1302
|
+
"examples": [
|
|
1303
|
+
"const d = fastenerClearanceDia('M6', 'normal'); // 6.6\npart = holePattern(part, fr, { n: 2, m: 2, spacingU: 20, spacingV: 20, dia: d });"
|
|
1304
|
+
]
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
"name": "fastenerTapDrillDia",
|
|
1308
|
+
"signature": "fastenerTapDrillDia(size)",
|
|
1309
|
+
"params": [
|
|
1310
|
+
{
|
|
1311
|
+
"name": "size",
|
|
1312
|
+
"text": "size"
|
|
1313
|
+
}
|
|
1314
|
+
],
|
|
1315
|
+
"description": "Tap-drill diameter (mm) for a fastener size.",
|
|
1316
|
+
"doc": "Return the clearance or tap-drill diameter in **mm** without cutting. Useful\nfor custom patterns:\n\n\n\n`listFastenerSizes()` → `{ metric: ['M1.6','M2',…], unc: ['#4-40',…] }`.\n\n---\n\n## Fillet Helper (C6)",
|
|
1317
|
+
"examples": [
|
|
1318
|
+
"const d = fastenerClearanceDia('M6', 'normal'); // 6.6\npart = holePattern(part, fr, { n: 2, m: 2, spacingU: 20, spacingV: 20, dia: d });"
|
|
1319
|
+
]
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
"name": "fastenerMajorDia",
|
|
1323
|
+
"signature": "fastenerMajorDia(size)",
|
|
1324
|
+
"params": [
|
|
1325
|
+
{
|
|
1326
|
+
"name": "size",
|
|
1327
|
+
"text": "size"
|
|
1328
|
+
}
|
|
1329
|
+
],
|
|
1330
|
+
"description": "Major / nominal diameter (mm).",
|
|
1331
|
+
"doc": "Major / nominal diameter (mm).",
|
|
1332
|
+
"examples": [
|
|
1333
|
+
"const d = fastenerMajorDia('M4');"
|
|
1334
|
+
]
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
"name": "listFastenerSizes",
|
|
1338
|
+
"signature": "listFastenerSizes()",
|
|
1339
|
+
"params": [],
|
|
1340
|
+
"description": "List the fastener size keys the clearance and tap-drill tables accept.",
|
|
1341
|
+
"doc": "List the fastener size keys the clearance and tap-drill tables accept.",
|
|
1342
|
+
"examples": [
|
|
1343
|
+
"const sizes = listFastenerSizes();"
|
|
1344
|
+
]
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
"name": "resolveFastenerSize",
|
|
1348
|
+
"signature": "resolveFastenerSize(size)",
|
|
1349
|
+
"params": [
|
|
1350
|
+
{
|
|
1351
|
+
"name": "size",
|
|
1352
|
+
"text": "size"
|
|
1353
|
+
}
|
|
1354
|
+
],
|
|
1355
|
+
"description": "Normalize a fastener size token to a table key + series. ",
|
|
1356
|
+
"doc": "Normalize a fastener size token to a table key + series.\nAccepts: 'M3', 'm3', 3, '3', 'M2.5', 'M2_5', '#8-32', '1/4-20'.",
|
|
1357
|
+
"examples": [
|
|
1358
|
+
"const size = resolveFastenerSize('M3');"
|
|
1359
|
+
]
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
"name": "filletEdges",
|
|
1363
|
+
"signature": "filletEdges(part, edgesIn, radiusIn, opts = {})",
|
|
1364
|
+
"params": [
|
|
1365
|
+
{
|
|
1366
|
+
"name": "part",
|
|
1367
|
+
"text": "part"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
"name": "edgesIn",
|
|
1371
|
+
"text": "edgesIn"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
"name": "radiusIn",
|
|
1375
|
+
"text": "radiusIn"
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
"name": "opts",
|
|
1379
|
+
"text": "opts = {}",
|
|
1380
|
+
"default": "{}"
|
|
1381
|
+
}
|
|
1382
|
+
],
|
|
1383
|
+
"description": "filletEdges(part, edges, radius, opts) — circular fillet of radius r on a SET of straight convex edges. edges = objects from convexEdges() (required: they carry the mesh indices this helper needs; edges from OTHER selections can still be filleted if the edge object has {a, b, ...",
|
|
1384
|
+
"doc": "Circular fillet of radius `r` on a **set** of straight convex edges\n(Manifold has no native fillet; this is a geometric construction).\n`edges` must come from `convexEdges()` (it needs the per-edge vertex\nindices to recover the in-face directions — and the in-face geometry, not\njust the normals, is what makes non-90° corners work). `radius` is a\nnumber (same `r` for all edges) or a `number[]` parallel to `edges`\n(per-edge radii). `opts` (optional): `{ sphericalCorners: true }`\n(see below).\n\n\n\n**How it works (per edge).** In the cross-section perpendicular to the\nedge, the two faces meet at interior angle θ. The fillet arc of radius `r`\nis tangent to both faces at distance `t = r/tan(θ/2)` from the corner,\ncentered on the interior angle bisector at `r/sin(θ/2)`. The removed\ncross-section is the sliver `r·t − ½·r²·(π−θ)` (= `r²(1−π/4)` at 90°).\nThe cutter is exactly `parallelepiped(t·f0, t·f1, edge) − cylinder(r)` —\nboth are exact primitives, so the result is geometrically exact for any\nθ. The in-face boundary directions `f0`/`f1` come from the adjacent\ntriangles' third vertices (robust to Manifold's `faceID` grouping, which\ncan merge faces from different planes into one). All cutters for the set\nare unioned and subtracted once, so shared-corner interactions resolve\nthrough the boolean — matching analytic inclusion-exclusion for adjacent\nedges (two cutters at a corner, three at a box corner).\n\n**Closed circular rims (v2, 2026-09-08).** A curved surface (a cylinder\nwall, a hole wall) meeting a planar face tessellates as a LOOP of many\nshort straight mesh edges — e.g. a Ø12 hole rim at 48 segments has\n~0.78mm segments. In v1 this loop was filleted PER SEGMENT, and any\nsegment failing the size guard below was silently skipped — for a real\nfillet radius (r=1 on that Ø12 rim, t=1 > 0.45·0.78mm) EVERY segment\nfailed, so the whole rim's fillet silently vanished with no error. v2\ndetects a maximal chain of input edges that (a) share consecutive mesh\nvertices, (b) turn ≤30° at each shared vertex (a genuine polygon corner\nturns 60-180°; a tessellated circle turns 360/segs°, well under 30° for\nany segs≥12), and (c) keep the same interior angle θ (within 3°) and the\nsame radius. If that chain closes into a loop AND fits an exact circle\n(3-point circumcircle, verified against every other vertex in the run),\nthe WHOLE rim is filleted as one exact revolved cutter — the same 2D\ncorner-sliver cross-section swept a full 360° around the rim's own axis\n— instead of per-segment boxes, so the old per-segment size guard does\nnot apply to it at all. `convexEdges(part)` (unfiltered, or filtered only\nby position/orientation — do NOT filter out short segments) is the\ncorrect input; a \"filter out the tiny seam edges\" workaround is no longer\nnecessary or correct for a genuine curved rim. If a chain doesn't close,\nor doesn't fit a clean circle (mixed/non-circular topology), filletEdges\nfalls back to the v1 per-edge construction for every edge in that chain,\nincluding the size guard below — so isolated straight edges and\nnon-circular chains behave exactly as before.\n\n**Constraints (v1 per-edge path — still the fallback for singleton edges\nand non-circular chains).**\n- **Planar faces only** — each adjacent face must be planar at the edge\n (checked: all same-face neighbor triangles coplanar within 1e-3). A\n fillet touching a curved face **throws** for a SINGLETON edge. (A\n successfully-fit closed circular run skips this check entirely — the\n circle fit plus per-vertex on-circle verification is a strictly more\n specific validity proof for \"this chain is one smooth curved feature\"\n than the singleton check, which was never designed to look past one\n edge.)\n- **Convex edges only** — concave corners (rounding = adding material)\n throw. `convexEdges()` already filters these out; passing them directly\n also throws via the ball probe. (Applies to every edge, run or not.)\n- **Size guard** — for a SINGLETON edge (or an edge in a chain that didn't\n qualify as a closed circular run), `r` must satisfy `t < 0.45·L` where\n `L` is the edge length; individual edges that FAIL this guard are\n **skipped** when other edges still produce cutters. If **every** requested\n edge is skipped / rejected, `filletEdges` **throws** (no silent unchanged\n part). Closed-circular-run members are exempt — their per-segment `L` is a\n tessellation artifact, not a signal that the feature is too small.\n- **Arc tessellation** — a SINGLETON edge's fillet arc is an inscribed\n 384-gon: the result volume sits at most `L·(π−(n/2)·sin(2π/n))·r²` BELOW\n the circle-exact value per edge. A closed run's revolve resolution is\n tied to the rim's own mesh segment count exactly (verified necessary\n for a numerically clean boolean: Manifold's boolean difference between\n the original n-segment part and a cutter revolved at a DIFFERENT\n segment count — even a clean integer multiple of n — silently removes\n LESS than the cutter's own volume), with a separately-tunable, finer\n resolution for the small fillet arc itself.\n- **Known gaps** — an OPEN curved run (a fillet on a less-than-360° arc)\n does not get the closed-run treatment and can still lose short segments\n to the size guard; not exercised by any part in the current corpus\n (every curved surface here comes from a full-revolution primitive). A\n closed-run cutter throws (rather than silently clipping) if `r` is so\n large the fillet would revolve through the rim's own axis.\n\n**Spherical corner caps** (`opts.sphericalCorners: true`). Three fillets\nmeeting at a box corner converge to a sharp cusp point — the plain\nresult is a valid but pointy corner. With this option the cusp pocket is\ncut away by a ball of radius `r` centered on the trihedral incenter\n(equidistant `r` from all three faces and lying ON all three fillet\ncylinder axes), leaving a spherical corner patch that is tangent to each\nfillet sail along a circle (C1 junction) and to each face at one point —\ni.e. the true CAD r/r/r rounded corner. v1 scope: applies only at\nvertices where exactly THREE filleted edges meet at ~90° with EQUAL\nradii; other corners keep the cusp, and non-triple corners are\nunaffected (the option is a no-op on an edge set whose corners have\nfewer than three fillets).\n\n**Verified** against analytic volumes: single edge, 4 top edges, all 12\nbox edges (pair + triple corner overlaps), an obtuse wedge (90°/116°/153°\ncorners), and mixed per-edge radii — see `cadgen-workspace/reports/c6-report.md`.\n\n---\n\n\n---\n\n## Cross-section substrate (Slice 21)\n\nReusable **plane + 2D profile** value for later edge→sweep path,\nfillet-via-sweep, then extrude/revolve/loft siblings. This slice ships the\nsubstrate only — those followers are **not** started here.\n\nPlane comes from `workplaneFromFace` (primary mobile path: selected planar\nface). Profile is a light 2D shape in plane UV. The returned value is a plain\nobject (no class inheritance):",
|
|
1385
|
+
"examples": [
|
|
1386
|
+
"// round all 12 box corners at r=3\npart = filletEdges(part, convexEdges(part), 3);\n\n// fillet only the 4 vertical corners, mixed radii per edge\nconst vert = convexEdges(part).filter(e => Math.abs(e.tangent[2]) > 0.99);\npart = filletEdges(part, vert, [3, 3, 5, 5]);\n\n// fully-rounded box corners: r=5 fillets + spherical corner patches\npart = filletEdges(part, convexEdges(part), 5, { sphericalCorners: true });",
|
|
1387
|
+
"{\n kind: 'crossSection',\n plane: { center, normal, x, y }, // workplaneFromFace frame\n profile: { type: 'circle'|'rectangle'|'polygon', ... },\n contours: [ [[u,v], ...] ], // ready for makeExtrude / sweep later\n}"
|
|
1388
|
+
]
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
"name": "makeRevolve",
|
|
1392
|
+
"signature": "makeRevolve(contours, segments = 96, degrees = 360)",
|
|
1393
|
+
"params": [
|
|
1394
|
+
{
|
|
1395
|
+
"name": "contours",
|
|
1396
|
+
"text": "contours"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"name": "segments",
|
|
1400
|
+
"text": "segments = 96",
|
|
1401
|
+
"default": "96"
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
"name": "degrees",
|
|
1405
|
+
"text": "degrees = 360",
|
|
1406
|
+
"default": "360"
|
|
1407
|
+
}
|
|
1408
|
+
],
|
|
1409
|
+
"description": "makeRevolve(contours, segments=96, degrees=360) — revolve a 2D profile around its Y axis (result's axis = Z). contours = [[x,y]...] outer first + optional holes; winding is normalized automatically; throws loudly on an invalid profile instead of returning a silent empty manifo...",
|
|
1410
|
+
"doc": "Revolve a 2D profile around its **Y** axis → result axis = **Z**.\n`contours` = `[[x,y]...]` outer first + optional hole contours after;\nwinding is **auto-normalized** (outermost CCW, holes CW) — do NOT hand-roll\n`new CrossSection(...).revolve()` and fight winding yourself (wrong winding\nfails silently in raw CrossSection). Profile: **x = radial distance (≥ 0),\ny = height along the axis**. If a polygon crosses the Y-axis, only the\npositive-X side is used (Manifold clip). `degrees` is the sweep (default\n360, must be > 0 and ≤ 360). Throws a named error on an invalid profile\ninstead of returning a silent empty manifold.",
|
|
1411
|
+
"examples": [
|
|
1412
|
+
"// revolved flange ⌀90×10 + boss ⌀30 base, 30 tall — one closed silhouette\nlet part = makeRevolve([ [[0,0],[45,0],[45,10],[15,10],[15,30],[0,30]] ], 96);\n\n// hollow tube OD40 ID28 × 30: outer contour + inner (through) contour\nconst tube = makeRevolve([ [[0,0],[20,0],[20,30],[0,30]],\n [[14,0],[14,30],[20,30],[20,0]] ], 64);"
|
|
1413
|
+
]
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
"name": "makeExtrude",
|
|
1417
|
+
"signature": "makeExtrude(contours, height)",
|
|
1418
|
+
"params": [
|
|
1419
|
+
{
|
|
1420
|
+
"name": "contours",
|
|
1421
|
+
"text": "contours"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
"name": "height",
|
|
1425
|
+
"text": "height"
|
|
1426
|
+
}
|
|
1427
|
+
],
|
|
1428
|
+
"description": "makeExtrude(contours, height) — extrude a 2D profile by `height` along Z. ",
|
|
1429
|
+
"doc": "Extrude a 2D profile by `height` along +Z. Same contour rules as\nmakeRevolve (outer + optional holes, winding auto-fixed).\n\n\n\n**Contour-mode Extrude (Slice 25):** game-mode **Extrude** builds a profile on\nthe workplane, then Confirm emits:\n\n\n\n`height` is always > 0. When `part` already exists, Advanced Confirm is\nadditive (`part.add` of the placed solid). An empty script still uses\n`let part = placeInFrame(...)`. The Extrude card labels Out / In / Both as\nDirection. **In** uses `w = −height`; **Both** uses `w = −height/2`. The axis\ndefaults to the plane normal; a world axis is\nrefused unless it is parallel to that normal. Loud-fail on a bad plane,\nprofile, or distance.\n\n**Contour-mode Revolve (Slice 26):** game-mode **Revolve** builds a profile on\nthe workplane, then Confirm emits `makeCrossSection` + `makeRevolve` placed\nso the axis lies **on the profile plane** (default: along V). The profile\nis remapped with identity `(u,v)→(radial,height)` in the axis/radial basis\n(axis through the workplane origin). A centered circle therefore revolves\nabout a diameter — a sphere. Profiles that cross the axis are clipped to\n+radial (`makeRevolve` / Manifold); on-axis, zero-width, and entirely\n−radial profiles loud-fail.\n\n\n\n`angle` is always > 0 and ≤ 360 (default 360). Sense **In** starts at\n`−angle`; **Both** starts at `−angle/2`. Axis defaults to plane **V**; a\nworld axis is refused unless it lies on the profile plane. Loud-fail on a\nbad plane, profile, angle, or an on-axis / zero-width / entirely-negative\nradial profile.",
|
|
1430
|
+
"examples": [
|
|
1431
|
+
"const plate = makeExtrude([ [[-40,-15],[40,-15],[40,15],[-40,15]] ], 3);",
|
|
1432
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs = makeCrossSection(fr, profileCircle(5, 32));\npart = placeInFrame(xs.plane, makeExtrude(xs.contours, 10), [0, 0, 0]);\n// when part already exists, Confirm unions instead of replacing:\n// part = part.add(placeInFrame(xs.plane, makeExtrude(xs.contours, 10), [0, 0, 0]));",
|
|
1433
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs = makeCrossSection(fr, profileCircle(5, 32));\npart = placeInFrame({\n center: xs.plane.center,\n x: xs.plane.x, y: xs.plane.normal, normal: xs.plane.y,\n}, makeRevolve(xs.contours.map((ring) => ring.map(([u, v]) => [u, v])), 96, 360));"
|
|
1434
|
+
]
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
"name": "makeLoft",
|
|
1438
|
+
"signature": "makeLoft(sections, opts = {})",
|
|
1439
|
+
"params": [
|
|
1440
|
+
{
|
|
1441
|
+
"name": "sections",
|
|
1442
|
+
"text": "sections"
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
"name": "opts",
|
|
1446
|
+
"text": "opts = {}",
|
|
1447
|
+
"default": "{}"
|
|
1448
|
+
}
|
|
1449
|
+
],
|
|
1450
|
+
"description": "makeLoft(sections, opts?) — loft two or more profiles on parallel or angled planes. ",
|
|
1451
|
+
"doc": "Loft ≥2 `makeCrossSection` values into a solid. **Parallel planes** (same\nworkplane + per-profile offset along the normal, normals within about 8°)\nuse the polar warp. `offsetPlaneFrame(plane, offset)` copies a PlaneFrame\nand translates `center` by `offset * normal`. That solid is **local** (XY =\nstation UV, Z along the shared normal, z=0 at the lowest station) — Confirm\nplaces it with `placeInFrame`. **Angled planes** keep input order. Each\ncontour is mapped through its own frame, arc-length resampled, and\nshift-aligned, then carried on a Hermite spine so a right-angle elbow does\nnot fold. That solid is local to the **first** profile's plane\n(`placeInFrame` on that plane). The legacy `loft({ topCS, bottomCS, height })`\ncup helper is unchanged.\n\n\n\n**Contour-mode Loft:** game-mode **Loft** builds a multi-profile list (min 2,\ndefault circle r=5 @ 0 and circle r=8 @ 20 on the shared workplane). Circle /\nrect / polygon / polyline edit the selected profile. Each station can stay on\nthat plane with an offset, or pick a face, a saved workplane, or a saved\nsketch's plane. Confirm emits one `makeCrossSection` per station plus\n`makeLoft`, then `placeInFrame`. Offset-only stations still use\n`offsetPlaneFrame`. A station with its own frame emits that frame, and the\nplacement frame is the first station. Second Confirm replaces the same marked\nblock. **Back** exits with no commit. Live preview skins the stations as\noffsets, planes, or shapes change.\n\n**Loud failures:** < 2 profiles; coincident stations (zero-length loft);\ndegenerate / empty contours; a turn tighter than the profiles\n(self-intersection); empty result volume. Never a silent wrong solid.\n\n`opts.align` (default true) matches cornered stations by their outermost\nvertex angle (a 45° copy of the same rectangle un-rotates back to a prism).\nA nearly circular station does **not** spin the other profile — that was\nthe off-angle circle↔rectangle default. `opts.resolution` (default 64) feeds\nthe polar sample count. The warp builds an **angle-indexed table**: uniform\nangles, arc-length samples, and every profile vertex angle, then ray-hits\neach station. Rectangle corners are table entries, so a circle’s chords no\nlonger bite them. Legacy `loft({ topCS, bottomCS, height })` is unchanged.\n\n**Default contour plane** (no face and no saved workplane) is world **+Z**\nwith **X/Y** axes — the standard views. A picked face or construction\nworkplane still supplies the frame. Angle sliders in the contour chip rotate\nthat frame; Confirm uses the edited plane.\n\n**Workplane** (Advanced) inserts a literal PlaneFrame\n`{ center, normal, x, y }` — a rendered, selectable construction plane.\nIt does **not** create a host cube. Tapping it on an empty script leaves\nthe viewport empty of solids (the plane overlay remains).\n\n**Blank run:** an empty, whitespace, or comment-only script (and a\nconstruction-plane-only script) clears the 3D view. Undo back to a blank\nbuffer does not keep the previous solid. A failed non-empty script still\nrestores the last good mesh.\n\n**Rules for both:**\n- `contours` is an **array of contours** `[outer, hole1, ...]`; a single\n solid can be written as `[...pts]` (bare point list) — both accepted.\n- Every contour needs **≥ 3 distinct points**, closed polygon (auto-closed\n if first ≠ last). Open polylines / 2-point lists throw.\n- For a **hollow** part: outer contour + inner contour (through-hole).\n- Invalid profile → **named throw** (never a silent empty).\n\n---\n\n## Example: Complex Part\n\n\n\n## Security Notes\n\nScripts run in an isolated Web Worker sandbox with:\n- No network access (fetch, XMLHttpRequest, WebSocket blocked)\n- No storage access (indexedDB, localStorage blocked)\n- No worker spawning\n- Memory limits enforced\n- Execution timeout enforced\n\nImported models are available via `window.__importedManifolds['filename']`.",
|
|
1452
|
+
"examples": [
|
|
1453
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs0 = makeCrossSection(fr, profileCircle(5, 32));\nconst xs1 = makeCrossSection(offsetPlaneFrame(fr, 20), profileCircle(8, 32));\npart = placeInFrame(fr, makeLoft([xs0, xs1]));",
|
|
1454
|
+
"// Create a flanged tube with mounting holes\n\n// Main tube\nconst mainTube = tube(15, 12, 40, 64);\n\n// Bottom flange\nconst flange = Manifold.cylinder(5, 25, 25, 64);\n\n// Mounting holes in flange\nconst bore = Manifold.cylinder(10, 3, 3, 32);\nconst holes = polarArray(bore, 4, 20, 'z');\n\n// Combine\nlet part = mainTube.add(flange);\npart = part.subtract(holes);\n\n// Center and align bottom to Z=0\npart = center(part, [true, true, false]);\npart = align(part, { min: [undefined, undefined, 0] });\n\nreturn part;"
|
|
1455
|
+
]
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
"name": "offsetPlaneFrame",
|
|
1459
|
+
"signature": "offsetPlaneFrame(plane, offset)",
|
|
1460
|
+
"params": [
|
|
1461
|
+
{
|
|
1462
|
+
"name": "plane",
|
|
1463
|
+
"text": "plane"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
"name": "offset",
|
|
1467
|
+
"text": "offset"
|
|
1468
|
+
}
|
|
1469
|
+
],
|
|
1470
|
+
"description": "Copy of a workplane translated along its normal. ",
|
|
1471
|
+
"doc": "Loft ≥2 `makeCrossSection` values into a solid. **Parallel planes** (same\nworkplane + per-profile offset along the normal, normals within about 8°)\nuse the polar warp. `offsetPlaneFrame(plane, offset)` copies a PlaneFrame\nand translates `center` by `offset * normal`. That solid is **local** (XY =\nstation UV, Z along the shared normal, z=0 at the lowest station) — Confirm\nplaces it with `placeInFrame`. **Angled planes** keep input order. Each\ncontour is mapped through its own frame, arc-length resampled, and\nshift-aligned, then carried on a Hermite spine so a right-angle elbow does\nnot fold. That solid is local to the **first** profile's plane\n(`placeInFrame` on that plane). The legacy `loft({ topCS, bottomCS, height })`\ncup helper is unchanged.\n\n\n\n**Contour-mode Loft:** game-mode **Loft** builds a multi-profile list (min 2,\ndefault circle r=5 @ 0 and circle r=8 @ 20 on the shared workplane). Circle /\nrect / polygon / polyline edit the selected profile. Each station can stay on\nthat plane with an offset, or pick a face, a saved workplane, or a saved\nsketch's plane. Confirm emits one `makeCrossSection` per station plus\n`makeLoft`, then `placeInFrame`. Offset-only stations still use\n`offsetPlaneFrame`. A station with its own frame emits that frame, and the\nplacement frame is the first station. Second Confirm replaces the same marked\nblock. **Back** exits with no commit. Live preview skins the stations as\noffsets, planes, or shapes change.\n\n**Loud failures:** < 2 profiles; coincident stations (zero-length loft);\ndegenerate / empty contours; a turn tighter than the profiles\n(self-intersection); empty result volume. Never a silent wrong solid.\n\n`opts.align` (default true) matches cornered stations by their outermost\nvertex angle (a 45° copy of the same rectangle un-rotates back to a prism).\nA nearly circular station does **not** spin the other profile — that was\nthe off-angle circle↔rectangle default. `opts.resolution` (default 64) feeds\nthe polar sample count. The warp builds an **angle-indexed table**: uniform\nangles, arc-length samples, and every profile vertex angle, then ray-hits\neach station. Rectangle corners are table entries, so a circle’s chords no\nlonger bite them. Legacy `loft({ topCS, bottomCS, height })` is unchanged.\n\n**Default contour plane** (no face and no saved workplane) is world **+Z**\nwith **X/Y** axes — the standard views. A picked face or construction\nworkplane still supplies the frame. Angle sliders in the contour chip rotate\nthat frame; Confirm uses the edited plane.\n\n**Workplane** (Advanced) inserts a literal PlaneFrame\n`{ center, normal, x, y }` — a rendered, selectable construction plane.\nIt does **not** create a host cube. Tapping it on an empty script leaves\nthe viewport empty of solids (the plane overlay remains).\n\n**Blank run:** an empty, whitespace, or comment-only script (and a\nconstruction-plane-only script) clears the 3D view. Undo back to a blank\nbuffer does not keep the previous solid. A failed non-empty script still\nrestores the last good mesh.\n\n**Rules for both:**\n- `contours` is an **array of contours** `[outer, hole1, ...]`; a single\n solid can be written as `[...pts]` (bare point list) — both accepted.\n- Every contour needs **≥ 3 distinct points**, closed polygon (auto-closed\n if first ≠ last). Open polylines / 2-point lists throw.\n- For a **hollow** part: outer contour + inner contour (through-hole).\n- Invalid profile → **named throw** (never a silent empty).\n\n---\n\n## Example: Complex Part\n\n\n\n## Security Notes\n\nScripts run in an isolated Web Worker sandbox with:\n- No network access (fetch, XMLHttpRequest, WebSocket blocked)\n- No storage access (indexedDB, localStorage blocked)\n- No worker spawning\n- Memory limits enforced\n- Execution timeout enforced\n\nImported models are available via `window.__importedManifolds['filename']`.",
|
|
1472
|
+
"examples": [
|
|
1473
|
+
"const fr = { center: [0, 0, 0], normal: [0, 0, 1], x: [1, 0, 0], y: [0, 1, 0] };\nconst xs0 = makeCrossSection(fr, profileCircle(5, 32));\nconst xs1 = makeCrossSection(offsetPlaneFrame(fr, 20), profileCircle(8, 32));\npart = placeInFrame(fr, makeLoft([xs0, xs1]));",
|
|
1474
|
+
"// Create a flanged tube with mounting holes\n\n// Main tube\nconst mainTube = tube(15, 12, 40, 64);\n\n// Bottom flange\nconst flange = Manifold.cylinder(5, 25, 25, 64);\n\n// Mounting holes in flange\nconst bore = Manifold.cylinder(10, 3, 3, 32);\nconst holes = polarArray(bore, 4, 20, 'z');\n\n// Combine\nlet part = mainTube.add(flange);\npart = part.subtract(holes);\n\n// Center and align bottom to Z=0\npart = center(part, [true, true, false]);\npart = align(part, { min: [undefined, undefined, 0] });\n\nreturn part;"
|
|
1475
|
+
]
|
|
1476
|
+
},
|
|
1477
|
+
{
|
|
1478
|
+
"name": "sheetMetalSolid",
|
|
1479
|
+
"signature": "sheetMetalSolid(spec)",
|
|
1480
|
+
"params": [
|
|
1481
|
+
{
|
|
1482
|
+
"name": "spec",
|
|
1483
|
+
"text": "spec"
|
|
1484
|
+
}
|
|
1485
|
+
],
|
|
1486
|
+
"description": "sheetMetalSolid(spec) — SendCutSend sheet-metal part from its JSON spec (base flange, bends, tabs, holes, automatic corner reliefs). ",
|
|
1487
|
+
"doc": "sheetMetalSolid(spec) — SendCutSend sheet-metal part from its JSON spec\n(base flange, bends, tabs, holes, automatic corner reliefs). Written by\nSheet Metal mode inside the sheet-metal markers; see utils/sheetMetal.",
|
|
1488
|
+
"examples": [
|
|
1489
|
+
"let part = sheetMetalSolid(sheetSpec);"
|
|
1490
|
+
]
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
"name": "profileCircle",
|
|
1494
|
+
"signature": "profileCircle(radius, segments = 32)",
|
|
1495
|
+
"params": [
|
|
1496
|
+
{
|
|
1497
|
+
"name": "radius",
|
|
1498
|
+
"text": "radius"
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
"name": "segments",
|
|
1502
|
+
"text": "segments = 32",
|
|
1503
|
+
"default": "32"
|
|
1504
|
+
}
|
|
1505
|
+
],
|
|
1506
|
+
"description": "profileCircle(radius, segments=32) → { type:'circle', radius, segments, contours } Contours centered at UV origin — enough for basic extrude / future fillet.",
|
|
1507
|
+
"doc": "profileCircle(radius, segments=32) → { type:'circle', radius, segments, contours }\nContours centered at UV origin — enough for basic extrude / future fillet.",
|
|
1508
|
+
"examples": [
|
|
1509
|
+
"const p = profileCircle(5, 32);"
|
|
1510
|
+
]
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
"name": "profileRectangle",
|
|
1514
|
+
"signature": "profileRectangle(width, height, centered = true)",
|
|
1515
|
+
"params": [
|
|
1516
|
+
{
|
|
1517
|
+
"name": "width",
|
|
1518
|
+
"text": "width"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
"name": "height",
|
|
1522
|
+
"text": "height"
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
"name": "centered",
|
|
1526
|
+
"text": "centered = true",
|
|
1527
|
+
"default": "true"
|
|
1528
|
+
}
|
|
1529
|
+
],
|
|
1530
|
+
"description": "profileRectangle(width, height, centered=true) → rectangle profile in UV.",
|
|
1531
|
+
"doc": "profileRectangle(width, height, centered=true) → rectangle profile in UV.",
|
|
1532
|
+
"examples": [
|
|
1533
|
+
"const p = profileRectangle(20, 12, true);"
|
|
1534
|
+
]
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
"name": "profilePolygon",
|
|
1538
|
+
"signature": "profilePolygon(points)",
|
|
1539
|
+
"params": [
|
|
1540
|
+
{
|
|
1541
|
+
"name": "points",
|
|
1542
|
+
"text": "points"
|
|
1543
|
+
}
|
|
1544
|
+
],
|
|
1545
|
+
"description": "profilePolygon(points) → closed polyline/polygon profile in UV. ",
|
|
1546
|
+
"doc": "Simple closed polyline / polygon (≥ 3 `[u,v]` points; explicit close optional;\nwinding normalized CCW). Enough for a quarter-circle fillet profile:",
|
|
1547
|
+
"examples": [
|
|
1548
|
+
"const r = 3;\nconst filletProf = profilePolygon([\n [0, 0], [r, 0],\n [r * Math.cos(Math.PI / 4), r * Math.sin(Math.PI / 4)],\n [0, r],\n]);"
|
|
1549
|
+
]
|
|
1550
|
+
},
|
|
1551
|
+
{
|
|
1552
|
+
"name": "makeCrossSection",
|
|
1553
|
+
"signature": "makeCrossSection(plane, profile)",
|
|
1554
|
+
"params": [
|
|
1555
|
+
{
|
|
1556
|
+
"name": "plane",
|
|
1557
|
+
"text": "plane"
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
"name": "profile",
|
|
1561
|
+
"text": "profile"
|
|
1562
|
+
}
|
|
1563
|
+
],
|
|
1564
|
+
"description": "makeCrossSection(plane, profile) → reusable { kind, plane, profile, contours }. plane: workplaneFromFace frame. profile: profileCircle/Rectangle/Polygon result, or { type, ... }, a { type:'path', points, closed } wire (two or more [u,v], zero area allowed), or bare contours / ...",
|
|
1565
|
+
"doc": "**Parameters:**\n- `plane` — frame from `workplaneFromFace` (`center`, `normal`, `x`, `y`)\n- `profile` — `profileCircle` / `profileRectangle` / `profilePolygon` result,\n a `{ type, ... }` descriptor, or a contours / point list (same rules as\n `makeExtrude`)\n\n**Returns:** `{ kind:'crossSection', plane, profile, contours }`\n\n**Loud failures:** missing plane axes; non-positive sizes; < 3 polygon points;\ndegenerate (zero-area) profile.\n\n**UI:** Advanced rail → **Profile** (with **Workplane**) → contour mode\n(circle / rectangle / polygon / polyline). Face select feeds the plane.\nSaved contours stay pickable for Extrude / Revolve / Sweep / Loft. Preview\noverlays the profile on the plane while editing.\n\n**Non-goals (wait for Product brief):** fillet-via-sweep;\nextrude/revolve/loft from this value.\n(Edge→sweep path is Slice 22 — see below.) A constrained contour\nuses `solveContour`.\n\n---\n\n## Edge → sweep path (Slice 22)\n\nOrdered **sweep path / wire** from the current edge selection (including\ntangent-prop chains). Later slices consume this value to sweep a cross-section\ncutter along it. This slice ships the path value only — fillet-via-sweep is\n**not** started here (wait for Product brief).",
|
|
1566
|
+
"examples": [
|
|
1567
|
+
"let part = Manifold.cube([40, 30, 20], true);\nconst topFace = facesByNormal(part, [0, 0, 1])[0];\nconst fr = workplaneFromFace(part, topFace);\nconst xs = makeCrossSection(fr, profileCircle(5, 32));\n// xs.plane / xs.profile / xs.contours — consume in later slices\nreturn part;",
|
|
1568
|
+
"{\n kind: 'sweepPath',\n closed: false, // true for circular / loop selections\n points: [ [x,y,z], ... ], // ordered polyline (closed: first ≠ last)\n length: 40, // total path length\n edgeCount: 3,\n}"
|
|
1569
|
+
]
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
"name": "solveContour",
|
|
1573
|
+
"signature": "solveContour(spec)",
|
|
1574
|
+
"params": [
|
|
1575
|
+
{
|
|
1576
|
+
"name": "spec",
|
|
1577
|
+
"text": "spec"
|
|
1578
|
+
}
|
|
1579
|
+
],
|
|
1580
|
+
"description": "solveContour(spec) → a contour profile in plane UV. spec is `{ points, lines, arcs, dimensions, constraints, refs }`. ",
|
|
1581
|
+
"doc": "Solve a constrained contour in plane UV. Lengths are millimetres. Angles are\ndegrees. A dimension name is a string on that dimension and is not a script\nbinding. Horizontal is constant `v`. Vertical is constant `u`. Both are the\nworkplane frame, not the screen.\n\n\n\n**Returns:** `{ type:'contour', contours, points, lines, arcs, dimensions, constraints, dof, status, conflict, repeated, open }`.\n`status` is `under`, `full`, or `conflict`. `repeated` lists constraints\nwhose removal does not change the rank, each with `warning: 'repeated'`.\nThat warning is not a failure. More than 128 points throws. An open chain\nof three or more points is closed with one more line before the solve.\nA contour may hold more than one chain. A vertex with more than two\nedges throws.\n\n**Loud failures:** unknown id, unknown kind, equal of a line and an arc,\na name that is not an identifier or is used twice on the contour, a bare\nidentifier where a number belongs.",
|
|
1582
|
+
"examples": [
|
|
1583
|
+
"const contour = solveContour({\n points: [\n { id: 'p0', at: [0, 0] },\n { id: 'p1', at: [40, 0] },\n { id: 'p2', at: [40, 20] },\n { id: 'p3', at: [0, 20] },\n ],\n lines: [\n { id: 'e0', a: 'p0', b: 'p1' },\n { id: 'e1', a: 'p1', b: 'p2' },\n { id: 'e2', a: 'p2', b: 'p3' },\n { id: 'e3', a: 'p3', b: 'p0' },\n ],\n arcs: [],\n dimensions: [\n { id: 'd0', kind: 'length', edge: 'e0', value: 40, name: 'width' },\n ],\n constraints: [\n { id: 'k0', kind: 'horizontal', items: ['e0'] },\n { id: 'k1', kind: 'fix', items: ['p0'], at: { p0: [0, 0] } },\n ],\n});\nconst xs = makeCrossSection(fr, contour);"
|
|
1584
|
+
]
|
|
1585
|
+
},
|
|
1586
|
+
{
|
|
1587
|
+
"name": "makeSweepPath",
|
|
1588
|
+
"signature": "makeSweepPath(edges, opts = {})",
|
|
1589
|
+
"params": [
|
|
1590
|
+
{
|
|
1591
|
+
"name": "edges",
|
|
1592
|
+
"text": "edges"
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
"name": "opts",
|
|
1596
|
+
"text": "opts = {}",
|
|
1597
|
+
"default": "{}"
|
|
1598
|
+
}
|
|
1599
|
+
],
|
|
1600
|
+
"description": "makeSweepPath(edges, opts?) → reusable ordered sweep path / wire. edges: feature / convexEdges-style {a,b,va,vb,...} (selection or query). ",
|
|
1601
|
+
"doc": "**Parameters:**\n- `edges` — array of feature edges `{ a, b, va, vb, length?, key? }` (from\n `convexEdges` / Edge pick selection)\n- `opts.reverse` — optional; reverse polyline direction\n\n**Returns:** `{ kind:'sweepPath', closed, points, length, edgeCount }`\n\n**Loud failures (script):** empty / unusable edges; disconnected selection;\nbranched junctions; walk failure.\n\n**UI:** FEAT rail → **Path** → param popup (Body, Reverse). Uses current Edge\nselection + Tangent chip. Viewport preview shows order/direction (green→magenta\ngradient polyline, chevron arrows, start/end markers) — distinct from the\norange #20 selection halo. Auto-Run unchanged.\n\n**Non-goals (Slice 22):** fillet-via-sweep shipped in Slice 23; extrude/revolve/loft\nstill wait for Product brief; Profile API changes; full sketcher; C6 soft counters.\n\n\n---\n\n## Fillet via swept cross-section (Slice 23)\n\nUnlock fillets on **compound / curved-adjacent** edges (cases where C6\n`filletEdges` throws `curved-face fillet not supported`, e.g. post-fillet seams\nor when you prefer Path-driven construction) by sweeping a cutter along\n`makeSweepPath` and boolean-subtracting.",
|
|
1602
|
+
"examples": [
|
|
1603
|
+
"let part = Manifold.cube([40, 30, 20], true);\nconst top = facesByNormal(part, [0, 0, 1])[0];\nconst fr = workplaneFromFace(part, top);\n// Script path: pass convexEdges (or a filtered subset) — UI emits mid-matched selection.\nconst rim = convexEdges(part); // or selected edges from Edge pick + Tangent\nconst path = makeSweepPath(rim); // { kind:'sweepPath', closed, points, length, edgeCount }\n// Later: sweepPoints(profile, path.points, { closed: path.closed })\nreturn part;"
|
|
1604
|
+
]
|
|
1605
|
+
},
|
|
1606
|
+
{
|
|
1607
|
+
"name": "filletAlongPath",
|
|
1608
|
+
"signature": "filletAlongPath(part, path, radius, opts = {})",
|
|
1609
|
+
"params": [
|
|
1610
|
+
{
|
|
1611
|
+
"name": "part",
|
|
1612
|
+
"text": "part"
|
|
1613
|
+
},
|
|
1614
|
+
{
|
|
1615
|
+
"name": "path",
|
|
1616
|
+
"text": "path"
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
"name": "radius",
|
|
1620
|
+
"text": "radius"
|
|
1621
|
+
},
|
|
1622
|
+
{
|
|
1623
|
+
"name": "opts",
|
|
1624
|
+
"text": "opts = {}",
|
|
1625
|
+
"default": "{}"
|
|
1626
|
+
}
|
|
1627
|
+
],
|
|
1628
|
+
"description": "filletAlongPath(part, path, radius, opts?) Sweep a dihedral fillet (or equal-leg chamfer) along path → boolean subtract. ",
|
|
1629
|
+
"doc": "**Parameters:**\n- `part` — manifold body\n- `path` — `makeSweepPath` result, `{ points, closed }`, or `points[]` (+ `opts.closed`)\n- `radius` — fillet radius, or chamfer leg length (> 0)\n- `opts.profile` — `'fillet'` (default) or `'chamfer'`\n- `opts.segments` — arc segments for the fillet profile (default 12)\n- `opts.initialNormal` — optional. When set, keeps the legacy 90° wedge and a single start-frame RMF. Leave unset for the dihedral cutter.\n- `opts.arcSamples` / `opts.extrudeSegments` — legacy RMF sweep quality only\n\n**Path / cutter:** open chains sweep the wedge along a **linear polyline** of the\nedge wire (not Catmull-Rom — spline bulge left purple scraps). Closed paths that\nfit a circle use a **revolved meridian wedge** (C6-style, phase-locked to the\ntessellation). **Fillet-on-fillet / path on a prior blend:** keep the full wire,\nincluding tessellated micro rim arcs — do **not** skip those segments (skipping\nleft a gap instead of wrapping the prior fillet). The quarter-circle / chamfer\ncutter origin is pushed into a rear exterior bumper `(−e,−e)` plus thickness-`e`\nstrips so the boolean consumes coincident sliver sheets **without growing the\nrequested blend** (realized first-quadrant extent stays at `r`). Mixed-radius /\ntighter follow-on sweeps use a deeper rear pad than the original 4%·r sliver.\nDisconnected cutter scraps are dropped via `decompose` when present.\nLoud-fail if the kept solid is still scrap-sheet dirty.\n\n**Dihedral cutter:** each path segment is probed from the two adjacent triangles\n(in-face rays from the third vertices — not face normals, not faceID groups).\n`N` lies in one face, `B = T×N` points toward the other, and the profile is built\nfor that interior angle θ: fillet setback `t = r/tan(θ/2)`, removed area\n`r·t − ½·r²·(π−θ)` (at 90° this is `r²(1−π/4)`); chamfer area `½·c²·sin θ`\n(at 90° this is `½·c²`). Segments whose θ stays within 3° share one profile and\nare swept with those per-segment frames. A smooth segment that is not a convex\nedge keeps the neighboring frame, so a compound chain can still sweep. A closed run that fits a circle is\nrevolved. `opts.initialNormal` is the only path that still uses a 90° wedge and\none start-frame RMF. The exterior bumper still keeps cutter legs off the faces;\nat 90° it matches the old `(−e,−e)` pad.",
|
|
1630
|
+
"examples": [
|
|
1631
|
+
"let part = Manifold.cube([40, 30, 20], true);\n// Planar–planar (unchanged):\nconst e = convexEdges(part).filter(/* … */);\npart = filletEdges(part, e, 3, { sphericalCorners: true });\n\n// Sweep fillet (curved-adjacent / closed rim / post-fillet seam):\nconst rim = /* Edge pick + Tangent → selection, or convexEdges subset */;\nconst path = makeSweepPath(rim); // { kind:'sweepPath', closed, points, length, edgeCount }\npart = filletAlongPath(part, path, 2); // dihedral fillet\n// part = filletAlongPath(part, path, 2, { profile: 'chamfer' }); // equal-leg chamfer\nreturn part;"
|
|
1632
|
+
]
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
"name": "edge",
|
|
1636
|
+
"signature": "edge(part, id)",
|
|
1637
|
+
"params": [
|
|
1638
|
+
{
|
|
1639
|
+
"name": "part",
|
|
1640
|
+
"text": "part"
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
"name": "id",
|
|
1644
|
+
"text": "id"
|
|
1645
|
+
}
|
|
1646
|
+
],
|
|
1647
|
+
"description": "edge(part, id) → mesh segments of one boundary edge. id is the integer shown as e{id} in Fillet mode. ",
|
|
1648
|
+
"doc": "Fillet-mode labels and Accept use these instead of tessellation keys like\n`\"1268-1269\"`.\n\n\n\n**How ids are assigned (current mesh only):**\n- A **face id** is the minimum Manifold `faceID` in a coplanar connected group\n (normals within 0.1°, plane offset within 1e-3). Shown as `fN`.\n- A **boundary edge id** groups triangle segments that share one unordered face\n pair and connect through vertices. One CAD edge that was tessellated collinearly\n is one id (`eN`). A curved rim, where each facet is its own face, stays many ids.\n- Ids are sorted by `(min face, max face, midpoint)` so a fresh cube is stable.\n- `edge(part, id)` and `edgesBetween(part, faceA, faceB)` return\n `{ key, a, b, va, vb, mid, length }` segments for `makeSweepPath`.\n `edgesBetween` throws when that pair has more than one boundary — use `edge`.\n\n**Rematch limits:** ids are not a CAD feature tree. Manifold `faceID` is\nprovenance and can merge or split after a boolean, and two disconnected regions\ncan share one minimum faceID. `edge` / `edgesBetween` throw `re-pick edges`\nwhen the id or pair is missing. Re-running a script from scratch is stable only\nwhile the solid *before* the fillet is deterministic. After geometry changes,\nre-pick in Fillet mode (the labels update) rather than editing a stale id.\n\n**Loud failures (script):** bad/empty path; radius ≤ 0; concave edge; cannot orient\ncutter; sweep/boolean failure; ~0 volume removed (wrong orientation); near-no-op vs\nexpected wedge volume; empty result. Never silent wrong solid.\n\n**Soft-fail (UI):** empty / disconnected / branched edge selection — same messages\nas Path; no broken JS inserted.",
|
|
1649
|
+
"examples": [
|
|
1650
|
+
"let part = Manifold.cube([40, 30, 20], true);\nconst cat = boundaryEdges(part); // [{ id, faceA, faceB, mid, length }, ...]\nconst one = cat[0];\nconst selEdges = edgesBetween(part, one.faceA, one.faceB);\n// partial chain: [id, id].flatMap((id) => edge(part, id))\nconst path = makeSweepPath(selEdges);\npart = filletAlongPath(part, path, 2);\nreturn part;"
|
|
1651
|
+
]
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
"name": "edgesBetween",
|
|
1655
|
+
"signature": "edgesBetween(part, faceA, faceB)",
|
|
1656
|
+
"params": [
|
|
1657
|
+
{
|
|
1658
|
+
"name": "part",
|
|
1659
|
+
"text": "part"
|
|
1660
|
+
},
|
|
1661
|
+
{
|
|
1662
|
+
"name": "faceA",
|
|
1663
|
+
"text": "faceA"
|
|
1664
|
+
},
|
|
1665
|
+
{
|
|
1666
|
+
"name": "faceB",
|
|
1667
|
+
"text": "faceB"
|
|
1668
|
+
}
|
|
1669
|
+
],
|
|
1670
|
+
"description": "edgesBetween(part, faceA, faceB) → segments of the only boundary between those face ids. ",
|
|
1671
|
+
"doc": "Fillet-mode labels and Accept use these instead of tessellation keys like\n`\"1268-1269\"`.\n\n\n\n**How ids are assigned (current mesh only):**\n- A **face id** is the minimum Manifold `faceID` in a coplanar connected group\n (normals within 0.1°, plane offset within 1e-3). Shown as `fN`.\n- A **boundary edge id** groups triangle segments that share one unordered face\n pair and connect through vertices. One CAD edge that was tessellated collinearly\n is one id (`eN`). A curved rim, where each facet is its own face, stays many ids.\n- Ids are sorted by `(min face, max face, midpoint)` so a fresh cube is stable.\n- `edge(part, id)` and `edgesBetween(part, faceA, faceB)` return\n `{ key, a, b, va, vb, mid, length }` segments for `makeSweepPath`.\n `edgesBetween` throws when that pair has more than one boundary — use `edge`.\n\n**Rematch limits:** ids are not a CAD feature tree. Manifold `faceID` is\nprovenance and can merge or split after a boolean, and two disconnected regions\ncan share one minimum faceID. `edge` / `edgesBetween` throw `re-pick edges`\nwhen the id or pair is missing. Re-running a script from scratch is stable only\nwhile the solid *before* the fillet is deterministic. After geometry changes,\nre-pick in Fillet mode (the labels update) rather than editing a stale id.\n\n**Loud failures (script):** bad/empty path; radius ≤ 0; concave edge; cannot orient\ncutter; sweep/boolean failure; ~0 volume removed (wrong orientation); near-no-op vs\nexpected wedge volume; empty result. Never silent wrong solid.\n\n**Soft-fail (UI):** empty / disconnected / branched edge selection — same messages\nas Path; no broken JS inserted.",
|
|
1672
|
+
"examples": [
|
|
1673
|
+
"let part = Manifold.cube([40, 30, 20], true);\nconst cat = boundaryEdges(part); // [{ id, faceA, faceB, mid, length }, ...]\nconst one = cat[0];\nconst selEdges = edgesBetween(part, one.faceA, one.faceB);\n// partial chain: [id, id].flatMap((id) => edge(part, id))\nconst path = makeSweepPath(selEdges);\npart = filletAlongPath(part, path, 2);\nreturn part;"
|
|
1674
|
+
]
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
"name": "boundaryEdges",
|
|
1678
|
+
"signature": "boundaryEdges(part)",
|
|
1679
|
+
"params": [
|
|
1680
|
+
{
|
|
1681
|
+
"name": "part",
|
|
1682
|
+
"text": "part"
|
|
1683
|
+
}
|
|
1684
|
+
],
|
|
1685
|
+
"description": "boundaryEdges(part) → catalog { id, faceA, faceB, mid, length } for the current mesh. ",
|
|
1686
|
+
"doc": "Fillet-mode labels and Accept use these instead of tessellation keys like\n`\"1268-1269\"`.\n\n\n\n**How ids are assigned (current mesh only):**\n- A **face id** is the minimum Manifold `faceID` in a coplanar connected group\n (normals within 0.1°, plane offset within 1e-3). Shown as `fN`.\n- A **boundary edge id** groups triangle segments that share one unordered face\n pair and connect through vertices. One CAD edge that was tessellated collinearly\n is one id (`eN`). A curved rim, where each facet is its own face, stays many ids.\n- Ids are sorted by `(min face, max face, midpoint)` so a fresh cube is stable.\n- `edge(part, id)` and `edgesBetween(part, faceA, faceB)` return\n `{ key, a, b, va, vb, mid, length }` segments for `makeSweepPath`.\n `edgesBetween` throws when that pair has more than one boundary — use `edge`.\n\n**Rematch limits:** ids are not a CAD feature tree. Manifold `faceID` is\nprovenance and can merge or split after a boolean, and two disconnected regions\ncan share one minimum faceID. `edge` / `edgesBetween` throw `re-pick edges`\nwhen the id or pair is missing. Re-running a script from scratch is stable only\nwhile the solid *before* the fillet is deterministic. After geometry changes,\nre-pick in Fillet mode (the labels update) rather than editing a stale id.\n\n**Loud failures (script):** bad/empty path; radius ≤ 0; concave edge; cannot orient\ncutter; sweep/boolean failure; ~0 volume removed (wrong orientation); near-no-op vs\nexpected wedge volume; empty result. Never silent wrong solid.\n\n**Soft-fail (UI):** empty / disconnected / branched edge selection — same messages\nas Path; no broken JS inserted.",
|
|
1687
|
+
"examples": [
|
|
1688
|
+
"let part = Manifold.cube([40, 30, 20], true);\nconst cat = boundaryEdges(part); // [{ id, faceA, faceB, mid, length }, ...]\nconst one = cat[0];\nconst selEdges = edgesBetween(part, one.faceA, one.faceB);\n// partial chain: [id, id].flatMap((id) => edge(part, id))\nconst path = makeSweepPath(selEdges);\npart = filletAlongPath(part, path, 2);\nreturn part;"
|
|
1689
|
+
]
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
"name": "faceNames",
|
|
1693
|
+
"signature": "faceNames(part)",
|
|
1694
|
+
"params": [
|
|
1695
|
+
{
|
|
1696
|
+
"name": "part",
|
|
1697
|
+
"text": "part"
|
|
1698
|
+
}
|
|
1699
|
+
],
|
|
1700
|
+
"description": "faceNames(part) → every face name on the part, sorted. ",
|
|
1701
|
+
"doc": "Faces by the name the helper that built them recorded (see [docs/architecture.md](architecture.md), Face identity). `Manifold.cube` / `cylinder` / `sphere`, `tube`, `hexPrism`, `roundedBox`, `makeExtrude`, `makeRevolve`, `sweep` / `sweepPoints` and a parallel `makeLoft` stamp every face with `feature.role`: `feature` is the id of the marked block the call ran in (`cube1`, `tapDrillHole-11`), else `<helper>@<n>` in script order; `role` is `top bottom left right front back`, `side top bottom inner`, `surface`, `wall[i]`, `band[i]` / `corner[i]`, `cap0 cap1 wall[g]` (extrude and sweep), `seg[g] end0 end1` (revolve), `cap0 cap1 span[i][j]` (loft: bottom edge `i`, station span `j`). A label in several pieces (a slot through a top, a union of two copies) gets `[k]`, ordered by centre.\n\n\n\n`edgesOf(part, name, { includeConcave?, minAngleDeg? })` returns the convex feature edges that touch the named face, in the shape `convexEdges` returns, so they go straight into `filletEdges` / `chamferEdges`. Only edges on that face: four on a box top, never every edge on the body whose neighbour faces the same way. Concave edges are skipped and counted on `result.skipped` (pass `includeConcave: true` to blend them); it throws, naming the face and the concave count, when no convex edge is left.\n\n`facesNamed` throws, naming the faces that exist, when nothing matches; it never picks a nearby face. The faces carry `center`, `normal`, `tris`, `verts`, `area`, `body`, `name`, `label { feature, role, ordinal }` and `record`, and work wherever a `facesByNormal` face does. `surfaceOf` is the record the helper wrote from its arguments (`plane`, `cylinder`, `cone`, `sphere`, else `mesh`), in the frame the helper built in: a later translate or rotate moves the face, not its record. A hull, a fillet cutter or a freehand `Manifold.*` call outside those primitives has no stamped faces.",
|
|
1702
|
+
"examples": [
|
|
1703
|
+
"faceNames(part); // ['base.bottom', 'base.top', 'boss.side', …]\nconst top = facesNamed(part, 'base.top')[0];\nconst wp = workplaneFromFace(part, top);\npart = hole(part, wp, 10, 0, 4, 6);\nfacesNamed(part, 'plate.top'); // every piece: plate.top[0], plate.top[1]\nfacesNamed(part, 'boss.wall[*]'); // glob\nsurfaceOf(top); // { kind: 'plane', origin, normal }\npart = chamferEdges(part, edgesOf(part, 'boss.top'), 2); // the edges around that face only\nconst e = edgesOf(part, 'plate.top'); e.skipped; // concave edges left out, counted"
|
|
1704
|
+
]
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
"name": "facesNamed",
|
|
1708
|
+
"signature": "facesNamed(part, pattern)",
|
|
1709
|
+
"params": [
|
|
1710
|
+
{
|
|
1711
|
+
"name": "part",
|
|
1712
|
+
"text": "part"
|
|
1713
|
+
},
|
|
1714
|
+
{
|
|
1715
|
+
"name": "pattern",
|
|
1716
|
+
"text": "pattern"
|
|
1717
|
+
}
|
|
1718
|
+
],
|
|
1719
|
+
"description": "facesNamed(part, pattern) → the faces whose name matches `pattern`. ",
|
|
1720
|
+
"doc": "Faces by the name the helper that built them recorded (see [docs/architecture.md](architecture.md), Face identity). `Manifold.cube` / `cylinder` / `sphere`, `tube`, `hexPrism`, `roundedBox`, `makeExtrude`, `makeRevolve`, `sweep` / `sweepPoints` and a parallel `makeLoft` stamp every face with `feature.role`: `feature` is the id of the marked block the call ran in (`cube1`, `tapDrillHole-11`), else `<helper>@<n>` in script order; `role` is `top bottom left right front back`, `side top bottom inner`, `surface`, `wall[i]`, `band[i]` / `corner[i]`, `cap0 cap1 wall[g]` (extrude and sweep), `seg[g] end0 end1` (revolve), `cap0 cap1 span[i][j]` (loft: bottom edge `i`, station span `j`). A label in several pieces (a slot through a top, a union of two copies) gets `[k]`, ordered by centre.\n\n\n\n`edgesOf(part, name, { includeConcave?, minAngleDeg? })` returns the convex feature edges that touch the named face, in the shape `convexEdges` returns, so they go straight into `filletEdges` / `chamferEdges`. Only edges on that face: four on a box top, never every edge on the body whose neighbour faces the same way. Concave edges are skipped and counted on `result.skipped` (pass `includeConcave: true` to blend them); it throws, naming the face and the concave count, when no convex edge is left.\n\n`facesNamed` throws, naming the faces that exist, when nothing matches; it never picks a nearby face. The faces carry `center`, `normal`, `tris`, `verts`, `area`, `body`, `name`, `label { feature, role, ordinal }` and `record`, and work wherever a `facesByNormal` face does. `surfaceOf` is the record the helper wrote from its arguments (`plane`, `cylinder`, `cone`, `sphere`, else `mesh`), in the frame the helper built in: a later translate or rotate moves the face, not its record. A hull, a fillet cutter or a freehand `Manifold.*` call outside those primitives has no stamped faces.",
|
|
1721
|
+
"examples": [
|
|
1722
|
+
"faceNames(part); // ['base.bottom', 'base.top', 'boss.side', …]\nconst top = facesNamed(part, 'base.top')[0];\nconst wp = workplaneFromFace(part, top);\npart = hole(part, wp, 10, 0, 4, 6);\nfacesNamed(part, 'plate.top'); // every piece: plate.top[0], plate.top[1]\nfacesNamed(part, 'boss.wall[*]'); // glob\nsurfaceOf(top); // { kind: 'plane', origin, normal }\npart = chamferEdges(part, edgesOf(part, 'boss.top'), 2); // the edges around that face only\nconst e = edgesOf(part, 'plate.top'); e.skipped; // concave edges left out, counted"
|
|
1723
|
+
]
|
|
1724
|
+
},
|
|
1725
|
+
{
|
|
1726
|
+
"name": "edgesOf",
|
|
1727
|
+
"signature": "edgesOf(part, pattern, opts = {})",
|
|
1728
|
+
"params": [
|
|
1729
|
+
{
|
|
1730
|
+
"name": "part",
|
|
1731
|
+
"text": "part"
|
|
1732
|
+
},
|
|
1733
|
+
{
|
|
1734
|
+
"name": "pattern",
|
|
1735
|
+
"text": "pattern"
|
|
1736
|
+
},
|
|
1737
|
+
{
|
|
1738
|
+
"name": "opts",
|
|
1739
|
+
"text": "opts = {}",
|
|
1740
|
+
"default": "{}"
|
|
1741
|
+
}
|
|
1742
|
+
],
|
|
1743
|
+
"description": "edgesOf(part, name, opts?) → the convex feature edges around the named face(s), in the shape convexEdges returns, so they go straight into filletEdges / chamferEdges. `name` is anything facesNamed accepts. ",
|
|
1744
|
+
"doc": "Faces by the name the helper that built them recorded (see [docs/architecture.md](architecture.md), Face identity). `Manifold.cube` / `cylinder` / `sphere`, `tube`, `hexPrism`, `roundedBox`, `makeExtrude`, `makeRevolve`, `sweep` / `sweepPoints` and a parallel `makeLoft` stamp every face with `feature.role`: `feature` is the id of the marked block the call ran in (`cube1`, `tapDrillHole-11`), else `<helper>@<n>` in script order; `role` is `top bottom left right front back`, `side top bottom inner`, `surface`, `wall[i]`, `band[i]` / `corner[i]`, `cap0 cap1 wall[g]` (extrude and sweep), `seg[g] end0 end1` (revolve), `cap0 cap1 span[i][j]` (loft: bottom edge `i`, station span `j`). A label in several pieces (a slot through a top, a union of two copies) gets `[k]`, ordered by centre.\n\n\n\n`edgesOf(part, name, { includeConcave?, minAngleDeg? })` returns the convex feature edges that touch the named face, in the shape `convexEdges` returns, so they go straight into `filletEdges` / `chamferEdges`. Only edges on that face: four on a box top, never every edge on the body whose neighbour faces the same way. Concave edges are skipped and counted on `result.skipped` (pass `includeConcave: true` to blend them); it throws, naming the face and the concave count, when no convex edge is left.\n\n`facesNamed` throws, naming the faces that exist, when nothing matches; it never picks a nearby face. The faces carry `center`, `normal`, `tris`, `verts`, `area`, `body`, `name`, `label { feature, role, ordinal }` and `record`, and work wherever a `facesByNormal` face does. `surfaceOf` is the record the helper wrote from its arguments (`plane`, `cylinder`, `cone`, `sphere`, else `mesh`), in the frame the helper built in: a later translate or rotate moves the face, not its record. A hull, a fillet cutter or a freehand `Manifold.*` call outside those primitives has no stamped faces.",
|
|
1745
|
+
"examples": [
|
|
1746
|
+
"faceNames(part); // ['base.bottom', 'base.top', 'boss.side', …]\nconst top = facesNamed(part, 'base.top')[0];\nconst wp = workplaneFromFace(part, top);\npart = hole(part, wp, 10, 0, 4, 6);\nfacesNamed(part, 'plate.top'); // every piece: plate.top[0], plate.top[1]\nfacesNamed(part, 'boss.wall[*]'); // glob\nsurfaceOf(top); // { kind: 'plane', origin, normal }\npart = chamferEdges(part, edgesOf(part, 'boss.top'), 2); // the edges around that face only\nconst e = edgesOf(part, 'plate.top'); e.skipped; // concave edges left out, counted"
|
|
1747
|
+
]
|
|
1748
|
+
},
|
|
1749
|
+
{
|
|
1750
|
+
"name": "surfaceOf",
|
|
1751
|
+
"signature": "surfaceOf(face)",
|
|
1752
|
+
"params": [
|
|
1753
|
+
{
|
|
1754
|
+
"name": "face",
|
|
1755
|
+
"text": "face"
|
|
1756
|
+
}
|
|
1757
|
+
],
|
|
1758
|
+
"description": "surfaceOf(face) → the SurfaceRecord the helper that built the face recorded: `{ kind: 'plane', origin, normal }`, `{ kind: 'cylinder', axisOrigin, axisDir, radius }`, `{ kind: 'cone', apex, axisDir, halfAngle }`, `{ kind: 'sphere', center, radius }`, or `{ kind: 'mesh' }` when...",
|
|
1759
|
+
"doc": "Faces by the name the helper that built them recorded (see [docs/architecture.md](architecture.md), Face identity). `Manifold.cube` / `cylinder` / `sphere`, `tube`, `hexPrism`, `roundedBox`, `makeExtrude`, `makeRevolve`, `sweep` / `sweepPoints` and a parallel `makeLoft` stamp every face with `feature.role`: `feature` is the id of the marked block the call ran in (`cube1`, `tapDrillHole-11`), else `<helper>@<n>` in script order; `role` is `top bottom left right front back`, `side top bottom inner`, `surface`, `wall[i]`, `band[i]` / `corner[i]`, `cap0 cap1 wall[g]` (extrude and sweep), `seg[g] end0 end1` (revolve), `cap0 cap1 span[i][j]` (loft: bottom edge `i`, station span `j`). A label in several pieces (a slot through a top, a union of two copies) gets `[k]`, ordered by centre.\n\n\n\n`edgesOf(part, name, { includeConcave?, minAngleDeg? })` returns the convex feature edges that touch the named face, in the shape `convexEdges` returns, so they go straight into `filletEdges` / `chamferEdges`. Only edges on that face: four on a box top, never every edge on the body whose neighbour faces the same way. Concave edges are skipped and counted on `result.skipped` (pass `includeConcave: true` to blend them); it throws, naming the face and the concave count, when no convex edge is left.\n\n`facesNamed` throws, naming the faces that exist, when nothing matches; it never picks a nearby face. The faces carry `center`, `normal`, `tris`, `verts`, `area`, `body`, `name`, `label { feature, role, ordinal }` and `record`, and work wherever a `facesByNormal` face does. `surfaceOf` is the record the helper wrote from its arguments (`plane`, `cylinder`, `cone`, `sphere`, else `mesh`), in the frame the helper built in: a later translate or rotate moves the face, not its record. A hull, a fillet cutter or a freehand `Manifold.*` call outside those primitives has no stamped faces.",
|
|
1760
|
+
"examples": [
|
|
1761
|
+
"faceNames(part); // ['base.bottom', 'base.top', 'boss.side', …]\nconst top = facesNamed(part, 'base.top')[0];\nconst wp = workplaneFromFace(part, top);\npart = hole(part, wp, 10, 0, 4, 6);\nfacesNamed(part, 'plate.top'); // every piece: plate.top[0], plate.top[1]\nfacesNamed(part, 'boss.wall[*]'); // glob\nsurfaceOf(top); // { kind: 'plane', origin, normal }\npart = chamferEdges(part, edgesOf(part, 'boss.top'), 2); // the edges around that face only\nconst e = edgesOf(part, 'plate.top'); e.skipped; // concave edges left out, counted"
|
|
1762
|
+
]
|
|
1763
|
+
}
|
|
1764
|
+
]
|
|
1765
|
+
}
|