Skip to content

Commit f74c65d

Browse files
committed
fix: lint
1 parent 5e4e694 commit f74c65d

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/lib/3d/stl.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@ import { writeFloatLE, writeInt16LE, writeInt32LE } from '$lib/buffer';
22

33
const SOLID_NAME = 'THT-holder';
44

5-
const computeFaceNormal = (v: Float32Array, i: number): [number, number, number] => {
5+
const computeFaceNormal = (v: Float32Array, index: number): [number, number, number] => {
66
const [x0, y0, z0, x1, y1, z1, x2, y2, z2] = [
7-
v[i]!, v[i + 1]!, v[i + 2]!,
8-
v[i + 3]!, v[i + 4]!, v[i + 5]!,
9-
v[i + 6]!, v[i + 7]!, v[i + 8]!,
7+
v[index]!,
8+
v[index + 1]!,
9+
v[index + 2]!,
10+
v[index + 3]!,
11+
v[index + 4]!,
12+
v[index + 5]!,
13+
v[index + 6]!,
14+
v[index + 7]!,
15+
v[index + 8]!
1016
];
11-
const ex = x1 - x0, ey = y1 - y0, ez = z1 - z0;
12-
const fx = x2 - x0, fy = y2 - y0, fz = z2 - z0;
17+
const ex = x1 - x0,
18+
ey = y1 - y0,
19+
ez = z1 - z0;
20+
const fx = x2 - x0,
21+
fy = y2 - y0,
22+
fz = z2 - z0;
1323
const nx = ey * fz - ez * fy;
1424
const ny = ez * fx - ex * fz;
1525
const nz = ex * fy - ey * fx;
16-
const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
17-
return len > 0 ? [nx / len, ny / len, nz / len] : [0, 0, 0];
26+
const length_ = Math.hypot(nx, ny, nz);
27+
return length_ > 0 ? [nx / length_, ny / length_, nz / length_] : [0, 0, 0];
1828
};
1929

2030
export const generateStlFromVertices = (vertices: Float32Array): string[] => {

0 commit comments

Comments
 (0)