circuit-json-to-gltf 0.0.43 → 0.0.45

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.
Files changed (2) hide show
  1. package/dist/index.js +4 -63
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14785,10 +14785,6 @@ var import_booleans = __toESM(require_booleans(), 1);
14785
14785
  var geom3 = __toESM(require_geom3(), 1);
14786
14786
  var import_measureBoundingBox = __toESM(require_measureBoundingBox2(), 1);
14787
14787
  var RADIUS_EPSILON = 1e-4;
14788
- var toVec2 = (point, center) => [
14789
- point.x - center.x,
14790
- point.y - center.y
14791
- ];
14792
14788
  var getNumberProperty = (obj, key) => {
14793
14789
  const value = obj[key];
14794
14790
  return typeof value === "number" ? value : void 0;
@@ -14796,7 +14792,10 @@ var getNumberProperty = (obj, key) => {
14796
14792
  var createBoardOutlineGeom = (board, center, thickness) => {
14797
14793
  const outline = "outline" in board ? board.outline : void 0;
14798
14794
  if (outline && outline.length >= 3) {
14799
- let outlinePoints = outline.map((pt) => toVec2(pt, center));
14795
+ let outlinePoints = outline.map((pt) => [
14796
+ pt.x - center.x,
14797
+ -(pt.y - center.y)
14798
+ ]);
14800
14799
  if (arePointsClockwise(outlinePoints)) {
14801
14800
  outlinePoints = outlinePoints.slice().reverse();
14802
14801
  }
@@ -15004,7 +15003,6 @@ var geom33 = __toESM(require_geom3(), 1);
15004
15003
  var import_measureBoundingBox3 = __toESM(require_measureBoundingBox2(), 1);
15005
15004
  var DEFAULT_BOARD_THICKNESS = 1.6;
15006
15005
  var DEFAULT_COMPONENT_HEIGHT = 2;
15007
- var COPPER_THICKNESS = 0.035;
15008
15006
  function convertRotationFromCadRotation(rot) {
15009
15007
  return {
15010
15008
  x: rot.x * Math.PI / 180,
@@ -15117,63 +15115,6 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
15117
15115
  }
15118
15116
  boxes.push(boardBox);
15119
15117
  }
15120
- const pcbPours = db.pcb_copper_pour?.list?.() ?? [];
15121
- for (const pour of pcbPours) {
15122
- const isBottomLayer = pour.layer === "bottom";
15123
- const y = isBottomLayer ? -(effectiveBoardThickness / 2) - COPPER_THICKNESS / 2 : effectiveBoardThickness / 2 + COPPER_THICKNESS / 2;
15124
- if (pour.shape === "rect") {
15125
- const box = {
15126
- center: {
15127
- x: pour.center.x,
15128
- y,
15129
- z: pour.center.y
15130
- },
15131
- size: {
15132
- x: pour.width,
15133
- y: COPPER_THICKNESS,
15134
- z: pour.height
15135
- },
15136
- rotation: { x: 0, y: 0, z: 0 },
15137
- color: pour.covered_with_solder_mask ? pcbColor : copperColor
15138
- };
15139
- if (pour.rotation && typeof pour.rotation === "number") {
15140
- box.rotation.y = -(pour.rotation * Math.PI) / 180;
15141
- }
15142
- boxes.push(box);
15143
- } else if (pour.shape === "polygon") {
15144
- const { points } = pour;
15145
- let center_x = 0;
15146
- let center_y = 0;
15147
- for (const p of points) {
15148
- center_x += p.x;
15149
- center_y += p.y;
15150
- }
15151
- center_x /= points.length;
15152
- center_y /= points.length;
15153
- const relativePoints = points.map((p) => [
15154
- p.x - center_x,
15155
- -(p.y - center_y)
15156
- ]);
15157
- if (arePointsClockwise(relativePoints)) {
15158
- relativePoints.reverse();
15159
- }
15160
- const shape2d = (0, import_primitives3.polygon)({ points: relativePoints });
15161
- let geom = (0, import_extrusions3.extrudeLinear)({ height: COPPER_THICKNESS }, shape2d);
15162
- geom = (0, import_transforms4.translate)([0, 0, -COPPER_THICKNESS / 2], geom);
15163
- geom = (0, import_transforms4.rotateX)(-Math.PI / 2, geom);
15164
- const triangles = geom3ToTriangles(geom);
15165
- const bbox = createBoundingBox((0, import_measureBoundingBox3.default)(geom));
15166
- const mesh = { triangles, boundingBox: bbox };
15167
- const box = {
15168
- center: { x: center_x, y, z: center_y },
15169
- size: { x: 1, y: 1, z: 1 },
15170
- // size doesn't matter much as we provide mesh
15171
- mesh,
15172
- color: pour.covered_with_solder_mask ? pcbColor : copperColor
15173
- };
15174
- boxes.push(box);
15175
- }
15176
- }
15177
15118
  const cadComponents = db.cad_component?.list?.() ?? [];
15178
15119
  const pcbComponentIdsWith3D = /* @__PURE__ */ new Set();
15179
15120
  for (const cad of cadComponents) {
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.43",
5
+ "version": "0.0.45",
6
6
  "scripts": {
7
7
  "test": "bun test tests/",
8
8
  "format": "biome format --write .",