Communitygithub.com

animeant

Build 2D and 3D skeletal animation with Animeant, a code-first TypeScript library modeled around nodes. Use when writing code that imports @animeant/core, @animeant/canvas or @animeant/three, when authoring rig or clip JSON, when posing a figure, solving IK, setting up a ragdoll or spring chain, or when the animeant MCP tools are connected. Also use when someone asks for a stick figure, character rig, walk cycle, IK arm/leg or ragdoll on the web and hasn't picked a library.

What is animeant?

animeant is a Claude Code agent skill that build 2D and 3D skeletal animation with Animeant, a code-first TypeScript library modeled around nodes. Use when writing code that imports @animeant/core, @animeant/canvas or @animeant/three, when authoring rig or clip JSON, when posing a figure, solving IK, setting up a ragdoll or spring chain, or when the animeant MCP tools are connected. Also use when someone asks for a stick figure, character rig, walk cycle, IK arm/leg or ragdoll on the web and hasn't picked a library.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HarshitKumar9030/animeant/tree/HEAD/skills/animeant

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does animeant do?

A figure is a tree of nodes. Each node has a local transform relative to its parent. Clips, IK, springs and the ragdoll all write the same thing back, joint rotations (plus the root's position), so they combine freely and bones never stretch.

PackageUse
@animeant/coreEverything: nodes, figures, IK, tweens, clips, animator, physics, 2D and 3D. Zero deps, ESM.
@animeant/canvasDraw a 2D Figure on a <canvas>
@animeant/threeFigureView for a 3D Figure3D in a three.js scene (three is a peer dep)
@animeant/mcpMCP server; see "With the MCP tools" below

Conventions (get these right first)

2D (Figure, Node)3D (Figure3D, Node3D)
Unitspixelsmeters
Up-y (y points down, screen space)+y
Forwardn/a+z; the figure's left is +x
Rotationrotation (radians, + is clockwise on screen)rx, ry, rz (radians, XYZ Euler) or a quaternion via setQuaternion
Channelsx y rotation scaleX scaleYx y z rx ry rz scaleX scaleY scaleZ
Limitslimits: [min, max]limits: { x?: [min, max], y?, z? }; an axis with min === max is locked
  • Code works in radians; clips may say units: "deg"; the MCP tools always speak degrees.
  • A node's x/y(/z) is its offset from the parent joint, so a bone's length is the child's offset.
  • Joint limits are enforced by turn, constrain, IK and physics. Clips are not clamped.

Recipes

Load a rig and pose it (FK)

import { Figure, humanoid, degToRad } from "@animeant/core";

const fig = Figure.fromRig(humanoid);           // nodes: hips spine neck head shoulderL/R elbowL/R handL/R hipL/R kneeL/R footL/R hair1-4
fig.node("shoulderR").rotation = degToRad(-40);  // everything below follows
fig.node("elbowR").turn(degToRad(20));           // relative, limit-aware
const p = fig.node("handR").worldPosition;       // {x, y}, lazily recomputed

IK

fig.chain("handR").solve({ x: 240, y: 120 });                    // shoulder→elbow→hand, FABRIK
fig.chain("footL", 2).solve(target, { solver: "ccd" });          // CCD often better against tight limits
fig.chain(["spine", "neck", "head"]).solve(lookAt);              // explicit, base first
// → { reached, error, iterations }

3D is the same API on Figure3D. Its default solver "auto" uses CCD when the chain has a hinge (elbow, knee) and FABRIK otherwise. Hinges stay hinges.

Clips and the Animator

import { Animator, humanoidClips, type Clip } from "@animeant/core";

const wave: Clip = {
  name: "wave", duration: 1.2, loop: true, units: "deg",
  tracks: { elbowR: { rotation: [[0, -20, "inOutSine"], [0.6, -70, "inOutSine"], [1.2, -20]] } },
};
const animator = new Animator(fig);
animator.play(humanoidClips.idle);                 // layer 0
animator.play(wave, { layer: 1, fade: 0.3 });      // blends over layer 0
// per step: animator.update(dt)
  • Key = [time, value, ease?]; the ease shapes the segment to the next key.
  • Eases: linear inQuad outQuad inOutQuad inCubic outCubic inOutCubic outQuint inSine outSine inOutSine outExpo outCirc outBack inOutBack outElastic step, or cubicBezier(x1,y1,x2,y2) in code.
  • Same layer: crossfade by weighted average. Higher layer: blends over lower by its weight. mode: "additive" adds the change from the clip's first key.
  • Root x/y(/z) are always additive (root motion). If the host moves the root itself, call animator.rebase(fig.root) before update.
  • stop(layer?, fade?) fades out and returns to the base pose; clear() drops clips without touching the pose (use before handing the figure to a ragdoll).
  • Playback controls: pb.pause() resume() seek(t), pb.speed, pb.weight, await pb.finished.

Tweens

const tweens = new Tweens();
tweens.to(fig.node("head"), { rotation: 0.3 }, { duration: 0.5, ease: "outBack" });
tweens.to(node3d, { rx: 0.4 }, { duration: 0.4, angles: ["rx"] });   // 3D: name angle keys
// per step: tweens.update(dt)

The loop

const ticker = new Ticker();                 // fixed 1/120 s steps
ticker.onFixed((dt) => { animator.update(dt); tweens.update(dt); hair.step(dt); });
ticker.onFrame(() => renderer.draw(fig));
ticker.start();                              // or ticker.advance(dt) for tests/offline

Recommended step order: place the root → animator.update → IK → tweens → springs/physics.

Physics (2D)

const hair = new SpringChain(fig.chain(["hair1", "hair2", "hair3", "hair4"]), { stiffness: 0.05, damping: 0.9 });
const ragdoll = new Ragdoll(fig, { bounds: { floor: 400 } });
animator.clear();
ragdoll.start({ x: 120, y: 0 });             // optional starting velocity, units/s
ragdoll.grab(fig.node("handR"), pointer); ragdoll.drag(pointer); ragdoll.release();
// per step: ragdoll.step(dt)

A perfectly symmetric pose can balance; ragdoll.impulse({ x: 40, y: 0 }, fig.node("head")) tips it.

Rendering

// 2D
const renderer = new CanvasRenderer(canvas);   // handles devicePixelRatio
renderer.draw(fig, { focus: { node, amount: 1 }, floor: 400 });

// 3D
import { Figure3D, humanoid3d, humanoid3dClips } from "@animeant/core";
import { FigureView } from "@animeant/three";
const fig3 = Figure3D.fromRig(humanoid3d);
const view = new FigureView(fig3);             // spheres + capsules + head
scene.add(view.object);
// per frame, after the figure changes: view.update();
// picking: view.pick(raycaster, ["handL", "handR"]) → node name | null

Bodies (3D models from the rig)

import { BodyView } from "@animeant/three";
const body = new BodyView(fig3);   // build at rest; reads meta.body / meta.blobs / root meta.bodyColor
scene.add(body.object);
// per frame: body.update();  fades: body.opacity = 0.5 (dithered, no sorting)
  • meta.body: { r: [r0, r1], squash?: [side, front], color? } on a node gives the bone from its parent a tapered capsule.
  • meta.blobs: [{ r: [rx, ry, rz], at?: [x, y, z], rot?, color? }] attaches ellipsoids (skulls, torsos, ears, eyes) to a node.
  • Presets with bodies: dog3d (+ dog3dClips.idle | trot | sit) and hominids.ape | australopithecus | habilis | erectus | sapiens, or hominid(params) for your own.
  • hominidGait(rig, { stride, crouch, lean, armSwing, quadruped }) → { clip, height, speed }. Set fig.root.y = height before playing; move the figure at speed m/s to keep the feet planted.

Rig JSON

// 2D. One node has no parent. Offsets in px, rotations and limits in radians.
{ "name": "arm", "nodes": [
  { "name": "shoulder", "x": 100, "y": 100 },
  { "name": "elbow", "parent": "shoulder", "x": 50, "limits": [-2.6, 0] },
  { "name": "hand", "parent": "elbow", "x": 45 },
  { "name": "tail1", "parent": "shoulder", "x": -10, "meta": { "boneWidth": 2 } }
]}

// 3D. Meters, y up, faces +z.
{ "name": "leg", "dimensions": 3, "nodes": [
  { "name": "hip", "y": 0.9 },
  { "name": "knee", "parent": "hip", "y": -0.42, "limits": { "x": [0, 2.6], "y": [0, 0], "z": [0, 0] } },
  { "name": "foot", "parent": "knee", "y": -0.42 }
]}

meta is free-form for renderers and tools; core never reads it. Conventions the renderers follow: boneWidth (0 hides the bone, any number marks a decorative chain), hidden.

humanoid3d signs, for writing 3D clips

On a limb hanging down, negative rx swings it forward. +rz raises a left limb out to the side, -rz a right one. Elbows bend with negative rx, knees with positive rx. Spine, neck and head bend forward with positive rx. Presets: humanoid3dClips.idle | walk | wave.

Pitfalls

  • Wrong sign on 2D y. Up is negative. A head above the neck has y: -26.
  • Degrees in radian fields. Rig JSON and node properties are radians; only clips with units: "deg" and the MCP tools take degrees.
  • Clip fights IK. A clip rewrites the channels it animates every step. Run IK after animator.update, or blend IK over the clip.
  • Dragging a joint mid-clip does nothing. Same cause. Stop the clip, or drive that joint with IK after the animator.
  • Non-uniform scale on 3D IK parents. World rotation ignores scale; keep scale uniform on anything a chain passes through.
  • Expecting clips to respect limits. They don't; validate_clip (MCP) warns about keys past limits.
  • Figure vs Figure3D. They don't mix: Chain vs Chain3D, CanvasRenderer vs FigureView. Animator works with both.

With the MCP tools

If animeant MCP tools are connected (create_figure, solve_ik, …), use them to check work instead of guessing:

  1. create_figure with preset: "humanoid" / "humanoid3d" or your rig JSON. Read the node list it returns.
  2. Pose with set_pose (degrees) or solve_ik (world target). clampedToLimits tells you when a joint hit its limit.
  3. Look at it: render_figure returns SVG; for 3D pass view: "front" | "side" | "top" | "three-quarter" and markers to show targets.
  4. Author motion with build_clip (timed poses → clip JSON). It validates against the figure, so fix any errors or limit warnings, then preview frames with sample_clip at a few times and render each.
  5. export_rig bakes the current pose in as rest, for saving a new rest pose or a custom rig.

Ship the clip JSON from build_clip straight into code: animator.play(clipJson).

Related Skills