An infinite Japanese castle that builds itself around you โ and you are a crow.
โถ FLY IT NOW ยท zero installs, straight in your browser
There is no ground here. No sky. No single up. Just an endless organism of timber and lantern-light, rearranging itself to the cry of a biwa โ and every screw, shoji panel, painted byลbu and drifting ember you see was generated by code the moment you arrived. No 3D models. No textures. No sound packs. One repo, one seed, infinite castle.
Inspired by the Infinity Castle of Demon Slayer: Kimetsu no Yaiba.
![]() |
![]() |
| Diving a labyrinth ward โ every building complete, styled, inhabited | The lantern ocean under an ember storm โ straight down forever |
- ๐ฎ It never ends, and it never repeats itself into mush. The world is grown from an architectural grammar โ chapters of districts, districts of building plots, plots of rooms โ so every seed produces intentional streets, shrines and towers, not noise soup.
- ๐ฆโโฌ True free flight. Full loops. Inverted dives. Q/E barrel rolls. The camera follows your up โ after a half-loop, only the hanging lanterns will tell you which way the world thinks is down.
- ๐ The castle is alive. Districts turn and drift like slow machines. Reconfiguration waves roll through with a taiko boom, and architecture visibly assembles ahead of you and unwinds behind you, piece by piece.
- ๐ซ๏ธ Weather you can grab. Still air, warm haze, mist fall, ember storm, ash fall, spirit mist โ the castle cycles them, or you pin one. Every slider in the menu is deliberately extreme at its ends.
- ๐ A world you can hear being built. Wooden clacks, rapid hammering, sliding shoji, groaning beams, settling stone โ a constant synthesized construction soundscape whose intensity follows the actual generation rate, under the looping theme.
- ๐ฑ Runs on nearly anything. GPU-detected quality tiers, adaptive frame-time monitor, full touch controls with a floating joystick.
The core trick: treat the castle as one infinitely large building. Every question โ "is there a wall at (x, y, z)?" โ is answered by pure hashing of coordinates + seed. No stored state, no generation order, no borders. Any point in space can be resolved independently, which is what makes streaming in any direction trivial.
graph LR
S[seed + coords] --> C[Chapter<br/>288 m biome band]
C --> D[District<br/>72 m ยท 11 archetypes]
D --> P[Building plot<br/>24โ48 m footprint]
P --> R[Cell / room<br/>12 m]
R --> K[Parts kit<br/>beams ยท shoji ยท lanterns ยท art]
Eleven archetypes โ residential wards, lantern labyrinths, corridor canyons, hollow shafts, hanging temples, bridge webs, cathedral voidsโฆ Each brings a shape grammar (which cells of its 6ร6ร6 lattice may hold architecture), a fill density, motion behaviour, window style and fog character. Chapters weight which districts appear at which depth, so descending feels like crossing regions of one megastructure.
Naive per-cell filling erodes buildings into rubble. Instead, each district's plan is divided into 2ร2-cell plots (one block in four merges into a 4ร4 mansion). A single hash decides the plot's fate โ built or void, foundation level, height, and style (machiya, kura, yagura, tenshu) โ and every cell then asks "which plot owns my column?" The result: 100 % of buildings are complete from foundation to roof ridge, even though no two cells are ever generated together. Single-cell flight corridors, light wells and atria are carved through as guaranteed negative space.
Each cell picks an archetype recipe โ tatami hall, stair shaft, balcony ring, pillar forest, cathedral bay โ and builds itself from procedural parts: post-and-beam frames, glowing shoji lattices, engawa verandas, hip/gable/thatch roofs, chลchin lanterns (85 % amber, 9 % jade, 6 % indigo โ some breathing, some flickering), fusuma and byลbu paintings sampled from a runtime-painted art atlas, plus signs of life: irori hearths, tea sets, futons, laundry lines, drying persimmons. Everything in a cell merges to ~2 draw calls with vertex-baked ambient occlusion.
Three shells surround the player โ full cells (~55 m, built within a per-frame time budget, prioritised along your flight vector), landmarks (~190 m), and one-draw-call far proxies (~360 m) that carry procedural window grids and the same lighting as real architecture. Every part knows its centroid and build order, so new architecture flies in from the haze ahead and settles; evicted rooms unwind behind you; proxies hold their ground until real cells actually generate, then melt into the aerial perspective โ which here goes hot, not dark: the distance burns amber, like the castle's own furnace horizon.
Districts move as rigid bodies, so collision transforms your position into each district's local frame before testing โ you can graze a slowly rotating tower at 40 m/s and the walls stay solid.
Karplus-Strong biwa strings. Filtered-noise wind that tracks airspeed. And the construction soundscape: three looping beds (timber rumble, groaning beams, sifting grit) plus stereo-panned carpentry one-shots, all driven per-frame by cells-built-per-second, glued to the theme by a master compressor.
![]() |
![]() |
| Spirit mist pooling in the hanging temples | ESC โ the castle waits: every dial, styled like a shrine |
pnpm install
pnpm run devEvery setting lives in the URL โ seed, weather, density, illumination, volumes โ so a refresh keeps your world and a link shares it:
?seed=99&weather=emberstorm&mist=170&density=140&light=120
?dev=parts # orbit-view gallery of every kit piece
?dev=modules # gallery of complete generated rooms
| Desktop | Action |
|---|---|
Mouse / arrows / A D |
Steer โ full 3-D, no limits |
Q / E |
Roll |
Space / W / click |
Surge |
Shift / S |
Brake & hover |
Esc |
Pause โ the shrine menu (weather, density, illumination, speed, sound, quit) |
C / H / R / M |
Camera / hide HUD / new castle / mute |
Touch: joystick appears wherever your left thumb lands, right side drags to look, FLAP/BRAKE buttons.
Push to main โ GitHub Actions typechecks, builds and deploys to Pages (.github/workflows/deploy.yml). One-time setup: Settings โ Pages โ Source โ GitHub Actions. base: './' and relative asset paths make the build work at any URL.
Moving to a custom domain is a one-variable change. Set a repository variable SITE_URL (Settings โ Secrets and variables โ Actions โ Variables), e.g. https://castle.example.dev/, and the build regenerates the canonical link, Open Graph and Twitter tags, JSON-LD, sitemap.xml, robots.txt โ and writes the CNAME file Pages needs โ all from that one value. Locally: SITE_URL=https://castle.example.dev/ pnpm run build.
src/
โโโ audio/ Web Audio synthesis โ buses, construction soundscape, biwa, wind
โโโ core/ renderer, GPU-detected quality tiers, seeded hashing
โโโ dev/ procedural geometry galleries
โโโ fx/ sky shells, mist decks, motes, weather, bloom
โโโ input/ pointer-lock mouse, keyboard, floating touch stick
โโโ kit/ geometry kit, shared shader materials, art atlas
โโโ physics/ district-frame sphere collision + escape
โโโ player/ crow with wing-wash aerodynamics, 6-DOF flight, camera rig
โโโ ui/ intro, tour, HUD, pause shrine
โโโ world/ districts, plots, archetypes, landmarks, streaming, motion
All code in this repository is open source under the MIT License โ fork it, learn from it, build your own castle.
Two audio files are not covered by that license: the background theme (from the Demon Slayer: Kimetsu no Yaiba original soundtrack) and the entrance sting. They remain the property of their respective rights holders (Aniplex / ufotable and the OST composers) and are included solely as a non-commercial fan homage. If you fork this project for anything beyond personal use, replace them with your own audio โ the game degrades gracefully if the files are absent. Rights holders may request removal at any time.
Everything else โ every mesh, texture, painting and sound effect โ is generated by the code in this repo and carries its license.
- Read CONTRIBUTING.md before proposing a change.
- Follow CODE_OF_CONDUCT.md when participating.
- Report vulnerabilities privately per SECURITY.md.
dive into the dark โ it goes down forever ๐ฎ




