Crowd
Skill ferret-crowd · download all skills · SKILL.md
When to use#
Many animated characters on screen at once: streets, battles, stadiums, herds. For still objects (wrecks, trees, aircraft without bones) use ferret-perspective alone.
The model#
A CrowdModel is made once per character from a skinned instance (mid, its lightest tier) and a factory of full instances; agents of that model share its VAT set, impostor atlas and full-instance pool. Each agent is an entity with a Perspective ladder (full, vat, impostor, point, none) and a CrowdAgent (clip, phase, rate, tint); every rung shows the same moment of the same clip.
Steps#
new BabylonBackend(scene),world.addService(new PerspectiveService({ backend, budget: { maxFull } })),world.addService(new CrowdService(backend)).- A model:
crowdModelFromLibrary(scene, lib, id, { walk: 'cc-clips/Walk_Fwd', idle: 'cc-clips/Idle' }, { cache, maxFull }), orCrowdModel.prepare(scene, { key, clips, mid, full })for your own glb. - Agents:
spawnCrowdAgent(world, model, { position, heading, clip, phase, rate, tint, wander | path }), or move the entity yourself and callagent.play(name). - Pass the persistent cache: the bakes and the measured ladder are kept by
key(name the content and a version). - Look with
crowd.stats,crowd.list,perspective.force(?force=vatin examples/crowd), andnode tools/crowd/check.mjs.
Check afterwards#
crowd.stats shows a handful of full, most agents at vat / impostor; the run is the same with and without the view (agents move in the fixed step); the sample's numbers on the RTX hold.
What usually goes wrong#
- Agents slide: the clip's speed is measured from root motion or the feet; give
speedin the clip spec when the measurement is wrong. - VAT figures missing parts: parts must ride a bone (child nodes of a joint) or be skinned; loose objects elsewhere are left out.
- VAT figures in the wrong place or mirrored: a mesh with its own world transform; the set compensates
W * A * W^-1with the first mesh'sW, so all meshes of a model need the same world matrix. - Shader errors with many bones and instances: the VAT rung uses 4 influences; do not add more per-instance attributes.
- Bake takes long the first time: it is cached; pass
cacheand keepkeystable.
Files#
reference/crowd.md— gameplay/crowd.mdreference/api-crowd.md— every export of@ferret/crowdwith signature and doc commentreference/commands.md— 4 commands of these packages with their arguments