forgecad 0.7.0 → 0.8.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 +1 -1
- package/dist/assets/{AdminPage-DAu1C1ST.js → AdminPage-D4bocK4E.js} +1 -1
- package/dist/assets/{DocsPage-Gc_BCdqC.js → DocsPage-D3A_g8V3.js} +85 -45
- package/dist/assets/{EditorApp-DG1-oUSV.css → EditorApp-BWYUSpUN.css} +133 -51
- package/dist/assets/EditorApp-Cihhqcsq.js +11692 -0
- package/dist/assets/{EmbedViewer-CEO8XbV8.js → EmbedViewer-kWjKaC_t.js} +1 -1
- package/dist/assets/LandingPageProofDriven-Bg2IUc3l.css +856 -0
- package/dist/assets/LandingPageProofDriven-DXkKlyhI.js +601 -0
- package/dist/assets/{PricingPage-BSrxu6d7.js → PricingPage-BsU5vzEx.js} +1 -1
- package/dist/assets/{SettingsPage-FUCSIRq6.js → SettingsPage-PqvpAKIs.js} +1 -1
- package/dist/assets/{evalWorker-KoR0SNKq.js → evalWorker-C-hzNUMy.js} +2218 -286
- package/dist/assets/{index-wTEK39at.js → index-Pz321YAt.js} +7416 -1481
- package/dist/assets/{index-CyVd1D4D.css → index-ay13WNfa.css} +501 -2
- package/dist/assets/{manifold-B1sGWdYk.js → manifold-BcbjWLIo.js} +3 -3
- package/dist/assets/{manifold-D7o0N50J.js → manifold-DBckbFgx.js} +1 -1
- package/dist/assets/{manifold-G5sBaXzi.js → manifold-O2AAGXyj.js} +1 -1
- package/dist/assets/{reportWorker-DYcRHhv9.js → reportWorker-Dxr-5A7w.js} +2003 -259
- package/dist/docs/index.html +2 -2
- package/dist/docs-raw/CLI.md +488 -0
- package/dist/docs-raw/generated/assembly.md +19 -11
- package/dist/docs-raw/generated/concepts.md +1023 -360
- package/dist/docs-raw/generated/core.md +1165 -264
- package/dist/docs-raw/generated/curves.md +168 -1
- package/dist/docs-raw/generated/lib.md +10 -5
- package/dist/docs-raw/generated/output.md +1 -1
- package/dist/docs-raw/generated/sdf.md +208 -0
- package/dist/docs-raw/generated/sketch.md +1281 -329
- package/dist/docs-raw/generated/viewport.md +29 -2
- package/dist/index.html +2 -2
- package/dist/landing/proof-ams-adapter.png +0 -0
- package/dist/landing/proof-bolt-and-nut.png +0 -0
- package/dist/landing/proof-fillet-enclosure.png +0 -0
- package/dist/landing/proof-glasses.png +0 -0
- package/dist/landing/proof-gyroid.png +0 -0
- package/dist/sitemap.xml +6 -6
- package/dist-cli/forgecad.js +3148 -555
- package/dist-cli/forgecad.js.map +1 -1
- package/dist-cli/{solver-FV7TJZGI.js → solver-46FFSK2U.js} +1 -3
- package/dist-cli/{solver-FV7TJZGI.js.map → solver-46FFSK2U.js.map} +1 -1
- package/dist-skill/CONTEXT.md +3700 -1153
- package/dist-skill/SKILL-dev.md +15 -17
- package/dist-skill/SKILL.md +14 -9
- package/dist-skill/docs/API/core/concepts.md +28 -1
- package/dist-skill/docs/CLI.md +488 -0
- package/dist-skill/docs/generated/assembly.md +19 -11
- package/dist-skill/docs/generated/core.md +1165 -264
- package/dist-skill/docs/generated/curves.md +168 -1
- package/dist-skill/docs/generated/lib.md +10 -5
- package/dist-skill/docs/generated/output.md +1 -1
- package/dist-skill/docs/generated/sdf.md +208 -0
- package/dist-skill/docs/generated/sketch.md +1281 -329
- package/dist-skill/docs/generated/viewport.md +29 -2
- package/dist-skill/docs/guides/joint-design.md +78 -0
- package/dist-skill/docs-dev/API/core/concepts.md +28 -1
- package/dist-skill/docs-dev/CLI.md +488 -0
- package/dist-skill/docs-dev/coding.md +1 -1
- package/dist-skill/docs-dev/component-model.md +164 -0
- package/dist-skill/docs-dev/generated/assembly.md +19 -11
- package/dist-skill/docs-dev/generated/core.md +1165 -264
- package/dist-skill/docs-dev/generated/curves.md +168 -1
- package/dist-skill/docs-dev/generated/lib.md +10 -5
- package/dist-skill/docs-dev/generated/output.md +1 -1
- package/dist-skill/docs-dev/generated/sdf.md +208 -0
- package/dist-skill/docs-dev/generated/sketch.md +1281 -329
- package/dist-skill/docs-dev/generated/viewport.md +29 -2
- package/dist-skill/docs-dev/guides/joint-design.md +78 -0
- package/examples/api/attachTo-basics.forge.js +3 -3
- package/examples/api/bill-of-materials.forge.js +9 -9
- package/examples/api/bolt-pattern.forge.js +5 -5
- package/examples/api/boolean-operations.forge.js +2 -2
- package/examples/api/bounding-box-visualizer.forge.js +1 -1
- package/examples/api/clone-duplicate.forge.js +1 -1
- package/examples/api/connector-assembly.forge.js +4 -2
- package/examples/api/connector-basics.forge.js +5 -5
- package/examples/api/constrained-sketch-mechanical.forge.js +4 -4
- package/examples/api/elbow-test.forge.js +3 -3
- package/examples/api/extrude-options.forge.js +4 -4
- package/examples/api/fillet-showcase.forge.js +1 -1
- package/examples/api/gears-tier1.forge.js +5 -5
- package/examples/api/group-test.forge.js +2 -2
- package/examples/api/mesh-import-slats.forge.js +3 -3
- package/examples/api/patterns.forge.js +3 -3
- package/examples/api/pointAlong-orientation.forge.js +2 -2
- package/examples/api/profile-2020-b-slot6.forge.js +4 -4
- package/examples/api/sketch-rounding-strategies.forge.js +1 -1
- package/examples/api/smooth-curve-connections.forge.js +1 -1
- package/examples/api/transition-curves.forge.js +3 -3
- package/examples/constraints/01-fully-constrained-rect.forge.js +2 -2
- package/examples/constraints/02-underconstrained-triangle.forge.js +1 -1
- package/examples/constraints/03-redundant-constraints.forge.js +2 -2
- package/examples/constraints/05-parallel-with-linedistance.forge.js +2 -2
- package/examples/constraints/06-complex-spectrogram.forge.js +1 -1
- package/examples/constraints/07-perpendicular-chain.forge.js +4 -4
- package/examples/constraints/08-symmetric-bracket.forge.js +4 -4
- package/examples/constraints/09-stress-spiral.forge.js +1 -1
- package/examples/constraints/10-stress-honeycomb.forge.js +1 -1
- package/examples/constraints/11-surface-grid.forge.js +2 -2
- package/examples/constraints/12-surface-nested.forge.js +4 -4
- package/examples/constraints/13-surface-complex.forge.js +1 -1
- package/examples/exact-arc-housing.forge.js +12 -0
- package/examples/furniture/adjustable-table.forge.js +13 -13
- package/examples/furniture/bathroom.forge.js +15 -15
- package/examples/furniture/chair.forge.js +12 -12
- package/examples/furniture/picture-frame.forge.js +6 -6
- package/examples/furniture/shoe-rack-doors.forge.js +8 -8
- package/examples/furniture/shoe-rack.forge.js +7 -7
- package/examples/furniture/table-lamp.forge.js +8 -8
- package/examples/gcode/lissajous-vase.forge.js +4 -4
- package/examples/gcode/math-surface.forge.js +3 -3
- package/examples/gcode/parametric-vase.forge.js +4 -4
- package/examples/gcode/spiral-tower.forge.js +4 -4
- package/examples/generative/crystal-growth.forge.js +7 -7
- package/examples/generative/frost-spires.forge.js +6 -6
- package/examples/generative/golden-spiral-tower.forge.js +8 -8
- package/examples/generative/molten-forge.forge.js +6 -6
- package/examples/generative/neon-coral.forge.js +7 -7
- package/examples/mechanical/3d-printer.forge.js +9 -9
- package/examples/mechanical/5-finger-robot-hand.forge.js +4 -4
- package/examples/mechanical/airplane-propeller.forge.js +7 -7
- package/examples/mechanical/bolt-and-nut.forge.js +10 -10
- package/examples/mechanical/door-with-hinges.forge.js +7 -7
- package/examples/mechanical/fillet-enclosure.forge.js +14 -10
- package/examples/mechanical/headphone-hanger-v2.forge.js +9 -9
- package/examples/mechanical/robot_hand.forge.js +10 -10
- package/examples/mechanical/robot_hand_2.forge.js +17 -17
- package/examples/nurbs-surface.forge.js +8 -0
- package/examples/nurbs-tube.forge.js +7 -0
- package/examples/products/bottle.forge.js +7 -7
- package/examples/products/chess-set.forge.js +6 -6
- package/examples/products/classical-piano.forge.js +9 -9
- package/examples/products/clock.forge.js +21 -21
- package/examples/products/cup.forge.js +5 -5
- package/examples/products/iphone.forge.js +12 -12
- package/examples/products/laptop.forge.js +9 -9
- package/examples/products/laser-cut-box.forge.js +6 -6
- package/examples/products/laser-cut-tray.forge.js +6 -6
- package/examples/products/liquid-soap-dispenser.forge.js +5 -5
- package/examples/products/origami-fish.forge.js +6 -6
- package/examples/products/spiderman-cake.forge.js +2 -2
- package/examples/shelf/container.forge.js +5 -5
- package/examples/shelf/shelf-unit.forge.js +6 -6
- package/examples/toolbox/bolted-joint.forge.js +5 -5
- package/package.json +3 -1
- package/dist/assets/EditorApp-D9bJvtf7.js +0 -11338
- package/dist/assets/LandingPage-CdCuEOdC.js +0 -451
- package/dist-cli/chunk-PZ5AY32C.js +0 -10
- package/dist-cli/chunk-PZ5AY32C.js.map +0 -1
- package/dist-skill/docs/CLI/export.md +0 -91
- package/dist-skill/docs/CLI/projects.md +0 -107
- package/dist-skill/docs/CLI/studio_publishing.md +0 -52
- package/dist-skill/docs/CLI/validation.md +0 -66
- package/dist-skill/docs-dev/API/core/sdf-advanced.md +0 -92
- package/dist-skill/docs-dev/API/core/sdf-primitives.md +0 -58
- package/dist-skill/docs-dev/API/core/sdf-workflow.md +0 -42
- package/dist-skill/docs-dev/CLI/export.md +0 -91
- package/dist-skill/docs-dev/CLI/projects.md +0 -107
- package/dist-skill/docs-dev/CLI/studio_publishing.md +0 -52
- package/dist-skill/docs-dev/CLI/validation.md +0 -66
|
@@ -9,8 +9,10 @@ Smooth curves, lofted surfaces, swept solids, and splines.
|
|
|
9
9
|
|
|
10
10
|
## Contents
|
|
11
11
|
|
|
12
|
-
- [Curves & Surfacing](#curves-surfacing) — `hermiteTransitionG2`, `spline2d`, `spline3d`, `loft`, `loftAlongSpine`, `sweep`, `variableSweep`, `surfacePatch`, `transitionCurve`, `transitionSurface`, `connectEdges`
|
|
12
|
+
- [Curves & Surfacing](#curves-surfacing) — `hermiteTransitionG2`, `nurbs3d`, `spline2d`, `spline3d`, `loft`, `loftAlongSpine`, `sweep`, `variableSweep`, `nurbsSurface`, `surfacePatch`, `transitionCurve`, `transitionSurface`, `connectEdges`
|
|
13
13
|
- [Curve3D](#curve3d)
|
|
14
|
+
- [NurbsCurve3D](#nurbscurve3d)
|
|
15
|
+
- [NurbsSurface](#nurbssurface)
|
|
14
16
|
- [PathBuilder](#pathbuilder) — Line Segments, Arcs, Curves, Closing & Output
|
|
15
17
|
- [HermiteCurve3D](#hermitecurve3d)
|
|
16
18
|
- [QuinticHermiteCurve3D](#quintichermitecurve3d)
|
|
@@ -36,6 +38,37 @@ hermiteTransitionG2(a: QuinticHermiteCurveEndpoint, b: QuinticHermiteCurveEndpoi
|
|
|
36
38
|
| `curvature?` | `Vec3` | Second derivative / curvature vector. Default [0, 0, 0]. |
|
|
37
39
|
| `weight?` | `number` | Weight: scales tangent magnitude relative to chord length. Default 1.0. |
|
|
38
40
|
|
|
41
|
+
#### `nurbs3d()` — Create a NURBS curve from control points.
|
|
42
|
+
|
|
43
|
+
With default options, creates a cubic non-rational B-spline with uniform clamped knots. Set `weights` for rational curves (exact circles, conics). Set `degree` for linear (1), quadratic (2), cubic (3), or higher-order curves.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// Simple cubic B-spline through control points
|
|
47
|
+
const curve = nurbs3d([[0,0,0], [10,5,0], [20,-5,10], [30,0,5]]);
|
|
48
|
+
const tube = sweep(circle(2), curve);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// Rational quadratic — exact circular arc
|
|
53
|
+
const arc = nurbs3d(
|
|
54
|
+
[[10,0,0], [10,10,0], [0,10,0]],
|
|
55
|
+
{ degree: 2, weights: [1, Math.SQRT1_2, 1] }
|
|
56
|
+
);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
nurbs3d(points: Vec3[], options?: NurbsCurve3DOptions): NurbsCurve3D
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**`NurbsCurve3DOptions`**
|
|
64
|
+
|
|
65
|
+
| Option | Type | Description |
|
|
66
|
+
|--------|------|-------------|
|
|
67
|
+
| `degree?` | `number` | Polynomial degree (default 3 = cubic). Must be ≥ 1. |
|
|
68
|
+
| `weights?` | `number[]` | Rational weights, one per control point (default: all 1.0 = non-rational). |
|
|
69
|
+
| `knots?` | `number[]` | Knot vector (default: uniform clamped). Must have length = controlPoints.length + degree + 1. |
|
|
70
|
+
| `closed?` | `boolean` | Whether the curve is closed/periodic (default false). |
|
|
71
|
+
|
|
39
72
|
#### `spline2d()` — Build a smooth Catmull-Rom spline sketch from 2D control points.
|
|
40
73
|
|
|
41
74
|
A closed spline (default) returns a filled profile. An open spline requires a strokeWidth option to produce a solid sketch. Use tension (0..1, default 0.5) to control curve tightness.
|
|
@@ -143,6 +176,39 @@ variableSweep(spine: SweepPathInput, sections: VariableSweepSection[], options?:
|
|
|
143
176
|
| `boundsPadding?` | `number` | Optional extra bounds padding. |
|
|
144
177
|
| `up?` | `Vec3` | Preferred "up" vector for local profile frame. Auto fallback is used near parallel segments. |
|
|
145
178
|
|
|
179
|
+
#### `nurbsSurface()` — Create a NURBS surface from a grid of control points.
|
|
180
|
+
|
|
181
|
+
The control grid is indexed as `controlGrid[u][v]` — each row is a curve in the V direction, and columns trace curves in the U direction.
|
|
182
|
+
|
|
183
|
+
With default options, creates a bicubic non-rational B-spline surface with uniform clamped knots.
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
// Simple 4×4 control grid — a gently curved surface
|
|
187
|
+
const grid = [
|
|
188
|
+
[[0,0,0], [10,0,2], [20,0,2], [30,0,0]],
|
|
189
|
+
[[0,10,1], [10,10,5], [20,10,5], [30,10,1]],
|
|
190
|
+
[[0,20,1], [10,20,5], [20,20,5], [30,20,1]],
|
|
191
|
+
[[0,30,0], [10,30,2], [20,30,2], [30,30,0]],
|
|
192
|
+
];
|
|
193
|
+
const surface = nurbsSurface(grid, { thickness: 2 });
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
nurbsSurface(controlGrid: Vec3[][], options?: NurbsSurfaceOptions): Shape
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**`NurbsSurfaceOptions`**
|
|
201
|
+
|
|
202
|
+
| Option | Type | Description |
|
|
203
|
+
|--------|------|-------------|
|
|
204
|
+
| `degreeU?` | `number` | Degree in U direction (default 3). |
|
|
205
|
+
| `degreeV?` | `number` | Degree in V direction (default 3). |
|
|
206
|
+
| `weights?` | `number[][]` | Weights grid — same dimensions as controlGrid (default: all 1.0). |
|
|
207
|
+
| `knotsU?` | `number[]` | Knot vector in U direction (default: uniform clamped). |
|
|
208
|
+
| `knotsV?` | `number[]` | Knot vector in V direction (default: uniform clamped). |
|
|
209
|
+
| `thickness?` | `number` | Sheet thickness — if > 0, thickens the surface into a solid (default 0 = surface only). |
|
|
210
|
+
| `resolution?` | `number` | Tessellation resolution — points per direction (default 32). |
|
|
211
|
+
|
|
146
212
|
#### `surfacePatch()` — Create a smooth surface patch from 4 boundary curves (Coons patch).
|
|
147
213
|
|
|
148
214
|
The four curves form the boundary of a quadrilateral patch:
|
|
@@ -317,6 +383,91 @@ tangentAt(t: number): Vec3
|
|
|
317
383
|
length(samples?: number): number
|
|
318
384
|
```
|
|
319
385
|
|
|
386
|
+
### `NurbsCurve3D`
|
|
387
|
+
|
|
388
|
+
**Properties:**
|
|
389
|
+
|
|
390
|
+
| Property | Type | Description |
|
|
391
|
+
|----------|------|-------------|
|
|
392
|
+
| `controlPoints` | `Vec3[]` | — |
|
|
393
|
+
| `weights` | `number[]` | — |
|
|
394
|
+
| `knots` | `number[]` | — |
|
|
395
|
+
| `degree` | `number` | — |
|
|
396
|
+
| `closed` | `boolean` | — |
|
|
397
|
+
|
|
398
|
+
**Methods:**
|
|
399
|
+
|
|
400
|
+
#### `pointAt()` — Evaluate the curve at parameter t ∈ [0, 1]. Uses De Boor's algorithm — exact, O(degree²).
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
pointAt(t: number): Vec3
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### `tangentAt()` — Evaluate the unit tangent vector at parameter t ∈ [0, 1].
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
tangentAt(t: number): Vec3
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### `sample()` — Sample the curve uniformly at `count` points.
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
sample(count?: number): Vec3[]
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
#### `sampleAdaptive()` — Sample with adaptive density — more points in high-curvature regions.
|
|
419
|
+
|
|
420
|
+
```ts
|
|
421
|
+
sampleAdaptive(minCount?: number, maxCount?: number): Vec3[]
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
#### `length()` — Approximate arc length by summing polyline segment lengths.
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
length(samples?: number): number
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
#### `toPolyline()` — Convert to a format compatible with sweep() path input.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
toPolyline(samples?: number): Vec3[]
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### `NurbsSurface`
|
|
437
|
+
|
|
438
|
+
**Properties:**
|
|
439
|
+
|
|
440
|
+
| Property | Type | Description |
|
|
441
|
+
|----------|------|-------------|
|
|
442
|
+
| `controlGrid` | `Vec3[][]` | — |
|
|
443
|
+
| `weightsGrid` | `number[][]` | — |
|
|
444
|
+
| `knotsU` | `number[]` | — |
|
|
445
|
+
| `knotsV` | `number[]` | — |
|
|
446
|
+
| `degreeU` | `number` | — |
|
|
447
|
+
| `degreeV` | `number` | — |
|
|
448
|
+
| `nU` | `number` | — |
|
|
449
|
+
| `nV` | `number` | — |
|
|
450
|
+
|
|
451
|
+
**Methods:**
|
|
452
|
+
|
|
453
|
+
#### `pointAt()` — Evaluate the surface at parameters (u, v) ∈ [0, 1]². Uses tensor product evaluation: evaluate basis functions in U and V independently.
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
pointAt(u: number, v: number): Vec3
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### `normalAt()` — Evaluate the surface normal at (u, v) via cross product of partial derivatives.
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
normalAt(u: number, v: number): Vec3
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
#### `tessellate()` — Tessellate the surface into a triangle mesh. Returns positions, normals, and triangle indices.
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
tessellate(resU?: number, resV?: number): { positions: Vec3[]; normals: Vec3[]; indices: number[]; }
|
|
469
|
+
```
|
|
470
|
+
|
|
320
471
|
### `PathBuilder`
|
|
321
472
|
|
|
322
473
|
**Line Segments**
|
|
@@ -532,6 +683,22 @@ tangentBezierTo(cp2x: number, cp2y: number, x: number, y: number, weight?: numbe
|
|
|
532
683
|
smoothThrough(waypoints: [ number, number ][], tension?: number): this
|
|
533
684
|
```
|
|
534
685
|
|
|
686
|
+
#### `nurbsTo()` — Rational B-spline edge to (x, y) with explicit control points and weights.
|
|
687
|
+
|
|
688
|
+
The control points define the B-spline shape between the current position and (x, y). The current position is NOT included in `controlPoints` — it is automatically prepended. The endpoint (x, y) is the last control point.
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
nurbsTo(controlPoints: [ number, number ][], opts?: { weights?: number[]; degree?: number; }): this
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
#### `exactArcTo()` — Exact circular arc to (x, y) using a rational quadratic NURBS.
|
|
695
|
+
|
|
696
|
+
Unlike `arcTo()` which tessellates to a polyline, this preserves the exact arc definition. When extruded through the OCCT backend, it produces a true cylindrical face — not a faceted approximation.
|
|
697
|
+
|
|
698
|
+
```ts
|
|
699
|
+
exactArcTo(x: number, y: number, opts?: { radius?: number; clockwise?: boolean; }): this
|
|
700
|
+
```
|
|
701
|
+
|
|
535
702
|
#### [`fillet()`](/docs/core#fillet) — Round the last corner (the junction between the previous two segments) with a tangent arc of the given radius.
|
|
536
703
|
|
|
537
704
|
Must be called after at least two line/arc segments that form a corner. The fillet trims back both segments and inserts a tangent arc.
|
|
@@ -17,13 +17,14 @@ Pre-built fasteners, gears, pipes, structural profiles, and utility shapes. Acce
|
|
|
17
17
|
|
|
18
18
|
### `lib`
|
|
19
19
|
|
|
20
|
-
Pre-built parametric parts available in user scripts as `lib.*`. **Details** Every key in this object becomes a method on the `lib` namespace exposed to `.forge.js` scripts. The catalog includes: **Fasteners:** `bolt`, `nut`, `washer`, `fastenerSet`, `fastenerHole`, `boltHole`, `counterbore`, `hexNut`, `holePattern` **Structure:** `tube`, `pipe`, `bracket`, `pipeRoute`, `elbow`, `tSlotProfile`, `tSlotExtrusion`, `profile2020BSlot6Profile`, `profile2020BSlot6` **Threads:** `thread` **Gears:** `spurGear`, `bevelGear`, `faceGear`, `sideGear`, `ringGear`, `rackGear`, `gearPair`, `bevelGearPair`, `faceGearPair`, `sideGearPair` **Utilities:** `explode` Extend this by adding new entries here and registering the corresponding runner binding in `runner.ts`. Sizes outside the supported ranges will throw at runtime with a descriptive error.
|
|
20
|
+
Pre-built parametric parts available in user scripts as `lib.*`. **Details** Every key in this object becomes a method on the `lib` namespace exposed to `.forge.js` scripts. The catalog includes: **Fasteners:** `bolt`, `nut`, `washer`, `fastenerSet`, `fastenerHole`, `boltHole`, `counterbore`, `hexNut`, `holePattern` **Structure:** `tube`, `pipe`, `bracket`, `pipeRoute`, `elbow`, `tSlotProfile`, `tSlotExtrusion`, `profile2020BSlot6Profile`, `profile2020BSlot6` **Threads:** `thread` **Gears:** `spurGear`, `bevelGear`, `faceGear`, `sideGear`, `ringGear`, `rackGear`, `gearPair`, `bevelGearPair`, `faceGearPair`, `sideGearPair` **Gear ratios (pure math helpers):** `gearRatio`, `rackRatio`, `planetaryRatio` **Bolt patterns:** `boltPattern` — define hole positions once, cut them from multiple parts **Utilities:** `explode` Extend this by adding new entries here and registering the corresponding runner binding in `runner.ts`. Sizes outside the supported ranges will throw at runtime with a descriptive error.
|
|
21
21
|
|
|
22
22
|
- `boltHole(diameter: number, depth: number): Shape` — Simple cylindrical through-hole cutter centered on Z=0. Subtract the result from a part to produce a plain cylindrical clearance hole. For ISO metric sizes with fit classes and counterbore/countersink, use {
|
|
23
23
|
- `fastenerHole(opts: FastenerHoleOptions): Shape` — ISO metric fastener hole cutter with optional counterbore or countersink. **Details** Returns a cutter shape (subtract from a solid to produce the hole). Sizes outside M2–M10 will throw. Extend `METRIC_HOLE_TABLE` in this file to add new sizes. **Example** ```ts const plate = box(60, 40, 8, true) .subtract(lib.fastenerHole({ size: 'M5', fit: 'normal', depth: 8 }) .translate(15, 10, 4)); ```
|
|
24
24
|
- `counterbore(holeDia: number, boreDia: number, boreDepth: number, totalDepth: number): Shape` — Counterbore hole cutter — through-hole with a wider cylindrical recess at the top. Use for socket-head cap screws that must sit flush. Subtract from a solid. For ISO metric sizing and fit classes, prefer {
|
|
25
25
|
- `tube(outerX: number, outerY: number, outerZ: number, wall: number): Shape` — Rectangular hollow tube (thin-wall box section). Both the outer and inner boxes are centered on the XY plane with their base at Z=0.
|
|
26
26
|
- `pipe(height: number, outerRadius: number, wall: number, segments?: number): Shape` — Hollow cylindrical pipe. Centered on the XY plane, extending upward along +Z from z=0 to z=height. For complex routed pipe geometry, see `lib.pipeRoute`.
|
|
27
|
+
- `explode<T extends ExplodeItem[] | ShapeGroup>(items: T, options?: ExplodeOptions): T` — Apply deterministic exploded-view offsets to an assembly tree. **Details** Traverses arrays of shapes/sketches/named items, nested `{ name, group: [...] }` structures, and [`ShapeGroup`](/docs/core#shapegroup) outputs, translating each node by a computed offset while preserving names, colors, and nesting. Returns the same structure type as the input. In `radial` mode the algorithm is branch-aware and parent-relative: each node fans out from its immediate parent's center, so nested assemblies peel apart level by level. Named items may also include an inline `explode: { stage?, direction?, axisLock? }` property to override per-item behavior. Use this function when you want to bake the explode offset into the geometry before returning (e.g. to drive the amount with a `param()` slider). For a viewport-only explode slider without rerunning the script, use [`explodeView()`](/docs/viewport#explodeview) instead. **Example** ```js const explodeAmt = param('Explode', 0, { min: 0, max: 40, unit: 'mm' }); return lib.explode(assembly, { amount: explodeAmt, stages: [0.4, 0.8], mode: 'radial', byName: { Shaft: { direction: [1, 0, 0], stage: 1.4 } }, }); ```
|
|
27
28
|
- `hexNut(acrossFlats: number, height: number, holeDia: number): Shape` — Generic hex nut with a cylindrical bore. Constructed via intersection of three rotated rectangular slabs, then a bore is subtracted. Centered at origin, height along Z. For standard ISO metric nuts by thread size, use `lib.nut` instead.
|
|
28
29
|
- `bracket(width: number, height: number, depth: number, thick: number, holeDia?: number): Shape` — L-shaped mounting bracket with optional through-holes. Produces a right-angle bracket: a horizontal base plate and a vertical wall. Both legs share `width`. Optional holes are drilled through the base (along Z) and the wall (along Y).
|
|
29
30
|
- `holePattern(rows: number, cols: number, spacingX: number, spacingY: number, holeDia: number, depth: number): Shape` — Rectangular grid of cylindrical hole cutters. Returns the union of `rows × cols` cylinders laid out on a regular grid. Subtract from a solid to produce the full pattern. **Example** ```ts const pattern = lib.holePattern(3, 4, 20, 20, 4, 10); const panel = box(80, 70, 10, true).subtract(pattern.translate(-30, -30, 5)); ```
|
|
@@ -38,13 +39,17 @@ Pre-built parametric parts available in user scripts as `lib.*`. **Details** Eve
|
|
|
38
39
|
- `tSlotExtrusion(length: number, options?: TSlotExtrusionOptions): Shape` — Build a T-slot extrusion from the generated 2D profile. Extrudes along +Z by default.
|
|
39
40
|
- `profile2020BSlot6Profile(options?: Profile2020BSlot6ProfileOptions): Sketch` — Accurate-ish 2D profile for 20x20 B-type slot 6. Returns a drawing-ready Sketch centered at origin.
|
|
40
41
|
- `profile2020BSlot6(length: number, options?: Profile2020BSlot6Options): Shape` — 20x20 B-type slot 6 extrusion with profile-accurate defaults. Pass option overrides if your supplier's profile differs slightly.
|
|
41
|
-
- `spurGear(options: SpurGearOptions): Shape` — Involute external spur gear with optional center bore. Specify module, teeth, faceWidth as required parameters. Optional tuning includes pressureAngleDeg (default 20), backlash, clearance, addendum, dedendum, boreDiameter, and segmentsPerTooth (default 10).
|
|
42
|
-
- `bevelGear(options: BevelGearOptions): Shape` — Conical bevel gear generated from a tapered involute extrusion. Specify pitchAngleDeg directly or derive it from mateTeeth + shaftAngleDeg.
|
|
42
|
+
- `spurGear(options: SpurGearOptions): Shape` — Involute external spur gear with optional center bore. Specify module, teeth, faceWidth as required parameters. Optional tuning includes pressureAngleDeg (default 20), backlash, clearance, addendum, dedendum, boreDiameter, and segmentsPerTooth (default 10). **Connectors (for assembly-based positioning):** - `bore`: revolute connector at the bore center, axis along +Z. Carries measurements: `{ module, teeth, pitchRadius, outerRadius, faceWidth }`. Use `.connect("Housing.seat", "Gear.bore")` to mount a gear on a shaft seat.
|
|
43
|
+
- `bevelGear(options: BevelGearOptions): Shape` — Conical bevel gear generated from a tapered involute extrusion. Specify pitchAngleDeg directly or derive it from mateTeeth + shaftAngleDeg. **Connectors (for assembly-based positioning):** - `bore`: revolute connector at the large-end bore center (Z=0), axis along -Z (away from teeth). - `apex`: connector at the cone apex above the gear (the point where the pitch cone converges), axis along +Z. Useful for meshing two bevel gears — their apices should coincide. Carries measurements: `{ module, teeth, pitchRadius, pitchAngleDeg, coneDistance, faceWidth }`.
|
|
43
44
|
- `faceGear(options: FaceGearOptions): Shape` — Face gear (crown style) where teeth are on one face (top or bottom) instead of the outer rim. Uses the same involute tooth sizing as spurGear, then projects the tooth band axially from one side. Alias for sideGear (which is kept for backward compatibility).
|
|
44
45
|
- `sideGear(options: SideGearOptions): Shape` — Crown/face style gear where the teeth project from one side of the disk instead of the outer cylindrical rim.
|
|
45
|
-
- `ringGear(options: RingGearOptions): Shape` — Internal ring gear with involute-derived tooth spaces. Specify rimWidth or outerDiameter for the annular body.
|
|
46
|
-
- `rackGear(options: RackGearOptions): Shape` — Linear rack gear with pressure-angle flanks. Use with spurGear for rack-and-pinion mechanisms.
|
|
46
|
+
- `ringGear(options: RingGearOptions): Shape` — Internal ring gear with involute-derived tooth spaces. Specify rimWidth or outerDiameter for the annular body. **Connectors (for assembly-based positioning):** - `bore`: connector at the ring center, axis along +Z. For planetary gearboxes, this is where the ring mounts to the housing. Carries measurements: `{ module, teeth, pitchRadius, innerRadius, outerRadius, faceWidth }`.
|
|
47
|
+
- `rackGear(options: RackGearOptions): Shape` — Linear rack gear with pressure-angle flanks. Use with spurGear for rack-and-pinion mechanisms. **Orientation:** teeth run along the X axis with tooth tips pointing +Y (pitch line at Y=0). The rack is extruded +Z by `faceWidth`. Rotate the rack to align with a different slide axis. **Connectors (for assembly-based positioning):** - `teeth`: prismatic connector at the pitch line center, axis along +X (slide direction). Carries measurements: `{ module, teeth, faceWidth, length }`. Connect to a housing's rack channel: ```js housing.withConnectors({ rack_channel: connector("rack-channel", { origin: [pitchR, 0, channelZ], axis: [1, 0, 0], kind: "prismatic", }), }); assembly.connect("Housing.rack_channel", "Rack.teeth", { as: "slide" }); ```
|
|
47
48
|
- `gearPair(options: GearPairOptions): GearPairResult` — Build or validate a spur-gear pair and return ratio, backlash, and mesh diagnostics. Accepts either shapes from spurGear() or analytical specs for each member. When place is true (default), the gear is auto-positioned at the correct center distance.
|
|
48
49
|
- `bevelGearPair(options: BevelGearPairOptions): BevelGearPairResult` — Build or validate a bevel-gear pair and return ratio diagnostics plus recommended joint placement vectors.
|
|
49
50
|
- `faceGearPair(options: FaceGearPairOptions): FaceGearPairResult` — Build or validate a perpendicular pair between a face gear and a vertical spur gear.
|
|
50
51
|
- `sideGearPair(options: SideGearPairOptions): SideGearPairResult` — Pair helper for side (crown/face) gear + perpendicular "vertical" spur gear. Auto-placement rotates the spur around +Y and positions it to mesh at the side tooth band.
|
|
52
|
+
- `gearRatio(teethA: number, teethB: number, options?: { internal?: boolean; }): number` — Coupling ratio between two meshed spur gears. When gear A turns 1°, gear B turns `-teethA / teethB` degrees (negative because meshed external gears rotate in opposite directions). ```js assembly.addJointCoupling("B_spin", { terms: [{ joint: "A_spin", ratio: lib.gearRatio(12, 24) }], // -0.5 }); ``` Pass `{ internal: true }` for internal gear pairs (ring gear + spur/planet), where the two rotate in the same direction.
|
|
53
|
+
- `rackRatio(module: number, pinionTeeth: number): number` — Coupling ratio between a pinion and a rack. When the pinion rotates by `θ` degrees, the rack slides by `θ × (π × module × teeth / 360)` mm. Equivalently, 1mm of rack travel = `180 / (π × pitchRadius)` degrees of pinion rotation. ```js // Pinion spin driven by rack slide: assembly.addJointCoupling("pinion_spin", { terms: [{ joint: "rack_slide", ratio: lib.rackRatio(1.5, 12) }], // ~6.37 deg/mm }); ```
|
|
54
|
+
- `planetaryRatio(sunTeeth: number, ringTeeth: number): number` — Planetary gear reduction ratio when the ring is held fixed. Input: sun. Output: carrier. Ratio: `1 + ringTeeth / sunTeeth`. One turn of the sun produces `1 / ratio` turns of the carrier.
|
|
55
|
+
- `boltPattern(options: BoltPatternOptions): BoltPattern` — Define a bolt pattern once and cut it from multiple parts. ```js const bolts = lib.boltPattern({ size: 'M5', positions: [[20, 15], [-20, 15], [20, -15], [-20, -15]], }); const base = bolts.cut(box(60, 50, 10), 12, { from: -1 }); const cover = bolts.cut(box(60, 50, 3), 5, { from: -1 }); // Same positions in both parts — guaranteed aligned. ```
|
|
@@ -20,7 +20,7 @@ Dimensions, BOM entries, verification checks, and sketch export.
|
|
|
20
20
|
|
|
21
21
|
BOM entries are accumulated during script execution and exported alongside the model in report views. Rows are grouped by normalized `description + unit`. Pass an explicit `key` to force multiple descriptions to collapse into a single line item.
|
|
22
22
|
|
|
23
|
-
- `quantity` must be a finite number `>= 0`. A quantity of `0` is silently ignored (useful for conditional scripting with
|
|
23
|
+
- `quantity` must be a finite number `>= 0`. A quantity of `0` is silently ignored (useful for conditional scripting with `param()`-driven counts).
|
|
24
24
|
- `unit` defaults to `"pieces"` when omitted or empty.
|
|
25
25
|
- The assembly `solved.bom()` / `solved.bomCsv()` API is separate and covers per-part assembly metadata; this function is for free-form purchased-item annotation.
|
|
26
26
|
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
---
|
|
2
|
+
skill-group: sdf
|
|
3
|
+
skill-order: 100
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SDF Modeling (Experimental)
|
|
7
|
+
|
|
8
|
+
Signed Distance Field modeling for organic forms, smooth booleans, TPMS lattices, and deformations. Access via `sdf.*`. Experimental — slower render times and lower mesh quality than B-rep.
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
|
|
12
|
+
- [SdfShape](#sdfshape)
|
|
13
|
+
- [sdf](#sdf)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Classes
|
|
18
|
+
|
|
19
|
+
### `SdfShape`
|
|
20
|
+
|
|
21
|
+
An immutable SDF expression. Supports SDF-specific operations (smooth booleans, domain warps, etc.) and converts to a ForgeCAD Shape via `.toShape()`.
|
|
22
|
+
|
|
23
|
+
#### `toShape()` — Mesh this SDF into a ForgeCAD Shape via Manifold.levelSet(). Once converted, the result is a regular Shape — booleans, transforms, export all work.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
toShape(options?: SdfToShapeOptions): Shape
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### [`union()`](/docs/core#union) — SDF union (sharp).
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
union(...others: SdfShape[]): SdfShape
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### `subtract()` — SDF difference (sharp) — subtracts others from this.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
subtract(...others: SdfShape[]): SdfShape
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### `intersect()` — SDF intersection (sharp).
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
intersect(...others: SdfShape[]): SdfShape
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### `smoothUnion()` — Smooth union — blends shapes together with a smooth radius.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
smoothUnion(other: SdfShape, radius: number): SdfShape
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### `smoothSubtract()` — Smooth difference — smoothly carves other from this.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
smoothSubtract(other: SdfShape, radius: number): SdfShape
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### `smoothIntersect()` — Smooth intersection — smoothly intersects.
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
smoothIntersect(other: SdfShape, radius: number): SdfShape
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### `morph()` — Morph between this shape and another. t=0 → this, t=1 → other.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
morph(other: SdfShape, t: number): SdfShape
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### `translate()`
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
translate(x: number, y: number, z: number): SdfShape
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `rotate()` — Rotate around an arbitrary axis through the origin.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
rotate(axis: [ number, number, number ], angleDeg: number): SdfShape
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### `rotateX()` — Rotate around the X axis by the given angle in degrees.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
rotateX(angleDeg: number): SdfShape
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### `rotateY()` — Rotate around the Y axis by the given angle in degrees.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
rotateY(angleDeg: number): SdfShape
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### `rotateZ()` — Rotate around the Z axis by the given angle in degrees.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
rotateZ(angleDeg: number): SdfShape
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### `scale()`
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
scale(factor: number): SdfShape
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### `twist()` — Twist around the Z axis.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
twist(degreesPerUnit: number): SdfShape
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### `bend()` — Bend around the Z axis with given radius.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
bend(radius: number): SdfShape
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### `repeat()` — Repeat in space. Spacing of 0 on an axis means no repetition. Count of 0 = infinite.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
repeat(spacing: Vec3, count?: Vec3): SdfShape
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### `shell()` — Hollow out, keeping only a shell of given thickness.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
shell(thickness: number): SdfShape
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### `displace()` — Displace the surface by a function of position, or by a pattern SdfShape.
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
// Function displacement
|
|
135
|
+
shape.displace((x, y, z) => Math.sin(x) * 0.5)
|
|
136
|
+
|
|
137
|
+
// Pattern displacement (e.g. basketWeave)
|
|
138
|
+
shape.displace(sdf.basketWeave({ threads: 16, spacing: 3 }))
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
displace(fn: ((x: number, y: number, z: number) => number) | SdfShape, constants?: Record<string, number>): SdfShape
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `surfaceDisplace()` — Displace the surface using a 2D pattern in surface-local UV coordinates.
|
|
146
|
+
|
|
147
|
+
Automatically detects the shape's UV parametrization (sphere, cylinder, torus) from the SDF tree. Falls back to triplanar mapping for arbitrary shapes.
|
|
148
|
+
|
|
149
|
+
UV coordinates are in **surface millimeters** — patterns defined with `spacing: 3` always produce 3mm spacing, regardless of shape size.
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// Surface-following basket weave — auto-detects sphere UV
|
|
153
|
+
sdf.sphere(27).shell(3)
|
|
154
|
+
.surfaceDisplace(sdf.basketWeave({ spacing: 3, depth: 0.8 }))
|
|
155
|
+
.toShape()
|
|
156
|
+
|
|
157
|
+
// Custom 2D pattern via function
|
|
158
|
+
shape.surfaceDisplace((u, v) => -Math.sin(u * 2) * 0.3)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
surfaceDisplace(pattern: SurfacePattern | ((u: number, v: number) => number), options?: SurfaceDisplaceOptions): SdfShape
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### `onion()` — Create concentric onion layers.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
onion(layers: number, thickness: number): SdfShape
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Constants
|
|
174
|
+
|
|
175
|
+
### `sdf`
|
|
176
|
+
|
|
177
|
+
SDF modeling — signed distance field primitives, smooth booleans, TPMS lattices, domain warps, and surface patterns. **Experimental.** Slower render times and lower mesh quality than B-rep. Use for organic forms, smooth blending, or TPMS lattices where these trade-offs are acceptable. For mechanical parts, prefer B-rep. All shapes live as a lazy expression tree until `.toShape()` is called, which meshes them via `Manifold.levelSet()` and returns a regular Shape. ```js const shape = sdf.smoothUnion(sdf.sphere(10), sdf.box(15, 15, 15), { radius: 3 }) .toShape({ edgeLength: 0.5 }) .color('#4488cc'); ```
|
|
178
|
+
|
|
179
|
+
- `sphere(radius: number): SdfShape` — Create an SDF sphere centered at the origin.
|
|
180
|
+
- `box(x: number, y: number, z: number): SdfShape` — Create an SDF box centered at the origin with given full dimensions (not half-extents).
|
|
181
|
+
- `cylinder(height: number, radius: number): SdfShape` — Create an SDF cylinder centered at the origin, axis along Z.
|
|
182
|
+
- `torus(majorRadius: number, minorRadius: number): SdfShape` — Create an SDF torus centered at the origin, lying in the XY plane.
|
|
183
|
+
- `capsule(height: number, radius: number): SdfShape` — Create an SDF capsule centered at the origin, axis along Z.
|
|
184
|
+
- `cone(height: number, radius: number): SdfShape` — Create an SDF cone with base at z=0 and tip at z=height.
|
|
185
|
+
- `smoothUnion(a: SdfShape, b: SdfShape, options: { radius: number; }): SdfShape` — Smooth union — blends shapes together with a smooth transition radius.
|
|
186
|
+
- `smoothDifference(a: SdfShape, b: SdfShape, options: { radius: number; }): SdfShape` — Smooth difference — smoothly subtracts b from a.
|
|
187
|
+
- `smoothIntersection(a: SdfShape, b: SdfShape, options: { radius: number; }): SdfShape` — Smooth intersection — smoothly intersects a and b.
|
|
188
|
+
- `morph(a: SdfShape, b: SdfShape, t: number): SdfShape` — Morph between two SDF shapes. t=0 → a, t=1 → b.
|
|
189
|
+
- `blend(a: SdfShape, b: SdfShape, fn: (x: number, y: number, z: number) => number, options?: BlendOptions): SdfShape` — Spatially blend between two SDF patterns. The blend function receives (x, y, z) and returns 0..1: 0 = fully pattern `a`, 1 = fully pattern `b`.
|
|
190
|
+
- `gyroid(options: TpmsOptions): SdfShape` — Gyroid TPMS lattice — the most common lattice for additive manufacturing.
|
|
191
|
+
- `schwarzP(options: TpmsOptions): SdfShape` — Schwarz-P TPMS lattice — isotropic pore structure.
|
|
192
|
+
- `diamond(options: TpmsOptions): SdfShape` — Diamond TPMS lattice — stiffest TPMS structure.
|
|
193
|
+
- `lidinoid(options: TpmsOptions): SdfShape` — Lidinoid TPMS lattice — visually distinct from gyroid, popular in research and art.
|
|
194
|
+
- `noise(options?: NoiseOptions): SdfShape` — 3D Simplex noise field — produces organic, natural-looking displacements.
|
|
195
|
+
- `voronoi(options?: VoronoiOptions): SdfShape` — 3D Voronoi pattern — organic cellular structures like bone, coral, or soap bubbles.
|
|
196
|
+
- `honeycomb(options?: HoneycombOptions): SdfShape` — Honeycomb (hexagonal) lattice pattern. Intersect with your shape to apply.
|
|
197
|
+
- `waves(options?: WavesOptions): SdfShape` — Sinusoidal wave ridges — parallel ridges along an axis.
|
|
198
|
+
- `knurl(options?: KnurlOptions): SdfShape` — Knurl pattern — crossed helical grooves for grips and handles.
|
|
199
|
+
- `perforated(options?: PerforatedOptions): SdfShape` — Perforated plate pattern — regular array of cylindrical holes.
|
|
200
|
+
- `scales(options?: ScalesOptions): SdfShape` — Fish/dragon scale pattern — overlapping circular scales in hex-packed rows.
|
|
201
|
+
- `brick(options?: BrickOptions): SdfShape` — Brick/stone wall pattern — running bond with mortar grooves.
|
|
202
|
+
- `weave(options?: WeaveOptions): SdfShape` — Grid lattice pattern — two families of infinite slabs crossing at 90°.
|
|
203
|
+
- `basketWeave(options?: BasketWeaveOptions): SurfacePattern` — Basket weave surface pattern — threads with over-under crossings in UV space. Returns a SurfacePattern for use with `.surfaceDisplace()`.
|
|
204
|
+
- `twist(shape: SdfShape, degreesPerUnit: number): SdfShape` — Twist an SDF shape around the Z axis.
|
|
205
|
+
- `bend(shape: SdfShape, radius: number): SdfShape` — Bend an SDF shape around the Z axis.
|
|
206
|
+
- `repeat(shape: SdfShape, spacing: Vec3, count?: Vec3): SdfShape` — Repeat an SDF shape in space.
|
|
207
|
+
- `SurfacePattern: typeof SurfacePattern` — A 2D surface pattern — a heightmap function for use with `.surfaceDisplace()`.
|
|
208
|
+
- `fromFunction(fn: (x: number, y: number, z: number) => number, bounds: { min: Vec3; max: Vec3; }, constants?: Record<string, number>): SdfShape` — Create an SDF shape from an arbitrary distance function. You must provide bounds since the function is opaque.
|