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
No description
27 Replies
Ray Kholodovsky
oooh beautiful
shibo
shibo2w ago
cool
RaghavArora14
RaghavArora14OP2w ago
yeah it looks like the texture from circuit-to-svg needs to be scaled down a bit to fit properly
shibo
shibo2w ago
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
RaghavArora14
RaghavArora14OP2w ago
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
shibo
shibo2w ago
I noticed that too, try to reproduce in circuit-to-svg
RaghavArora14
RaghavArora14OP2w ago
cool btw this is what the svg we are getting
No description
No description
shibo
shibo2w ago
yes, create a test in circuit-to-svg by requesting different sizes for the same circuit and see if it scales correctly
RaghavArora14
RaghavArora14OP2w ago
i did and they all passed, it scales correctly at default, 0,5 and 2x
No description
No description
No description
RaghavArora14
RaghavArora14OP2w ago
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.
RaghavArora14
RaghavArora14OP2w ago
now using three individual board instead of one single mesh
No description
RaghavArora14
RaghavArora14OP2w ago
this is wrong right? the positioning of meshes seems correct tho @shibo
shibo
shibo2w ago
Close The plates holes are on the edge of the boards
RaghavArora14
RaghavArora14OP2w ago
yeah will need some work, but we want the outer panel as well right??
shibo
shibo2w ago
ofc
RaghavArora14
RaghavArora14OP2w ago
cool working on that hows this
RaghavArora14
RaghavArora14OP2w ago
No description
RaghavArora14
RaghavArora14OP2w ago
how is this? @shibo
shibo
shibo2w ago
there is a slight offset + the texture is stretched away from the outsides a lot better though
RaghavArora14
RaghavArora14OP2w ago
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
shibo
shibo2w ago
is it possible that the texture is correct but the panel is the one that's not correctly sized?
RaghavArora14
RaghavArora14OP2w ago
very likely yes because scaling it down seems to work well maybe we just need to increase the panel dimensions
shibo
shibo2w ago
but the 3d models and cutouts align correctly inside the panel, so it's not likely
RaghavArora14
RaghavArora14OP2w ago
yeah but before the cutouts were also not allgining right? see this, this is the before
No description
RaghavArora14
RaghavArora14OP2w ago
only change i made was scaling it down and it fit
shibo
shibo2w ago
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
RaghavArora14
RaghavArora14OP2w ago
true thats also possible lemme do some debugging

Did you find this page helpful?