Theory of Three-Dimensional Orderings of Charge-Density Waves in 1T-TaX2 (X: S, Se)