circuit-json-to-gltf 0.0.14 → 0.0.16
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.js +29 -5
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1145,14 +1145,19 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
|
|
|
1145
1145
|
continue;
|
|
1146
1146
|
pcbComponentIdsWith3D.add(cad.pcb_component_id);
|
|
1147
1147
|
const pcbComponent = db.pcb_component.get(cad.pcb_component_id);
|
|
1148
|
+
const isBottomLayer = pcbComponent?.layer === "bottom";
|
|
1148
1149
|
const size = cad.size ?? {
|
|
1149
1150
|
x: pcbComponent?.width ?? 2,
|
|
1150
1151
|
y: defaultComponentHeight,
|
|
1151
1152
|
z: pcbComponent?.height ?? 2
|
|
1152
1153
|
};
|
|
1153
|
-
const center = cad.position ? {
|
|
1154
|
+
const center = cad.position ? {
|
|
1155
|
+
x: cad.position.x,
|
|
1156
|
+
y: isBottomLayer ? -Math.abs(cad.position.z) : cad.position.z,
|
|
1157
|
+
z: cad.position.y
|
|
1158
|
+
} : {
|
|
1154
1159
|
x: pcbComponent?.center.x ?? 0,
|
|
1155
|
-
y: boardThickness / 2 + size.y / 2,
|
|
1160
|
+
y: isBottomLayer ? -(boardThickness / 2 + size.y / 2) : boardThickness / 2 + size.y / 2,
|
|
1156
1161
|
z: pcbComponent?.center.y ?? 0
|
|
1157
1162
|
};
|
|
1158
1163
|
const meshType = model_stl_url ? "stl" : model_obj_url ? "obj" : model_gltf_url ? "gltf" : "glb";
|
|
@@ -1165,14 +1170,32 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
|
|
|
1165
1170
|
if (cad.rotation) {
|
|
1166
1171
|
if (model_glb_url || model_gltf_url) {
|
|
1167
1172
|
box.rotation = convertRotationFromCadRotation({
|
|
1168
|
-
x: cad.rotation.x,
|
|
1173
|
+
x: isBottomLayer ? cad.rotation.x + 180 : cad.rotation.x,
|
|
1169
1174
|
y: cad.rotation.z,
|
|
1170
1175
|
// Circuit Z rotation becomes model Y rotation
|
|
1171
1176
|
z: cad.rotation.y
|
|
1172
1177
|
// Circuit Y rotation becomes model Z rotation
|
|
1173
1178
|
});
|
|
1174
1179
|
} else {
|
|
1175
|
-
box.rotation = convertRotationFromCadRotation(
|
|
1180
|
+
box.rotation = convertRotationFromCadRotation({
|
|
1181
|
+
x: isBottomLayer ? cad.rotation.x + 180 : cad.rotation.x,
|
|
1182
|
+
y: cad.rotation.y,
|
|
1183
|
+
z: cad.rotation.z
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
} else if (isBottomLayer) {
|
|
1187
|
+
if (model_glb_url || model_gltf_url) {
|
|
1188
|
+
box.rotation = convertRotationFromCadRotation({
|
|
1189
|
+
x: 180,
|
|
1190
|
+
y: 0,
|
|
1191
|
+
z: 0
|
|
1192
|
+
});
|
|
1193
|
+
} else {
|
|
1194
|
+
box.rotation = convertRotationFromCadRotation({
|
|
1195
|
+
x: 180,
|
|
1196
|
+
y: 0,
|
|
1197
|
+
z: 0
|
|
1198
|
+
});
|
|
1176
1199
|
}
|
|
1177
1200
|
}
|
|
1178
1201
|
const defaultTransform = coordinateTransform ?? (model_glb_url || model_gltf_url ? void 0 : COORDINATE_TRANSFORMS.Z_UP_TO_Y_UP_USB_FIX);
|
|
@@ -1199,10 +1222,11 @@ async function convertCircuitJsonTo3D(circuitJson, options = {}) {
|
|
|
1199
1222
|
Math.min(component.width, component.height),
|
|
1200
1223
|
defaultComponentHeight
|
|
1201
1224
|
);
|
|
1225
|
+
const isBottomLayer = component.layer === "bottom";
|
|
1202
1226
|
boxes.push({
|
|
1203
1227
|
center: {
|
|
1204
1228
|
x: component.center.x,
|
|
1205
|
-
y: boardThickness / 2 + compHeight / 2,
|
|
1229
|
+
y: isBottomLayer ? -(boardThickness / 2 + compHeight / 2) : boardThickness / 2 + compHeight / 2,
|
|
1206
1230
|
z: component.center.y
|
|
1207
1231
|
},
|
|
1208
1232
|
size: {
|
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.16",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "bun test tests/",
|
|
8
8
|
"format": "biome format --write .",
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@resvg/resvg-wasm": {
|
|
50
50
|
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"@resvg/resvg-js": {
|
|
53
|
+
"optional": true
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
}
|