/claim #534

Summary

Implements high-fidelity PCB texture rendering using circuit-to-svg and resvg-wasm as specified in issue #534. This allows the 3D viewer to display intricate traces, pads, and silkscreen details directly on the board geometry.

Changes Made

Dependencies Added

  • circuit-to-svg (^0.0.108) - Converts circuit JSON to SVG format
  • @resvg/resvg-wasm (^2.6.2) - High-fidelity SVG to PNG conversion

New Files Created

  • src/utils/pcb-texture-generator.ts: Core utility with singleton WASM initialization and memory cleanup.
  • src/hooks/use-pcb-texture.ts: React hook for managing texture lifecycles and Three.js disposal.
  • stories/pcb-texture.stories.tsx: Dedicated Storybook demo for visual verification.

Modified Files

  • src/hooks/index.ts: Added export for usePcbTexture.
  • src/utils/create-board-material.ts: Updated to support map (texture) and color neutralization.
  • src/utils/manifold/create-three-geometry-meshes.ts: Updated to pass pcbTexture to the material creator.
  • src/CadViewerManifold.tsx: Integrated the hook into the main rendering pipeline.

Technical Highlights

  • WASM Safety: Uses a promise-based singleton pattern to prevent race conditions during initialization.
  • Memory Management: Explicitly revokes Blob URLs and disposes of Three.js textures on unmount to prevent GPU memory leaks.
  • Visual Accuracy: Automatically switches board color to white when a texture is present to ensure accurate color reproduction of traces and silkscreen.

Checks Status

  • Type Check: bunx tsc --noEmit passed.
  • Format Check: All modified files formatted with Biome. (Note: Pre-existing errors in unrelated repo files persist).
  • Build: bun run build successful.

Screenshots

Screenshot 2026-01-16 163211

Fixes #534

Claim

Total prize pool $150
Total paid $0
Status Pending
Submitted January 16, 2026
Last updated January 16, 2026

Contributors

KE

Kesavaraja M

@Kesavaraja67

100%

Sponsors

TS

tscircuit

@tscircuit

$150