mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 13:37:58 +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;
|
lineLookup[`${a}_${b}`] = index;
|
||||||
|
|
||||||
const line = new THREE.Line3(geometry.vertices[a], geometry.vertices[b]);
|
const line = new THREE.Line3(geometry.vertices[a], geometry.vertices[b]);
|
||||||
lines.push({ line, faces: [] });
|
const faces = [];
|
||||||
|
lines.push({ line, faces });
|
||||||
}
|
}
|
||||||
|
lines[index].faces.push(faceIndex);
|
||||||
const { faces } = lines[index];
|
|
||||||
faces.push(faceIndex);
|
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function createLines(geometry, settings) {
|
export default function createLines(geometry, settings) {
|
||||||
|
const faces = [];
|
||||||
const lines = [];
|
const lines = [];
|
||||||
const lineLookup = {};
|
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];
|
const { normal, materialIndex: objectIndex, a, b, c } = geometry.faces[i];
|
||||||
|
|
||||||
// skip faces that point up or down
|
// 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 indexA = addLine(geometry, lineLookup, lines, a, b, i);
|
||||||
const indexB = addLine(geometry, lineLookup, lines, b, c, 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 flatNormal = normalize({ x: normal.z, y: normal.x });
|
||||||
const lineIndexes = [indexA, indexB, indexC];
|
const lineIndexes = [indexA, indexB, indexC];
|
||||||
return { lineIndexes, flatNormal, objectIndex };
|
|
||||||
});
|
faces.push({ lineIndexes, flatNormal, objectIndex });
|
||||||
|
}
|
||||||
|
|
||||||
return { lines, faces };
|
return { lines, faces };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user