Building a tunnel that feels endless doesn’t require actually infinite geometry. This demo lines up 26 neon rings (TorusGeometry) at a fixed spacing and keeps advancing the camera’s z position — once it exceeds the total length (totalLen = RINGS × SPACING), a modulo (%) wraps it back to the start: z = (time * speed) % totalLen.
The camera technically teleports at the wrap, but fog (scene.fog = new THREE.FogExp2(...)) fades the rings ahead into the background color, the same trick discussed in the fog entry, so the cut is never visible. Each ring gets its own rotation speed and color (cycling hue by ring order in HSL) so passing through feels rhythmic rather than static.
This "wrap position with modulo" pattern isn’t just for tunnels — it’s the same trick behind infinite-scrolling backgrounds and recycled floor/obstacle geometry in endless-runner games. The key is resetting coordinates rather than creating or destroying geometry.
When to use
Intro sequences, endless-runner backgrounds, or a "warp" moment flying past data or portfolio items.