FERRETGame engine over Babylon.js
Ferret

People (humans)

@ferret/humans builds a person from one JSON spec and needs no character files besides the module's data packs (a base figure, a shape space, level-of-detail tiers, expression targets, the Customizer gait clips). The same spec always gives the same person; a short share code (encodeHuman) carries it over a network, in a manifest or in a chat message.

A figure#

const data = await loadHumanData(name => fetch('humans-assets/' + name).then(r => r.arrayBuffer()));
const spec = { ...defaultHuman(7), kit: 'animal-headed', kitOptions: recipe('wolf'), outfit: { words: 'brown linen tunic, brown boots', pieces: [] } };
const fig = await loadFigure(scene, data, spec, { tier: 'L1m' });   // glb in memory through the glTF loader, locomotion graph on its joints
entity.add(Animator, { graph: fig.graph, groups: fig.groups, loops: fig.loops });

Tiers: full, L0d/L0m (hero), L1d/L1m, L2d/L2m, L3d/L3m (crowd); d = desktop, m = mobile materials. The skeleton is the 87 joints of the Customizer (kits append tails and ears), so every cc-clips clip plays. The body faces +z, left is +x.

What is in a spec#

body (sex, age, height, build, proportions), face (axes, blends, words), skin, eyes, hair, brows, lashes, beard, outfit (words or pieces), motion (gait style axes), kit and kitOptions. describeFace(words) fills the face from a description; fitFaceToLandmarks from a picture's landmarks; outfitFromPicture takes garment colours and patterns from pixels.

Kits and species#

animal-headed, fantasy, reptilian, robot, greek, egyptian, norse. Species are option sets, not a library: recipe('wolf'), fox, cat, bear, rabbit, horse, hawk, elf, orc, dwarf, goblin, giant, lizardfolk, crocodile, android, robot. Proof figures: proofSpec('zeus'), horus, odin, tyr, wolf-guard, orc-warrior, lizard-scout, android-clerk.

Commands#

registerHumansCommands(host, data) gives humans.create / get / set / randomise / preset / dress / validate / diff / describe / report / bake / save / sheet / fromPicture / compare. The viewer (?humans) registers them on world.commands and adds humans.show / clip / expression / light / camera / screenshot / place. humans.bake writes a glb: joint nodes, skin, PBR materials, fabric textures, 51 ARKit morph targets on the head, sockets and chains in the scene extras.

In the game#

  • Manifest: spawns[].human holds a share code (edit.spawn.human sets it); humanAvatarLook is the AvatarLook of Multiplayer (the code travels, each machine builds the person); humanLook is a Look for a Transformer.
  • Crowds: planCrowd + bakeVariant (baked vertex animation, thin instances): 1000 people at tier L3d cost about 1 ms on an RTX 3050.
  • Asset library: node tools/humans/p14-library.mjs writes the proof figures and species as human-* character items (desktop L1m and low L3d glb, validated).
  • Unreal: FerretHumans.h (tail and ear chains, two-bone leg IK, parity-tested against the TypeScript) and FerretHumansNode.h.

What usually goes wrong#

Bending a Customizer bone about its local X (the bone axis) twists it: hinge about Z. Colours in specs are linear. Ferret.humans is its own namespace in the library bundle. A giant needs kitOptions.scale: the shape pack caps height near 2.3 m.