How to rotate the object the same regardless of the direction of the camera?

The sphere rotates along the world axis, everything looks fine until the camera starts to rotate around sphere. When the camera moving, the rotation of the object will continue along the world axis and it looks weird. How to consider the direction of the camera when rotating a sphere and make the rotation always the same?

I found how to get camera direction:


And how to rotate the object by the camera direction:

quaternion.setFromAxisAngle(vector, angle);

But I don’t understand how to rotate this direction axis vector to rotate the object along the x or y axis.

It’s not very clear what you’re trying to achieve, if you want the sphere to always rotate along x or y axis based on mouse horizontal/vertical movement regardless of the camera position, you can do it like this:

sphere.rotateOnWorldAxis({x:0, y:1, z:0}, deltaCoords.x * 0.001);
sphere.rotateOnWorldAxis({x:1, y:0, z:0}, deltaCoords.y * 0.001);