circuit-json-to-gltf 0.0.51 → 0.0.53

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
@@ -79,6 +79,7 @@ interface Box3D {
79
79
  meshType?: "stl" | "obj" | "glb";
80
80
  label?: string;
81
81
  labelColor?: Color;
82
+ isTranslucent?: boolean;
82
83
  }
83
84
  interface Scene3D {
84
85
  boxes: Box3D[];
package/dist/index.js CHANGED
@@ -15148,7 +15148,8 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
15148
15148
  const meshType = model_stl_url ? "stl" : model_obj_url ? "obj" : model_gltf_url ? "gltf" : model_glb_url ? "glb" : hasFootprinterModel ? "glb" : void 0;
15149
15149
  const box = {
15150
15150
  center,
15151
- size
15151
+ size,
15152
+ isTranslucent: cad.show_as_translucent_model
15152
15153
  };
15153
15154
  if (model_stl_url || model_obj_url || model_glb_url || model_gltf_url) {
15154
15155
  box.meshUrl = model_stl_url || model_obj_url || model_glb_url || model_gltf_url;
@@ -15198,10 +15199,6 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
15198
15199
  if (box.mesh && modelScaleFactor !== 1) {
15199
15200
  box.mesh = scaleMesh(box.mesh, modelScaleFactor);
15200
15201
  }
15201
- if (box.mesh && cad.position && usingObjFormat) {
15202
- const meshBottom = box.mesh.boundingBox.min.y;
15203
- box.center.y -= meshBottom;
15204
- }
15205
15202
  if (!box.mesh) {
15206
15203
  box.color = componentColor;
15207
15204
  }
@@ -15940,16 +15937,22 @@ var GLTFBuilder = class {
15940
15937
  meshData = convertMeshToGLTFOrientation(meshData);
15941
15938
  let materialIndex = defaultMaterialIndex;
15942
15939
  if (box.color) {
15943
- materialIndex = this.addMaterialFromColor(box.color, !box.mesh);
15940
+ materialIndex = this.addMaterialFromColor({
15941
+ color: box.color,
15942
+ makeTransparent: !box.mesh,
15943
+ isTranslucent: box.isTranslucent
15944
+ });
15944
15945
  } else if (box.mesh) {
15946
+ const opacity = box.isTranslucent ? 0.5 : 1;
15945
15947
  materialIndex = this.addMaterial({
15946
15948
  name: `MeshMaterial_${this.materials.length}`,
15947
15949
  pbrMetallicRoughness: {
15948
- baseColorFactor: [0.7, 0.7, 0.7, 1],
15950
+ baseColorFactor: [0.7, 0.7, 0.7, opacity],
15949
15951
  metallicFactor: 0.1,
15950
15952
  roughnessFactor: 0.9
15951
15953
  },
15952
- alphaMode: "OPAQUE"
15954
+ alphaMode: box.isTranslucent ? "BLEND" : "OPAQUE",
15955
+ doubleSided: box.isTranslucent ? true : void 0
15953
15956
  });
15954
15957
  }
15955
15958
  const meshIndex = this.addMesh(meshData, materialIndex, box.label);
@@ -15975,7 +15978,10 @@ var GLTFBuilder = class {
15975
15978
  ];
15976
15979
  baseColor = [color[0], color[1], color[2], color[3]];
15977
15980
  }
15978
- const alpha = objMaterial.dissolve !== void 0 ? 1 - objMaterial.dissolve : baseColor[3];
15981
+ let alpha = objMaterial.dissolve !== void 0 ? 1 - objMaterial.dissolve : baseColor[3];
15982
+ if (box.isTranslucent) {
15983
+ alpha = 0.5;
15984
+ }
15979
15985
  baseColor[3] = alpha;
15980
15986
  const gltfMaterialIndex = this.addMaterial({
15981
15987
  name: `OBJ_${name}`,
@@ -15984,7 +15990,8 @@ var GLTFBuilder = class {
15984
15990
  metallicFactor: 0.05,
15985
15991
  roughnessFactor: 0.95
15986
15992
  },
15987
- alphaMode: alpha < 1 ? "BLEND" : "OPAQUE"
15993
+ alphaMode: alpha < 1 ? "BLEND" : "OPAQUE",
15994
+ doubleSided: box.isTranslucent ? true : void 0
15988
15995
  });
15989
15996
  const materialIndex = objMesh.materialIndexMap?.get(name) ?? -1;
15990
15997
  objMaterialIndices.set(materialIndex, gltfMaterialIndex);
@@ -16430,7 +16437,8 @@ var GLTFBuilder = class {
16430
16437
  this.materials.push(material);
16431
16438
  return index;
16432
16439
  }
16433
- addMaterialFromColor(color, makeTransparent = false) {
16440
+ addMaterialFromColor(opts) {
16441
+ const { color, makeTransparent = false, isTranslucent = false } = opts;
16434
16442
  const baseColor = typeof color === "string" ? this.parseColorString(color) : [color[0] / 255, color[1] / 255, color[2] / 255, color[3]];
16435
16443
  if (makeTransparent) {
16436
16444
  baseColor[3] = 0.5;
@@ -16442,7 +16450,8 @@ var GLTFBuilder = class {
16442
16450
  metallicFactor: 0.05,
16443
16451
  roughnessFactor: 0.95
16444
16452
  },
16445
- alphaMode: makeTransparent ? "BLEND" : "OPAQUE"
16453
+ alphaMode: makeTransparent || isTranslucent ? "BLEND" : "OPAQUE",
16454
+ doubleSided: isTranslucent ? true : void 0
16446
16455
  });
16447
16456
  }
16448
16457
  parseColorString(color) {
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.51",
5
+ "version": "0.0.53",
6
6
  "scripts": {
7
7
  "test": "bun test tests/",
8
8
  "format": "biome format --write .",
@@ -32,7 +32,7 @@
32
32
  "@types/react-dom": "^19.1.7",
33
33
  "@vitejs/plugin-react": "^5.0.0",
34
34
  "bun-match-svg": "^0.0.12",
35
- "circuit-json": "^0.0.312",
35
+ "circuit-json": "^0.0.327",
36
36
  "circuit-to-svg": "0.0.283",
37
37
  "graphics-debug": "^0.0.65",
38
38
  "looks-same": "^9.0.1",
@@ -41,7 +41,7 @@
41
41
  "react-cosmos": "^7.0.0",
42
42
  "react-cosmos-plugin-vite": "^7.0.0",
43
43
  "react-dom": "^19.1.1",
44
- "tscircuit": "^0.0.800",
44
+ "tscircuit": "^0.0.1020",
45
45
  "tsup": "^8.5.0",
46
46
  "vite": "^7.1.1"
47
47
  },