Please help with tank cannon rotation

I have a GLB gun model that should rotate 360 ​​degrees and lookAt the mouse pointer

I calculate the angle between two points (raycaster, setFromCamera, intersectPlane, math.atan2)

the first point is the position of the gun
the second point is the mouse pointer on the Plane

If I rotate gltf.scene on the Y axis then everything is fine, but the point around which I rotate the object does not correspond to the point in gltf .scene.children
In the first case, the gun rotates and looks at the mouse cursor, but does not rotate relative to the position of the child

The second case: if I rotate children, but already along the z axis (the Y axis will not work here), then the gun rotates absolutely perfectly around the point that is set in blender, but its rotation angle is limited and only works when I move forward on the tank or back if i turn the tank left or right the rotation breaks (does not work correctly, it is logical)

Can you please tell me how to fix the rotation in the second case?

Please do not suggest me to use lookAt(), this is not suitable for a tank, the gun rotates only in one axis

                var mouse = new Vector2();
                let plane = new Plane(new Vector3(0, 1, 0), -1);
                let raycaster = new Raycaster();
                let pointOfIntersection = new Vector3();
                let player = this.players[key];
                window.addEventListener('mousemove', (e: MouseEvent) =>
                {
                    mouse.x = ( e.clientX / window.innerWidth ) * 2 - 1;
                    mouse.y = - ( e.clientY / window.innerHeight ) * 2 + 1
                        
                    raycaster.setFromCamera(mouse, camera.get());
                    raycaster.ray.intersectPlane(plane, pointOfIntersection);
                    
                    let angle = Math.atan2(player.getGunModel().position.x - pointOfIntersection.x, player.getGunModel().position.z - pointOfIntersection.z);

                    // idel look cursor (not ideal spin)
                    player.getGunModel().rotation.y = angle;

                    // ideal spin (not ideal look cursor) 
                    player.getGunModel().children[0].rotation.z = angle;
                });

I don’t really understand what you’re trying to do; a picture or demo might help.

Maybe update the gun’s worldMatrix, then create a target point using the X and Z of the mouse pointer on the ground and the Y position of the gun, then tell the gun to lookAt() that target point?

if (gun.children[0] instanceof Mesh)
        {
            if (gun.children[0].geometry instanceof BufferGeometry)
            {
                gun.children[0].geometry.translate(0.15, -0.15, 0)
            }
        }

        this.turretModel.add(gun);
        
        this.turretPivot = new Object3D()
        this.turretPivot.add(this.turretModel);

        this.turretOffset = new Object3D();
        this.turretOffset.position.set(-0.08, 0, +0.078);
        vehicleModel.add(this.turretOffset);

I already found a solution