FERRETGame engine over Babylon.js
Ferret

Ferret

Ferret is a general-purpose game engine for OS Beroun and ordinary web browsers, built on top of Babylon.js. Babylon gives rendering, the scene graph, loaders and audio. Ferret adds the game layer Babylon does not have: characters and their movement, collisions and triggers, animation graphs, NPC behaviour, transformations, interactables, zones, levels and level travel, UI, media, networking, and a family of realistic-physics capabilities.

The same game build runs as an OS Beroun app (its web engine, its app packages, its Platform API) and as a web page on a desktop or phone, on screens from the console's 640×480 up to 4K.

The gate towers of a castle level
A level in a browser. More pictures.

See it run: a duel with a Dragon#

The fight example (examples/fight) is a Viking against a Crusader Knight on a 1200 by 1200 m field of spruces, bushes and mountains, while Knight Lady Kira flies a Dragon that breathes fire over them. The fighters are played by the rules in @ferret/combat (blows, blocks, dodges, stamina, staggers, death), steered by an AI or by you; the Dragon is a flight model with its own AI. Everything is built from the asset library, and you can change who you are while it runs.

The duel, running in this page (about 190 MB of models and animations, loaded only when you press the button; this page carries the mobile quality tier). Roles on the fly: 0 observer, 1 knight, 2 viking, 3 the Lady on the Dragon. Fighters: W A S D move, mouse looks, left button strikes (hold for the heavy blow), right button blocks, Space dodges, Shift runs. Dragon: W / S climb and dive, mouse or arrows steer, Space breathes fire, Q / Z speed. Observer: mouse looks, W A S D flies. The legend is on the screen.

The rules, the Dragon and the controls are in the combat guide.

See it run: the school courtyard#

The School Outside example (examples/school-outside) is a level made in Unreal Engine 5 and brought over by Ferret's export pipeline: the castle courtyard with its towers, braziers and torches, walled in by collision that was built from the same scene. You walk it in first person with the original's movement values. The wooden door under the word SCHOOL is the one piece of game logic: step up to it and the player is hidden, the door's video plays on the doorway, the view blends to a cut-scene camera, the leaves open, and the player comes back at the start of the game.

Two minutes in the courtyard, recorded with Ferret's scene recorder: a walk over the level, the notice board with the school's welcome page, and the exit door, whose video plays on the doorway before the player is back at the start.
The same example, running in this page (about 50 MB, loaded only when you press the button; this page carries the light quality tier, the full example has three). Walk: W A S D or the arrow keys. Look: mouse. Jump: Space. Run: Shift. Use: E. Menu: Esc. Walk to the door in the gate to see the exit.

The level package, the door behaviour and the rebuild steps are in examples/school-outside/README.md.

See it run: a five-speed gearbox#

The gearbox example (examples/gearbox) is generated from one file of numbers: 141 solid parts, checked for clashes, meshing and ratios, built into glTF models, then driven by Ferret's physics. Nothing in the picture is animated by hand: the shafts, free gears, sleeves, forks, the crown, the planets and the oil level move from the state of the machine, node by node. Below is a run through the demo, then the demo itself.

Seventy-nine seconds with the controls: engine speed, clutch, gears by hand, housing opacity. A shift with the clutch engaged is refused by the box, as in a car.
The same demo, running in this page (about 19 MB, loaded only when you press the button). Engine: slider or Up / Down. Clutch: Space. Gear: N, 1 to 5, R or Left / Right. Brake: hold B (stop before reverse). Housing: slider or Esc. Drag to orbit, wheel to zoom.

How it is made, the shift, the limits and the wear are in the gearbox guide; the files and the rebuild steps are in examples/gearbox/README.md.

What is in the box#

AreaWhat you getWhere to read
RuntimeA fixed-step World, entities with components, services, an event bus, a debug command channelThe world
PlatformOne interface over OS Beroun and the browser: saved state, suspend, exit, screen, quality tiersPlatform and display
Input and UIActions instead of devices; a responsive HTML overlayInput and UI
GameplayCharacters, animation graphs with random motion, NavMesh AI, interactables, zones, transformations (also by a record shared between players)Gameplay packages
ContentLevels as folders and .ferret packages with a validated manifest; packages that carry code and run it on demandLevels and packages
StreamingLevels and assets over HTTPS: catalogs, a persistent cache, cells that follow the camera, transitions a game definesStreaming and catalogs, Writing a transition
NetworkingReplication over interchangeable transports, remote avatars, shared named records, gateways to a game's backendNetworking
PhysicsTwo rigid-body kernels and sixteen capabilities that add realism only where a game switches it on, down to a transaxle with synchronisers, oil, heat and wearPhysics overview, Gearbox
PresentationCutaway section planes with hatched caps, frame-exact capture to WebM or PNG, reflective environments for metalGameplay packages
ToolsUnreal Engine 5 export pipeline (levels, characters, clips, animation blueprints, look and parity checks), a model viewer, the level editor commands, agent skillsTools, Agent skills

Where Ferret runs#

TargetWeb engineInput
OS Beroun on the consoleWPE WebKit, WebGL2cursor, A, B, D-pad and sticks
OS Beroun on Androidthe system WebView (Chromium 110 or newer)the device's keys, pad, touch
Desktop browserstheir own, WebGL2 (WebGPU where present)keyboard and mouse with Pointer Lock, gamepad
Mobile browserstheir own, WebGL2touch with virtual sticks, gamepad

WebGL2 is the baseline renderer everywhere; nothing in Ferret depends on WebGPU. There is no mouse or Pointer Lock on the console, so games bind actions, and the engine maps devices to them.

How the pieces depend on each other#

Dependencies point one way. A game takes only what it needs; a single-player game never loads net.

core, platform
   ← assets, physics, input
      ← character, animation, ai
         ← transform, interaction, zones
            ← levels, ui, media, net

The physics capabilities sit on top of physics and are independent of each other. Where one capability's output is another's input, a small link in physics-links moves it, so no capability knows about the others.

New here: Getting started, then The world. An overview to show others: the presentation (PDF). Looking for something specific: the API reference lists every export of every package with its signature, and / searches guides and API together.