If you just want to stabilize them so you don't really care about which edge of the face they're on they align with, you can simply Sample Nearest
edge for its index, then Sample Index
for that edge's directional vector using the two Positions from Edge Vertices
:
Update: Stabilize for animation
To stabilize the rotations when the mesh is deformed, instead of referencing the nearest edge dynamically, we can do as you've suspected we should, and employ the positions of certain two face corners instead. The Corners of Face
node with its Sort Index set to $0$ can get us the first corner. Using Offset Corner in Face
set to Offset: $1$ we can select the very next one. We can now subtract the positions of these two corners and capture that information as an attribute on the Face domain to use later in the nodetree for alignment:
Left: Align to nearest edge Right: Align to the first two face corners
With more complex geometry and deformations, even when you stabilize the two axes, the third one can still randomly switch between one direction and its opposite, resulting in unwanted movement. To stabilize the third axis, you can finally align it to the Cross Product
of the two previous ones (a third vector that's perpendicular to both):
Left: Two axes stabilized. Third sometimes switching sides. Right: All three axes aligned