Skip to content

@bendyline/molen-figures/kernel ​

Molen figures capability: stylized human, biped and quadruped rigs, gaits and sockets (kernel) with procedural skinned bodies (client).

ts
import { /* … */ } from '@bendyline/molen-figures/kernel';

Classes ​

SkinnedMeshBuilder ​

Constructors ​

Constructor ​
ts
new SkinnedMeshBuilder(): SkinnedMeshBuilder;
Returns ​

SkinnedMeshBuilder

Methods ​

box() ​
ts
box(
   region, 
   min, 
   max, 
   s, 
   color
): void;

An axis-aligned box with hard (per-face) normals.

Parameters ​
region ​

FigureRegion

min ​

Vec3

max ​

Vec3

s ​

Skin

color ​

RGB

Returns ​

void

cap() ​
ts
cap(
   region, 
   ring, 
   s, 
   color, 
   apex?, 
   outward?
): number;

Fan-close a ring onto a new vertex at apex (default: the ring center).

Parameters ​
region ​

FigureRegion

ring ​

RingRef

s ​

Skin

color ​

RGB

apex? ​

Vec3

outward? ​

boolean

Returns ​

number

disc() ​
ts
disc(
   region, 
   center, 
   normal, 
   radius, 
   sides, 
   s, 
   color
): void;

A flat disc facing normal (hard normal), fanned from its center.

Parameters ​
region ​

FigureRegion

center ​

Vec3

normal ​

Vec3

radius ​

number

sides ​

number

s ​

Skin

color ​

RGB

Returns ​

void

ellipsoid() ​
ts
ellipsoid(
   region, 
   center, 
   axis, 
   radii, 
   segments, 
   rings, 
   s, 
   color, 
   latMin?, 
   latMax?
): RingRef | undefined;

A lat-long ellipsoid with its polar axis along axis (unit), radii (a, b, c) along the two tangents and the axis; latMin/latMax (−1..1, fraction of the axis) crop it for caps and shells. Returns the ring nearest latMin when the bottom is open.

Parameters ​
region ​

FigureRegion

center ​

Vec3

axis ​

Vec3

radii ​

Vec3

segments ​

number

rings ​

number

s ​

Skin

color ​

RGB

latMin? ​

number

latMax? ​

number

Returns ​

RingRef | undefined

finalize() ​
ts
finalize(tier, skinned?): SkinnedMeshBuffers;

Smooth (area-weighted) normals for shared vertices; hard normals where given; quantized.

Parameters ​
tier ​

FigureTier

skinned? ​

boolean

Returns ​

SkinnedMeshBuffers

loft() ​
ts
loft(
   region, 
   a, 
   b
): void;

Quads between two rings of equal side count (b is "further along" the segment).

Parameters ​
region ​

FigureRegion

a ​

RingRef

b ​

RingRef

Returns ​

void

mark() ​
ts
mark(): number;

Vertex count so far (a mark for mirrorX).

Returns ​

number

mirrorX() ​
ts
mirrorX(mark, jointMirror): void;

Duplicate everything emitted since mark mirrored across x = 0 with reversed winding and remapped joints, in the same order (deterministic left/right symmetry).

Parameters ​
mark ​

number

jointMirror ​

(joint) => number

Returns ​

void

quad() ​
ts
quad(
   region, 
   a, 
   b, 
   c, 
   d
): void;
Parameters ​
region ​

FigureRegion

a ​

number

b ​

number

c ​

number

d ​

number

Returns ​

void

ring() ​
ts
ring(
   region, 
   center, 
   axis, 
   rx, 
   rz, 
   sides, 
   s, 
   color, 
   phase?
): RingRef;

A ring of sides vertices around center in the plane perpendicular to axis, with radii rx along the first tangent and rz along the second (for a vertical axis: +X and +Z). bulge offsets the ring along the axis per vertex (0..1 of rx) for organic caps.

Parameters ​
region ​

FigureRegion

center ​

Vec3

axis ​

Vec3

rx ​

number

rz ​

number

sides ​

number

s ​

Skin

color ​

RGB

phase? ​

number

Returns ​

RingRef

triangle() ​
ts
triangle(
   region, 
   a, 
   b, 
   c
): void;
Parameters ​
region ​

FigureRegion

a ​

number

b ​

number

c ​

number

Returns ​

void

triangleCount() ​
ts
triangleCount(): number;
Returns ​

number

vertex() ​
ts
vertex(
   p, 
   color, 
   s, 
   hardNormal?
): number;

Append a vertex; returns its index.

Parameters ​
p ​

Vec3

color ​

RGB

s ​

Skin

hardNormal? ​

Vec3

Returns ​

number

Interfaces ​

FigureAttachmentData ​

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

anchor? ​
ts
optional anchor?: FigureAnchor;

Which point of the attached entity sits on the socket (default origin).

offset? ​
ts
optional offset?: object;

