Designing Impossible Geometry
A technical breakdown of creating a seamless, infinite non-Euclidean loop using React Three Fiber, treadmill mechanics, and WebGL clipping planes.
The Illusion of Infinity
When you walk down the non-Euclidean corridor, it feels like you are walking infinitely forward, taking right turn after right turn. In reality, you are on a mathematical treadmill.
Instead of moving the camera through an infinitely generated world, the camera remains relatively stationary while the world moves around it. The corridor is composed of discrete "chunks." As a chunk moves behind the camera, it is instantly teleported to the front of the line. This creates an endless loop using only a finite number of 3D meshes, heavily optimizing memory and rendering performance.
The Impossible Turn
The hallmark of a non-Euclidean space is geometry that contradicts standard physical laws—like taking four 90-degree right turns and ending up in a completely different hallway instead of where you started.
To achieve this, I used Shader-Based Global Clipping Planes.
Normally, WebGL renders everything within the camera's frustum. However, I injected custom GLSL code into the materials of the hallway walls. I defined a mathematical plane in 3D space located exactly at the threshold of the right-hand turn. As the camera approaches the corner, any pixel of the "blocking" wall that crosses this mathematical plane is instantly discarded (discard;) in the fragment shader.
This dynamically punches a perfect, pixel-accurate hole into the solid wall, revealing the hidden corridor extension behind it right as you look into the turn.
Cinematic Camera Mechanics
To ground the impossible geometry in reality, the camera uses a highly flattened 50mm cinematic telephoto lens. This flattens the perspective, making the corridor look longer and more dramatic, while obscuring the teleportation of chunks in the far distance. The scroll-driven movement applies easing and damping to simulate the weight and inertia of walking.
Experience the illusion
Walk the infinite corridor and see the clipping planes in action.
Enter Corridor