The resultant of 3 normals

Yesterday I created an thread about Terrain normal. I figured it with the help of users which post in the thread and I’m very proud of the result:
In the video the cyan arrow is the normal of terrain, and I snapped the object on terrain sample height and it fits the terrain. When I place on the flat surface the angle between y-axis and normal is 0, so I know it is working:
2jjaav

However, I want to add the feature to player to rotate the building around the y axis, but when I do this:
2f9lku
(I calculate all in OnGizmosDraw to test in editmode - i’ll move in LateUpdate)

The terrain fit breaks because the normal is calculated at the pivot and doesn’t take care of y rotation so it works only when it is rotated default:
n6xl9j

I think that I need to calculate 3 normal vectors at the extreme points of the object and somehow to compose the 3 vectors and find the resultant of them

[If a moderator sees this sorry if I posted so many threads in last week, but I’m very motivated to finish my project, and maybe I choose a project to ambitious for my limited knowledge, but I’m about to finish and I can’t give up]

I have the solution. It is so simple:

RaycastHit hit;
            if (Physics.Raycast(Blueprint.transform.position, Vector3.down, out hit))
            {

                Blueprint.transform.rotation = Quaternion.FromToRotation(Blueprint.transform.up, hit.normal) * Blueprint.transform.rotation;
            }

It is a little bit glitchy, but still amazing:
au40gs