circuit-json-to-gltf 0.0.52 → 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 +1 -0
- package/dist/index.js +21 -8
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
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;
|
|
@@ -15936,16 +15937,22 @@ var GLTFBuilder = class {
|
|
|
15936
15937
|
meshData = convertMeshToGLTFOrientation(meshData);
|
|
15937
15938
|
let materialIndex = defaultMaterialIndex;
|
|
15938
15939
|
if (box.color) {
|
|
15939
|
-
materialIndex = this.addMaterialFromColor(
|
|
15940
|
+
materialIndex = this.addMaterialFromColor({
|
|
15941
|
+
color: box.color,
|
|
15942
|
+
makeTransparent: !box.mesh,
|
|
15943
|
+
isTranslucent: box.isTranslucent
|
|
15944
|
+
});
|
|
15940
15945
|
} else if (box.mesh) {
|
|
15946
|
+
const opacity = box.isTranslucent ? 0.5 : 1;
|
|
15941
15947
|
materialIndex = this.addMaterial({
|
|
15942
15948
|
name: `MeshMaterial_${this.materials.length}`,
|
|
15943
15949
|
pbrMetallicRoughness: {
|
|
15944
|
-
baseColorFactor: [0.7, 0.7, 0.7,
|
|
15950
|
+
baseColorFactor: [0.7, 0.7, 0.7, opacity],
|
|
15945
15951
|
metallicFactor: 0.1,
|
|
15946
15952
|
roughnessFactor: 0.9
|
|
15947
15953
|
},
|
|
15948
|
-
alphaMode: "OPAQUE"
|
|
15954
|
+
alphaMode: box.isTranslucent ? "BLEND" : "OPAQUE",
|
|
15955
|
+
doubleSided: box.isTranslucent ? true : void 0
|
|
15949
15956
|
});
|
|
15950
15957
|
}
|
|
15951
15958
|
const meshIndex = this.addMesh(meshData, materialIndex, box.label);
|
|
@@ -15971,7 +15978,10 @@ var GLTFBuilder = class {
|
|
|
15971
15978
|
];
|
|
15972
15979
|
baseColor = [color[0], color[1], color[2], color[3]];
|
|
15973
15980
|
}
|
|
15974
|
-
|
|
15981
|
+
let alpha = objMaterial.dissolve !== void 0 ? 1 - objMaterial.dissolve : baseColor[3];
|
|
15982
|
+
if (box.isTranslucent) {
|
|
15983
|
+
alpha = 0.5;
|
|
15984
|
+
}
|
|
15975
15985
|
baseColor[3] = alpha;
|
|
15976
15986
|
const gltfMaterialIndex = this.addMaterial({
|
|
15977
15987
|
name: `OBJ_${name}`,
|
|
@@ -15980,7 +15990,8 @@ var GLTFBuilder = class {
|
|
|
15980
15990
|
metallicFactor: 0.05,
|
|
15981
15991
|
roughnessFactor: 0.95
|
|
15982
15992
|
},
|
|
15983
|
-
alphaMode: alpha < 1 ? "BLEND" : "OPAQUE"
|
|
15993
|
+
alphaMode: alpha < 1 ? "BLEND" : "OPAQUE",
|
|
15994
|
+
doubleSided: box.isTranslucent ? true : void 0
|
|
15984
15995
|
});
|
|
15985
15996
|
const materialIndex = objMesh.materialIndexMap?.get(name) ?? -1;
|
|
15986
15997
|
objMaterialIndices.set(materialIndex, gltfMaterialIndex);
|
|
@@ -16426,7 +16437,8 @@ var GLTFBuilder = class {
|
|
|
16426
16437
|
this.materials.push(material);
|
|
16427
16438
|
return index;
|
|
16428
16439
|
}
|
|
16429
|
-
addMaterialFromColor(
|
|
16440
|
+
addMaterialFromColor(opts) {
|
|
16441
|
+
const { color, makeTransparent = false, isTranslucent = false } = opts;
|
|
16430
16442
|
const baseColor = typeof color === "string" ? this.parseColorString(color) : [color[0] / 255, color[1] / 255, color[2] / 255, color[3]];
|
|
16431
16443
|
if (makeTransparent) {
|
|
16432
16444
|
baseColor[3] = 0.5;
|
|
@@ -16438,7 +16450,8 @@ var GLTFBuilder = class {
|
|
|
16438
16450
|
metallicFactor: 0.05,
|
|
16439
16451
|
roughnessFactor: 0.95
|
|
16440
16452
|
},
|
|
16441
|
-
alphaMode: makeTransparent ? "BLEND" : "OPAQUE"
|
|
16453
|
+
alphaMode: makeTransparent || isTranslucent ? "BLEND" : "OPAQUE",
|
|
16454
|
+
doubleSided: isTranslucent ? true : void 0
|
|
16442
16455
|
});
|
|
16443
16456
|
}
|
|
16444
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.
|
|
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.
|
|
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.
|
|
44
|
+
"tscircuit": "^0.0.1020",
|
|
45
45
|
"tsup": "^8.5.0",
|
|
46
46
|
"vite": "^7.1.1"
|
|
47
47
|
},
|