Extra socket-local offset.

pos? ​
ts
optional pos?: Vec3;
rot? ​
ts
optional rot?: Quat;
socket ​
ts
socket: string;

Socket name on the parent figure, e.g. 'head.top', 'hand.r', 'back', 'saddle'.


FigureBody ​

Properties ​

bounds ​
ts
bounds: FigureBounds;
buffers ​
ts
buffers: SkinnedMeshBuffers;
inverseBind ​
ts
inverseBind: Float32Array;

16 floats (column-major) per joint: the inverse of its rest-pose figure-space transform.

rig ​
ts
rig: FigureRig;

FigureBounds ​

Properties ​

max ​
ts
max: Vec3;
min ​
ts
min: Vec3;
sphere ​
ts
sphere: object;
center ​
ts
center: Vec3;
radius ​
ts
radius: number;

FigureData ​

The authored descriptor: a preset plus overrides (the figure component and molen/figure@1).

Extends ​

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

age? ​
ts
optional age?: FigureAge;
Inherited from ​

FigureDescriptor.age

blendTicks? ​
ts
optional blendTicks?: number;

Ticks to blend between modes (default 12).

build? ​
ts
optional build?: number;
Inherited from ​

FigureDescriptor.build

facing? ​
ts
optional facing?: "velocity" | "manual";

How the figure turns: toward its velocity (default) or left to whoever writes transform.rot.

features? ​
ts
optional features?: Partial<FigureFeatures>;
Inherited from ​

FigureDescriptor.features

height? ​
ts
optional height?: number;
Inherited from ​

FigureDescriptor.height

palette? ​
ts
optional palette?: Partial<FigurePalette>;
Inherited from ​

FigureDescriptor.palette

preset ​
ts
preset: 
  | "human.adult"
  | "human.child"
  | "human.elder"
  | "dog"
  | "cat"
  | "horse"
  | "deer"
  | "cow"
  | "sheep";
Inherited from ​

FigureDescriptor.preset

proportions? ​
ts
optional proportions?: Partial<FigureProportions>;
Inherited from ​

FigureDescriptor.proportions

seed? ​
ts
optional seed?: string;
Inherited from ​

FigureDescriptor.seed

speedSource? ​
ts
optional speedSource?: "auto" | "transform" | "none";

Where speed comes from: movers/velocities ('auto', default), transform deltas, or nothing.

turnRate? ​
ts
optional turnRate?: number;

Max turn rate in rad/s for facing: 'velocity' (default 10).


FigureDescriptor ​

The authored descriptor: a preset plus overrides (the figure component and molen/figure@1).

Extends ​

  • JsonObject

Extended by ​

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

age? ​
ts
optional age?: FigureAge;
build? ​
ts
optional build?: number;
features? ​
ts
optional features?: Partial<FigureFeatures>;
height? ​
ts
optional height?: number;
palette? ​
ts
optional palette?: Partial<FigurePalette>;
preset ​
ts
preset: 
  | "human.adult"
  | "human.child"
  | "human.elder"
  | "dog"
  | "cat"
  | "horse"
  | "deer"
  | "cow"
  | "sheep";
proportions? ​
ts
optional proportions?: Partial<FigureProportions>;
seed? ​
ts
optional seed?: string;

FigureEntry ​

Properties ​

descriptor ​
ts
descriptor: ResolvedFigureDescriptor;
key ​
ts
key: string;
rig ​
ts
rig: FigureRig;
seed ​
ts
seed: number;

FigureFeatures ​

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

ears ​
ts
ears: FigureEarStyle;
feet ​
ts
feet: FigureFootStyle;
hair ​
ts
hair: FigureHairStyle;
hands ​
ts
hands: FigureHandStyle;
horns ​
ts
horns: FigureHornStyle;
legs ​
ts
legs: FigureLegwearStyle;
mane ​
ts
mane: boolean;
sleeves ​
ts
sleeves: FigureSleeveStyle;
tail ​
ts
tail: FigureTailStyle;

FigureIntentData ​

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

footIk? ​
ts
optional footIk?: boolean;

Plant feet on the ground field (opt-in; both halves must sample the same ground).

ik? ​
ts
optional ik?: Partial<Record<FigureIkEffector, Vec3>>;

Figure-local effector goals solved by two-bone IK after the gait.

lookAt? ​
ts
optional lookAt?: 
  | {
  pos: Vec3;
}
  | {
  entity: string;
};

Aim the head at a world point or another entity.

mode? ​
ts
optional mode?: FigureMode;

Force a mode instead of deriving it from motion.

overrides? ​
ts
optional overrides?: Record<string, Quat>;

Joint-local rotations by canonical joint name, replacing the gait for those joints.


FigureJoint ​

Properties ​

bindPos ​
ts
bindPos: Vec3;

Parent-local rest offset, meters.

bindRot ​
ts
bindRot: Quat;
length ​
ts
length: number;

