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 🙏

© 2026 – Pkg Stats / Ryan Hefner

live2d-browser-renderer

v0.1.4

Published

A library for rendering Live2D models in browsers Developed by Mercallure

Readme

Live2D Browser Renderer

模态跃迁自研用于在浏览器中渲染Live2D模型的轻量级库。该库基于pixi.js和pixi-live2d-display,提供了简单易用的API来加载和显示Live2D模型,并支持音频同步功能。

安装

npm install live2d-browser-renderer

或者使用yarn:

yarn add live2d-browser-renderer

基本用法

import Live2DRenderer, { Live2DEventType } from 'live2d-browser-renderer';

// 获取canvas元素
const canvas = document.getElementById('live2d-canvas');

// 创建渲染器实例
const renderer = new Live2DRenderer(canvas, 'haru', {
  autoResize: true
});

// 渲染模型
renderer.render();

// 添加事件监听
renderer.on(Live2DEventType.MODEL_LOADED, (event) => {
  console.log('模型加载完成!', event.model);
});

// 获取麦克风流并播放
navigator.mediaDevices.getUserMedia({ audio: true })
  .then(stream => {
    // 播放音频并同步Live2D模型的口型动作
    renderer.playAudio(stream);
  })
  .catch(err => {
    console.error('无法获取麦克风:', err);
  });

// 停止音频同步
function stopAudio() {
  renderer.stopAudio();
}

// 清理资源
function cleanup() {
  renderer.destroy();
}

API

Live2DRenderer

主渲染器类,用于加载和显示Live2D模型。

构造函数

constructor(container: HTMLCanvasElement, modelName: ModelName, options?: Live2DRendererOptions)
  • container: Canvas元素,用于渲染模型
  • modelName: 模型名称,应是预定义模型中的一个,可选项包括kei_vowels_proofficereal_girloffice_m
  • options: 可选的渲染器配置
    • autoInteract: 是否开启自动交互
    • autoResize: 是否跟随父元素大小变化

方法

  • render(): 将模型渲染到舞台上
  • destroy(): 销毁渲染器和模型资源
  • playAudio(mediaStream: MediaStream): 播放音频并同步模型动作
  • stopAudio(): 停止音频同步
  • on(eventType: Live2DEventType, callback: Live2DEventCallback): 添加事件监听器
  • off(eventType: Live2DEventType, callback: Live2DEventCallback): 移除事件监听器

事件类型

enum Live2DEventType {
  MODEL_LOADED = 'modelLoaded',
  ERROR = 'error',
  AUDIO_START = 'audioStart',
  AUDIO_STOP = 'audioStop'
}

浏览器兼容性

该库支持所有现代浏览器,包括:

  • Chrome 60+
  • Firefox 60+
  • Safari 12+
  • Edge 79+

许可证

MIT