voxolith
API reference@voxolith/gen-creatureFunctions

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

ParameterTypeDefault valueDescription
paramsCreatureParamsundefinedThe creature; not mutated. Start from a PRESETS entry.
rng() => numberundefinedSource 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();

On this page