Length of the segment this joint drives, meters (0 for leaf/helper joints).

name ​
ts
name: string;
parent ​
ts
parent: number;

Parent joint index, always smaller than the joint's own index; -1 for the root.


FigureMeshGroup ​

Properties ​

count ​
ts
count: number;

Number of indices in the group.

region ​
ts
region: FigureRegion;
start ​
ts
start: number;

Offset into indices of the group's first index.


FigureMetrics ​

Properties ​

ankleHeight ​
ts
ankleHeight: number;
archetype ​
ts
archetype: FigureArchetype;
bodyLength ​
ts
bodyLength: number;
bodyRadius ​
ts
bodyRadius: number;
chestLen ​
ts
chestLen: number;
chestZ ​
ts
chestZ: number;
earLen ​
ts
earLen: number;
footLen ​
ts
footLen: number;
foreArmLen ​
ts
foreArmLen: number;
handLen ​
ts
handLen: number;
headHeight ​
ts
headHeight: number;
headLen ​
ts
headLen: number;

Head length along its axis (biped: up; quadruped: forward along the muzzle).

headPitch ​
ts
headPitch: number;

Quadruped head pitch below the neck line, radians.

headWidth ​
ts
headWidth: number;
height ​
ts
height: number;
hipHalf ​
ts
hipHalf: number;
hipHeight ​
ts
hipHeight: number;
hipsLen ​
ts
hipsLen: number;

hips → spine, spine → chest, chest → neck segment lengths.

hipZ ​
ts
hipZ: number;
legLength ​
ts
legLength: number;

Hip-to-ankle (biped) or shoulder-to-ground (quadruped) length: the Froude scale.

legY ​
ts
legY: number;

Quadruped leg joint height (shoulder and hip).

limbRadius ​
ts
limbRadius: number;
lowerLegLen ​
ts
lowerLegLen: number;
neckLen ​
ts
neckLen: number;
neckPitch ​
ts
neckPitch: number;
quadFootLen ​
ts
quadFootLen: number;
quadLowerLen ​
ts
quadLowerLen: number;
quadToesLen ​
ts
quadToesLen: number;
quadUpperLen ​
ts
quadUpperLen: number;
shoulderHalf ​
ts
shoulderHalf: number;
snoutLen ​
ts
snoutLen: number;
spineLen ​
ts
spineLen: number;
tailLen ​
ts
tailLen: number;
torsoRadius ​
ts
torsoRadius: number;
upperArmLen ​
ts
upperArmLen: number;
upperLegLen ​
ts
upperLegLen: number;

FigurePalette ​

Colors as "#rrggbb" (sRGB). Skin doubles as fur/hide for animals; markings are secondary.

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

accent ​
ts
accent: string;
bottom ​
ts
bottom: string;
eyes ​
ts
eyes: string;
hair ​
ts
hair: string;
markings ​
ts
markings: string;
shoes ​
ts
shoes: string;
skin ​
ts
skin: string;
top ​
ts
top: string;

FigurePose ​

Properties ​

local ​
ts
local: Float32Array;

7 floats per joint in rig order: parent-local position xyz and rotation xyzw.

rig ​
ts
rig: FigureRig;

FigurePreset ​

Properties ​

age ​
ts
age: FigureAge;
archetype ​
ts
archetype: FigureArchetype;
build ​
ts
build: number;
features ​
ts
features: FigureFeatures;
height ​
ts
height: number;
palette ​
ts
palette: FigurePalette;
proportions ​
ts
proportions: FigureProportions;
species ​
ts
species: FigureSpecies;

FigureProportions ​

Proportion multipliers applied to the archetype's canonical segment table (1 = preset).

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

armRatio ​
ts
armRatio: number;
bodyLength ​
ts
bodyLength: number;

Quadruped body length as a multiple of height (withers).

earSize ​
ts
earSize: number;
headScale ​
ts
headScale: number;
hipWidth ​
ts
hipWidth: number;
legRatio ​
ts
legRatio: number;
neckLength ​
ts
neckLength: number;
neckPitch ​
ts
neckPitch: number;

Neck pitch above the spine line, radians (quadrupeds; 0 for bipeds).

shoulderWidth ​
ts
shoulderWidth: number;
snoutLength ​
ts
snoutLength: number;

Snout length as a multiple of the head unit (0 = flat face).

tailLength ​
ts
tailLength: number;

Tail length as a multiple of height.

torsoRatio ​
ts
torsoRatio: number;

FigureRig ​

Properties ​

archetype ​
ts
archetype: FigureArchetype;
eyeHeight ​
ts
eyeHeight: number;
height ​
ts
height: number;
hipHeight ​
ts
hipHeight: number;
index ​
ts
index: Readonly<Record<string, number>>;
joints ​
ts
joints: readonly FigureJoint[];
key ​
ts
key: string;

Content key of the descriptor this rig was derived from.

