mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 03:23:48 +01:00
clean up create lines
This commit is contained in:
parent
64d28affe6
commit
8f475195b8
@ -10,24 +10,27 @@ function addLine(geometry, lineLookup, lines, a, b, faceIndex) {
|
||||
lineLookup[`${a}_${b}`] = index;
|
||||
|
||||
const line = new THREE.Line3(geometry.vertices[a], geometry.vertices[b]);
|
||||
lines.push({ line, faces: [] });
|
||||
const faces = [];
|
||||
lines.push({ line, faces });
|
||||
}
|
||||
|
||||
const { faces } = lines[index];
|
||||
faces.push(faceIndex);
|
||||
lines[index].faces.push(faceIndex);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
export default function createLines(geometry, settings) {
|
||||
const faces = [];
|
||||
const lines = [];
|
||||
const lineLookup = {};
|
||||
|
||||
const faces = geometry.faces.map((face, i) => {
|
||||
for (let i = 0; i < geometry.faces.length; i ++) {
|
||||
const { normal, materialIndex: objectIndex, a, b, c } = geometry.faces[i];
|
||||
|
||||
// skip faces that point up or down
|
||||
if (normal.y > .999 || normal.y < -.999) return;
|
||||
if (normal.y > .999 || normal.y < -.999) {
|
||||
faces.push(null);
|
||||
continue;
|
||||
}
|
||||
|
||||
const indexA = addLine(geometry, lineLookup, lines, a, b, i);
|
||||
const indexB = addLine(geometry, lineLookup, lines, b, c, i);
|
||||
@ -35,8 +38,9 @@ export default function createLines(geometry, settings) {
|
||||
|
||||
const flatNormal = normalize({ x: normal.z, y: normal.x });
|
||||
const lineIndexes = [indexA, indexB, indexC];
|
||||
return { lineIndexes, flatNormal, objectIndex };
|
||||
});
|
||||
|
||||
faces.push({ lineIndexes, flatNormal, objectIndex });
|
||||
}
|
||||
|
||||
return { lines, faces };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user