I also noticed that when trying to come up with the answer in the other thread. Here is a sandcastle where I inserted the relevant coordinate system axes (red, green and blue) for debugging:
It can be seen that the alignment is just a little off:
Thanks @sean_lilley for the solution: The computation of the angle between the (local) y-Axis of the plane and the UNIT_Z axis was wrong. It should have been the angle between the y-Axis and the projection of the UNIT_Z axis on the plane.
Here is the simplified sandcastle, with this change being applied:
The result is indeed the plane being properly aligned with the horizon:
The computation of the orientation is commented, and it should be possible to apply that more or less directly to the Sandcastle that you posted, near the line
I did a quick check by inserting this solution in your Sandcastle here:
… but there are some computations that could be omitted now, or simplified, or optimized, or moved into own function - this is only to show that this should solve the issue in general.