legLength ​
ts
legLength: number;
metrics ​
ts
metrics: FigureMetrics;
socketIndex ​
ts
socketIndex: Readonly<Record<string, number>>;
sockets ​
ts
sockets: readonly FigureSocket[];

FigureRuntime ​

Properties ​

world ​
ts
readonly world: World;

Methods ​

entryFor() ​
ts
entryFor(id): FigureEntry | undefined;

The resolved rig of a figure entity (cached), or undefined when it has no valid figure.

Parameters ​
id ​

string

Returns ​

FigureEntry | undefined

poseFor() ​
ts
poseFor(id, tick): FigurePose | undefined;

The entity's pose at a tick, with its intent, look-at, and anchor applied (memoized per tick).

Parameters ​
id ​

string

tick ​

number

Returns ​

FigurePose | undefined

socketLocal() ​
ts
socketLocal(
   id, 
   socket, 
   tick
): TransformLike | undefined;

A socket's figure-space transform under the entity's current pose.

Parameters ​
id ​

string

socket ​

string

tick ​

number

Returns ​

TransformLike | undefined

socketWorld() ​
ts
socketWorld(
   id, 
   socket, 
   tick
): TransformLike | undefined;

A socket's world-space transform.

Parameters ​
id ​

string

socket ​

string

tick ​

number

Returns ​

TransformLike | undefined

warnOnce() ​
ts
warnOnce(id, code): void;

Emit figures-error once per (entity, code).

Parameters ​
id ​

string

code ​

string

Returns ​

void


FiguresHandle ​

Properties ​

runtime ​
ts
readonly runtime: FigureRuntime;
world ​
ts
readonly world: World;

Methods ​

attach() ​
ts
attach(
   itemId, 
   figureId, 
   socket, 
   offset?, 
   anchor?
): boolean;

Parent itemId to a figure socket; places it immediately so it never pops.

Parameters ​
itemId ​

string

figureId ​

string

socket ​

string

offset? ​
pos? ​

Vec3

rot? ​

Quat

anchor? ​

FigureAnchor

Returns ​

boolean

descriptorOf() ​
ts
descriptorOf(id): ResolvedFigureDescriptor | undefined;
Parameters ​
id ​

string

Returns ​

ResolvedFigureDescriptor | undefined

detach() ​
ts
detach(itemId, opts?): boolean;

Remove the attachment (and by default the parent link), keeping the world pose.

Parameters ​
itemId ​

string

opts? ​
keepWorld? ​

boolean

Returns ​

boolean

dismount() ​
ts
dismount(riderId): boolean;
Parameters ​
riderId ​

string

Returns ​

boolean

dispose() ​
ts
dispose(): void;
Returns ​

void

mount() ​
ts
mount(
   riderId, 
   figureId, 
   seat?
): boolean;

Seat a rider on a figure mount (adds mountable from the rig when absent).

Parameters ​
riderId ​

string

figureId ​

string

seat? ​

string

Returns ​

boolean

poseAt() ​
ts
poseAt(id, tick?): FigurePose | undefined;

The entity's pose at a tick (default: the current tick).

Parameters ​
id ​

string

tick? ​

number

Returns ​

FigurePose | undefined

rigOf() ​
ts
rigOf(id): FigureRig | undefined;
Parameters ​
id ​

string

Returns ​

FigureRig | undefined

socket() ​
ts
socket(
   id, 
   name, 
   tick?
): TransformLike | undefined;

A socket's world transform at a tick (default: the current tick).

Parameters ​
id ​

string

name ​

string

tick? ​

number

Returns ​

TransformLike | undefined


FigureSocket ​

Properties ​

joint ​
ts
joint: number;
name ​
ts
name: string;
pos ​
ts
pos: Vec3;

Joint-local offset, meters.

rot ​
ts
rot: Quat;

Joint-local orientation; +Z of the socket faces "out".


FiguresOptions ​

Extends ​

Properties ​

groundHeight? ​
ts
optional groundHeight?: (x, z) => number;

