@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
36 lines (35 loc) • 949 B
JavaScript
;
export function tetsSharedFace(tetGeometry, tetId0, tetId1) {
const tet0 = tetGeometry.tetrahedrons.get(tetId0);
const tet1 = tetGeometry.tetrahedrons.get(tetId1);
if (!tet0 || !tet1) {
return;
}
for (const neighbourData of tet0.neighbours) {
if (neighbourData) {
if (neighbourData.id == tetId1) {
const faceIndex0 = neighbourData.faceIndex;
const tet1NeighbourData = tet1.neighbours[faceIndex0];
if (tet1NeighbourData) {
const faceIndex1 = tet1NeighbourData.faceIndex;
return { faceIndex0, faceIndex1 };
}
}
}
}
return;
}
export function tetsShareFace(tetGeometry, tetId0, tetId1) {
const tet0 = tetGeometry.tetrahedrons.get(tetId0);
if (!tet0) {
return false;
}
for (const neighbourData of tet0.neighbours) {
if (neighbourData) {
if (neighbourData.id == tetId1) {
return true;
}
}
}
return false;
}