Raycasting objects with viewport zoom

I’m having some problems with raycasting objects. My scene is being a part of my viewport so I placed my scene in a div. I managed to align the raycaster by using “pageX” instead of “clientX” and then to calculate the offset which was working fine the only problem is that when the viewport is being zoomed in or out the offset is going out of sync again.

I have no idea how I can fix this problem, so any pointers into the right direction are very welcome. Thanks

For anyone running into a similar problem what fixed it for me is setting the sections above my scene to 100VH and by doing so the raycaster didn’t go out of sync anymore when scaling the viewport.