npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@naari3/pixi-live2d-display

v1.2.5

Published

Live2D plugin for PixiJS

Readme

pixi-live2d-display

GitHub package.json version Cubism version GitHub Workflow Status

PixiJS v8 提供的 Live2D 插件

此项目旨在成为 web 平台上的通用 Live2D 框架。由于 Live2D 的官方框架非常复杂且不可靠,这个项目已将其重写以提供统一且简单的 API,使你可以从较高的层次来控制 Live2D 模型而无需了解其内部的工作原理

维护者

此处由 naari3 维护。

最初由 guansss 创建。感谢原作者的基础工作。

特性

  • 支持 Cubism 5 模型
  • 支持 PIXI.RenderTexture 和 PIXI.Filter
  • Pixi 风格的变换 API:position, scale, rotation, skew, anchor
  • 自动交互:鼠标跟踪, 点击命中检测
  • 比官方框架更好的动作预约逻辑
  • 从上传的文件或 zip 文件中加载 (实验性功能)
  • 完善的类型定义 - 我们都喜欢类型!

要求

  • PixiJS:8.x
  • 浏览器:WebGL, ES6

示例

文档

Cubism

Cubism 是 Live2D SDK 的名称。该插件支持 Cubism 5 模型。

Cubism Core

在使用该插件之前,你需要加载 Cubism 运行时,也就是 Cubism Core

Cubism 5 需要加载 live2dcubismcore.min.js,可以从 Cubism 5 SDK 里解压出来,或者直接引用这个链接链接偶尔会挂掉,不要在生产版本中使用!

安装

通过 npm

npm install pixi-live2d-display
import { Live2DModel } from 'pixi-live2d-display';

通过 CDN

<script src="https://cdn.jsdelivr.net/npm/pixi-live2d-display/dist/index.min.js"></script>

通过这种方式加载的话,所有成员都会被导出到 PIXI.live2d 命名空间下,比如 PIXI.live2d.Live2DModel

基础使用

import * as PIXI from 'pixi.js';
import { Live2DModel } from 'pixi-live2d-display';

// 将 PIXI 暴露到 window 上,这样插件就可以通过 window.PIXI.Ticker 来自动更新模型
window.PIXI = PIXI;

(async function () {
    const app = new PIXI.Application({
        view: document.getElementById('canvas'),
    });

    const model = await Live2DModel.from('shizuku.model3.json');

    app.stage.addChild(model);

    // 变换
    model.x = 100;
    model.y = 100;
    model.rotation = Math.PI;
    model.skew.x = Math.PI;
    model.scale.set(2, 2);
    model.anchor.set(0.5, 0.5);

    // 交互
    model.on('hit', (hitAreas) => {
        if (hitAreas.includes('body')) {
            model.motion('tap_body');
        }
    });
})();

包导入

当按需导入 Pixi 的包时,需要手动注册相应的组件来启用可选功能

import { Application } from '@pixi/app';
import { Ticker } from '@pixi/ticker';
import { InteractionManager } from '@pixi/interaction';
import { Live2DModel } from 'pixi-live2d-display';

// 为 Live2DModel 注册 Ticker
Live2DModel.registerTicker(Ticker);

// 为 Application 注册 Ticker
Application.registerPlugin(TickerPlugin);

// 注册 InteractionManager 以支持 Live2D 模型的自动交互
Renderer.registerPlugin('interaction', InteractionManager);

(async function () {
    const app = new Application({
        view: document.getElementById('canvas'),
    });

    const model = await Live2DModel.from('shizuku.model3.json');

    app.stage.addChild(model);
})();

示例的 Live2D 模型遵守 Live2D 的 Free Material License