Afterglowscreensavers

3D Maze, Walked Screensaver

The 3D Maze, Walked screensaver generates a perfect maze and glides a camera through it in first person, with textured brick walls, a floor, a ceiling and a lamp that travels with you. It runs in the browser with nothing to install; press ESC to exit.

Live preview

3D Maze, Walked screensaver — Fog is what makes the depth read.

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the 3D Maze, Walked screensaver works

The saver renders with three.js on your GPU. The library is vendored into this site rather than fetched from a CDN, and is loaded only when a 3D screensaver actually runs.

It reads nothing external — the maze is generated in the browser and the brick texture is drawn to a canvas at startup.

The scene resizes with the window and releases its WebGL context when the saver stops, so shuffle mode and Multi-view can cycle 3D savers without exhausting the browser's context limit.

If WebGL is unavailable the saver says so on screen rather than showing an empty black box.

Mazes, generated and walked

A perfect maze has exactly one path between any two cells, with no loops and no unreachable areas. Such a maze is a spanning tree of a grid, which is why generation is often framed as building a random spanning tree. The recursive backtracker (randomized depth-first search) carves from a cell to a random unvisited neighbour until stuck, then backs up. It produces many long corridors with a low branching factor.

Other algorithms have different characters. Prim's and Kruskal's algorithms, which build spanning trees, are biased toward many short dead ends, and Kruskal's tends to give regular patterns that are fairly easy to solve. The Aldous-Broder algorithm produces uniform spanning trees but is among the least efficient. The choice changes the feel of the maze without changing the guarantee that every cell can be reached.

Walking through is a different problem from generating. The wall-follower rule, keeping a hand on one wall, works when all the walls are connected together or to the outer boundary, which holds for perfect mazes. Maze War, written in 1973 by high school students at NASA Ames Research Center, is believed to be the first 3D first-person game.

A worked example

A depth-first search carves a perfect maze — one route between any two points, no loops. A breadth-first pass then finds the longest route through it, and the camera follows that path at walking pace, looking two cells ahead so it turns into corners smoothly instead of snapping. Fog closes off the far end of each corridor, which is what makes the depth readable. When the walk finishes, a new maze is generated.

Settings & tips

Frequently asked questions

Is the maze different every time?
Yes. It is carved fresh by a randomised depth-first search each run, so the layout and the route through it are never the same twice.
Why does the wall texture look hand-made?
Because it is drawn to a canvas when the saver starts, rather than loaded as an image. It keeps the saver self-contained, and the slight irregularity in the brick shading is what stops the corridors looking flat.
Does this need a special browser or plugin?
No. It uses WebGL, which every current desktop and mobile browser supports. Nothing is installed and no plugin is required.
Does it cost anything or need an account?
No. Every screensaver here is free, runs in the browser and needs no sign-up.
Why does a perfect maze have no loops?
Being a spanning tree means it connects all cells with the minimum number of passages, so adding any further opening would create a cycle.
Does the wall-follower rule always work?
It works when the maze's walls are all connected to the outer boundary. If you start on an isolated island of wall, you can circle it forever.
Do all generation algorithms make the same kind of maze?
No. The recursive backtracker makes long corridors, while Prim's and Kruskal's make many short dead ends, although all produce a perfect maze.

← All Classics screensavers