Commandar Rick - hey @shibo using your work was...
hey @shibo using your work was able to get this far, currently working on fixing the texture issue

27 Replies
oooh beautiful
cool
yeah it looks like the texture from circuit-to-svg needs to be scaled down a bit to fit properly
I thought the panel introduced this issue, but looks like the texture didn't work properly at all and only know we were able to observe the issue
The core issue is that circuit-to-svg doesn't respect the actual millimeter coordinates from the circuit JSON when positioning boards in a panel.
Looking at the actual data:
The panel is 50mm × 40mm centered at (0, 0)
The 3 boards are each 10mm × 30mm positioned at x = -15mm, 0mm, and +15mm
The SVG output is 800px × 600px
At 16 pixels/mm (800px / 50mm), we'd expect the boards to appear at SVG x-coordinates of 160px, 400px, and 640px respectively
But when examining the actual SVG, the boards appear at:
Board 1: ~92px (should be 160px)
Board 2: ~392px (should be 400px)
Board 3: ~692px (should be 640px)
This means circuit-to-svg is evenly distributing the boards with padding across the canvas width instead of using their actual coordinate positions. So when we map UV coordinates based on the mesh's correct physical dimensions (-25mm to +25mm), those UVs (0.2, 0.5, 0.8 for the board centers) don't align with where circuit-to-svg actually drew the content (0.115, 0.49, 0.865 in the SVG). This causes the texture to be misaligned and stretched horizontally on the 3D model, making the boards appear in the wrong positions with incorrect spacing.
@shibo
this will have to be fixed in circuit-to-svg before we can start to work here in circuit-json-to-gltf
I noticed that too, try to reproduce in circuit-to-svg
cool btw this is what the svg we are getting


yes, create a test in circuit-to-svg by requesting different sizes for the same circuit and see if it scales correctly
i did and they all passed, it scales correctly at default, 0,5 and 2x



so the issue isnt in circit to svg rather how circuit-json-to-gltf handles the svg
correction the margin is 42.85, our UV mapping in circuit-json-to-gltf assumes the mesh spans the full SVG canvas (0 to 800px), but circuit-to-svg has margins, so content only spans approximately Content spans ~42.85px to ~757.15px (714.3px wide)
now there are two problems:
Problem 1: Single mesh for entire panel
Created ONE 50×40mm mesh for the entire panel
Applied the panel texture (showing 3 boards) to this single mesh
UV mapping stretched the texture across the full 50mm width
Result: Boards appeared at wrong positions because the mesh didn't match the texture layout
Problem 2: Incorrect UV offset calculation assumption
The margin calculation was actually correct (42.85px per side), but it was being applied to the wrong mesh structure.
now using three individual board instead of one single mesh

this is wrong right? the positioning of meshes seems correct tho
@shibo
Close
The plates holes are on the edge of the boards
yeah will need some work, but we want the outer panel as well right??
ofc
cool
working on that
hows this

how is this?
@shibo
there is a slight offset + the texture is stretched away from the outsides
a lot better though
so this just scales the texture down, was only able to get this to work nothing else seems to work, the uv mapping seems correct and the svg is also correctly scaling up in circuit-to-svg
is it possible that the texture is correct but the panel is the one that's not correctly sized?
very likely yes because scaling it down seems to work well maybe we just need to increase the panel dimensions
but the 3d models and cutouts align correctly inside the panel, so it's not likely
yeah but before the cutouts were also not allgining right? see this, this is the before

only change i made was scaling it down and it fit
actually, the whole gltf object may be scaled down incorrectly, yeah, you gotta do some debugging
the board is cut in the correct positions, I'm just saying the whole gltf is scaled down possibly
true thats also possible lemme do some debugging