Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

kernelcad-fields

/kernelcad-fields

Tworzy pola odległości ze znakiem (SDF): kule, pudełka, walce, torusy, gładkie łączenia i materializację, do organicznych kształtów, do których nie sięga fillet BREP.

Repozytorium
kernelcad-web ↗
Licencja
MIT
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Tworzy pola odległości ze znakiem (SDF): kule, pudełka, walce, torusy, gładkie łączenia i materializację, do organicznych kształtów, do których nie sięga fillet BREP.

Oryginalny opis (EN)

Signed-distance fields — sdf.sphere/.box/.cylinder/.torus, sdf.smoothBlend, sdf.materialize. Use for smooth-blended primitives and organic shapes that BREP fillet cannot reach; result is a standard Shape.

Jak działa

  1. sdf primitive math (mm; centred at origin in local frame)
  2. Composition rules (slice 1)
  3. Resulting Shape limitations
  4. MCP introspection
  5. SDF diagnostic codes
  6. Memory + perf (measured, slice 1)
  7. Verification gates
  8. Related skills
Sekcje z nagłówków SKILL.md, w oryginale · 101 linii, 858 słów
Podgląd SKILL.md
---
name: kernelcad-fields
description: Signed-distance fields — sdf.sphere/.box/.cylinder/.torus, sdf.smoothBlend, sdf.materialize. Use for smooth-blended primitives and organic shapes that BREP fillet cannot reach; result is a standard Shape.
---

# kernelCAD — signed-distance fields

Compose signed-distance fields (`sdf.sphere/.box/.cylinder/.torus`), blend them smoothly with `sdf.smoothBlend`, then call `sdf.materialize(field, { resolution })` to obtain a standard `Shape` that flows through booleans / fillets / exports.

```ts
const a = sdf.box([60, 40, 6]);          // base plate, axis-aligned, centred at origin
const b = sdf.cylinder(8, 30);           // pin, axis +Z, centred at origin
const field = sdf.smoothBlend(a, b, 3);  // 3 mm smooth fillet at the junction
return sdf.materialize(field, { resolution: 30 });
```

## `sdf` primitive math (mm; centred at origin in local frame)

| Field | Returns |
|---|---|
| `sdf.sphere(r)` | `SdfField` (kind `'sphere'`) |
| `sdf.box([sx, sy, sz])` | `SdfField` (kind `'box'`, axis-aligned, centred) |
| `sdf.cylinder(r, h)` | `SdfField` (kind `'cylinder'`, axis +Z, centred) |
| `sdf.torus(R, r)` | `SdfField` (kind `'torus'`, ring axis +Z, centred) |
| `sdf.smoothBlend(a, b, k)` | `SdfField` (kind `'smoothBlend'`, polynomial smin with blend radius k mm) |
| `sdf.materialize(field, { resolution? })` | `Shape` (kind `sdfMaterialize`; default resolution 30, clamped to [10, 200]) |
| `sdf.bind(name, field)` | binds a field on the session so `evaluate_sdf` can sample it later (side effect; returns void) |

## Composition rules (slice 1)

- **`field.translate(dx, dy, dz)` positions a field before materialize.**
  Primitives live in their local frame; `.translate(...)` returns a new
  `SdfField` offset by `(dx, dy, dz)` mm with the `aabb` shifted to match,
  so the marching-cubes sample region follows. Chained translates compose
  additively. After `sdf.materialize` the result is a `Shape`, not an
  `SdfField` — use the Shape's own `.translate(...)`.
- **`smoothBlend` is union-only.** Smooth-intersect / smooth-difference
  are deferred to slice 2+.
- **`materialize` is synchronous.** It runs marching-cubes on the host
  (Node + browser) and sews in the same call. No async surface.

## Resulting `Shape` limitations

- The output is **polyhedral** — thousands of triangular planar faces, not
  analytic surfaces. Canonical face refs (`'top'`, `'bottom'`, ...) do
  not apply (sphere / box face semantics are lost at materialize).
- `fillet({ face: 'top' })`-style canonical face calls return
  `feature.face-ref.not-applicable`; use inline FaceQuery / EdgeQuery if
  edge-feature scoping is needed.
- Downstream `fillet` / `chamfer` on materialized SDF edges is supported
  in principle but quality is poor and OOM risk is real at high
  resolution; surface as `feature.kernel-failed`.
- Booleans (`union` / `subtract` / `intersect`) **do** work — standard
  Booleans run on the polyhedral solid.

## MCP introspection

- `evaluate_sdf({ file? | code?, fieldName, point: [x, y, z] })` — sample the signed distance from a `sdf.bind('<name>', field)`-bound `SdfField` at a 3D point; returns `{ ok, distance, inside, aabb, kind }`. Side-effect-free; use to verify SDF composition before calling the expensive `sdf.materialize`.

