  The surface code is a two-dimensional topological code with code parameters
that scale optimally with the number of physical qubits, under the constraint
of two-dimensional locality. In three spatial dimensions an analogous simple
yet optimal code was not previously known. Here, we introduce a construction
that takes as input a stabilizer code and produces as output a
three-dimensional topological code with related code parameters. The output
codes have the special structure of being topological defect networks formed by
layers of surface code joined along one-dimensional junctions, with a maximum
stabilizer check weight of six. When the input is a family of good low-density
parity-check codes, the output is a three-dimensional topological code with
optimal scaling code parameters and a polynomial energy barrier.
