Break out offset_3d() function for optimization.