Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

103 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

็„ก้™ๅŸŽ

M U G E N - J ลŒ ย ยทย  T H E ย  I N F I N I T Y ย  C A S T L E

An infinite Japanese castle that builds itself around you โ€” and you are a crow.

โ–ถ FLY IT NOW ยท zero installs, straight in your browser

The Infinity Castle title gate

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.


The descent

Diving through a lantern-lit ward Vertigo over the lantern ocean
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.

How an infinite castle is generated

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]
Loading

Districts give the castle personality

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.

Building plots guarantee complete houses

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.

Rooms are furnished by a parts kit

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.

Streaming that never pops

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.

Physics on moving architecture

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.

Sound from mathematics

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 over a temple quarter The pause shrine menu
Spirit mist pooling in the hanging temples ESC โ€” the castle waits: every dial, styled like a shrine

Take wing

pnpm install
pnpm run dev

Every 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.

Deployment

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.

Architecture

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

License & content notice

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.

Community

dive into the dark โ€” it goes down forever ๐Ÿฎ

About

๐Ÿฎ An infinite, self-assembling Japanese castle in your browser. Fly through it as a crow โ€” procedural architecture, weather and sound, zero art assets. Pure Three.js. ็„ก้™ๅŸŽ

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

12 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages