partforge 0.6.1 → 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.
Files changed (50) hide show
  1. package/README.md +61 -15
  2. package/bin/cli.js +82 -58
  3. package/docs/AUTHORING-PARTS.md +98 -26
  4. package/package.json +1 -1
  5. package/src/app-faceted-vase.js +10 -0
  6. package/src/faceted-vase-worker.js +3 -0
  7. package/src/framework/app.css +26 -0
  8. package/src/framework/assembly.js +6 -9
  9. package/src/framework/download.js +23 -0
  10. package/src/framework/geometry/feature-attribution.js +102 -0
  11. package/src/framework/geometry/helix-tube.js +10 -20
  12. package/src/framework/geometry/kernel-front.js +37 -0
  13. package/src/framework/geometry/kernel.js +56 -10
  14. package/src/framework/geometry/loft.js +79 -0
  15. package/src/framework/geometry/manifold-backend.js +67 -25
  16. package/src/framework/geometry/mesh-build.js +53 -0
  17. package/src/framework/geometry/occt-backend.js +117 -106
  18. package/src/framework/geometry/occt-repair.js +83 -0
  19. package/src/framework/geometry/polygon.js +89 -0
  20. package/src/framework/geometry/probe.js +37 -30
  21. package/src/framework/geometry/profile.js +96 -0
  22. package/src/framework/geometry/solid-sugar.js +32 -5
  23. package/src/framework/geometry/sweep.js +151 -0
  24. package/src/framework/geometry-service.js +4 -6
  25. package/src/framework/jobs.js +40 -18
  26. package/src/framework/mesh-cache.js +41 -0
  27. package/src/framework/mount.js +103 -240
  28. package/src/framework/param-deps.js +9 -18
  29. package/src/framework/pick-request/server.js +10 -0
  30. package/src/framework/regen-loop.js +45 -0
  31. package/src/framework/selection/format.js +2 -6
  32. package/src/framework/selection/hover.js +128 -0
  33. package/src/framework/selection/index.js +3 -0
  34. package/src/framework/selection/pick-toggle.js +34 -0
  35. package/src/framework/selection/pick.js +7 -30
  36. package/src/framework/selection/raycast.js +43 -0
  37. package/src/framework/selection/resolve.js +3 -8
  38. package/src/framework/status-ui.js +18 -0
  39. package/src/framework/view-state.js +11 -1
  40. package/src/framework/view-tabs.js +33 -0
  41. package/src/framework/viewer-controls.js +48 -0
  42. package/src/framework/viewer.js +9 -9
  43. package/src/framework/worker.js +12 -20
  44. package/src/parts/faceted-vase.js +75 -0
  45. package/src/parts/filleted-box.js +1 -1
  46. package/src/parts/planter.js +4 -3
  47. package/src/testing/build.js +3 -6
  48. package/src/testing/manifold.js +11 -0
  49. package/src/testing.js +1 -0
  50. package/src/framework/geometry/fuzzy-cut.js +0 -32
@@ -1,4 +1,4 @@
1
- import { viewSubParts } from "../framework/jobs.js";
1
+ import { viewSubParts, resolveParams, buildPosed } from "../framework/jobs.js";
2
2
 
3
3
  // Build every sub-part of a view in its display (assembly) pose with the given
4
4
  // Manifold kernel, returning live solids + copied-out meshes. Mirrors the
@@ -6,12 +6,9 @@ import { viewSubParts } from "../framework/jobs.js";
6
6
  // kernel.cleanup()) so callers can read exact solid facts (volume/genus/empty)
7
7
  // before they free the kernel. Meshes are JS-owned arrays and survive cleanup.
8
8
  export function buildView(kernel, part, view, params = {}) {
9
- const p = { ...part.defaults, ...params };
10
- const d = part.derive ? part.derive(p) : {};
9
+ const { p, d } = resolveParams(part, params);
11
10
  return viewSubParts(part, view, p).map((name) => {
12
- const sp = part.parts[name];
13
- let solid = sp.build(kernel, p, d);
14
- if (sp.place) solid = sp.place(solid, { view, purpose: "display", p, d });
11
+ const solid = buildPosed(kernel, part, name, { purpose: "display", view, p, d });
15
12
  return { name, solid, mesh: solid.toMesh() };
16
13
  });
17
14
  }
@@ -0,0 +1,11 @@
1
+ // Boots the Manifold WASM module in a Node process and returns a ready Manifold
2
+ // GeometryKernel — the one-call mirror of bootOcctKernel. (OCCT must NOT be booted
3
+ // in the same process — they crash together.)
4
+ import Module from "manifold-3d";
5
+ import { createManifoldKernel } from "../framework/geometry/manifold-backend.js";
6
+
7
+ export async function bootManifoldKernel({ quality = "preview" } = {}) {
8
+ const wasm = await Module();
9
+ wasm.setup();
10
+ return createManifoldKernel(wasm, { quality });
11
+ }
package/src/testing.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // job loop, the assembly collision check, an OCCT kernel, and mesh measures).
3
3
  // See docs/AUTHORING-PARTS.md "Testing a part".
4
4
  export { createManifoldKernel } from "./framework/geometry/manifold-backend.js";
5
+ export { bootManifoldKernel } from "./testing/manifold.js";
5
6
  export { handle, viewSubParts } from "./framework/jobs.js";
6
7
  export { assemblyOverlaps } from "./framework/assembly.js";
7
8
  export { bootOcctKernel } from "./testing/occt.js";
@@ -1,32 +0,0 @@
1
- // Fuzzy boolean cut via the raw OpenCASCADE kernel.
2
- //
3
- // replicad's high-level Shape3D.cut() runs BRepAlgoAPI_Cut with the default
4
- // (zero) fuzzy tolerance, which returns an EMPTY result for large near-tangent
5
- // helical groove tools (fine up to a few turns, empty by ~10). OCCT's fuzzy
6
- // boolean snaps near-coincident geometry within a tolerance and makes the
7
- // operation robust — this is how the full multi-turn drum gets cut.
8
- //
9
- // Mirrors replicad's own cut() (BRepAlgoAPI_Cut_3 + Build + SimplifyResult +
10
- // cast) and just adds SetFuzzyValue before Build.
11
-
12
- import { getOC, cast } from "replicad";
13
-
14
- export function fuzzyCut(base, tool, { fuzz = 1e-3, simplify = false } = {}) {
15
- const oc = getOC();
16
- const progress = new oc.Message_ProgressRange_1();
17
- const cutter = new oc.BRepAlgoAPI_Cut_3(base.wrapped, tool.wrapped, progress);
18
- cutter.SetFuzzyValue(fuzz);
19
- cutter.Build(progress);
20
- if (cutter.HasErrors && cutter.HasErrors()) {
21
- cutter.delete();
22
- progress.delete();
23
- throw new Error(`fuzzy cut failed (OCCT BOP error, fuzz=${fuzz})`);
24
- }
25
- // SimplifyResult merges coplanar faces but is very slow on helical results —
26
- // off by default; the mesh/STEP are fine without it.
27
- if (simplify) cutter.SimplifyResult(true, true, 1e-3);
28
- const result = cast(cutter.Shape());
29
- cutter.delete();
30
- progress.delete();
31
- return result;
32
- }