I'm trying to align corner pieces so they always face inwards and also maintain right angles, like so:
By aligning instances to vertex normals I'm getting something like this (red face is always pointing inwards, so it's doing something right): Current nodetree:
Earlier I tried to rotate or mirror instances by selecting them manually via vertex IDs, but that's tedious and not at all dynamic.
So the question is: what kind of vector math magic can I use to get the result in the first picture? Can it be done with vertex normals, or perhaps by somehow referencing neighboring points to get the orientation?
.blend file can be downloaded here.
PS: another question that was suggested while composing this one (How to properly orient instances along corner edges) didn't help very much.
Edit: typos
Edit 2: Temporary solution
I was able to scale (mirror) instances depending on their position in relation to bounding box center (if it's below, mirror along Z axis etc.):
That did the trick, but sadly it only works with simple boxes. Or you'll get something like this where mid-level corner pieces are incorrectly pointing upwards as they are below the bounging box center (this problem also applies to X and Y axis):