I think the way to do it would be to have a frame for every angle.
X rotation from 0 to 360
Y rotation from -180 to 180
So if you wanted a frame for each 10 degrees that would be 36*36 frames.
So the next step is to map an x,y angle to a frame. Z is handled by the sprite angle. A starting formula could be this:
36*int(angX/10)+int(angy/10)
X and y could be swapped depending on how your frames are laid out. You also want to ensure the angle is in the range 0 to 360. This should do it:
Ang=(Ang%360+360)%360
Ok cool. So all that’s left is to rotate the ball around in 3D somehow. I’m thinking just some physics. Simple case you’d want it to roll in the direction the ball is moving. Looks like it can spin in place in your gif. Might need some more 3D physics calculations. But I can’t calculate that off the top of my head.