## SDF diagnostic codes

- `feature.sdf.field-undefined` (error) — the SDF returned NaN/Infinity
  at a sample point, or the named `sdf.bind` binding wasn't found by
  `evaluate_sdf`. Causes: `smoothBlend(_, _, 0)` (k must be positive),
  divide-by-zero in a custom field, or a missing/typo'd binding name.
  Use `evaluate_sdf` to probe a point near the failure.
- `feature.sdf.materialize-resolution-out-of-range` (error) —
  `opts.resolution` must be an integer in `[10, 200]`. Use 20-30 for
  typical brackets; 40-60 for fine smooth-blends; 200 is the cap
  (200³ = 8M voxels).

## Memory + perf (measured, slice 1)

Surface-nets emits ~2 triangles per voxel on the surface, then the kernel sews
each triangle as an individual planar face. Sewing
dominates runtime and scales with triangle count (≈ resolution²·surface).
Default resolution 30 is the slice-1 sweet spot: agents can bump it for
fine surface quality at the cost of seconds-to-minutes more capture time.

- `sdf.sphere(2)` res=30 — ~750 tris, ~3 s.
- `sdf.sphere(10)` res=30 — ~7500 tris, ~20 s.
- `sdf.sphere(10)` res=50 — ~22000 tris, ~170 s (long, but still completes).
- `sdf.sphere(10)` res=100 — ~80000 tris, several minutes (use with care).

## Verification gates

After authoring an SDF-rooted Shape, run before reporting done:

| Gate | Pass criterion |
|------|----------------|
| G-eval | `kernelcad evaluate` exits 0 — no `feature.sdf.*` diagnostics |
| G-sdf-finite | `evaluate_sdf` at the AABB centre and three corner samples returns a finite `distance` (no NaN / Infinity) |
| G-smooth-blend-k-positive | Every `sdf.smoothBlend(_, _, k)` has `k > 0` — `k === 0` emits `feature.sdf.field-undefined` |
| G-materialize-resolution-in-range | `resolution` is an integer in `[10, 200]`. Default 30; bump to 40-60 for fine blends; reserve 100+ for hero captures |
| G-no-canonical-face-ref | Materialized output is polyhedral — do not use canonical face refs (`'top'`, `'bottom'`) on a materialize result; use inline queries instead |
| G-translate-after-materialize | Position the `SdfField` with `.translate(dx, dy, dz)` before `sdf.materialize`; once materialized the result is a `Shape`, not an `SdfField`, so only transform it with the Shape's own methods |
| G-bind-name-typo | If using `evaluate_sdf`, the `fieldName` passed in matches a `sdf.bind('<name>', field)` call in the script; mismatch emits `feature.sdf.field-undefined` |

## Related skills

- `kernelcad-authoring` — `sdf.materialize(...)` returns a standard `Shape`; chain `.translate`, `.rotate`, `.union`, `.subtract`, etc. as normal.
- `kernelcad-features` — fillet / chamfer on a materialized result may emit `feature.kernel-failed`; check before relying on it.
- `kernelcad-nurbs` — for freeform curved analytic surfaces, prefer NURBS; SDF is for smooth-blended primitives and organic shapes.
- `kernelcad-mcp` — `evaluate_sdf` is the cheap probe before the expensive `materialize`.

Wersje

W bazie nie ma innych skilli o nazwie kernelcad-fields.

Migawka bazy z 13.11.2026 · wersja paczki 03ed72149125 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100shader-sdf
    Tworzy funkcje odległości ze znakiem (SDF) w GLSL: prymitywy 2D i 3D, operacje boolowskie, gładkie łączenie, powtarzanie i podstawy raymarchingu, do kształtów proceduralnych i scen 3D.
  • 100shaders-and-sdf
    Wyjaśnia matematykę shaderów: pola odległości, szum i refrakcję oraz jak uzyskać podobny efekt w Roblox bez własnych shaderów.
  • 100verify
    Odczytuje raport brep dla części .brep.ts, ocenia zrzuty i prowadzi naprawę najmniejszej odpowiedzialnej sekcji.
  • 90kernelcad-design-loop
    Buduje i poprawia model CAD przez serwer kernelCAD: pisze kod .kcad.ts, ocenia go i sprawdza pętlą projektową.
  • 100implement
    Pomaga pisać i edytować części brepjs .brep.ts w funkcyjnym API: geometria, blok expected, reguły importu, a także budynki, BIM i IFC przez warstwę rodzin.
  • 100sdf
    Wspiera tworzenie i walidację modeli oraz światów SDFormat (.sdf) i przekazanie ich do symulatora, w tym linki, przeguby, sensory, fizykę i Gazebo.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.