We introduce a new model for the spectral energy distribution of galaxies, GRASIL-3D, which includes a careful modelling of the dust component of the interstellar medium. GRASIL-3D is an entirely new model based on the formalism of an existing and widely applied spectrophotometric model, GRASIL, but specifically designed to be interfaced with galaxies with any arbitrarily given geometry, such as galaxies calculated by theoretical hydrodynamical galaxy formation codes. GRASIL-3D is designed to separately treat radiative transfer in molecular clouds and in the diffuse cirrus component. The code has a general applicability to the outputs of simulated galaxies, either from Lagrangian or Eulerian hydrodynamic codes. As an application, the new model has been interfaced to the P-DEVA and GASOLINE smoothed-particle hydrodynamic codes, and has been used to calculate the spectral energy distribution for a variety of simulated galaxies from UV to sub-millimeter wavelengths, whose comparison with observational data gives encouraging results. In addition, GRASIL-3D allows 2D images of such galaxies to be obtained, at several angles and in different bands.