Hey Im having a object3D with 4 raycasters in each direction. The object is draggable and when the raycaster hits, it applies the rotation of the hit object to itself.

Here is a fiddle which just rotates a object3D container and alerts its Y rotation after updating matrix world. The rotation value (-3.141592653589793) is an angle calculated from 3 2d points like so:

let r = Math.atan2(p3.z - p1.z, p3.x - p1.x) - Math.atan2(p2.z - p1.z, p2.x - p1.x)

The problem is that multiple euler angles can represent the same rotation. So just evaluating the y angle does not work. If you inspect the other two angles (x and z), you will see a difference compared to the initial values.

I suggest you avoid to work with euler angles and focus on quaternions instead. Transform your direction vector like so: