prepareRigged()
Prepare a rigged rest model to be posed on the GPU (makeCrowd({ rigged: true }), or a renderer instance with parts) instead of baked per pose. The renderer samples each world cell back through every bone's inverse into this one model, as bakePose does per posed cell, so the model is uploaded...
function prepareRigged(
model: EntityModel,
rig: Rig,
cover?: ArrayLike<number> | undefined,
base?: EntityModel
): RiggedModel;Defined in: engine/src/animation/bake.ts:408
Prepare a rigged rest model to be posed on the GPU (makeCrowd({ rigged: true }), or a
renderer instance with parts) instead of baked per pose. The renderer samples each world cell
back through every bone's inverse into this one model, as bakePose does per posed cell,
so the model is uploaded once and only bone matrices change per frame.
The rig's cover is applied here: a voxel that was not on the rest surface draws its cover role
(a limb swinging out shows fur, not flesh), since whatever the GPU draws is exposed. Wounds are
carved into the rest model and so are on its surface, and keep showing their inside. Prepare
again after wound or sever.
Based on the rest-space animation of Gruen, Benthin, Kern and McAllister, "Ray Tracing Massive Amounts of Animated Geometry" (HPG 2026, doi:10.1145/3820014), and Kao, Makowski, Fujieda and Harada, "Voxel Deformation-Aware Neural Intersection Function" (EG 2026, doi:10.2312/egs.20261026). Unlike a bake, the diagonal bridges and crack fill are not reproduced (joints are still welded).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
model | EntityModel | undefined | The rest model; it must carry bones. |
rig | Rig | undefined | The entity's rig. |
cover? | ArrayLike<number> | undefined | rig.cover | Role → cover role table; defaults to rig.cover. |
base? | EntityModel | model | The undamaged model this one was wounded from, if any: its bone boxes (which contain the wounded model's) are used, so every wounded copy shares the base's poses. |
Returns
The model with bone ids and joints, as addModel takes it with parts.
Example
const rest = prepareRigged(rat.model, rat.rig!);
const id = renderer.addModel({ size: rest.size, data: rest.data, parts: rest.parts, joints: rest.joints });
// per frame:
const bones = poseMatrices(rat.rig!, sampleClip(walk, t, rat.rig!.bones.length));
renderer.setInstances([{ model: id, x, y, z, anchor: rest.anchor, yaw, base: ratBase, parts: bones }], { dynamic: true });