Cosmology and galaxy evolution studies with LSST, Euclid, and Roman, will require accurate redshifts for the detected galaxies. In this study, we present improved photometric redshift estimates for galaxies using a template library that populates three-colour space and is constrained by HST/CANDELS photometry. For the training sample, we use a sample of galaxies having photometric redshifts that allows us to train on a large, unbiased galaxy sample having deep, unconfused photometry at optical-to-mid infrared wavelengths. Galaxies in the training sample are assigned to cubes in 3D colour space, V − H, I − J, and z − H. We then derive the best-fitting spectral energy distributions of the training sample at the fixed CANDELS median photometric redshifts to construct the new template library for each individual colour cube (i.e. colour-cube-based template library). We derive photometric redshifts (photo-z) of our target galaxies using our new colour-cube-based template library and with photometry in only a limited set of bands, as expected for the aforementioned surveys. As a result, our method yields σ_(NMAD) of 0.026 and an outlier fraction of 6 per cent using only photometry in the LSST and Euclid/Roman bands. This is an improvement of ∼10 per cent on σ_(NMAD) and a reduction in outlier fraction of ∼13 per cent compared to other techniques. In particular, we improve the photo-z precision by about 30 per cent at 2 < z < 3. We also assess photo-z improvements by including K or mid-infrared bands to the ugrizYJH photometry. Our colour-cube-based template library is a powerful tool to constrain photometric redshifts for future large surveys