abyssal-garden README

README проекта с github.com/Noniv/abyssal-garden. Одним файлом markdown: README.md.

Abyssal Garden

A dreamy underwater world you can swim through, right in your browser.

Towering kelp forests, sunbeams pouring through a rippling surface, a sunken ship, manta rays gliding overhead. And all of it is made by code: no images, no 3D models, no sound files. The whole world fits in one 96 KB HTML file.

Kelp forest with a stone whale tail and a manta ray

Try it

  1. Download index.html.
  2. Open it in Chrome or Edge on a desktop computer.
  3. Wait a few seconds while the world is built, then press Dive in and start swimming.

Nothing to install, and it works offline. It needs a browser with WebGPU. If you see "This scene needs WebGPU", update your browser or switch to Chrome / Edge.

What's down there

Shipwreck Looking up through the kelp
Barrel sponges Light rays over the kelp basin

The purple grotto

Controls

Keyboard & mouse
Look around Move the mouse
Swim W A S D
Up / down E / Q
Swim faster Hold Shift
Jump to a viewpoint 1 to 6 (the spots in the screenshots)
Menu Esc releases the mouse and opens the menu with the list of controls; Resume takes you back
Sound on / off M (sound starts when you dive in)
Performance stats H
Detail level Low, Medium or High in the menu (reloads the page)

The seabed, cliffs and arches are solid: you glide along the rock instead of swimming into it, and you still fit through every tunnel and arch. Kelp, plants, corals, sponges, loose rocks, the floating boulders, the ship and the whale tail you can swim through.

On a touchscreen: hold one finger down to swim forward and slide it to steer. Put a second finger down to go faster. The ≡ button in the corner opens the menu. Phones always show the scene in landscape and start on Low or Medium detail. (Touch support is experimental.)

Detail levels

The Low, Medium and High buttons in the menu pick the detail level; the current one is lit. Each level is the same world, built with less in it:

Level What it is Picked on a first visit for
High The full scene Computers
Medium Half of the leaves, sparkles and pebbles; small rocks, sponges and corals cast no shadows Phones with 8 GB of memory
Low A quarter of the leaves, no anti-aliasing, coarser rocks and corals, simpler lighting, 480p to start with Other phones, and computers with 4 GB of memory or less

If loading crashes the tab, or the graphics driver gives up, the page starts again one level lower. Your browser remembers the level, and the resolution and draw distance the scene settled on, for the next visit.

How it works

Make it your own

The readable source code is in the source folder. To change something and rebuild index.html you need Node.js 18 or newer:

cd source
npm install
npm run build

This writes a new index.html next to this README. npm run build:readable writes an unminified version instead, which is easier to debug in the browser's developer tools.

npm run build:dev writes a separate dev.html with two extra tools that are not part of index.html: F flies the camera along a one-minute path through the whole world, and B runs that flight as a benchmark and reports frame and GPU times.

File What's inside
source/src/world.js The world layout: rock walls, arches, tunnels, kelp forests, sponge gardens, fish schools, mantas, the ship and the whale tail. A good place to start.
source/src/shaders.js The look: water and fog colors, lighting, kelp, rocks, the water surface and light rays (WGSL shader code)
source/src/main.js The renderer, the camera, the controls, the six viewpoints and the camera path the world is laid out around
source/src/audio.js The soundscape
source/src/quality.js The detail levels: which one a device starts on, and what is remembered between visits
source/src/math.js Noise, random numbers and mesh-building helpers
source/src/dev.js Development tools (fly-through and benchmark), only in dev.html
source/template.html The page around the scene: loading bar, start menu, links and their styles

Some easy first tweaks:

License

MIT: free to use, change and share, including in your own projects.

abyssal-garden (Noniv/abyssal-garden)

Ищем в базе…

Что это?Мечтательный подводный мир, по которому можно плавать прямо в браузере: с лесами ламинарии, солнечными лучами, затонувшим кораблём и скатами манта. Всё создаётся кодом, поэтому здесь нет изображений, 3D-моделей и звуковых файлов.
Здесь есть цель или это просто место для исследования?В README описана сцена для исследования: вы плаваете, осматриваетесь и наблюдаете за миром. Целей и игровых механик не упоминается.
Как это запустить?Скачайте index.html и откройте его в Chrome или Edge на настольном компьютере. Подождите несколько секунд, пока построится мир, затем нажмите «Погрузиться». Ничего устанавливать не нужно, работает оно и без интернета.
Какой браузер мне нужен?Браузер с поддержкой WebGPU. Рекомендуется Chrome или Edge на настольном компьютере. Если сцена не запускается, обновите браузер или перейдите на один из этих двух.
Работает ли это и на телефонах?Да, но пока экспериментально. Прижмите один палец, чтобы плыть вперёд, и проведите им, чтобы поворачивать. Добавьте второй палец, чтобы плыть быстрее. Кнопка меню находится в углу. На телефонах сцена всегда показывается в альбомной ориентации.
Могу ли я использовать это в своём проекте?Да. Проект распространяется под лицензией MIT, поэтому его можно свободно использовать, менять и делиться им, в том числе в собственных проектах.
Как строится весь мир без изображений и моделей?Морское дно формируется на вашей видеокарте каждый раз, когда открывается страница, а ламинария, камни, корабль и хвост кита строятся из простых математических фигур. Звук синтезируется в реальном времени с помощью Web Audio API.
Какое управление есть в сцене?Двигайте мышь, чтобы осматриваться, и используйте W, A, S, D, чтобы плыть. Клавиши E и Q отвечают за движение вверх и вниз. Удерживайте Shift, чтобы плыть быстрее, нажимайте от 1 до 6, чтобы перейти к точкам обзора. M включает и выключает звук, H показывает статистику производительности. Esc открывает меню.
Могу ли я сам изменить сцену?Да. Читаемый исходный код лежит в папке source, а с Node.js 18 или новее можно пересобрать index.html. Цвет воды, солнечный свет, яркость и скорость плавания — самые простые параметры для первых изменений.
Чем отличаются уровни детализации Low, Medium и High?Все уровни используют один и тот же мир, но на низких уровнях меньше листьев, блёсток и галечных камешков. На Low, кроме того, отключается сглаживание и упрощается освещение. Браузер запоминает выбранный уровень для следующего посещения.
Автор
Noniv
Размер
1.7 MB
Звёзды
2.1K
Обновлён
КоммитNov 14
Возраст
6 д
Коммиты · 90 дней