Skip to content

Commit 278ff4f

Browse files
authored
fix: vias improperly exported to STL (#70)
Updated `stl.ts` to follow (exactly the) same logic as `CrossSection.tsx`, correctly cross referencing with `layerTypes.ts` to find the required `viaVariation` and utilizing that specific variation's height. This allows designs to actually be exported as they appear in the cross section.
1 parent ca5da1f commit 278ff4f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/model/stl.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ import { BoxGeometry } from 'three/src/geometries/BoxGeometry.js';
33
import { Group } from 'three/src/objects/Group.js';
44
import { Mesh } from 'three/src/objects/Mesh.js';
55
import { downloadFile } from '~/utils/download-file';
6-
import { layerTypes } from './layerTypes';
7-
import { layout } from './layout';
6+
import { layout, rectLayer, rectViaLayer } from './layout';
87

98
export function exportSTL() {
109
const exporter = new STLExporter();
1110

1211
const scene = new Group();
1312

1413
for (const rect of layout.rects) {
15-
const layer = layerTypes.find((l) => l.name === rect.layer);
16-
if (layer == null) {
14+
const layer = rectLayer(rect);
15+
const viaLayer = rectViaLayer(layout, rect);
16+
if (!viaLayer || !layer) {
1717
continue;
1818
}
1919

20-
const geometry = new BoxGeometry(rect.width, rect.height, layer.crossHeight);
20+
const geometry = new BoxGeometry(rect.width, rect.height, viaLayer.crossHeight);
2121
const cube = new Mesh(geometry);
2222
cube.position.set(
2323
rect.x + rect.width / 2,
2424
-(rect.y + rect.height / 2),
25-
-layer.crossY - layer.crossHeight / 2,
25+
-viaLayer.crossY - viaLayer.crossHeight / 2,
2626
);
2727
cube.updateMatrixWorld();
2828
scene.add(cube);

0 commit comments

Comments
 (0)