Problem with the horizon

Hello,

I have built a simple flight simulator, but there is a problem with the horizon - it change its position when
I resize the browser’s window or I change the altitude or the roll of the airplane. How can I fix this?

Greetings!