circuit-json-to-gltf 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14592,7 +14592,6 @@ async function convertSvgToCanvasBrowser(svgString, resolution, backgroundColor)
|
|
|
14592
14592
|
});
|
|
14593
14593
|
}
|
|
14594
14594
|
async function renderBoardTextures(circuitJson, resolution = 1024) {
|
|
14595
|
-
console.log("Generating PCB texture...");
|
|
14596
14595
|
const [top, bottom] = await Promise.all([
|
|
14597
14596
|
renderBoardLayer(circuitJson, {
|
|
14598
14597
|
layer: "top",
|
|
@@ -14607,10 +14606,6 @@ async function renderBoardTextures(circuitJson, resolution = 1024) {
|
|
|
14607
14606
|
// Darker green for bottom layer
|
|
14608
14607
|
})
|
|
14609
14608
|
]);
|
|
14610
|
-
console.log("PCB texture generated:", {
|
|
14611
|
-
topLength: top.length,
|
|
14612
|
-
bottomLength: bottom.length
|
|
14613
|
-
});
|
|
14614
14609
|
return { top, bottom };
|
|
14615
14610
|
}
|
|
14616
14611
|
|
|
@@ -14715,11 +14710,53 @@ var createHoleGeoms = (boardCenter, thickness, holes = [], platedHoles = []) =>
|
|
|
14715
14710
|
const holeGeoms = [];
|
|
14716
14711
|
for (const hole of holes) {
|
|
14717
14712
|
const holeRecord = hole;
|
|
14713
|
+
const relX = hole.x - boardCenter.x;
|
|
14714
|
+
const relY = -(hole.y - boardCenter.y);
|
|
14715
|
+
const holeShape = holeRecord.hole_shape;
|
|
14716
|
+
if (holeShape === "pill") {
|
|
14717
|
+
const holeWidth = getNumberProperty(holeRecord, "hole_width");
|
|
14718
|
+
const holeHeight = getNumberProperty(holeRecord, "hole_height");
|
|
14719
|
+
if (!holeWidth || !holeHeight) continue;
|
|
14720
|
+
const rotate = holeHeight > holeWidth;
|
|
14721
|
+
const width = rotate ? holeHeight : holeWidth;
|
|
14722
|
+
const height = rotate ? holeWidth : holeHeight;
|
|
14723
|
+
const pillHole = createPillHole(
|
|
14724
|
+
relX,
|
|
14725
|
+
relY,
|
|
14726
|
+
width,
|
|
14727
|
+
height,
|
|
14728
|
+
thickness,
|
|
14729
|
+
rotate
|
|
14730
|
+
);
|
|
14731
|
+
holeGeoms.push(pillHole);
|
|
14732
|
+
continue;
|
|
14733
|
+
}
|
|
14734
|
+
if (holeShape === "rotated_pill") {
|
|
14735
|
+
const holeWidth = getNumberProperty(holeRecord, "hole_width");
|
|
14736
|
+
const holeHeight = getNumberProperty(holeRecord, "hole_height");
|
|
14737
|
+
if (!holeWidth || !holeHeight) continue;
|
|
14738
|
+
const rotation = getNumberProperty(holeRecord, "ccw_rotation") ?? 0;
|
|
14739
|
+
const rotationRad = -(rotation * Math.PI) / 180;
|
|
14740
|
+
const minDimension = Math.min(holeWidth, holeHeight);
|
|
14741
|
+
const maxAllowedRadius = Math.max(0, minDimension / 2 - RADIUS_EPSILON);
|
|
14742
|
+
const roundRadius = maxAllowedRadius <= 0 ? 0 : Math.min(holeHeight / 2, maxAllowedRadius);
|
|
14743
|
+
const hole2d = (0, import_primitives.roundedRectangle)({
|
|
14744
|
+
size: [holeWidth, holeHeight],
|
|
14745
|
+
roundRadius,
|
|
14746
|
+
segments: DEFAULT_SEGMENTS
|
|
14747
|
+
});
|
|
14748
|
+
let hole3d = (0, import_extrusions.extrudeLinear)({ height: thickness + 1 }, hole2d);
|
|
14749
|
+
hole3d = (0, import_transforms.translate)([0, 0, -(thickness + 1) / 2], hole3d);
|
|
14750
|
+
if (rotationRad !== 0) {
|
|
14751
|
+
hole3d = (0, import_transforms.rotateZ)(rotationRad, hole3d);
|
|
14752
|
+
}
|
|
14753
|
+
hole3d = (0, import_transforms.translate)([relX, relY, 0], hole3d);
|
|
14754
|
+
holeGeoms.push(hole3d);
|
|
14755
|
+
continue;
|
|
14756
|
+
}
|
|
14718
14757
|
const diameter = getNumberProperty(holeRecord, "hole_diameter") ?? getNumberProperty(holeRecord, "diameter");
|
|
14719
14758
|
if (!diameter) continue;
|
|
14720
14759
|
const radius = diameter / 2;
|
|
14721
|
-
const relX = hole.x - boardCenter.x;
|
|
14722
|
-
const relY = -(hole.y - boardCenter.y);
|
|
14723
14760
|
holeGeoms.push(createCircularHole(relX, relY, radius, thickness));
|
|
14724
14761
|
}
|
|
14725
14762
|
for (const plated of platedHoles) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "circuit-json-to-gltf",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.27",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "bun test tests/",
|
|
8
8
|
"format": "biome format --write .",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@vitejs/plugin-react": "^5.0.0",
|
|
32
32
|
"bun-match-svg": "^0.0.12",
|
|
33
33
|
"circuit-json": "^0.0.278",
|
|
34
|
-
"circuit-to-svg": "^0.0.
|
|
34
|
+
"circuit-to-svg": "^0.0.240",
|
|
35
35
|
"graphics-debug": "^0.0.65",
|
|
36
36
|
"looks-same": "^9.0.1",
|
|
37
37
|
"poppygl": "^0.0.16",
|