Ground height at a world XZ (default: the world's ground field, else y = 0).

Parameters ​
x ​

number

z ​

number

Returns ​

number

Inherited from ​

LocomotionOptions.groundHeight


FigureStateData ​

Kernel-owned, piecewise-constant: written only when motion changes, never per tick.

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

gait? ​
ts
optional gait?: FigureGait;
lookAtTick? ​
ts
optional lookAtTick?: number;

Tick the look-at target last changed (aim blend start).

mode ​
ts
mode: FigureMode;
modeAtTick ​
ts
modeAtTick: number;

Tick the current mode began (blend start).

phaseAt ​
ts
phaseAt: number;

Gait phase [0, 1) at phaseAtTick; phase(t) = frac(phaseAt + strideRate * (t - phaseAtTick) / tickRate).

phaseAtTick ​
ts
phaseAtTick: number;
prevMode? ​
ts
optional prevMode?: FigureMode;
speed ​
ts
speed: number;

Planar speed, m/s, quantized.

strideRate ​
ts
strideRate: number;

Gait cycles per second.

travel? ​
ts
optional travel?: number;

Travel direction relative to facing, radians (absent = forward).


LocomotionMemory ​

Previous positions of transform-delta figures, kept as a snapshot provider blob.

Properties ​

prev ​
ts
prev: Record<EntityId, Vec3>;

LocomotionOptions ​

Extended by ​

Properties ​

groundHeight? ​
ts
optional groundHeight?: (x, z) => number;

Ground height at a world XZ (default: the world's ground field, else y = 0).

Parameters ​
x ​

number

z ​

number

Returns ​

number


PoseBuffer ​

Properties ​

q ​
ts
q: Float32Array;

4 floats per joint: [x, y, z, w].

root ​
ts
root: Float32Array;

Root translation [x, y, z] added to the root joint's bind offset.


PoseEvalOptions ​

Properties ​

anchor? ​
ts
optional anchor?: FigureAnchor;

Re-anchor the root so this point sits at the figure origin (seats, saddles).

blendTicks? ​
ts
optional blendTicks?: number;

Ticks to blend from state.prevMode (default 12).

ik? ​
ts
optional ik?: Partial<Record<FigureIkEffector, Vec3>>;

Figure-local effector goals solved after the gait.

lookTarget? ​
ts
optional lookTarget?: Vec3;

Figure-local point the head aims at.

lookWeight? ​
ts
optional lookWeight?: number;

0..1 weight of the look-at (default 1).

overrides? ​
ts
optional overrides?: Record<string, Quat>;

Joint-local rotations by name that replace the evaluated rotation.

seed? ​
ts
optional seed?: number;

Seed for idle variation (see figureSeed).

tickRate ​
ts
tickRate: number;

ResolvedFigureDescriptor ​

A descriptor with every preset default filled in: the input of the rig and body generators.

Extends ​

  • JsonObject

Indexable ​

ts
[key: string]: JsonValue | undefined

Properties ​

age ​
ts
age: FigureAge;
archetype ​
ts
archetype: FigureArchetype;
build ​
ts
build: number;

-1 (slight) … 1 (heavy): limb and torso radii, shoulder width.

features ​
ts
features: FigureFeatures;
height ​
ts
height: number;

Standing height (bipeds: head top; quadrupeds: withers), meters.

palette ​
ts
palette: FigurePalette;
preset ​
ts
preset: 
  | "human.adult"
  | "human.child"
  | "human.elder"
  | "dog"
  | "cat"
  | "horse"
  | "deer"
  | "cow"
  | "sheep";
proportions ​
ts
proportions: FigureProportions;
seed ​
ts
seed: string;

Symmetry-safe detail jitter only; '' = none.

species ​
ts
species: FigureSpecies;

RingRef ​

Properties ​

center ​
ts
center: Vec3;
sides ​
ts
sides: number;
start ​
ts
start: number;

Index of the ring's first vertex.


SkinnedMeshBuffers ​

Properties ​

bytes ​
ts
bytes: number;
colors ​
ts
colors: Uint8Array;

8-bit linear RGB triplets.

groups ​
ts
groups: FigureMeshGroup[];
indices ​
ts
indices: Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>;
joints? ​
ts
optional joints?: Uint8Array<ArrayBufferLike>;

4 joint indices per vertex (2 used); absent on rigid tiers.

normals ​
ts
normals: Float32Array;
positions ​
ts
positions: Float32Array;
tier ​
ts
tier: FigureTier;
triangleCount ​
ts
triangleCount: number;
vertexCount ​
ts
vertexCount: number;
weights? ​
ts
optional weights?: Float32Array<ArrayBufferLike>;

4 weights per vertex summing to 1; absent on rigid tiers.


TwoBoneSolution ​

Properties ​

lowerDir ​
ts
lowerDir: Vec3;

Unit direction of the lower segment (middle joint to effector).

mid ​
ts
mid: Vec3;

Middle joint position.

reached ​
ts
reached: boolean;

False when the target was clamped to the reachable annulus.

upperDir ​
ts
upperDir: Vec3;

Unit direction of the upper segment (root to middle joint).

Type Aliases ​

FigureAge ​

ts
type FigureAge = "child" | "adult" | "elder";

FigureAnchor ​

ts
type FigureAnchor = "origin" | "pelvis" | "eye";

FigureArchetype ​

ts
type FigureArchetype = "biped" | "quadruped";

FigureEarStyle ​

ts
type FigureEarStyle = "none" | "round" | "pointed" | "floppy";

FigureFootStyle ​

ts
type FigureFootStyle = "plantigrade" | "digitigrade" | "unguligrade";

FigureGait ​

ts
type FigureGait = "walk" | "trot" | "gallop";

FigureHairStyle ​

ts
type FigureHairStyle = "none" | "cap" | "bob" | "long";

FigureHandStyle ​

ts
type FigureHandStyle = "mitten" | "fingers";

FigureHornStyle ​

ts
type FigureHornStyle = "none" | "short" | "long" | "antlers";

FigureIkEffector ​

ts
type FigureIkEffector = "hand.l" | "hand.r" | "foot.l" | "foot.r";

FigureLegwearStyle ​

ts
type FigureLegwearStyle = "shorts" | "long";

FigureMode ​

ts
type FigureMode = "idle" | "walk" | "run" | "jump" | "fall" | "sit" | "custom";

FigurePresetId ​

ts
type FigurePresetId = typeof FIGURE_PRESET_IDS[number];

FigureRegion ​

ts
type FigureRegion = 
  | "skin"
  | "hair"
  | "brow"
  | "eyes"
  | "top"
  | "sleeves"
  | "bottom"
  | "shoes"
  | "accent"
  | "markings";

FigureSleeveStyle ​

ts
type FigureSleeveStyle = "none" | "short" | "long";

FigureSpecies ​

ts
type FigureSpecies = "human" | "dog" | "cat" | "horse" | "deer" | "cow" | "sheep";

FigureTailStyle ​

ts
type FigureTailStyle = "none" | "short" | "long" | "bushy";

FigureTier ​

ts
type FigureTier = 0 | 1 | 2;

RGB ​

ts
type RGB = [number, number, number];

Linear RGB, each channel 0..1.


Skin ​

ts
type Skin = readonly [number, number, number, number];

A pair of joint influences: [joint, weight] each; weights need not be normalized.

Variables ​

BIPED_JOINT_NAMES ​

ts
const BIPED_JOINT_NAMES: readonly string[];

BIPED_SOCKET_NAMES ​

ts
const BIPED_SOCKET_NAMES: readonly string[];

Figure ​

ts
const Figure: ComponentType<FigureData>;

FIGURE_ATTACHMENT_COMPONENT ​

ts
const FIGURE_ATTACHMENT_COMPONENT: "figureAttachment";

FIGURE_COMPONENT ​

ts
const FIGURE_COMPONENT: "figure";

FIGURE_EXAMPLE ​

ts
const FIGURE_EXAMPLE: JsonValue;

FIGURE_FILE_EXAMPLE ​

ts
const FIGURE_FILE_EXAMPLE: JsonValue;

FIGURE_FORMAT ​

ts
const FIGURE_FORMAT: "molen/figure@1";

FIGURE_INTENT_COMPONENT ​

ts
const FIGURE_INTENT_COMPONENT: "figureIntent";

FIGURE_MODES ​

ts
const FIGURE_MODES: readonly FigureMode[];

FIGURE_PRESET_IDS ​

ts
const FIGURE_PRESET_IDS: readonly ["human.adult", "human.child", "human.elder", "dog", "cat", "horse", "deer", "cow", "sheep"];

Shipped presets; molen figure presets lists them with their descriptors.


FIGURE_PRESETS ​

ts
const FIGURE_PRESETS: Readonly<Record<FigurePresetId, FigurePreset>>;

FIGURE_REGIONS ​

ts
const FIGURE_REGIONS: readonly FigureRegion[];

Fixed region order used when concatenating mesh groups.


FIGURE_STATE_COMPONENT ​

ts
const FIGURE_STATE_COMPONENT: "figureState";

FigureAttachment ​

ts
const FigureAttachment: ComponentType<FigureAttachmentData>;

figureDescriptorFields ​

ts
const figureDescriptorFields: object;

The descriptor fields (no envelope): shared by the component and the file format.

Type Declaration ​

age ​
ts
age: z.ZodType<FigureDescriptor["age"]>;
build ​
ts
build: z.ZodType<number | undefined>;
features ​
ts
features: z.ZodType<Partial<FigureFeatures> | undefined>;
height ​
ts
height: z.ZodType<number | undefined>;
palette ​
ts
palette: z.ZodType<Partial<FigurePalette> | undefined>;
preset ​
ts
preset: z.ZodType<FigureDescriptor["preset"]>;
proportions ​
ts
proportions: z.ZodType<Partial<FigureProportions> | undefined>;
seed ​
ts
seed: z.ZodType<string | undefined>;

figureDescriptorSchema ​

ts
const figureDescriptorSchema: z.ZodType<FigureDescriptor>;

FigureIntent ​

ts
const FigureIntent: ComponentType<FigureIntentData>;

FigureState ​

ts
const FigureState: ComponentType<FigureStateData>;

GRAVITY ​

ts
const GRAVITY: number;

QUADRUPED_JOINT_NAMES ​

ts
const QUADRUPED_JOINT_NAMES: readonly string[];

QUADRUPED_SOCKET_NAMES ​

ts
const QUADRUPED_SOCKET_NAMES: readonly string[];

Functions ​

attachmentLocal() ​

ts
function attachmentLocal(socket, attachment): TransformLike;

The socket-local transform of an attachment: socket composed with the authored offset.

Parameters ​

socket ​

TransformLike

attachment ​

FigureAttachmentData

Returns ​

TransformLike


bipedRunFor() ​

ts
function bipedRunFor(fr, wasRunning): boolean;

Biped walk/run choice from Froude with hysteresis (run above 0.5, back below 0.4).

Parameters ​

fr ​

number

wasRunning ​

boolean

Returns ​

boolean


createFigureRuntime() ​

ts
function createFigureRuntime(world): FigureRuntime;

Parameters ​

world ​

World

Returns ​

FigureRuntime


deriveMetrics() ​

ts
function deriveMetrics(d): FigureMetrics;

Parameters ​

d ​

ResolvedFigureDescriptor

Returns ​

FigureMetrics


deriveRig() ​

ts
function deriveRig(d): FigureRig;

Derive the canonical rig of a resolved descriptor (pure; cache by descriptorKey).

Parameters ​

d ​

ResolvedFigureDescriptor

Returns ​

FigureRig


descriptorKey() ​

ts
function descriptorKey(resolved): string;

Stable content key of a resolved descriptor (same body ⇔ same key, in any process).

Parameters ​

resolved ​

ResolvedFigureDescriptor

Returns ​

string


evaluatePose() ​

ts
function evaluatePose(
   rig, 
   state, 
   tick, 
   opts, 
   out?
): FigurePose;

Evaluate the pose of a rig at a tick. state undefined means a standing idle. Pass out to reuse a pose buffer of the same rig (no allocation per call).

Parameters ​

rig ​

FigureRig

state ​

FigureStateData | undefined

tick ​

number

opts ​

PoseEvalOptions

out? ​

FigurePose

Returns ​

FigurePose


figureBodyKey() ​

ts
function figureBodyKey(descriptor, tier): string;

Content key of one body: descriptor key plus tier.

Parameters ​

descriptor ​

ResolvedFigureDescriptor

tier ​

FigureTier

Returns ​

string


figureMountable() ​

ts
function figureMountable(rig): MountableData;

A mountable component for a figure: rideable sockets become passenger seats.

Parameters ​

rig ​

FigureRig

Returns ​

MountableData


figurePhase() ​

ts
function figurePhase(
   state, 
   tick, 
   tickRate
): number;

Gait phase in [0, 1) at a (possibly fractional) tick.

Parameters ​

state ​

FigureStateData

tick ​

number

tickRate ​

number

Returns ​

number


figurePreset() ​

ts
function figurePreset(id): FigurePreset;

Parameters ​

id ​

| "human.adult" | "human.child" | "human.elder" | "dog" | "cat" | "horse" | "deer" | "cow" | "sheep"

Returns ​

FigurePreset


figureSeed() ​

ts
function figureSeed(seed, entityId): number;

The integer seed of a figure: its descriptor seed, else the entity id.

Parameters ​

seed ​

string | undefined

entityId ​

string

Returns ​

number


figuresOf() ​

ts
function figuresOf(world): FiguresHandle | undefined;

The figures handle installed on a world, if any.

Parameters ​

world ​

World

Returns ​

FiguresHandle | undefined


figuresScriptApi() ​

ts
function figuresScriptApi(handle): object;

The script-api namespace for figures (molen.figures.*); pass via buildWorld capabilities.

Parameters ​

handle ​

FiguresHandle

Returns ​

object


figureToWorld() ​

ts
function figureToWorld(entity, local): TransformLike;

A figure-space transform into world space through the entity transform.

Parameters ​

entity ​

TransformLike

local ​

TransformLike

Returns ​

TransformLike


fmix32() ​

ts
function fmix32(x): number;

murmur3 finalizer: a full-avalanche 32-bit mix.

Parameters ​

x ​

number

Returns ​

number


froude() ​

ts
function froude(speed, legLength): number;

Froude number v² / (g · L): the dimensionless gait speed.

Parameters ​

speed ​

number

legLength ​

number

Returns ​

number


generateFigureBody() ​

ts
function generateFigureBody(
   descriptor, 
   tier, 
   rig?
): FigureBody;

Generate the body of a resolved descriptor at a detail tier (0 near, 1 medium, 2 distant rigid). Pass the rig when already derived; it must come from the same descriptor.

Parameters ​

descriptor ​

ResolvedFigureDescriptor

tier ​

FigureTier

rig? ​

FigureRig

Returns ​

FigureBody


idleThresholds() ​

ts
function idleThresholds(height): object;

Idle/moving speed thresholds (m/s) with hysteresis, scaled by height.

Parameters ​

height ​

number

Returns ​

object

enter ​
ts
enter: number;
exit ​
ts
exit: number;

installFigures() ​

ts
function installFigures(world, opts?): FiguresHandle;

Install the figures systems (idempotent per world) and return the handle.

Parameters ​

world ​

World

opts? ​

FiguresOptions

Returns ​

FiguresHandle


jointTransform() ​

ts
function jointTransform(model, joint): TransformLike;

A joint's figure-space transform from a model buffer.

Parameters ​

model ​

Float32Array

joint ​

number

Returns ​

TransformLike


mirrorName() ​

ts
function mirrorName(name): string;

The name of the mirrored joint or socket ('.l' ↔ '.r', 'fl' ↔ 'fr', 'hl' ↔ 'hr').

Parameters ​

name ​

string

Returns ​

string


parseColor() ​

ts
function parseColor(hex): RGB;

Parse "#rrggbb" into linear RGB; invalid input yields mid grey.

Parameters ​

hex ​

string

Returns ​

RGB


poseModelSpace() ​

ts
function poseModelSpace(pose, out?): Float32Array;

Forward kinematics: every joint's figure-space transform (7 floats per joint).

Parameters ​

pose ​

FigurePose

out? ​

Float32Array&lt;ArrayBufferLike&gt;

Returns ​

Float32Array


quadrupedGaitFor() ​

ts
function quadrupedGaitFor(fr, prev): FigureGait;

Quadruped gait from Froude with ±12% hysteresis around walk<0.4≤trot<2.0≤gallop.

Parameters ​

fr ​

number

prev ​

FigureGait | undefined

Returns ​

FigureGait


registerFiguresComponents() ​

ts
function registerFiguresComponents(): void;

Register the figures components, renderable kind, and file format (idempotent).

Returns ​

void


registerFiguresSchema() ​

ts
function registerFiguresSchema(): void;

Register the figures components, the figure renderable kind, and molen/figure@1 (idempotent).

Returns ​

void


resolveFigureDescriptor() ​

ts
function resolveFigureDescriptor(descriptor): ResolvedFigureDescriptor;

Fill a descriptor from its preset; throws on an unknown preset. Extra keys are ignored.

Parameters ​

descriptor ​

FigureDescriptor

Returns ​

ResolvedFigureDescriptor


rigBindModel() ​

ts
function rigBindModel(rig): Float64Array;

Rest-pose transforms of every joint in figure space (7 floats per joint: pos, quat).

Parameters ​

rig ​

FigureRig

Returns ​

Float64Array


rigInverseBind() ​

ts
function rigInverseBind(rig): Float32Array;

Inverse bind matrices of a rig (column-major 4x4 per joint), for skinning.

Parameters ​

rig ​

FigureRig

Returns ​

Float32Array


scaleColor() ​

ts
function scaleColor(color, factor): RGB;

Scale a linear color (for shading variation such as darker hooves or a lighter belly).

Parameters ​

color ​

RGB

factor ​

number

Returns ​

RGB


socketBindPosition() ​

ts
function socketBindPosition(
   rig, 
   name, 
   model?
): Vec3 | undefined;

A socket's rest-pose position in figure space.

Parameters ​

rig ​

FigureRig

name ​

string

model? ​

Float64Array&lt;ArrayBufferLike&gt;

Returns ​

Vec3 | undefined


socketTransform() ​

ts
function socketTransform(
   rig, 
   pose, 
   socket, 
   model?
): TransformLike | undefined;

A socket's figure-space transform under a pose (model = poseModelSpace, computed if absent).

Parameters ​

rig ​

FigureRig

pose ​

FigurePose

socket ​

string | number

model? ​

Float32Array&lt;ArrayBufferLike&gt;

Returns ​

TransformLike | undefined


solveTwoBoneIk() ​

ts
function solveTwoBoneIk(
   root, 
   target, 
   pole, 
   upperLen, 
   lowerLen
): TwoBoneSolution;

Parameters ​

root ​

Vec3

target ​

Vec3

pole ​

Vec3

upperLen ​

number

lowerLen ​

number

Returns ​

TwoBoneSolution


strideRateFor() ​

ts
function strideRateFor(speed, legLength): number;

Stride frequency in cycles per second from Alexander's stride-length scaling (λ = 2.3 · Fr^0.3 · L, clamped to 0.4–4 leg lengths): 1.4 m/s adult ≈ 1.1 Hz.

Parameters ​

speed ​

number

legLength ​

number

Returns ​

number


unit01() ​

ts
function unit01(seed, stream): number;

Independent stateless draw in [0, 1) for a (seed, stream) pair.

Parameters ​

seed ​

number

stream ​

number

Returns ​

number


worldToFigure() ​

ts
function worldToFigure(entity, point): Vec3;

A world point into figure space (the inverse of the entity transform, scale ignored).

Parameters ​

entity ​

TransformLike

point ​

Vec3

Returns ​

Vec3

37 guides · 36 schema formats · 41 API entry points · 10 samples. API, CLI and schema pages are generated from the shipped build.