Skip to content

feat: Add PCB texture support using circuit-to-svg and resvg-wasm#633

Open
SiddhantOfficial wants to merge 5 commits intotscircuit:mainfrom
SiddhantOfficial:fix/issue-534-pcb-texture
Open

feat: Add PCB texture support using circuit-to-svg and resvg-wasm#633
SiddhantOfficial wants to merge 5 commits intotscircuit:mainfrom
SiddhantOfficial:fix/issue-534-pcb-texture

Conversation

@SiddhantOfficial
Copy link
Copy Markdown

Summary

Implements PCB texture rendering using circuit-to-svg and resvg-wasm as specified in issue #534.

Changes

  • New Dependencies:

    • circuit-to-svg (^0.0.108) - Generates SVG from circuit JSON
    • @resvg/resvg-wasm (^2.6.2) - High-fidelity SVG to PNG conversion
  • New Files:

    • src/utils/svg-texture-utils.ts - Core utilities for SVG to PNG texture conversion
    • src/hooks/usePcbSvgTexture.ts - React hook for managing PCB texture generation
    • stories/PcbTexture.stories.tsx - Storybook demos
  • Modified Files:

    • src/hooks/index.ts - Added export for new hook
    • package.json - Added new dependencies

Technical Implementation

  1. Uses circuit-to-svg to convert circuit JSON to SVG format
  2. Initializes resvg-wasm for WASM-based PNG rendering
  3. Converts SVG to PNG data URL for Three.js texture loading
  4. Provides React hook for async texture management with cleanup

Testing

  • Added Storybook stories demonstrating basic and complex PCB textures
  • Run npm run storybook to view the examples

Fixes #534

- Add svg-texture-utils.ts for SVG to PNG texture conversion
- Add usePcbSvgTexture hook for React integration  
- Use circuit-to-svg to render circuit JSON as SVG
- Use @resvg/resvg-wasm for high-quality PNG conversion

Closes tscircuit#534
- Add circuit-to-svg and @resvg/resvg-wasm dependencies
- Add PcbTexture.stories.tsx with basic and complex examples
- Demonstrates SVG to PNG texture conversion for PCB rendering
@vercel
Copy link
Copy Markdown

vercel bot commented Dec 23, 2025

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

Project Deployment Review Updated (UTC)
3d-viewer Ready Ready Preview, Comment Dec 24, 2025 0:34am

Copy link
Copy Markdown
Contributor

@rushabhcodes rushabhcodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your type checks are failing!

@rushabhcodes
Copy link
Copy Markdown
Contributor

Hey @SiddhantOfficial, please don’t be discouraged by this but we no longer support bounties, but we do have a sponsorship though.

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.

Texture Support (PCB should have texture on box)

2 participants