untitled-pixi-live2d-engine 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,47 +2,84 @@
2
2
 
3
3
  ![NPM Version](https://img.shields.io/npm/v/untitled-pixi-live2d-engine?style=flat-square&label=version)
4
4
  ![Cubism version](https://img.shields.io/badge/Cubism-2/3/4/5-ff69b4?style=flat-square)
5
+ ![PixiJS](https://img.shields.io/badge/PixiJS-v8-e72264?style=flat-square)
6
+ ![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6?style=flat-square)
5
7
 
6
8
  **English (Current)** | [**简体中文**](README-ZH.md) | [**日本語**](README-JA.md)
7
9
 
8
- A Live2D rendering and control plugin designed for **[PixiJS v8](https://pixijs.com/)**.
10
+ A Live2D rendering engine for **[PixiJS v8](https://pixijs.com/)**, supporting **Cubism 2 / 3 / 4 / 5** models.
9
11
 
10
- This project aims to provide a **unified, concise, and highly maintainable** API for loading, rendering, and interacting with Live2D models on the Web.
11
- Compared to the official Live2D SDK, this library significantly reduces usage complexity while preserving full functionality, with additional optimizations for stability and long-term maintainability.
12
+ This project is a major refactor of [pixi-live2d-display-mulmotion](https://github.com/Sekai-World/pixi-live2d-display), adapted for PixiJS v8 and Cubism 5 SDK with improvements to API design, rendering pipeline, and type safety.
12
13
 
13
- This project is based on the [pixi-live2d-display-mulmotion](https://github.com/Sekai-World/pixi-live2d-display) branch.
14
- It is **fully compatible with PixiJS v8 and Live2D Cubism 5.4 SDK**, and further provides:
14
+ ## Key Features
15
15
 
16
- - Additional practical APIs
17
- - Stronger TypeScript type safety
18
- - Optimized internal architecture for extensibility and maintainability
16
+ ### Native PixiJS v8 Rendering
19
17
 
20
- ## Features
18
+ Registers a custom **Render Pipe** with `extensions.add(Live2DPlugin)` to integrate with the PixiJS v8 rendering architecture:
21
19
 
22
- - Supports **all versions** of Live2D models (Cubism 2 / 3 / 4 / 5)
23
- - Compatible with `PIXI.RenderTexture` and `PIXI.Filter`
24
- - Provides a complete **PixiJS-style transform API**
25
- - `position`
26
- - `scale`
27
- - `rotation`
28
- - `skew`
29
- - `anchor`
20
+ - Supports `Filter` and `RenderTexture`
21
+ - Participates in **zIndex sorting** and **blend modes**
22
+ - Inherits renderer resolution — filters won't blur due to downsampling
30
23
 
31
- - Built-in interaction support
32
- - Mouse tracking
33
- - Hit area detection
24
+ ### Cubism 2–5 Support
34
25
 
35
- - Improved **motion scheduling and reservation logic** compared to the official SDK
36
- - Complete and strict **TypeScript type definitions**
37
- - Real-time lip sync support
38
- - **Parallel motion playback**
39
- - Support for **freezing at the last frame of motions**
26
+ Works with both **Cubism 2.1 (Legacy)** and **Cubism 5 (Modern)**, with separate bundle entries to import the corresponding runtime as needed.
27
+
28
+ ### Texture LOD
29
+
30
+ For large texture atlases (4096px+), three LOD strategies are available:
31
+
32
+ - **`full`** (default): generates a full mipmap chain
33
+ - **`single-auto`**: generates a lower-resolution texture on demand based on the model's actual screen size, reducing VRAM usage
34
+ - **`false`**: uses the original texture only
35
+
36
+ ```ts
37
+ const model = await Live2DModel.from('model.json', {
38
+ textureOptions: { lod: 'single-auto' }
39
+ })
40
+ ```
41
+
42
+ ### Automatic High-Precision Mask Detection
43
+
44
+ Complex models (many masked drawables, high vertex density, etc.) can produce visual artifacts when mask precision is insufficient. The engine automatically analyzes the model structure and enables high-precision masks when needed. This is enabled by default and can also be controlled manually.
45
+
46
+ ### Parallel Motions & Last-Frame Freeze
47
+
48
+ - **Parallel playback**: drive multiple motion groups simultaneously, useful for independent upper/lower body animations
49
+ - **Last-frame freeze**: hold a motion on its final frame, useful for pose switching or static illustrations
50
+
51
+ ```ts
52
+ // Parallel playback
53
+ model.parallelMotion([
54
+ { group: 'upper_body', index: 0 },
55
+ { group: 'lower_body', index: 1 }
56
+ ])
57
+
58
+ // Last-frame freeze
59
+ await model.parallelLastFrame([
60
+ { group: 'arm', index: 0 },
61
+ { group: 'expression', index: 2 }
62
+ ])
63
+ ```
64
+
65
+ ## Feature List
66
+
67
+ - **Cubism 2 / 3 / 4 / 5** model support
68
+ - Native PixiJS v8 rendering pipeline (Filter / RenderTexture / Render Pipe)
69
+ - Texture LOD and automatic high-precision mask detection
70
+ - Parallel motion playback / last-frame freeze
71
+ - Real-time lip sync
72
+ - PixiJS-style transforms: `position` / `scale` / `rotation` / `skew` / `anchor`
73
+ - Mouse tracking / hit area detection
74
+ - Improved motion reservation and priority scheduling
75
+ - Strict TypeScript type definitions
76
+ - Configurable Cubism work memory size
40
77
 
41
78
  ## Requirements
42
79
 
43
80
  - **PixiJS**: `8.x`
44
81
  - **Cubism runtime**: `2.1` or `5`
45
- - **Browser**: Must support `WebGL` and `ES6`
82
+ - **Browser**: must support `WebGL` and `ES6`
46
83
 
47
84
  ## Installation
48
85
 
@@ -55,7 +92,7 @@ npm install untitled-pixi-live2d-engine
55
92
  ```
56
93
 
57
94
  ```ts
58
- import { Live2DModel } from 'untitled-pixi-live2d-engine'
95
+ import { Live2DModel, Live2DPlugin } from 'untitled-pixi-live2d-engine'
59
96
 
60
97
  // Cubism Legacy only (Cubism 2.1)
61
98
  import { Live2DModel } from 'untitled-pixi-live2d-engine/cubism-legacy'
@@ -64,73 +101,44 @@ import { Live2DModel } from 'untitled-pixi-live2d-engine/cubism-legacy'
64
101
  import { Live2DModel } from 'untitled-pixi-live2d-engine/cubism'
65
102
  ```
66
103
 
67
- ### Import via HTML
104
+ ### Via HTML
68
105
 
69
106
  ```html
70
107
  <script src="https://cdn.jsdelivr.net/npm/untitled-pixi-live2d-engine/dist/index.min.js"></script>
71
108
  ```
72
109
 
73
- ## Cubism Runtime Overview
110
+ ## Cubism Runtime
74
111
 
75
- This project supports **all versions of Live2D models**, which can be categorized by Cubism architecture:
112
+ Live2D models are split into two categories by Cubism architecture, each requiring a different external runtime:
76
113
 
77
- - **Cubism Legacy**: Cubism 2.1
78
- - **Cubism Modern**: Cubism 3 / 4 / 5
114
+ | Category | Model Version | External Runtime | Bundle Entry |
115
+ |---|---|---|---|
116
+ | **Cubism Legacy** | Cubism 2.1 | `live2d.min.js` | `cubism-legacy.js` |
117
+ | **Cubism Modern** | Cubism 3 / 4 / 5 | `live2dcubismcore.min.js` | `cubism.js` |
118
+ | **Both** | — | Both of the above | `index.js` |
79
119
 
80
- Choose the appropriate runtime entry based on the model you are using.
120
+ ### Obtaining the External Runtime
81
121
 
82
- ### Using Cubism Legacy and Cubism Modern Together
122
+ **Cubism Legacy** — `live2d.min.js`
83
123
 
84
- #### Bundle entry
124
+ Official distribution was discontinued on [September 4, 2019](https://help.live2d.com/en/other/other_20/). Available from:
125
+ - [GitHub](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib)
126
+ - [jsDelivr CDN](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js)
85
127
 
86
- ```text
87
- index.js
88
- ```
89
-
90
- > Use this unified entry when your project needs to load both Cubism 2 and Cubism 3+ models.
91
-
92
- ### Cubism Legacy Only (Cubism 2.1)
93
-
94
- #### Prerequisites
95
-
96
- You must manually include `live2d.min.js`:
97
-
98
- - Official distribution was discontinued on
99
- [September 4, 2019](https://help.live2d.com/en/other/other_20/)
100
- - Available from:
101
- - GitHub:
102
- [https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib)
103
- - jsDelivr CDN:
104
- [https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js)
105
-
106
- #### Bundle entry
107
-
108
- ```text
109
- cubism-legacy.js
110
- ```
111
-
112
- ### Cubism Modern Only (Cubism 3 / 4 / 5)
113
-
114
- #### Prerequisites
128
+ **Cubism Modern** — `live2dcubismcore.min.js`
115
129
 
116
- You must include `live2dcubismcore.min.js`:
117
-
118
- - Downloadable from the official **Cubism 5 SDK**
119
- [https://www.live2d.com/download/cubism-sdk/download-web/](https://www.live2d.com/download/cubism-sdk/download-web/)
120
-
121
- #### Bundle entry
122
-
123
- ```text
124
- cubism.js
125
- ```
130
+ Download from the official [Cubism 5 SDK for Web](https://www.live2d.com/download/cubism-sdk/download-web/).
126
131
 
127
132
  ## Quick Start
128
133
 
129
- The following example is based on **PixiJS v8** and supports both Cubism Legacy and Cubism Modern.
134
+ The following example uses PixiJS v8 and supports both Cubism Legacy and Cubism Modern.
130
135
 
131
136
  ```ts
132
- import { Application } from 'pixi.js'
133
- import { configureCubismSDK, Live2DModel } from 'untitled-pixi-live2d-engine'
137
+ import { Application, extensions } from 'pixi.js'
138
+ import { configureCubismSDK, Live2DModel, Live2DPlugin } from 'untitled-pixi-live2d-engine'
139
+
140
+ // Register the Live2D render pipe before creating the Pixi renderer
141
+ extensions.add(Live2DPlugin)
134
142
 
135
143
  const app = new Application()
136
144
  await app.init({
@@ -142,11 +150,9 @@ await app.init({
142
150
 
143
151
  document.body.appendChild(app.canvas)
144
152
 
145
- // Configure Cubism Modern work memory (optional, default is 16MB)
146
- // Increase this value when loading multiple or high-complexity models
147
- // configureCubismSDK({
148
- // memorySizeMB: 32
149
- // })
153
+ // Configure Cubism Modern work memory (optional, default 16MB)
154
+ // Increase when loading multiple or complex models
155
+ // configureCubismSDK({ memorySizeMB: 32 })
150
156
 
151
157
  const model = await Live2DModel.from('model/model3.json')
152
158
  model.anchor.set(0.5)
@@ -155,7 +161,7 @@ model.position.set(app.screen.width / 2, app.screen.height / 2)
155
161
  app.stage.addChild(model)
156
162
  ```
157
163
 
158
- ## Common API Examples
164
+ ## API Examples
159
165
 
160
166
  ### Play a Motion
161
167
 
@@ -172,7 +178,7 @@ model.parallelMotion([
172
178
  ])
173
179
  ```
174
180
 
175
- ### Play and Freeze at the Last Frame
181
+ ### Last-Frame Freeze
176
182
 
177
183
  **Single motion:**
178
184
 
@@ -201,13 +207,16 @@ model.speak('audio_file_url')
201
207
  model.expression('id')
202
208
  ```
203
209
 
204
- For more advanced usage, see
205
- [pixi-live2d-display-lipsync](https://github.com/RaSan147/pixi-live2d-display)
206
-
207
210
  ## FAQ
208
211
 
209
- ### Q: Why do models stop updating when multiple models are loaded?
212
+ ### Q: Models stop updating after loading multiple models?
213
+
214
+ When using the Cubism Modern runtime, this is usually caused by insufficient work memory. Increase `memorySizeMB` during initialization (minimum 16MB):
215
+
216
+ ```ts
217
+ configureCubismSDK({ memorySizeMB: 32 })
218
+ ```
210
219
 
211
- When using the **Cubism Modern** runtime, this issue is usually caused by insufficient work memory configured via `configureCubismSDK`.
220
+ ## License
212
221
 
213
- Try increasing `memorySizeMB` during initialization (minimum: 16MB).
222
+ [MIT](LICENSE)