Getting started with Ferret
Skill ferret-getting-started · download all skills · SKILL.md
When to use#
Starting a new game on Ferret, running a sample, or finding out what a build produces.
Do this first#
pnpm install
pnpm build greybox # one sample: dist/web, dist/beroun, dist/lib
pnpm serve # static server for dist/web
Open dist/web/<sample>/index.html through pnpm serve. Samples: greybox (a character in a grey-box level), npc (NavMesh walkers, doors, levers), showcase (media, UI, transformations), physics (the realism capabilities).
The steps of a first game#
createGame({ canvas, storageKey, input: { actions, bindings } })givesworld,platform,scene,display,input, physics.- Build the level's meshes into
scene; static meshes withcheckCollisionsare solid. spawnCharacter(world, 'hero', position)then addPlayerController.game.display.trackCamera(player.rig.camera)so the field of view follows the screen.game.start().
Anything else a game uses (levels, zones, UI, net) is a service you add to the world.
What a build gives#
dist/web/<sample> for browsers; dist/beroun/<sample> as an OS Beroun app (manifest, icon, page, bundle); dist/lib/ferret.js exposes Ferret and BABYLON globals; dist/lib/ferret/ is the release for apps that load the engine from the OS's shared library.
Loading behind the splash#
LoadMarks (parts, load.report), warmUpScene (every shader compiled), releaseWhenReady, new SimHost({ paused: true }) started at the release, neverLowerQuality: true in createGame or the package's game block: everything ready during the splash, nothing loads after it.
Check afterwards#
The page opens, the character moves with the bound actions. Later changes are checked by the test of what changed and built one sample at a time; the whole pnpm test and pnpm build run only when asked. A game's logic goes in the game language (ferret-motion). pnpm docs builds the documentation, pnpm skills these skills.
What usually goes wrong#
- Opening
index.htmlfrom disk instead of throughpnpm serve. - One
storageKeyshared by two games in a browser: give each its own. - Expecting the first frame to hold all assets: they are loaded after the loading screen is up.
Files#
reference/getting-started.md— Install, build, run the samples, write a first game, run the tests, build this documentation.reference/index.md— What Ferret is, what it runs on, and how this documentation is organised.reference/api-game.md— every export of@ferret/gamewith signature and doc commentreference/commands.md— 1 commands of these packages with their arguments