Latest published (npm at build time)@rig-c/play 1.31.1github.com/rig-c/playnpm

@rig-c/play

The browser player for the model rigc writes — no Spine runtime, rigid parts as plain DOM elements or the whole rig in one canvas.

Live@rig-c/play 1.12.0 running in your browser — not a recording

Not loaded yet. Start downloads the player (about 0.4 MB) and Character 1 with the swing (about 1.3 MB); each other character or outfit you pick loads its rig (about 1.3–2.1 MB) from rig-c/examples.

The model is the Pose page's build: Character 1's rig from rig-c/examples with the retargeted cup swing added.

Skip to A minimal page · Install · Inputs and outputs · Limits · Docs

A rigged character usually means a canvas runtime that rasterizes everything. For a rigid part, though, the bone transform is a plain affine map that CSS matrix() expresses exactly — so the rigid parts can live in the DOM, where the browser composites them and you can inspect and style them like any element. Play keeps that path, and adds what the DOM cannot do alone: per-part mesh canvases, clip-path clipping, and skipping meshes that did not move. Switch the player above to One canvas to see the other mode draw the same pose, or pick another Character and Outfit: the player switches between the 20 Family rigs.

What you just ran

The player above is the published package doing what any page does with it — nothing on this site poses the rig:

  1. loadModel() read the rig's skeleton.model.json — Character 1 office from this site, every other pick from rig-c/examples at a pinned commit, fetched when you pick it — and cut each atlas region into its own bitmap (the .atlas and skeleton.json beside it are not fetched).
  2. new RigPlayer(root, assets, { mode }) opened the motion you picked on a live track; rig-c's core, bundled in the package, poses bones, constraints, physics and draw order on the CPU, one frame(dt) at a time.
  3. Each frame became a PosedFrame — region corners or mesh vertices, UVs, tint and clip, in draw order. A region is written as one matrix() string; meshes draw through one shared WebGL context and fall back to canvas2d (the status line says which ran).
  4. Bones and Mesh draw from the player's own read-only queries, bone(name) and posedFrame(); Pause calls pause().

Character 1 in the office outfit keeps both motions: swing — the cup swung like a pendulum — is the motion the Pose page retargeted onto that rig, and idle came with it from Parts. The other 19 rigs play the idle they were built with; the motion menu lists what the loaded rig carries.

A minimal page

Twenty-odd lines, from the README, load a model from jsDelivr, fit its stage box to a container and drive the clock:

<div id="stage" style="position: relative; width: 480px; height: 640px; overflow: hidden"></div>
<script type="module">
  import { loadModel, RigPlayer } from 'https://cdn.jsdelivr.net/npm/@rig-c/play@1/dist/index.js';
  const stage = document.getElementById('stage');
  const assets = await loadModel({ modelUrl: 'rigs/look/skeleton.model.json' });
  const root = stage.appendChild(document.createElement('div'));
  const player = new RigPlayer(root, assets);
  player.play(assets.animations[0].name);
  const box = assets.stage ?? player.bounds();
  const scale = Math.min(stage.clientWidth / box.width, stage.clientHeight / box.height);
  root.style.cssText = `position: absolute; transform-origin: 0 0; transform: scale(${scale});
    left: ${-box.x * scale}px; top: ${(box.y + box.height) * scale}px`;
  player.renderer.syncPixelRatio();
  let last = performance.now();
  requestAnimationFrame(function tick(now) {
    player.frame((now - last) / 1000);
    last = now;
    requestAnimationFrame(tick);
  });
</script>

The player does not run its own clock: the page calls frame(dt), so pausing, slowing down or stopping the loop is yours to decide (this site's player stays paused when your system asks for reduced motion). To play the same model inside PixiJS, Phaser or Three.js, see the adapters.

Key terms. Model document — skeleton.model.json (spec rigc-compiled/3). Region attachment — a rigid part, an <img> with a CSS matrix. Mesh attachment — a deforming part on its own small canvas. Render mode — dom (default) or canvas. Mesh backend — webgl (default since 1.9) or canvas2d. Attachment set — a named swap of slot attachments from sets.json.

Install

npm i @rig-c/play
npm i -D @rig-c/core    # rigc build writes the model the player loads

Runs in the browser as an ES module; rig-c's posing core is bundled, so there is nothing else to install. The package is MIT and links nothing from Esoteric Software — see Licensing.

Inputs and outputs

InOut
skeleton.model.json — the compiled model rigc build writes (spec rigc-compiled/3)DOM mode (default): one <img> per rigid slot posed by a CSS matrix(), small per-part canvases for meshes
Its atlas page images (the .atlas and skeleton.json beside it are not fetched)Canvas mode: the whole frame in one <canvas> per player
(optional) sets.json — named attachment sets, spec rig-parts-sets/1Reads off the pose: player.bone(name), player.bounds(), slotIdentity()
(optional) your own PosedFrame records, via DomRenderer.render

Limits

From REFERENCE.md §Status and MIGRATION.md §No counterpart in 1.0.0:

  • Status: "Production." — 60 fps on every engine measured for the practical scenario (REFERENCE.md §"Status").
  • Reads rigc's model only: "a Spine export is refused by name"; loadModel reads a compiled model document and nothing else (README §Why, MIGRATION.md §"No counterpart in 1.0.0").
  • Which render mode is faster where is "not measured on a device yet", so the default stays dom (REFERENCE.md §"Status").
  • Dark/two-colour tint stays out of scope in DOM mode; RGB tint needs reference-filter support, Safari 15+ (REFERENCE.md §"Status").
  • Clipping caveats: an inverse polygon matches Spine's clipper only when convex, and the cost of many clip-paths on real-device Safari is not measured (REFERENCE.md §"Status").
  • No per-slot changes from code (attachment, colour) and no scale on load; scaling the root element is the caller's (MIGRATION.md §"No counterpart in 1.0.0").

Go deeper