Skip to content

feat(pcb): evaluate PcbBoard to a real centered FR4 solid in the live app#228

Open
ecto wants to merge 1 commit into
mainfrom
pcb-board-solid-rust-eval
Open

feat(pcb): evaluate PcbBoard to a real centered FR4 solid in the live app#228
ecto wants to merge 1 commit into
mainfrom
pcb-board-solid-rust-eval

Conversation

@ecto
Copy link
Copy Markdown
Owner

@ecto ecto commented Jun 3, 2026

What

Makes a PCB board a genuine FR4 solid in the live app path (Task 1 from the modeless-PCB follow-up), not just a data-only placeholder rendered by a workaround.

The merged foundation (#227) added PcbBoard evaluation to vcad-eval and the TS evaluator, but the CRDT materializer still emitted CsgOp::Empty for a board node — so the live app never reached that code, and boards only appeared via the PcbBoardBodies data-mesh workaround (and were invisible in STEP export / ray tracing).

Changes

  • crates/vcad-app/materializer.rs — emit a real PcbBoard op (mirroring the EmbroideryPattern case) so the kernel extrudes a genuine slab. doc.pcb is still set for the legacy getNodePcb fallback. (This is the change that actually activates the board solid in the app.)
  • Centering in vcad-eval/evaluate.rs, vcad-kernel-wasm evaluate_node (the requested VCode-path arm, with cutouts noted TODO), and TS engine/evaluate.ts — the kernel extrudes from z=0, so shift the slab down by thickness/2. The top surface now lands at +thickness/2, exactly where PcbScene draws the copper (layerZ = thickness/2 + …) and where the legacy PcbBoardMesh sat.
  • Reconcile the double-slab: ViewportContent renders <PcbScene showBoard={false} />, and PcbBoardBodies is gutted to only the doc.pcb-only legacy path. The kernel part is now the single source of the slab — no z-fighting/doubling, focused or not.
  • data/materials.ts — resolve the board's __pcb_fr4__ material key to FR4 green (#0d5a2d); previously unresolved → board rendered default white.
  • Testvcad-eval unit test asserting a board evaluates to a non-empty solid centered on z=0 (also covers export-non-empty).
  • Regenerated kernel WASM artifacts.

Verification

Built and run locally. Verified against the running app's actual Three.js scene + evaluated meshes:

  • ✅ Board evaluates to a real solid — evaluated mesh non-empty; unit test green.
  • ✅ Slab centered z ∈ [-0.8, 0.8] for a 1.6 mm board (was [0, 1.6]); matches the copper plane.
  • ✅ Board mesh renders FR4 green — read the live material color: rgb(0.051, 0.353, 0.176) = #0d5a2d.
  • Single board slab mesh in the scene (no z-fight) with PcbBoardBodies returning null for real PcbBoard nodes; the ghosted mechanical box stays at opacity 0.16.
  • cargo test --workspace, npm test --workspaces, npm run build -w @vcad/app, and cargo clippy/cargo fmt on the changed crates all pass.

Note: the only cargo clippy --workspace -- -D warnings failures are pre-existing needless_borrow lints in the untouched vcad-desktop crate (newer clippy 1.95.0); my crates are clean. Framed 3D screenshots were unreliable in the headless preview (on-demand frameloop + transparent canvas), so the board appearance was verified by reading the rendered Three.js material/geometry directly rather than by pixel capture.

🤖 Generated with Claude Code

… app

The merged board-solid work added PcbBoard evaluation to vcad-eval / the TS
evaluator, but the CRDT materializer still emitted `CsgOp::Empty` for a board
node, so the live app never reached it — boards rendered only via the
`PcbBoardBodies` data-mesh workaround.

- materializer: emit a real `PcbBoard` op (mirroring EmbroideryPattern) so the
  kernel extrudes a genuine slab; keep `doc.pcb` for the legacy fallback.
- vcad-eval, vcad-kernel-wasm `evaluate_node`, and TS `evaluate.ts`: center the
  extruded slab on z=0 so its top lands at +thickness/2, where PcbScene draws
  the copper (layerZ) and where the legacy PcbBoardMesh sat.
- ViewportContent: `PcbScene showBoard={false}` and gut `PcbBoardBodies` to the
  doc.pcb-only legacy path, so the kernel part is the single slab (no z-fight).
- materials: resolve the board's `__pcb_fr4__` key to FR4 green (#0d5a2d).
- add a vcad-eval test asserting a board evaluates to a non-empty, centered solid.

Regenerated kernel WASM artifacts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated (UTC)
mecheval Ignored Ignored Jun 3, 2026 9:06pm
vcad Ignored Ignored Jun 3, 2026 9:06pm
vcad-docs Ignored Ignored Jun 3, 2026 9:06pm
vcad-mcp Ignored Ignored Jun 3, 2026 9:06pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant