circuit-json-to-gltf 0.0.131 → 0.0.133

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 (3) hide show
  1. package/dist/index.d.ts +80 -4
  2. package/dist/index.js +1530 -1168
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,9 +1,66 @@
1
- import { CircuitJson } from 'circuit-json';
1
+ import { CircuitJson, PcbBoard } from 'circuit-json';
2
2
 
3
+ /** Temporary structural input matching circuit-json PR #816 until its release. */
4
+ interface PcbBendRecord {
5
+ type: "pcb_bend";
6
+ pcb_bend_id: string;
7
+ pcb_board_id: string;
8
+ name?: string;
9
+ pcb_group_id?: string;
10
+ subcircuit_id?: string;
11
+ start: {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ end: {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ bend_angle: number;
20
+ bend_radius: number;
21
+ bend_side: "left" | "right";
22
+ }
23
+ /** Temporary structural input matching circuit-json PR #816. Geometry is flat
24
+ * board-local Circuit JSON (+Z up, mm); polygon outlines are already positioned.
25
+ */
26
+ type PcbStiffenerRecord = {
27
+ type: "pcb_stiffener";
28
+ pcb_stiffener_id: string;
29
+ pcb_board_id: string;
30
+ name?: string;
31
+ pcb_group_id?: string;
32
+ subcircuit_id?: string;
33
+ layer: "top" | "bottom";
34
+ material: "fr4" | "polyimide" | "stainless_steel" | "aluminum";
35
+ thickness: number;
36
+ adhesive_thickness?: number;
37
+ } & ({
38
+ shape: "rect";
39
+ center: {
40
+ x: number;
41
+ y: number;
42
+ };
43
+ width: number;
44
+ height: number;
45
+ rotation?: number;
46
+ } | {
47
+ shape: "polygon";
48
+ outline: {
49
+ x: number;
50
+ y: number;
51
+ }[];
52
+ });
53
+
54
+ /** Accept unreleased flex records alongside existing Circuit JSON elements. */
55
+ type CircuitJsonWithPcbFlex = (CircuitJson[number] | PcbBendRecord | PcbStiffenerRecord | (Omit<PcbBoard, "material"> & {
56
+ material: "flex";
57
+ }))[];
3
58
  interface AuthHeaders extends Record<string, string> {
4
59
  Authorization: string;
5
60
  }
6
61
  interface ConversionOptions {
62
+ /** Fold boards at render time; stored Circuit JSON remains flat. Default: false. */
63
+ foldPcbs?: boolean;
7
64
  format?: "gltf" | "glb";
8
65
  boardTextureResolution?: number;
9
66
  showPcbNotes?: boolean;
@@ -48,6 +105,23 @@ interface Size3 {
48
105
  z: number;
49
106
  }
50
107
  interface Triangle {
108
+ /** Original PCB surface identity, retained after folding. */
109
+ pcbFace?: "top" | "bottom" | "side";
110
+ /** Flat PCB texture coordinates, retained/interpolated during tessellation. */
111
+ uvs?: [
112
+ {
113
+ u: number;
114
+ v: number;
115
+ },
116
+ {
117
+ u: number;
118
+ v: number;
119
+ },
120
+ {
121
+ u: number;
122
+ v: number;
123
+ }
124
+ ];
51
125
  vertices: [Point3, Point3, Point3];
52
126
  normal: Point3;
53
127
  color?: Color;
@@ -127,6 +201,8 @@ interface GLTFExportOptions {
127
201
  includeCustomExtensions?: boolean;
128
202
  }
129
203
  interface CircuitTo3DOptions {
204
+ /** Fold boards at render time (default: false); supports parallel, non-overlapping bends. */
205
+ foldPcbs?: boolean;
130
206
  pcbColor?: Color;
131
207
  boardSideColor?: Color;
132
208
  componentColor?: Color;
@@ -164,7 +240,7 @@ declare function renderBoardTextures(circuitJson: CircuitJson, { resolution, bac
164
240
  bottom: string;
165
241
  }>;
166
242
 
167
- declare function convertCircuitJsonTo3D(circuitJson: CircuitJson, options?: CircuitTo3DOptions): Promise<Scene3D>;
243
+ declare function convertCircuitJsonTo3D(inputCircuitJson: CircuitJsonWithPcbFlex, options?: CircuitTo3DOptions): Promise<Scene3D>;
168
244
 
169
245
  declare function convertSceneToGLTF(scene: Scene3D, options?: GLTFExportOptions): Promise<ArrayBuffer | object>;
170
246
 
@@ -270,7 +346,7 @@ declare const COORDINATE_TRANSFORMS: {
270
346
  readonly OBJ_Z_UP_TO_Y_UP: CoordinateTransformConfig;
271
347
  };
272
348
 
273
- declare function convertCircuitJsonToGltf(circuitJson: CircuitJson, options?: ConversionOptions): Promise<ArrayBuffer | object>;
349
+ declare function convertCircuitJsonToGltf(circuitJson: CircuitJsonWithPcbFlex, options?: ConversionOptions): Promise<ArrayBuffer | object>;
274
350
 
275
351
  interface Point {
276
352
  x: number;
@@ -282,4 +358,4 @@ interface BRepShape {
282
358
  is_negative?: boolean;
283
359
  }
284
360
 
285
- export { type BRepShape, type BoardRenderOptions, type BoundingBox, type Box3D, CAMERA_PRESET_DIRECTIONS, COORDINATE_TRANSFORMS, type Camera3D, type CameraFitOptions, type CameraPreset, type CircuitTo3DOptions, type Color, type ConversionOptions, type CoordinateTransformConfig, type GLTFExportOptions, type LayerRef, type Light3D, type OBJMaterial, type OBJMesh, type Point, type Point3, type STLMesh, type Scene3D, type Size3, type Triangle, applyCoordinateTransform, clearGLBCache, clearOBJCache, clearSTLCache, convertCircuitJsonTo3D, convertCircuitJsonToGltf, convertSceneToGLTF, getBestCameraPosition, loadGLB, loadJscadPlan, loadOBJ, loadSTL, renderBoardLayer, renderBoardTextures, transformTriangles };
361
+ export { type BRepShape, type BoardRenderOptions, type BoundingBox, type Box3D, CAMERA_PRESET_DIRECTIONS, COORDINATE_TRANSFORMS, type Camera3D, type CameraFitOptions, type CameraPreset, type CircuitJsonWithPcbFlex, type CircuitTo3DOptions, type Color, type ConversionOptions, type CoordinateTransformConfig, type GLTFExportOptions, type LayerRef, type Light3D, type OBJMaterial, type OBJMesh, type PcbBendRecord, type PcbStiffenerRecord, type Point, type Point3, type STLMesh, type Scene3D, type Size3, type Triangle, applyCoordinateTransform, clearGLBCache, clearOBJCache, clearSTLCache, convertCircuitJsonTo3D, convertCircuitJsonToGltf, convertSceneToGLTF, getBestCameraPosition, loadGLB, loadJscadPlan, loadOBJ, loadSTL, renderBoardLayer, renderBoardTextures, transformTriangles };