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 +99 -90
- package/dist/cubism-legacy.es.js +274 -136
- package/dist/cubism-legacy.js +273 -135
- package/dist/cubism-legacy.min.js +1 -1
- package/dist/cubism.es.js +306 -134
- package/dist/cubism.js +305 -133
- package/dist/cubism.min.js +1 -1
- package/dist/index.es.js +315 -137
- package/dist/index.js +314 -136
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +145 -21
package/README.md
CHANGED
|
@@ -2,47 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
5
|
+

|
|
6
|
+

|
|
5
7
|
|
|
6
8
|
**English (Current)** | [**简体中文**](README-ZH.md) | [**日本語**](README-JA.md)
|
|
7
9
|
|
|
8
|
-
A Live2D rendering
|
|
10
|
+
A Live2D rendering engine for **[PixiJS v8](https://pixijs.com/)**, supporting **Cubism 2 / 3 / 4 / 5** models.
|
|
9
11
|
|
|
10
|
-
This project
|
|
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
|
-
|
|
14
|
-
It is **fully compatible with PixiJS v8 and Live2D Cubism 5.4 SDK**, and further provides:
|
|
14
|
+
## Key Features
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
- Stronger TypeScript type safety
|
|
18
|
-
- Optimized internal architecture for extensibility and maintainability
|
|
16
|
+
### Native PixiJS v8 Rendering
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
Registers a custom **Render Pipe** with `extensions.add(Live2DPlugin)` to integrate with the PixiJS v8 rendering architecture:
|
|
21
19
|
|
|
22
|
-
- Supports
|
|
23
|
-
-
|
|
24
|
-
-
|
|
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
|
-
|
|
32
|
-
- Mouse tracking
|
|
33
|
-
- Hit area detection
|
|
24
|
+
### Cubism 2–5 Support
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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**:
|
|
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
|
-
###
|
|
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
|
|
110
|
+
## Cubism Runtime
|
|
74
111
|
|
|
75
|
-
|
|
112
|
+
Live2D models are split into two categories by Cubism architecture, each requiring a different external runtime:
|
|
76
113
|
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
120
|
+
### Obtaining the External Runtime
|
|
81
121
|
|
|
82
|
-
|
|
122
|
+
**Cubism Legacy** — `live2d.min.js`
|
|
83
123
|
|
|
84
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
146
|
-
// Increase
|
|
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
|
-
##
|
|
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
|
-
###
|
|
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:
|
|
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
|
-
|
|
220
|
+
## License
|
|
212
221
|
|
|
213
|
-
|
|
222
|
+
[MIT](LICENSE)
|