circuit-json-to-gltf 0.0.164 → 0.0.166

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/README.md CHANGED
@@ -162,6 +162,7 @@ silkscreen colors. Explicit conversion options take precedence.
162
162
  ## Architecture
163
163
 
164
164
  The converter uses a modular architecture:
165
+
165
166
  1. **Circuit to 3D Converter**: Parses circuit JSON and creates a 3D scene representation
166
167
  2. **Board Renderer**: Renders PCB layers as textures using circuit-to-svg and resvg
167
168
  3. **Model Loaders**: Load STL and OBJ files for component 3D models
package/dist/index.d.ts CHANGED
@@ -78,6 +78,7 @@ interface ConversionOptions {
78
78
  showBoundingBoxes?: boolean;
79
79
  coordinateTransform?: CoordinateTransformConfig;
80
80
  projectBaseUrl?: string;
81
+ resolveStaticAsset?: CircuitTo3DOptions["resolveStaticAsset"];
81
82
  authHeaders?: AuthHeaders;
82
83
  }
83
84
  interface CoordinateTransformConfig {
@@ -253,6 +254,8 @@ interface CircuitTo3DOptions {
253
254
  showReferenceSurfaces?: boolean;
254
255
  showBoundingBoxes?: boolean;
255
256
  projectBaseUrl?: string;
257
+ /** Resolve the selected CAD model URL before loading it. */
258
+ resolveStaticAsset?: (modelUrl: string) => string;
256
259
  authHeaders?: AuthHeaders;
257
260
  }
258
261
  interface BoardRenderOptions {
@@ -342,7 +345,7 @@ interface CadComponentMesh {
342
345
  positions: number[];
343
346
  indices: number[];
344
347
  }
345
- type CadComponentMeshOptions = Pick<CircuitTo3DOptions, "coordinateTransform" | "projectBaseUrl" | "authHeaders"> & {
348
+ type CadComponentMeshOptions = Pick<CircuitTo3DOptions, "coordinateTransform" | "projectBaseUrl" | "resolveStaticAsset" | "authHeaders"> & {
346
349
  pcbComponent?: PcbComponent;
347
350
  };
348
351
  /** Load the actual CAD model at its supplied position and rotation, using the
package/dist/index.js CHANGED
@@ -17331,6 +17331,7 @@ async function loadCadComponentBox(cad, options = {}) {
17331
17331
  showBoundingBoxes = false,
17332
17332
  coordinateTransform,
17333
17333
  projectBaseUrl,
17334
+ resolveStaticAsset = (url) => url,
17334
17335
  authHeaders
17335
17336
  } = options;
17336
17337
  const {
@@ -17423,14 +17424,14 @@ async function loadCadComponentBox(cad, options = {}) {
17423
17424
  });
17424
17425
  if (model_stl_url) {
17425
17426
  box.mesh = await loadSTL({
17426
- url: model_stl_url,
17427
+ url: resolveStaticAsset(model_stl_url),
17427
17428
  transform: defaultTransform,
17428
17429
  projectBaseUrl,
17429
17430
  authHeaders
17430
17431
  });
17431
17432
  } else if (model_obj_url) {
17432
17433
  box.mesh = await loadOBJ({
17433
- url: model_obj_url,
17434
+ url: resolveStaticAsset(model_obj_url),
17434
17435
  transform: defaultTransform,
17435
17436
  projectBaseUrl,
17436
17437
  authHeaders
@@ -17438,7 +17439,7 @@ async function loadCadComponentBox(cad, options = {}) {
17438
17439
  } else if (model_glb_url) {
17439
17440
  try {
17440
17441
  box.mesh = await loadGLB({
17441
- url: model_glb_url,
17442
+ url: resolveStaticAsset(model_glb_url),
17442
17443
  transform: defaultTransform,
17443
17444
  projectBaseUrl,
17444
17445
  authHeaders
@@ -17448,7 +17449,7 @@ async function loadCadComponentBox(cad, options = {}) {
17448
17449
  }
17449
17450
  } else if (model_gltf_url) {
17450
17451
  box.mesh = await loadGLTF({
17451
- url: model_gltf_url,
17452
+ url: resolveStaticAsset(model_gltf_url),
17452
17453
  transform: defaultTransform,
17453
17454
  projectBaseUrl,
17454
17455
  authHeaders
@@ -17456,7 +17457,7 @@ async function loadCadComponentBox(cad, options = {}) {
17456
17457
  } else if (model_step_url) {
17457
17458
  try {
17458
17459
  box.mesh = await loadSTEP({
17459
- url: model_step_url,
17460
+ url: resolveStaticAsset(model_step_url),
17460
17461
  transform: defaultTransform,
17461
17462
  projectBaseUrl,
17462
17463
  authHeaders
@@ -19047,6 +19048,7 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
19047
19048
  coordinateTransform,
19048
19049
  showBoundingBoxes = false,
19049
19050
  projectBaseUrl,
19051
+ resolveStaticAsset,
19050
19052
  authHeaders
19051
19053
  } = options;
19052
19054
  const foldPcbs = options.foldPcbs ?? inputCircuitJson.some(
@@ -19342,6 +19344,7 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
19342
19344
  showBoundingBoxes,
19343
19345
  coordinateTransform,
19344
19346
  projectBaseUrl,
19347
+ resolveStaticAsset,
19345
19348
  authHeaders,
19346
19349
  // Preserve the fold renderer's existing flat bottom-layer convention.
19347
19350
  defaultCadRotation: bends.length && pcbComponent ? {
@@ -20967,6 +20970,7 @@ async function convertCircuitJsonToGltf(circuitJson, options = {}) {
20967
20970
  showBoundingBoxes,
20968
20971
  showReferenceSurfaces: options.showReferenceSurfaces,
20969
20972
  projectBaseUrl: options.projectBaseUrl,
20973
+ resolveStaticAsset: options.resolveStaticAsset,
20970
20974
  authHeaders: options.authHeaders
20971
20975
  });
20972
20976
  const gltfOptions = {
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.164",
5
+ "version": "0.0.166",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/tscircuit/circuit-json-to-gltf.git"
@@ -29,7 +29,6 @@
29
29
  "@jscad/modeling": "^2.12.6",
30
30
  "@tscircuit/alphabet": "^0.0.25",
31
31
  "@tscircuit/cableprinter": "^0.0.6",
32
- "@tscircuit/footprinter": "^0.0.431",
33
32
  "earcut": "^3.0.2",
34
33
  "gl-matrix": "^3.4.4",
35
34
  "jscad-electronics": "^0.0.243",
@@ -47,6 +46,7 @@
47
46
  "@tscircuit/circuit-json-util": "^0.0.114",
48
47
  "@tscircuit/core": "^0.0.1955",
49
48
  "@tscircuit/flex-utils": "https://jscdn.tscircuit.com/@tscircuit/flex-utils/0.0.8.tgz",
49
+ "@tscircuit/footprinter": "^0.0.450",
50
50
  "@tscircuit/image-utils": "^0.0.10",
51
51
  "@tscircuit/props": "^0.0.664",
52
52
  "@types/bun": "latest",
@@ -74,6 +74,7 @@
74
74
  "@resvg/resvg-js": "2",
75
75
  "circuit-to-svg": ">=0.0.445",
76
76
  "@tscircuit/circuit-json-util": "*",
77
+ "@tscircuit/footprinter": "*",
77
78
  "circuit-json": ">=0.0.539"
78
79
  },
79
80
  "peerDependenciesMeta": {