circuit-json-to-gltf 0.0.146 → 0.0.147

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 +23 -1
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -16308,9 +16308,31 @@ function getBoundingBoxCenter(bounds) {
16308
16308
 
16309
16309
  // lib/loaders/cable.ts
16310
16310
  function loadCable(cable) {
16311
+ const pin1Side = (position, end) => {
16312
+ if (!position || cable.path.length < 2) return void 0;
16313
+ const tip = end === "from" ? cable.path[0] : cable.path.at(-1);
16314
+ const next = end === "from" ? cable.path[1] : cable.path.at(-2);
16315
+ const axis = vec3.normalize(vec3.create(), [
16316
+ next.x - tip.x,
16317
+ next.y - tip.y,
16318
+ next.z - tip.z
16319
+ ]);
16320
+ const side = vec3.fromValues(
16321
+ position.x - tip.x,
16322
+ position.y - tip.y,
16323
+ position.z - tip.z
16324
+ );
16325
+ vec3.scaleAndAdd(side, side, axis, -vec3.dot(side, axis));
16326
+ if (vec3.length(side) < 1e-6) return void 0;
16327
+ vec3.normalize(side, side);
16328
+ return [side[0], side[1], side[2]];
16329
+ };
16311
16330
  const meshes = createCableMeshes({
16312
16331
  definition: parseCableString(cable.cableprinter_string),
16313
- path: cable.path.map(({ x, y, z: z3 }) => [x, y, z3])
16332
+ path: cable.path.map(({ x, y, z: z3 }) => [x, y, z3]),
16333
+ // Orient in circuit Z-up before the paired mesh transform to scene Y-up.
16334
+ startPin1Side: pin1Side(cable.from_connector_pin1_position, "from"),
16335
+ endPin1Side: pin1Side(cable.to_connector_pin1_position, "to")
16314
16336
  });
16315
16337
  return meshes.map((mesh) => {
16316
16338
  const circuitTriangles = [];
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.146",
5
+ "version": "0.0.147",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/tscircuit/circuit-json-to-gltf.git"
@@ -25,7 +25,7 @@
25
25
  "@tscircuit/cableprinter": "^0.0.4",
26
26
  "earcut": "^3.0.2",
27
27
  "gl-matrix": "^3.4.4",
28
- "jscad-electronics": "^0.0.187",
28
+ "jscad-electronics": "^0.0.193",
29
29
  "jscad-planner": "^0.0.19",
30
30
  "jscad-to-gltf": "^0.0.5",
31
31
  "occt-import-js": "^0.0.23"
@@ -47,7 +47,7 @@
47
47
  "@types/react-dom": "^19.1.7",
48
48
  "@vitejs/plugin-react": "^5.0.0",
49
49
  "bun-match-svg": "^0.0.12",
50
- "circuit-json": "^0.0.516",
50
+ "circuit-json": "^0.0.519",
51
51
  "circuit-to-svg": "^0.0.429",
52
52
  "graphics-debug": "^0.0.96",
53
53
  "looks-same": "^9.0.1",
@@ -78,6 +78,6 @@
78
78
  },
79
79
  "overrides": {
80
80
  "@tscircuit/core": "^0.0.1955",
81
- "circuit-json": "^0.0.516"
81
+ "circuit-json": "^0.0.519"
82
82
  }
83
83
  }