Vertex shader animated polygon flip

I am trying to create a vertex shader-based animation that would flip each polygon of a (two sided) mesh.
It should look similar to this, except with every polygon of the mesh, rather than just one plane:

245169-flip1.gif

In that example, I use the plane’s pivot and the world X axis for the RotateAboutAxis node. But when it comes to a more complex mesh (a character, for instance), you need the center point of each polygon as the pivot, and a vector perpendicular to that polygon’s normal direction as the rotation axis.
I made several unsucessful attempts, and I am having trouble getting the rotation right.

Could you point me in the right direction? Or maybe you can think of a better approach to this effect?

Thank you.

You are on the right path, but you need something, to get pivot of the subject. As an example, you can encode that in your vertex colors or UVs.

Yes, that is what I was trying just now.
So far, I have found a node that gives you the tangent and binormal vectors, so I can put that into the rotation axis.

Now I only need to find the center of the polygon/barycentric coordinates to use them as the rotation pivot.

Vertex colors could work for static meshes, but I would rather do it in the material, so that the effect would work on animated meshes, too. Except I have no idea how to find the barycenter of each triangle/polygon, since I don’t have access to the 3 vertices of each triangle, but just the one vertex being processed at the time.

Any ideas?

Also, here’s another gif. I got it working on spheres and sphere-like meshes with hardened/flat normals, since you can fake the polygon pivot doing “objectPivot + (vertexNormal * objectRadius)”.

First row is rotating in their V/binormal axis, second row in the U/tangent axis, and the third in the W/normal one:

245213-flip3.gif