Live2D
How to use the Live2D integration in Pixi’VN to load models, play motions, switch expressions, and combine them with Pixi’VN's own animations — the character animation style popular in Gal Games.
The Live2D integration is currently in a testing phase and its API may change in future releases.
Live2D is a technology that allows 2D illustrations to move naturally, creating fluid and expressive animations without the need to redraw every frame. Instead of a bone skeleton (as in Spine 2D), a Live2D model is a single illustration whose parts are deformed and blended by parameters (angle, eye openness, mouth shape, ...), driven by motions (predefined animation clips) and expressions (predefined parameter presets, e.g. facial expressions).
It is widely used in visual novels, games, and interactive applications (especially VTubers) to bring characters to life.
You can learn more about Live2D on the official Live2D website.
Within your Pixi’VN project, you can use the Live2D integration to display and animate Live2D models for your characters. This integration is a wrapper around untitled-pixi-live2d-engine — note that this is not an official PixiJS/Live2D plugin, but a community-maintained engine that bridges Live2D with PixiJS — allowing you to use its features directly inside your Pixi’VN project.
Installation
To add Live2D to an existing Pixi’VN template (created with create-pixi-vn), run the following command in the project folder:
npm create pixi-vn@latest add live2dIt adds the dependency to package.json and sets up main.ts, vite.config.ts and (for ink templates) the hashtag commands. If the changes cannot be applied cleanly, the project is left untouched.
To install the Live2D package in an existing JavaScript project, use one of the following commands:
npm install @drincs/pixi-vn-live2dextensions.add(Live2DPlugin) must be called at startup, in your main file, before Game.init is called.
import { extensions } from "pixi.js";
import { Live2DPlugin } from "@drincs/pixi-vn-live2d/core";
extensions.add(Live2DPlugin);
Game.init(body, {
// ...
});You can enable Live2D hashtag commands in your ink scripts by using the createLive2DHandler function.
import { addBaseHashtagCommands } from "@drincs/pixi-vn-ink";
import { createLive2DHandler } from "@drincs/pixi-vn-live2d/ink";
addBaseHashtagCommands({ bundleIds, assetAliasIds });
createLive2DHandler(); The show, edit, and remove hashtag commands can also be used with live2d, just like with any other canvas element.
Pixi’VN Live2D includes Agent Skills for AI coding assistants, covering the TypeScript integration and Ink commands.
Codex:
npx skills@latest add DRincs-Productions/pixi-vn-live2d@latest --skill '*' --agent codex -g -yClaude Code:
npx skills@latest add DRincs-Productions/pixi-vn-live2d@latest --skill '*' --agent claude-code -g -yOther agents:
npx skills@latest add DRincs-Productions/pixi-vn-live2d@latest --all -yAvailable skills:
- pixi-vn-live2d — runtime setup, model loading, positioning, expressions, motions and saved state.
- pixi-vn-live2d-ink — registering and using Live2D Ink commands, source aliases and entrance/exit transitions.
Usage
You can use the Live2D component just like any other Pixi’VN component. Unlike Spine, a Live2D model doesn't need to be pre-loaded through Assets.load — registering the alias with Assets.add is enough, since Live2D resolves and fetches the model itself.
Because that fetch is asynchronous, the model isn't safe to use until its ready promise resolves — await it right after construction, before reading anything derived from the loaded model (e.g. its size).
For example:
import { canvas } from "@drincs/pixi-vn";
import { Live2D } from "@drincs/pixi-vn-live2d";
const live2d = new Live2D({
source: "shizuku",
xAlign: 0.5,
yAlign: 1,
scale: 0.5,
});
await live2d.ready;
canvas.add("shizuku", live2d);A Live2D model's animations are grouped into motion groups (e.g. idle, tap_body), each containing one or more motion clips. You can start one with the motion function; omitting the clip index plays a random clip from the group.
By default, the model automatically loops its idle motion group (Cubism 2) or Idle group (Cubism 4) on its own — configurable via the idleMotionGroup option — so you only need to call motion for a deliberate, one-off animation such as reacting to a tap or a click.
import { canvas, newLabel } from "@drincs/pixi-vn";
import { Live2D } from "@drincs/pixi-vn-live2d";
export const startLabel = newLabel("start", [
async () => {
const live2d = new Live2D({
source: "shizuku",
xAlign: 0.5,
yAlign: 1,
scale: 0.5,
});
await live2d.ready;
canvas.add("shizuku", live2d);
},
() => {
canvas.find<Live2D>("shizuku")?.motion("tap_body");
},
]);A Live2D model can define multiple expressions — presets of parameter values, typically used for facial expressions — which you can switch between at runtime with the expression function. As with motion, omitting the id picks a random expression.
import { canvas, newLabel } from "@drincs/pixi-vn";
import { Live2D } from "@drincs/pixi-vn-live2d";
export const startLabel = newLabel("start", [
async () => {
const live2d = new Live2D({
source: "shizuku",
xAlign: 0.5,
yAlign: 1,
scale: 0.5,
});
await live2d.ready;
canvas.add("shizuku", live2d);
},
() => {
canvas.find<Live2D>("shizuku")?.expression("f01");
},
]);You can combine Live2D motions with Pixi’VN's classic motion-based animations (canvas.animate), as shown in the example below.
For more advanced games, you can also drive Live2D directly from a ticker triggered by events, such as a button press, instead of relying only on predefined sequences.
import { canvas, newLabel } from "@drincs/pixi-vn";
import { Live2D } from "@drincs/pixi-vn-live2d";
export const startLabel = newLabel("start", [
async () => {
const live2d = new Live2D({
source: "shizuku",
xAlign: 0.3,
yAlign: 1,
scale: 0.5,
});
await live2d.ready;
canvas.add("shizuku", live2d);
canvas.animate(
live2d,
[
[{ x: canvas.width * 0.7 }, { duration: 2, ease: "linear" }],
[{ x: canvas.width * 0.3 }, { duration: 2, ease: "linear" }],
],
{ repeat: Infinity },
);
},
]);You can stop every motion currently playing on a model — as well as any lipsync audio — with the stopMotions function.
import { canvas, newLabel } from "@drincs/pixi-vn";
import { Live2D } from "@drincs/pixi-vn-live2d";
export const startLabel = newLabel("start", [
async () => {
const live2d = new Live2D({
source: "shizuku",
xAlign: 0.5,
yAlign: 1,
scale: 0.5,
});
await live2d.ready;
canvas.add("shizuku", live2d);
live2d.motion("tap_body");
},
() => {
canvas.find<Live2D>("shizuku")?.stopMotions();
},
]);