This paper proposes a novel code for optical code division multiple access (OCDMA) systems, called the three-dimensional (3D) spectral/temporal/spatial single weight zero cross-correlation (3D-SWZCC) code. The proposed code could potentially be used in the next generation of passive optical networks (NG-PONs) to provide a 3D-SWZCC-OCDMA-NG-PON system. The developed code has a high capacity and a zero cross-correlation property that completely suppresses the multiple access interference (MAI) effects that are a main drawback for OCDMA systems. Previously, a two-dimensional (2D) SWZCC code was proposed for two-dimensional OCDMA (2D-OCDMA) systems. It works by devoting the first and second components to spectral and spatial encodings, respectively. However, the proposed code aims to carry out encoding domains in spectral, time, and spatial aspects for the first, second, and third components, respectively. One-dimensional, 2D, and 3D systems can support up to 68, 157, and 454 active users with total code lengths equal to 68, 171, and 273, respectively. Numerical results reveal that the 3D-SWZCC code outperforms codes from previous studies, including 3D codes such as perfect difference (PD), PD/multi-diagonal (PD/MD), dynamic cyclic shift/MD (DCS/MD), and Pascal’s triangle zero cross-correlation (PTZCC), according to various metrics. The system function is provided by exhibiting the architecture of the transmitter and receiver in the PON context, where the proposed code demonstrates its effectiveness in meeting optical communication requirements based on 3D-OCDMA-PON by producing a high quality factor (Q) of 18.8 and low bit error rate (BER) of 3.48 × 10−29 over a long distance that can reach 30 Km for a data rate of 0.622 Gbps.