fix: honor board solder_mask_color in the 3D render (#957) - #959
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@imrishabh18 @rushabhcodes — either of you able to review this? Fixes #957. The 3D viewer hard-coded the FR4 green solder mask in two independent paths, so a board built with 6 files, +139/-3. CI green and mergeable against |
rushabhcodes
left a comment
There was a problem hiding this comment.
can you share the render with different colors
16941a0 to
76d6e75
Compare
|
Here are the renders — same board, only Board face colour actually emitted in the SVG for each:
On Two things worth pointing out from generating these:
Generated by setting |
|
@rushabhcodes any way that this could land? |

Fixes #957.
Problem
The 3D viewer hard-coded the FR4 green solder mask, so a board built with
solderMaskColor="black"still rendered green even though the Circuit JSON carriedsolder_mask_colorcorrectly. This made the 3D preview misleading for any board that isn't green.Two independent code paths had the same hard-coding:
soldermask-drawing.ts— the textured mask layer derived its palette frommaterialonly.convert-circuit-json-to-3d-svg.ts— literallyconst solderMaskColor = colors.fr4SolderMaskGreen.Change
solderMaskColorPresetscovering the documented presets (green,red,blue,purple,black,white,yellow). Each preset is a pair of[mask over bare substrate, mask over copper], since solder mask is translucent and copper underneath lifts the coating — that's what keeps traces readable through the mask.resolveSolderMaskPresethelper so both render paths agree instead of duplicating the lookup.boardData.solder_mask_colorthroughcreateSoldermaskTextureForLayer→drawSoldermaskLayer, and applied it in the SVG path too.Backwards compatibility
Boards with no color, an empty string, or
not_specifiedresolve toundefinedand keep the existing material-derived default (FR4 green / FR1), so nothing changes for current boards. Unrecognized values fall back rather than throwing.Verification
bunx tsc --noEmit— cleanbun run format:check— cleanbun test tests/solder-mask-color.test.ts— 6 pass / 0 failNote:
bun testhas 3 pre-existing failures onmain(2 faux-board z-offset tests + the Atari outline SVG test). I confirmed they fail identically on the unmodified checkout, so they're untouched by this change.