circuit-json-to-gltf 0.0.144 → 0.0.146

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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PcbStiffener, CircuitJson, PcbBoard } from 'circuit-json';
2
+ import { MaterialOptions } from 'jscad-planner';
2
3
  import { mat4 } from 'gl-matrix';
3
4
 
4
5
  /** Circuit JSON bend geometry, board-local +Z up, millimeters. */
@@ -80,6 +81,8 @@ interface Size3 {
80
81
  z: number;
81
82
  }
82
83
  interface Triangle {
84
+ /** Authored JSCAD appearance; color tuples use linear 0–1 RGB. */
85
+ material?: MaterialOptions;
83
86
  /** Original PCB surface identity, retained after folding. */
84
87
  pcbFace?: "top" | "bottom" | "side";
85
88
  /** Flat PCB texture coordinates, retained/interpolated during tessellation. */
package/dist/index.js CHANGED
@@ -7640,7 +7640,7 @@ var require_polyhedron = __commonJS({
7640
7640
  colors: void 0,
7641
7641
  orientation: "outward"
7642
7642
  };
7643
- const { points, faces, colors, orientation } = Object.assign({}, defaults, options);
7643
+ const { points, faces, colors: colors2, orientation } = Object.assign({}, defaults, options);
7644
7644
  if (!(Array.isArray(points) && Array.isArray(faces))) {
7645
7645
  throw new Error("points and faces must be arrays");
7646
7646
  }
@@ -7650,11 +7650,11 @@ var require_polyhedron = __commonJS({
7650
7650
  if (faces.length < 1) {
7651
7651
  throw new Error("one or more faces are required");
7652
7652
  }
7653
- if (colors) {
7654
- if (!Array.isArray(colors)) {
7653
+ if (colors2) {
7654
+ if (!Array.isArray(colors2)) {
7655
7655
  throw new Error("colors must be an array");
7656
7656
  }
7657
- if (colors.length !== faces.length) {
7657
+ if (colors2.length !== faces.length) {
7658
7658
  throw new Error("faces and colors must have the same length");
7659
7659
  }
7660
7660
  }
@@ -7670,7 +7670,7 @@ var require_polyhedron = __commonJS({
7670
7670
  }
7671
7671
  const polygons = faces.map((face, findex) => {
7672
7672
  const polygon3 = poly3.create(face.map((pindex) => points[pindex]));
7673
- if (colors && colors[findex]) polygon3.color = colors[findex];
7673
+ if (colors2 && colors2[findex]) polygon3.color = colors2[findex];
7674
7674
  return polygon3;
7675
7675
  });
7676
7676
  return geom35.create(polygons);
@@ -17398,15 +17398,29 @@ var createBoardOuterLoop = (board, center) => {
17398
17398
  // lib/loaders/jscad-plan.ts
17399
17399
  var JSCAD_PLAN_TRANSFORM = COORDINATE_TRANSFORMS.CIRCUIT_Z_UP_TO_SCENE_Y_UP;
17400
17400
  var loadJscadPlan = (plan) => {
17401
- const zUpGeometry = executeJscadOperations(
17402
- jscadModeling2,
17403
- plan
17404
- );
17405
- const polygons = geom33.toPolygons(zUpGeometry);
17406
- const triangles = transformTriangles(
17407
- geom3ToTriangles(zUpGeometry, polygons),
17408
- JSCAD_PLAN_TRANSFORM
17401
+ const plans = Array.isArray(plan) ? plan.flat(Infinity) : [plan];
17402
+ const zUpGeometry = plans.map(
17403
+ (operation) => executeJscadOperations(jscadModeling2, operation)
17409
17404
  );
17405
+ const geometries = zUpGeometry.flat(Infinity);
17406
+ const sourceTriangles = geometries.flatMap((geometry) => {
17407
+ const polygons = geom33.toPolygons(geometry);
17408
+ return polygons.flatMap((polygon3) => {
17409
+ const color3 = polygon3.color ?? geometry.color;
17410
+ const material = geometry.material || color3 ? {
17411
+ ...color3 ? {
17412
+ color: color3.slice(0, 3),
17413
+ opacity: color3[3] ?? 1
17414
+ } : {},
17415
+ ...geometry.material
17416
+ } : void 0;
17417
+ return geom3ToTriangles(geometry, [polygon3]).map((triangle) => ({
17418
+ ...triangle,
17419
+ material
17420
+ }));
17421
+ });
17422
+ });
17423
+ const triangles = transformTriangles(sourceTriangles, JSCAD_PLAN_TRANSFORM);
17410
17424
  return {
17411
17425
  triangles,
17412
17426
  boundingBox: boundsOfTriangles2(triangles)
@@ -18399,7 +18413,8 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
18399
18413
  drillColor
18400
18414
  };
18401
18415
  const pcbPanel = db.pcb_panel?.list?.()[0];
18402
- const pcbBoard = db.pcb_board?.list?.()[0];
18416
+ const pcbBoards = db.pcb_board?.list?.() ?? [];
18417
+ const pcbBoard = pcbBoards[0];
18403
18418
  const pcbComponents = db.pcb_component?.list?.() ?? [];
18404
18419
  const bends = inputCircuitJson.filter(
18405
18420
  (e) => e.type === "pcb_bend"
@@ -18469,81 +18484,96 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
18469
18484
  panelBox.color = resolvedPcbColor;
18470
18485
  }
18471
18486
  boxes.push(panelBox);
18472
- } else if (pcbBoard) {
18473
- const pcbHoles = db.pcb_hole?.list?.() ?? [];
18474
- const pcbPlatedHoles = db.pcb_plated_hole?.list?.() ?? [];
18475
- const pcbCutouts = db.pcb_cutout?.list?.() ?? [];
18476
- const boardCutouts = filterCutoutsForBoard(pcbCutouts, pcbBoard);
18477
- const boardMesh = createBoardMesh(pcbBoard, {
18478
- thickness: effectiveBoardThickness,
18479
- holes: pcbHoles,
18480
- platedHoles: pcbPlatedHoles,
18481
- cutouts: boardCutouts,
18482
- drillQuality: boardDrillQuality
18483
- });
18484
- const meshWidth = boardMesh.boundingBox.max.x - boardMesh.boundingBox.min.x;
18485
- const meshHeight = boardMesh.boundingBox.max.z - boardMesh.boundingBox.min.z;
18486
- let foldedBoardMesh = boardMesh;
18487
- if (foldPcbs && bends.length) {
18488
- const foldResult = tryCreatePcbFold(bends, effectiveBoardThickness, {
18489
- // Match flex-utils' getCadFoldContext: translate circuit-world XY mm
18490
- // into board-local +Z-up points before the shared surface deformation.
18491
- outline: pcbBoard.outline?.map((point) => ({
18492
- x: point.x - pcbBoard.center.x,
18493
- y: point.y - pcbBoard.center.y
18494
- }))
18487
+ } else if (pcbBoards.length) {
18488
+ for (const pcbBoard2 of pcbBoards) {
18489
+ const effectiveBoardThickness2 = pcbBoard2.thickness ?? boardThickness;
18490
+ const boardCircuitJson = circuitJson.filter((element) => {
18491
+ if (element.type === "pcb_board")
18492
+ return element.pcb_board_id === pcbBoard2.pcb_board_id;
18493
+ if (!element.type.startsWith("pcb_")) return true;
18494
+ if (element.pcb_board_id)
18495
+ return element.pcb_board_id === pcbBoard2.pcb_board_id;
18496
+ return pcbBoards.length === 1 || element.subcircuit_id === pcbBoard2.subcircuit_id;
18495
18497
  });
18496
- if (foldResult.ok) {
18497
- const meshResult = tryFoldBoardMesh(boardMesh, foldResult.value);
18498
- if (meshResult.ok) {
18499
- fold = foldResult.value;
18500
- foldedBoardMesh = meshResult.value;
18498
+ const boardDb = cju(boardCircuitJson);
18499
+ const pcbHoles = boardDb.pcb_hole?.list?.() ?? [];
18500
+ const pcbPlatedHoles = boardDb.pcb_plated_hole?.list?.() ?? [];
18501
+ const pcbCutouts = boardDb.pcb_cutout?.list?.() ?? [];
18502
+ const boardCutouts = filterCutoutsForBoard(pcbCutouts, pcbBoard2);
18503
+ const boardMesh = createBoardMesh(pcbBoard2, {
18504
+ thickness: effectiveBoardThickness2,
18505
+ holes: pcbHoles,
18506
+ platedHoles: pcbPlatedHoles,
18507
+ cutouts: boardCutouts,
18508
+ drillQuality: boardDrillQuality
18509
+ });
18510
+ const meshWidth = boardMesh.boundingBox.max.x - boardMesh.boundingBox.min.x;
18511
+ const meshHeight = boardMesh.boundingBox.max.z - boardMesh.boundingBox.min.z;
18512
+ let foldedBoardMesh = boardMesh;
18513
+ if (foldPcbs && bends.length) {
18514
+ const foldResult = tryCreatePcbFold(bends, effectiveBoardThickness2, {
18515
+ // Match flex-utils' getCadFoldContext: translate circuit-world XY mm
18516
+ // into board-local +Z-up points before the shared surface deformation.
18517
+ outline: pcbBoard2.outline?.map((point) => ({
18518
+ x: point.x - pcbBoard2.center.x,
18519
+ y: point.y - pcbBoard2.center.y
18520
+ }))
18521
+ });
18522
+ if (foldResult.ok) {
18523
+ const meshResult = tryFoldBoardMesh(boardMesh, foldResult.value);
18524
+ if (meshResult.ok) {
18525
+ fold = foldResult.value;
18526
+ foldedBoardMesh = meshResult.value;
18527
+ } else {
18528
+ reportFoldIssue(
18529
+ `PCB board ${pcbBoard2.pcb_board_id}`,
18530
+ meshResult.issue
18531
+ );
18532
+ }
18501
18533
  } else {
18502
18534
  reportFoldIssue(
18503
- `PCB board ${pcbBoard.pcb_board_id}`,
18504
- meshResult.issue
18535
+ `PCB board ${pcbBoard2.pcb_board_id}`,
18536
+ foldResult.issue
18505
18537
  );
18506
18538
  }
18507
- } else {
18508
- reportFoldIssue(`PCB board ${pcbBoard.pcb_board_id}`, foldResult.issue);
18509
18539
  }
18510
- }
18511
- const boardBox = {
18512
- center: {
18513
- x: pcbBoard.center.x,
18514
- y: 0,
18515
- z: pcbBoard.center.y
18516
- },
18517
- size: {
18518
- x: Number.isFinite(meshWidth) ? meshWidth : pcbBoard.width,
18519
- y: effectiveBoardThickness,
18520
- z: Number.isFinite(meshHeight) ? meshHeight : pcbBoard.height
18521
- },
18522
- mesh: foldedBoardMesh,
18523
- color: resolvedPcbColor,
18524
- sideColor: resolvedBoardSideColor
18525
- };
18526
- if (shouldRenderTextures && textureResolution > 0) {
18527
- try {
18528
- const textures = await renderBoardTextures(circuitJson, {
18529
- resolution: textureResolution,
18530
- showPcbNotes,
18531
- ...boardTextureColors
18532
- });
18533
- boardBox.texture = {
18534
- top: textures.top,
18535
- bottom: textures.bottom
18536
- };
18537
- } catch (error) {
18538
- console.warn("Failed to render board textures:", error);
18540
+ const boardBox = {
18541
+ center: {
18542
+ x: pcbBoard2.center.x,
18543
+ y: 0,
18544
+ z: pcbBoard2.center.y
18545
+ },
18546
+ size: {
18547
+ x: Number.isFinite(meshWidth) ? meshWidth : pcbBoard2.width,
18548
+ y: effectiveBoardThickness2,
18549
+ z: Number.isFinite(meshHeight) ? meshHeight : pcbBoard2.height
18550
+ },
18551
+ mesh: foldedBoardMesh,
18552
+ color: resolvedPcbColor,
18553
+ sideColor: resolvedBoardSideColor
18554
+ };
18555
+ if (shouldRenderTextures && textureResolution > 0) {
18556
+ try {
18557
+ const textures = await renderBoardTextures(boardCircuitJson, {
18558
+ resolution: textureResolution,
18559
+ showPcbNotes,
18560
+ ...boardTextureColors
18561
+ });
18562
+ boardBox.texture = {
18563
+ top: textures.top,
18564
+ bottom: textures.bottom
18565
+ };
18566
+ } catch (error) {
18567
+ console.warn("Failed to render board textures:", error);
18568
+ boardBox.color = resolvedPcbColor;
18569
+ }
18570
+ } else {
18539
18571
  boardBox.color = resolvedPcbColor;
18540
18572
  }
18541
- } else {
18542
- boardBox.color = resolvedPcbColor;
18573
+ if (fold && boardBox.mesh)
18574
+ boardBox.size = getBoundingBoxSize(boardBox.mesh.boundingBox);
18575
+ boxes.push(boardBox);
18543
18576
  }
18544
- if (fold && boardBox.mesh)
18545
- boardBox.size = getBoundingBoxSize(boardBox.mesh.boundingBox);
18546
- boxes.push(boardBox);
18547
18577
  } else if (drawFauxBoard) {
18548
18578
  const hasComponentBounds = pcbComponents.length > 0;
18549
18579
  const componentBounds = hasComponentBounds ? findBoundsAndCenter(pcbComponents) : null;
@@ -18966,6 +18996,9 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
18966
18996
  return options.showErrors ? withCircuitJsonErrors(scene, inputCircuitJson) : scene;
18967
18997
  }
18968
18998
 
18999
+ // lib/gltf/gltf-builder.ts
19000
+ var import_modeling = __toESM(require_src(), 1);
19001
+
18969
19002
  // lib/gltf/gltf-types.ts
18970
19003
  var COMPONENT_TYPE = {
18971
19004
  BYTE: 5120,
@@ -19162,6 +19195,10 @@ var GLTFBuilder = class {
19162
19195
  await this.addOBJMeshWithMaterials(box, box.mesh);
19163
19196
  return;
19164
19197
  }
19198
+ if (box.mesh?.triangles.some((triangle) => triangle.material)) {
19199
+ this.addJscadMeshWithMaterials(box);
19200
+ return;
19201
+ }
19165
19202
  let meshData;
19166
19203
  if (box.mesh) {
19167
19204
  meshData = createMeshFromSTL(box.mesh);
@@ -19200,6 +19237,98 @@ var GLTFBuilder = class {
19200
19237
  });
19201
19238
  this.gltf.scenes[0].nodes.push(nodeIndex);
19202
19239
  }
19240
+ addJscadMeshWithMaterials(box) {
19241
+ const mesh = box.mesh;
19242
+ const groups = /* @__PURE__ */ new Map();
19243
+ for (const triangle of mesh.triangles) {
19244
+ const authored = triangle.material ?? {};
19245
+ const base = this.jscadColor(authored.color, [0.7, 0.7, 0.7]);
19246
+ const opacity = authored.opacity ?? (box.isTranslucent ? 0.5 : 1);
19247
+ const transparent = authored.transparent ?? (opacity < 1 || !!box.isTranslucent);
19248
+ const strength = authored.emissiveIntensity ?? 1;
19249
+ const index = this.addMaterial({
19250
+ pbrMetallicRoughness: {
19251
+ baseColorFactor: [...base, opacity],
19252
+ metallicFactor: authored.metalness ?? 0.1,
19253
+ roughnessFactor: authored.roughness ?? 0.9
19254
+ },
19255
+ emissiveFactor: this.jscadColor(authored.emissive, [0, 0, 0]),
19256
+ ...strength !== 1 ? {
19257
+ extensions: {
19258
+ KHR_materials_emissive_strength: { emissiveStrength: strength }
19259
+ }
19260
+ } : {},
19261
+ alphaMode: transparent ? "BLEND" : "OPAQUE",
19262
+ doubleSided: transparent || void 0
19263
+ });
19264
+ if (strength !== 1)
19265
+ this.gltf.extensionsUsed = ["KHR_materials_emissive_strength"];
19266
+ const group = groups.get(index) ?? [];
19267
+ group.push(triangle);
19268
+ groups.set(index, group);
19269
+ }
19270
+ const primitives = [...groups].map(([material, triangles]) => ({
19271
+ material,
19272
+ // Match addBox: preserve its scene-frame rotation and canonical export orientation.
19273
+ meshData: convertMeshToGLTFOrientation(
19274
+ transformMesh(
19275
+ createMeshFromSTL({ triangles, boundingBox: mesh.boundingBox }),
19276
+ { x: 0, y: 0, z: 0 },
19277
+ box.rotation
19278
+ )
19279
+ )
19280
+ }));
19281
+ const meshIndex = this.addMultiPrimitiveMesh(
19282
+ primitives,
19283
+ box.label || `JscadMesh${this.meshes.length}`,
19284
+ "jscad"
19285
+ );
19286
+ const nodeIndex = this.nodes.length;
19287
+ this.nodes.push({
19288
+ name: box.label || `Box${nodeIndex}`,
19289
+ mesh: meshIndex,
19290
+ translation: this.toGltfTranslation(box.center),
19291
+ ...this.getPoppyglNodeExtras(box)
19292
+ });
19293
+ this.gltf.scenes[0].nodes.push(nodeIndex);
19294
+ }
19295
+ jscadColor(color3, fallback) {
19296
+ if (color3 === void 0) return fallback;
19297
+ if (Array.isArray(color3)) return [...color3];
19298
+ let rgb;
19299
+ if (typeof color3 === "number")
19300
+ rgb = [
19301
+ (color3 >> 16 & 255) / 255,
19302
+ (color3 >> 8 & 255) / 255,
19303
+ (color3 & 255) / 255
19304
+ ];
19305
+ else {
19306
+ const css = color3.trim().toLowerCase();
19307
+ if (css.startsWith("#")) {
19308
+ const hex = css.slice(1);
19309
+ rgb = import_modeling.colors.hexToRgb(
19310
+ hex.length === 3 || hex.length === 4 ? `#${[...hex].map((digit) => digit + digit).join("")}` : css
19311
+ );
19312
+ } else if (/^rgba?\(/.test(css)) {
19313
+ rgb = css.slice(css.indexOf("(") + 1, -1).split(/[,\s/]+/).slice(0, 3).map(
19314
+ (channel) => parseFloat(channel) / (channel.endsWith("%") ? 100 : 255)
19315
+ );
19316
+ } else if (/^hsla?\(/.test(css)) {
19317
+ const [h, s, l] = css.slice(css.indexOf("(") + 1, -1).split(/[,\s/]+/);
19318
+ rgb = import_modeling.colors.hslToRgb(
19319
+ (parseFloat(h) % 360 + 360) % 360 / 360,
19320
+ parseFloat(s) / 100,
19321
+ parseFloat(l) / 100
19322
+ );
19323
+ } else rgb = import_modeling.colors.colorNameToRgb(css);
19324
+ if (!rgb || rgb.length < 3 || rgb.some((value) => !Number.isFinite(value))) {
19325
+ throw new Error(`Unsupported JSCAD material color: ${color3}`);
19326
+ }
19327
+ }
19328
+ return rgb.slice(0, 3).map(
19329
+ (value) => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4
19330
+ );
19331
+ }
19203
19332
  async addOBJMeshWithMaterials(box, objMesh) {
19204
19333
  const meshDataArray = createMeshFromOBJ(objMesh);
19205
19334
  const objMaterialIndices = /* @__PURE__ */ new Map();
@@ -19289,9 +19418,11 @@ var GLTFBuilder = class {
19289
19418
  }
19290
19419
  const materials = [];
19291
19420
  if (topTriangles.length > 0 && box.texture?.top) {
19421
+ const textureIndex = await this.addTextureFromDataUrl(box.texture.top);
19292
19422
  const topMaterialIndex = this.addMaterial({
19293
19423
  name: `TopMaterial_${this.materials.length}`,
19294
19424
  pbrMetallicRoughness: {
19425
+ ...textureIndex !== -1 ? { baseColorTexture: { index: textureIndex } } : {},
19295
19426
  baseColorFactor: [1, 1, 1, 1],
19296
19427
  metallicFactor: 0,
19297
19428
  roughnessFactor: 0.8
@@ -19299,24 +19430,17 @@ var GLTFBuilder = class {
19299
19430
  alphaMode: "OPAQUE",
19300
19431
  doubleSided: true
19301
19432
  });
19302
- const textureIndex = await this.addTextureFromDataUrl(box.texture.top);
19303
- if (textureIndex !== -1) {
19304
- const material = this.materials[topMaterialIndex];
19305
- if (material.pbrMetallicRoughness) {
19306
- material.pbrMetallicRoughness.baseColorTexture = {
19307
- index: textureIndex
19308
- };
19309
- }
19310
- }
19311
19433
  materials.push({
19312
19434
  triangles: topTriangles,
19313
19435
  materialIndex: topMaterialIndex
19314
19436
  });
19315
19437
  }
19316
19438
  if (bottomTriangles.length > 0 && box.texture?.bottom) {
19439
+ const textureIndex = await this.addTextureFromDataUrl(box.texture.bottom);
19317
19440
  const bottomMaterialIndex = this.addMaterial({
19318
19441
  name: `BottomMaterial_${this.materials.length}`,
19319
19442
  pbrMetallicRoughness: {
19443
+ ...textureIndex !== -1 ? { baseColorTexture: { index: textureIndex } } : {},
19320
19444
  // baseColorFactor: [ 0.04,
19321
19445
  // 0.16,
19322
19446
  // 0.08, 1.0],
@@ -19326,15 +19450,6 @@ var GLTFBuilder = class {
19326
19450
  alphaMode: "OPAQUE",
19327
19451
  doubleSided: true
19328
19452
  });
19329
- const textureIndex = await this.addTextureFromDataUrl(box.texture.bottom);
19330
- if (textureIndex !== -1) {
19331
- const material = this.materials[bottomMaterialIndex];
19332
- if (material.pbrMetallicRoughness) {
19333
- material.pbrMetallicRoughness.baseColorTexture = {
19334
- index: textureIndex
19335
- };
19336
- }
19337
- }
19338
19453
  materials.push({
19339
19454
  triangles: bottomTriangles,
19340
19455
  materialIndex: bottomMaterialIndex
@@ -19455,47 +19570,33 @@ var GLTFBuilder = class {
19455
19570
  const faceMeshes = createBoxMeshByFaces(box.size);
19456
19571
  const faceMaterials = {};
19457
19572
  if (box.texture?.top) {
19573
+ const textureIndex = await this.addTextureFromDataUrl(box.texture.top);
19458
19574
  const topMaterialIndex = this.addMaterial({
19459
19575
  name: `TopMaterial_${this.materials.length}`,
19460
19576
  pbrMetallicRoughness: {
19577
+ ...textureIndex !== -1 ? { baseColorTexture: { index: textureIndex } } : {},
19461
19578
  baseColorFactor: [0.04, 0.16, 0.08, 1],
19462
19579
  metallicFactor: 0,
19463
19580
  roughnessFactor: 0.8
19464
19581
  },
19465
19582
  alphaMode: "OPAQUE"
19466
19583
  });
19467
- const textureIndex = await this.addTextureFromDataUrl(box.texture.top);
19468
- if (textureIndex !== -1) {
19469
- const material = this.materials[topMaterialIndex];
19470
- if (material.pbrMetallicRoughness) {
19471
- material.pbrMetallicRoughness.baseColorTexture = {
19472
- index: textureIndex
19473
- };
19474
- }
19475
- }
19476
19584
  faceMaterials.top = topMaterialIndex;
19477
19585
  } else {
19478
19586
  faceMaterials.top = defaultMaterialIndex;
19479
19587
  }
19480
19588
  if (box.texture?.bottom) {
19589
+ const textureIndex = await this.addTextureFromDataUrl(box.texture.bottom);
19481
19590
  const bottomMaterialIndex = this.addMaterial({
19482
19591
  name: `BottomMaterial_${this.materials.length}`,
19483
19592
  pbrMetallicRoughness: {
19593
+ ...textureIndex !== -1 ? { baseColorTexture: { index: textureIndex } } : {},
19484
19594
  baseColorFactor: [0.04, 0.16, 0.08, 1],
19485
19595
  metallicFactor: 0,
19486
19596
  roughnessFactor: 0.8
19487
19597
  },
19488
19598
  alphaMode: "OPAQUE"
19489
19599
  });
19490
- const textureIndex = await this.addTextureFromDataUrl(box.texture.bottom);
19491
- if (textureIndex !== -1) {
19492
- const material = this.materials[bottomMaterialIndex];
19493
- if (material.pbrMetallicRoughness) {
19494
- material.pbrMetallicRoughness.baseColorTexture = {
19495
- index: textureIndex
19496
- };
19497
- }
19498
- }
19499
19600
  faceMaterials.bottom = bottomMaterialIndex;
19500
19601
  } else {
19501
19602
  faceMaterials.bottom = defaultMaterialIndex;
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.144",
5
+ "version": "0.0.146",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/tscircuit/circuit-json-to-gltf.git"
@@ -22,16 +22,15 @@
22
22
  "dependencies": {
23
23
  "@jscad/modeling": "^2.12.6",
24
24
  "@tscircuit/alphabet": "^0.0.25",
25
+ "@tscircuit/cableprinter": "^0.0.4",
25
26
  "earcut": "^3.0.2",
26
27
  "gl-matrix": "^3.4.4",
27
28
  "jscad-electronics": "^0.0.187",
28
- "jscad-planner": "^0.0.14",
29
+ "jscad-planner": "^0.0.19",
29
30
  "jscad-to-gltf": "^0.0.5",
30
- "occt-import-js": "^0.0.23",
31
- "@tscircuit/cableprinter": "^0.0.4"
31
+ "occt-import-js": "^0.0.23"
32
32
  },
33
33
  "devDependencies": {
34
- "@tscircuit/flex-utils": "https://jscdn.tscircuit.com/@tscircuit/flex-utils/0.0.8.tgz",
35
34
  "@biomejs/biome": "^2.1.4",
36
35
  "@google/model-viewer": "^4.1.0",
37
36
  "@napi-rs/canvas": "^1.0.9",
@@ -40,6 +39,7 @@
40
39
  "@resvg/resvg-wasm": "^2.6.2",
41
40
  "@tscircuit/circuit-json-util": "^0.0.114",
42
41
  "@tscircuit/core": "^0.0.1955",
42
+ "@tscircuit/flex-utils": "https://jscdn.tscircuit.com/@tscircuit/flex-utils/0.0.8.tgz",
43
43
  "@tscircuit/props": "^0.0.664",
44
44
  "@types/bun": "latest",
45
45
  "@types/earcut": "^3.0.0",
@@ -51,7 +51,7 @@
51
51
  "circuit-to-svg": "^0.0.429",
52
52
  "graphics-debug": "^0.0.96",
53
53
  "looks-same": "^9.0.1",
54
- "poppygl": "0.0.29",
54
+ "poppygl": "0.0.32",
55
55
  "react": "^19.1.1",
56
56
  "react-cosmos": "^7.0.0",
57
57
  "react-cosmos-plugin-vite": "^7.0.0",