Maybe old news but it took me forever to figure out how to apply the inverse of a rotateXYZ. It's necessary not only to invert the angles but also to reverse the order: rotateXYZ does X, then Y, then Z, so the inverse must do Z, Y, X.

Here, the blue triangle should be stationary (if the rotation is undone properly), but it isn't when taking the naive approach.