Latest published (npm at build time)@rig-c/pixi 0.2.0@rig-c/phaser 0.2.0@rig-c/three 0.2.0github.com/rig-c/adaptersnpm

Engine adapters

The adapters put a rigc-built rig inside the engine or renderer your game already uses. Play computes the pose; the host draws it with its own objects.

What it is

Three packages, each versioned on its own, with 0.x APIs. The badge above lists each current npm release; the recording below keeps its original versions:

  • @rig-c/pixi: a PixiJS 8 adapter.
  • @rig-c/phaser: a Phaser 4.2+ adapter for WebGL scenes.
  • @rig-c/three: a native Three.js 0.186.1 renderer and live Group.

Each one reads the model document rigc build writes, skeleton.model.json, through @rig-c/play.

Recorded video One rig, three hosts: @rig-c/pixi 0.1.1 on PixiJS 8.22.0, @rig-c/phaser 0.1.1 on Phaser 4.2.1 and @rig-c/three 0.1.1 on Three.js 0.186.1. Each panel is the adapters repository's own demo page, run against the npm releases, playing rigc's walk gallery rig and its 0.9 s walk animation; all three read the same skeleton.model.json through @rig-c/play 1.10.0, unmodified. Every frame was posed by seeking each page to the same time (30 fps) and reading its WebGL canvas, and the 0.9 s cycle plays four times. At equal times the panels differ by a mean of 0.03 (PixiJS vs Phaser) and 0.54 (PixiJS vs Three.js) on 0–255 RGB, against 2.4 between neighbouring frames; the Three.js demo draws the rig smaller, so its panel is enlarged more.

When to use it

Use an adapter when your game or page already renders with PixiJS, Phaser or Three.js, and the rig must sit in that scene graph with your other objects. Three.js is a 3D renderer, so its adapter is for 2D characters inside 3D scenes and interactive pages.

If you only need a rig in a web page, with no engine, use Play directly. It draws as DOM elements or one canvas. Native engines such as Godot or Unity are planned, not available.

What it solves

rigc compiles a rig into two things side by side: Spine 4.3 skeleton data and its own model document. An official Spine runtime can load the Spine data, but it brings the Spine Runtimes licence with it. An adapter is a third way: rig-c's own poser runs inside the engine's scene graph and renderer, reads the model document, and links no Spine runtime.

What you get

  • A live object per host: PixiRig (a Pixi Container), PhaserRig (a Phaser Container) and ThreeRig (a flat Three.js Group). Each owns an independent player and exposes play, seek, bone() and bounds().
  • A renderer per host for when you own the player: PixiRenderer, PhaserRenderer and ThreeRenderer. Each draws a supplied PosedFrame.
  • Shared page textures: several rigs over one ModelAssets load share page textures until the last holder releases them.

How it works

  1. Load the model with @rig-c/play's loadModel, using the files rigc build wrote, unmodified.
  2. Create the host object, for example new PixiRig(assets, { ticker: app.ticker }), and add it to your stage or scene.
  3. Each update, @rig-c/play poses the rig and produces a PosedFrame record.
  4. The adapter reads slot corners or mesh vertices, page UVs, tint, blend and clip straight from that record. It maps world (x, y) to (x, -y) and draws with the host's native objects.
  5. On removal, destroy() frees that rig's own resources. Dispose the shared assets after the last rig is gone.
npm install @rig-c/pixi pixi.js @rig-c/play

Swap in @rig-c/phaser phaser or @rig-c/three three for the other hosts.

Run a pointer-follow example

The upstream look example is a runnable page: move the pointer to turn the face, with eyes following immediately and the head and body following on a spring. Start with PixiJS below. This route runs locally from a fixed source archive; it needs Bun, curl, tar and a browser with WebGL.

In a new directory:

mkdir rig-c-look
cd rig-c-look
curl -fL https://codeload.github.com/rig-c/adapters/tar.gz/cccc84136c0342312c4d353b46bae9d8c130627f -o source.tar.gz
tar -xzf source.tar.gz --strip-components=1
bun install --frozen-lockfile
cat > look.vite.config.ts <<'EOF'
import { defineConfig, mergeConfig } from 'vite';
import upstream from './vite.config.ts';
export default defineConfig((env) => {
  if (typeof upstream !== 'function') throw new Error('Expected the pinned Vite config');
  return mergeConfig(upstream(env), {
    optimizeDeps: { entries: ['examples/look/index.html'] },
  });
});
EOF
BROWSER=none bun run example:look --config look.vite.config.ts --host 127.0.0.1 --port 5173 --strictPort

Open the local PixiJS page. Wait for the loading message to become dial values, then move across the canvas; leaving it returns the target to neutral. Stop the server with Ctrl-C when finished. The committed model and image are already in the archive: no fixture fetch or rebuild is needed. The small Vite config keeps the upstream aliases and helper intact, while limiting dependency scanning to this example; the default config also scans unrelated test/oracle pages whose packages are not installed by this recipe.

What this run uses

The source pin is cccc841; its frozen lockfile selects Play 1.12.0, PixiJS 8.22.0, rig-c 2.64.1 (the public rig-c/core reader) and Vite 6.4.4. The page imports @rig-c/pixi from this checkout's 0.1.2 workspace source, through the upstream Vite development alias. It does not install that adapter from npm. Keep the archive and lock together; the current-release badges above describe a different, build-time lookup.

