We present the numerical procedure suitable for computing the distribution of electrical currents in a superconductor with geometry extending in all three spatial dimensions when it is exposed to a magnetic field changing in time. Its main advantage is that it solves the problem in terms of vector potential, of the magnetic field. Such an A-formulation is usually the default option for magnetic field calculations in commercial finite element codes. We have used it in the past when a two-dimensional (2D) approximation was found to be sufficient to predict AC losses of single wires, cables, and coils with circular turns. Incorporation of superconductor properties based on the critical state model is straightforward in 2D because the flow of current is restricted to one direction only. The main challenge in extending the method to three dimensions is to cope with the situation when currents could flow in any direction. We have found that assuming that the local current density in a superconductor is always parallel to the local electrical field, and that its modulus is limited by the critical current density, provides sufficient input for accomplishing a new working equation, linking the vector of current density to the time derivative of the magnetic vector potential. Our method successfully passed testing on the benchmark problem of superconducting cube magnetization. It is also used to interpret the magnetization measured on two cylindrical superconducting objects in the transverse field: one was a tube made from bulk BSCCO and the other a REBCO coated conductor tape helically wound on a non-metallic tube. Computed magnetization loops in both cases show good agreement with experiments and confirm the validity of the method.