generateCreature()
Generate a rigged, animated creature: the rest-pose body built bone by bone, layered inside by depth (fur, fat, flesh, muscle) with bones and organs below the surface, painted, bound to a 26-bone rig, and given walk, turn, run, idle, sniff and death clips at 12 fps. The rig's cover table draws...
function generateCreature(
params: CreatureParams,
rng: () => number,
id?: string
): object;Defined in: index.ts:58
Generate a rigged, animated creature: the rest-pose body built bone by bone, layered inside by
depth (fur, fat, flesh, muscle) with bones and organs below the surface, painted, bound to a
26-bone rig, and given walk, turn, run, idle, sniff and death clips at 12 fps. The rig's
cover table draws flesh a pose uncovers as fur, so only damage shows the inside. Pure and
deterministic in its params and rng.
Coarse only: there is no finer-scale context. For a world at a fixed voxels-per-metre, size the params with atScale first.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
params | CreatureParams | undefined | The creature; not mutated. Start from a PRESETS entry. |
rng | () => number | undefined | Source of all randomness, returning 0..1 (e.g. seededRandom(seed)). |
id? | string | "creature" | The entity id. |
Returns
object
The entity (kind creature, with rig and clips, nose towards +z, anchored on the
ground under the middle of the body) and stats.
entity
entity: Entity;stats
stats: CreatureStats;Example
import { seededRandom } from "@voxolith/renderer/core";
import { makeAnimator } from "@voxolith/engine/animation";
import { generateCreature, PRESETS } from "@voxolith/gen-creature";
const { entity } = generateCreature(PRESETS["grey rat"], seededRandom(9));
const anim = makeAnimator(entity, "walk");
for (const e of anim.update(dt)) if (e.name.startsWith("foot.")) footstep();cloneParams()
Copy of the params, so presets are never mutated by a caller.
minVoxelsPerMetre()
The smallest world scale, in voxels per metre, at which atScale builds this creature at its real size (see realSizeAt): about 84 for the default rat (size 1.2), 88 for the fat rat (1.15). Scales from here up to about 250 vox/m are real size. The size snaps to a 0.05 grid, so this is where the...