The fixture directory contains a compiled model and one atlas image used at runtime:

FileBytesSHA-256
skeleton.model.json2,182,6041c2786199210007021fa82874e375a7d29f91e422285ccdf9416caa976585c50
skeleton.png1,790,672d41b70387f1e1f6e988f319c466441f1b0e0dadc731212278113c747ac2cef4e

The fixture's introduction records a Parts 1.34.0 build on Core 2.59.0, from the project owner's painting, with cylinder-based face turn and slider dials. The committed example and fixture are distributed under the repository's MIT licence; retain that notice when copying them. These are the public bytes this recipe plays, not a new build from the released depth producer. Upstream still marks a refresh to a released public depth rig as pending. Slider motion here does not establish depth-producer acceptance, full 3D rotation or parity between hosts. The separate head-turn preview has its own implementation.

Connect it to your own page

Read the pinned helper, page and host setup together. pointer-dials.ts is example-side TypeScript: import it from the checkout, or copy it with its MIT notice into a bundler-based application. It is not a package export. The upstream page is the complete executable reference; the lifecycle below explains where each piece belongs.

  1. Load the same model bytes into both readers. Fetch the model URL and check response.ok. Pass its text to readModel(text, modelUrl) from rig-c/core. Pass the same text back to loadModel({ modelUrl, regions: 'none', fetch }) from @rig-c/play through the public fetch callback, delegating image requests to the browser's fetch. Keep the model and its image pages together. There is no need to unwrap the opaque ModelAssets.document.
  2. Create the host rig. The PixiJS host creates a WebGLRenderer, a stage Container and new PixiRig(assets, { ticker: null, autoUpdate: false }), fits the rig's bounds and adds it to the stage. With manual stepping there is only one clock. The example's LookController selects the declared idle, sets the environment and adds its existing calibrated global hair impulse.
  3. Bind declared slider names. For the reusable helper, call readPointerDialBindings(doc, { yaw: 'yaw_dial', pitch: 'pitch_dial' }), then new PointerDials(bindings) and assign rig.player.adjust = follow.adjust. Yaw and pitch are required. Add roll, body, gazeX or gazeY only when your model declares their dial bones and usable sliders. The upstream LookController requests all six for this fixture, and derives yaw/pitch direction signs from its animation curves; preserve that probe when reusing its fixture. A different rig supplies its own names and directions.
  4. Feed input, then pose and draw. On pointermove, call pointerToNormalized(event.clientX, event.clientY, canvas.getBoundingClientRect()) and pass its fx, fy to follow.setPointer. CSS coordinates map right/up to positive X/Y and clamp to [-1, 1]; an empty rectangle or nonfinite input maps to zero. On pointerleave, call follow.clearPointer(). In each frame, with elapsed seconds dt, call follow.step(dt) before rig.advance(dt), then renderer.render({ container: stage }). The full upstream page uses controller.step(dt) to perform that sequence plus its hair input; do not advance the rig a second time. For a touch-controlled application, bind pointer down/move/up/cancel, set the canvas touch policy and clear on release; the pinned example itself only listens to move/leave.
  5. Release in ownership order. Stop your animation frame loop and remove your input listeners. Remove the rig from its stage and call rig.destroy() before assets.dispose(); shared assets stay alive until the last rig releases them. Destroy a renderer only if your page owns it. The upstream page exposes window.__lookDemo.dispose(): it cancels its clock, destroys the rig, disposes assets, destroys its host and removes the canvas. It also calls this on non-persisted pagehide; this is the example's inspection API, not a package API.

Each requested dial must have exactly one local, non-looping slider, with finite from/to, nonzero finite scale and a positive animation duration. The helper inverts time = to + (value - from) * scale at time zero and at the duration, then sorts the two endpoints. It preserves asymmetric bands; the raw model's max is not the parsed range. A missing or unsupported slider throws PointerDialRefusal with the axis and bone. Do not replace that refusal with guessed angles or direct head-bone writes.

For these fixture bytes, the derived bands are:

AxisDial boneLocal channelBand
yawyaw_dialrotation[-15, 15]
pitchpitch_dialrotation[-12, 12]
rollroll_dialrotation[-8, 8]
bodybody_dialrotation[-6, 6]
gazeXgaze_x_dialrotation[-1, 1]
gazeYgaze_y_dialrotation[-1, 1]

Failures and checks

A missing requested dial produces a console warning and a static rig with the missing axis in the HUD. A failed model fetch sets document.body.dataset.lookReady to error and records window.__lookDemoError; the pinned page leaves its loading text in place. Inspect the console/network and that error value, or add a visible error message and release partially created resources in your application's catch path. Do not treat a loading message as success.

From the extracted repository, bun run test:look exercises the actual helper's reader, refusal, normalization, asymmetric clamp and spring controls without a browser. ?manual=1 disables the page clock for controlled stepping via its inspection API. The reproducible route here is scoped to PixiJS; the upstream host links are available, but no new three-host equivalence or physical touch-device result is claimed.

Key concepts

  • Host: the engine or renderer an adapter targets. Each host lives in packages/<host>.
  • Model document: skeleton.model.json, the source the adapters read. Spine is one export of it.
  • PosedFrame: the per-frame record @rig-c/play produces and every renderer draws.
  • ModelAssets: one loadModel result, which several rigs can share.
  • Parity: an adapter plays the same pose for the same time as @rig-c/play, held to the player's output by a test.

Go deeper