Have the sprite's aim rotate to the mouse position

I’m building demo for a top-down shooter and I want the sprite to aim and rotate where the mouse is pointing. I’m having trouble getting the sprite to rotate correctly. It only goes 180 and then back to 0, not going a full 360. here’s the code:

onMouseMove(event: EventMouse) {
        const mousePos = event.getUILocation();

        // Calculate the angle between the mouse position and the center of the screen
        const canvas = find("Canvas").getComponent(UITransform);
        const center = new Vec2(canvas.width / 2, canvas.height / 2);
        const direction = new Vec2(mousePos.x - center.x, mousePos.y - center.y);
        const angle = Vec2.angle(direction, new Vec2(0, 1)) * 180 / Math.PI;

        // Set the rotation of the line based on the angle
        this.mainPlayer.setRotationFromEuler(new Vec3(0, 0, angle));
    }

I also tried replacing 180 with 360 but it looks like its not allowing negative numbers. Does anyone have experience with this?

I found the solution:

onMouseMove(event: EventMouse) {
        const mousePos = event.getUILocation();

        // Calculate the angle between the mouse position and the center of the screen
        const canvas = find("Canvas").getComponent(UITransform);
        const center = new Vec2(canvas.width / 2, canvas.height / 2);
        const direction = new Vec2(mousePos.x - center.x, mousePos.y - center.y);
        const angle = Math.atan2(direction.y, direction.x) * 180 / Math.PI;

        // Set the rotation of the line based on the angle
        this.mainPlayer.setRotationFromEuler(new Vec3(0, 0, angle + 90)); // +90 so the player points directly where the mouse is
    }

I added the 90 as an offset.