pixi-live2d-display-advanced 1.0.1 → 2.0.0-beta.2
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 +151 -97
- package/dist/cubism-legacy.es.js +4203 -0
- package/dist/{cubism2.js → cubism-legacy.js} +922 -3464
- package/dist/cubism-legacy.min.js +1 -0
- package/dist/{cubism4.es.js → cubism.es.js} +13306 -11954
- package/dist/{cubism4.js → cubism.js} +13265 -11912
- package/dist/cubism.min.js +1 -0
- package/dist/extra.es.js +45 -36
- package/dist/extra.js +53 -42
- package/dist/extra.min.js +1 -1
- package/dist/index.es.js +12078 -10322
- package/dist/index.js +12086 -10329
- package/dist/index.min.js +1 -1
- package/package.json +20 -25
- package/types/extra.d.ts +3 -7
- package/types/index.d.ts +2158 -1035
- package/README.zh.md +0 -152
- package/dist/cubism2.es.js +0 -6746
- package/dist/cubism2.min.js +0 -1
- package/dist/cubism4.min.js +0 -1
package/README.md
CHANGED
|
@@ -1,179 +1,233 @@
|
|
|
1
1
|
# pixi-live2d-display-advanced
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
4
|
+

|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
**English (Current)** | [**简体中文**](README-ZH.md)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
A Live2D rendering and control plugin designed for **[PixiJS v8](https://pixijs.com/)**.
|
|
9
|
+
|
|
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
|
+
|
|
13
|
+
This project is based on the
|
|
14
|
+
[pixi-live2d-display-mulmotion](https://github.com/Sekai-World/pixi-live2d-display) branch.
|
|
15
|
+
Starting from **v2.0.0**, it is **fully compatible with PixiJS v8 and Live2D Cubism 5.4 SDK**, and further provides:
|
|
16
|
+
|
|
17
|
+
- Additional practical APIs
|
|
18
|
+
- Stronger TypeScript type safety
|
|
19
|
+
- Optimized internal architecture for extensibility and maintainability
|
|
20
|
+
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
> The project is currently in the testing phase. If you want to try it out, please install it using the following command:
|
|
23
|
+
>
|
|
24
|
+
> If you are using PixiJS v7, please install the v1.x version.
|
|
25
|
+
>
|
|
26
|
+
> ```shell
|
|
27
|
+
> npm install pixi-live2d-display-advanced@prerelease
|
|
28
|
+
> ```
|
|
10
29
|
|
|
11
|
-
Compared to [pixi-live2d-display-mulmotion](https://www.npmjs.com/package/pixi-live2d-display-mulmotion), this project
|
|
12
|
-
additionally supports **playing the last frame of motions**, which is especially useful in
|
|
13
|
-
**Project SEKAI-like projects** where animations need to be reapplied frequently, and uses `@pixi/sound` as the audio
|
|
14
|
-
backend, fixing many issues such as model update and display anomalies.
|
|
15
30
|
|
|
16
31
|
---
|
|
17
32
|
|
|
18
33
|
## Features
|
|
19
34
|
|
|
20
|
-
- Supports all versions of Live2D models (Cubism 2
|
|
35
|
+
- Supports **all versions** of Live2D models (Cubism 2 / 3 / 4 / 5)
|
|
21
36
|
- Compatible with `PIXI.RenderTexture` and `PIXI.Filter`
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
37
|
+
- Provides a complete **PixiJS-style transform API**
|
|
38
|
+
- `position`
|
|
39
|
+
- `scale`
|
|
40
|
+
- `rotation`
|
|
41
|
+
- `skew`
|
|
42
|
+
- `anchor`
|
|
43
|
+
|
|
44
|
+
- Built-in interaction support
|
|
45
|
+
- Mouse tracking
|
|
46
|
+
- Hit area detection
|
|
47
|
+
|
|
48
|
+
- Improved **motion scheduling and reservation logic** compared to the official SDK
|
|
49
|
+
- Complete and strict **TypeScript type definitions**
|
|
50
|
+
- Real-time lip sync support
|
|
51
|
+
- **Parallel motion playback**
|
|
52
|
+
- Support for **freezing at the last frame of motions**
|
|
30
53
|
|
|
31
54
|
---
|
|
32
55
|
|
|
33
56
|
## Requirements
|
|
34
57
|
|
|
35
|
-
- **PixiJS**:
|
|
36
|
-
- **Cubism
|
|
37
|
-
- **Browser**: WebGL
|
|
58
|
+
- **PixiJS**: `8.x`
|
|
59
|
+
- **Cubism runtime**: `2.1` or `5`
|
|
60
|
+
- **Browser**: Must support `WebGL` and `ES6`
|
|
38
61
|
|
|
39
62
|
---
|
|
40
63
|
|
|
41
|
-
##
|
|
64
|
+
## Installation
|
|
42
65
|
|
|
43
|
-
|
|
44
|
-
- [Interaction Example](https://codepen.io/guansss/pen/KKgXBOP/left?editors=0010)
|
|
45
|
-
- [Render Texture & Filter Example](https://codepen.io/guansss/pen/qBaMNQV/left?editors=1010)
|
|
46
|
-
- [Live2D Viewer Online](https://guansss.github.io/live2d-viewer-web/)
|
|
47
|
-
- [Parallel Motions Example](#parallel-motions)
|
|
48
|
-
- [Play Motion Last Frame](#play-motion-last-frame)
|
|
66
|
+
### Using npm / pnpm
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
```bash
|
|
69
|
+
pnpm add pixi-live2d-display-advanced
|
|
70
|
+
# or
|
|
71
|
+
npm install pixi-live2d-display-advanced
|
|
72
|
+
```
|
|
51
73
|
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
```ts
|
|
75
|
+
import { Live2DModel } from 'pixi-live2d-display-advanced'
|
|
54
76
|
|
|
55
|
-
|
|
77
|
+
// Cubism Legacy only (Cubism 2.1)
|
|
78
|
+
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism-legacy'
|
|
56
79
|
|
|
57
|
-
|
|
80
|
+
// Cubism Modern only (Cubism 3 / 4 / 5)
|
|
81
|
+
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism'
|
|
82
|
+
```
|
|
58
83
|
|
|
59
|
-
|
|
60
|
-
Currently, there are three versions: **Cubism 2.1**, **Cubism 3**, and **Cubism 4** (Cubism 4 is backward-compatible
|
|
61
|
-
with Cubism 3).
|
|
84
|
+
---
|
|
62
85
|
|
|
63
|
-
|
|
86
|
+
## Cubism Runtime Overview
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
This project supports **all versions of Live2D models**, which can be categorized by Cubism architecture:
|
|
66
89
|
|
|
67
|
-
- **Cubism
|
|
90
|
+
- **Cubism Legacy**: Cubism 2.1
|
|
91
|
+
- **Cubism Modern**: Cubism 3 / 4 / 5
|
|
68
92
|
|
|
69
|
-
|
|
70
|
-
- Or use this [link](https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js) _(not guaranteed to be
|
|
71
|
-
always available, do not use in production)_
|
|
93
|
+
Choose the appropriate runtime entry based on the model you are using.
|
|
72
94
|
|
|
73
|
-
|
|
95
|
+
### Using Cubism Legacy and Cubism Modern Together
|
|
74
96
|
|
|
75
|
-
|
|
76
|
-
- Available on [GitHub](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib)
|
|
77
|
-
- Or via [jsDelivr CDN](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js)
|
|
97
|
+
#### Bundle entry
|
|
78
98
|
|
|
79
|
-
|
|
99
|
+
```text
|
|
100
|
+
index.js
|
|
101
|
+
```
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
> Use this unified entry when your project needs to load both Cubism 2 and Cubism 3+ models.
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-
- `cubism4.js` + `live2dcubismcore.min.js` → supports Cubism 3 & 4 models
|
|
85
|
-
- `index.js` + both runtimes → supports all versions
|
|
105
|
+
---
|
|
86
106
|
|
|
87
|
-
|
|
88
|
-
> Do **not** use `cubism2.js` and `cubism4.js` together. Use `index.js` instead if you need both.
|
|
107
|
+
### Cubism Legacy Only (Cubism 2.1)
|
|
89
108
|
|
|
90
|
-
|
|
109
|
+
#### Prerequisites
|
|
91
110
|
|
|
92
|
-
|
|
111
|
+
You must manually include `live2d.min.js`:
|
|
93
112
|
|
|
94
|
-
|
|
113
|
+
- Official distribution was discontinued on
|
|
114
|
+
[September 4, 2019](https://help.live2d.com/en/other/other_20/)
|
|
115
|
+
- Available from:
|
|
116
|
+
- GitHub:
|
|
117
|
+
[https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib)
|
|
118
|
+
- jsDelivr CDN:
|
|
119
|
+
[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)
|
|
95
120
|
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
#### Bundle entry
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
cubism-legacy.js
|
|
98
125
|
```
|
|
99
126
|
|
|
100
|
-
|
|
127
|
+
---
|
|
101
128
|
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
### Cubism Modern Only (Cubism 3 / 4 / 5)
|
|
130
|
+
|
|
131
|
+
#### Prerequisites
|
|
132
|
+
|
|
133
|
+
You must include `live2dcubismcore.min.js`:
|
|
104
134
|
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
- Downloadable from the official **Cubism 5 SDK**
|
|
136
|
+
[https://www.live2d.com/download/cubism-sdk/download-web/](https://www.live2d.com/download/cubism-sdk/download-web/)
|
|
107
137
|
|
|
108
|
-
|
|
109
|
-
|
|
138
|
+
#### Bundle entry
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
cubism.js
|
|
110
142
|
```
|
|
111
143
|
|
|
112
144
|
---
|
|
113
145
|
|
|
114
|
-
##
|
|
115
|
-
|
|
116
|
-
See example project: [pixi-live2d-display-lipsync](https://github.com/RaSan147/pixi-live2d-display)
|
|
146
|
+
## Quick Start
|
|
117
147
|
|
|
118
|
-
|
|
119
|
-
This is required to fix potential issues with model updates.
|
|
148
|
+
The following example is based on **PixiJS v8** and supports both Cubism Legacy and Cubism Modern.
|
|
120
149
|
|
|
121
150
|
```ts
|
|
122
|
-
import {
|
|
151
|
+
import { Application } from 'pixi.js'
|
|
152
|
+
import { configureCubism, Live2DModel } from 'pixi-live2d-display-advanced'
|
|
153
|
+
|
|
154
|
+
const app = new Application({
|
|
155
|
+
resizeTo: window,
|
|
156
|
+
preference: 'webgl'
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
document.body.appendChild(app.view as HTMLCanvasElement)
|
|
123
160
|
|
|
124
|
-
// Configure Cubism
|
|
125
|
-
|
|
126
|
-
|
|
161
|
+
// Configure Cubism Modern work memory (optional, default is 16MB)
|
|
162
|
+
// Increase this value when loading multiple or high-complexity models
|
|
163
|
+
configureCubism({
|
|
164
|
+
memorySizeMB: 32
|
|
127
165
|
})
|
|
128
166
|
|
|
129
|
-
|
|
130
|
-
|
|
167
|
+
const model = await Live2DModel.from('model/model3.json')
|
|
168
|
+
model.anchor.set(0.5)
|
|
169
|
+
model.position.set(app.screen.width / 2, app.screen.height / 2)
|
|
170
|
+
|
|
131
171
|
app.stage.addChild(model)
|
|
132
172
|
```
|
|
133
173
|
|
|
134
174
|
---
|
|
135
175
|
|
|
136
|
-
##
|
|
176
|
+
## Common API Examples
|
|
177
|
+
|
|
178
|
+
### Play a Motion
|
|
137
179
|
|
|
138
180
|
```ts
|
|
139
|
-
model.
|
|
140
|
-
{ group: motion_group1, index: motion_index1, priority: MotionPriority.NORMAL },
|
|
141
|
-
{ group: motion_group2, index: motion_index2, priority: MotionPriority.NORMAL }
|
|
142
|
-
])
|
|
181
|
+
model.motion('group', index)
|
|
143
182
|
```
|
|
144
183
|
|
|
145
|
-
|
|
146
|
-
`model.parallelMotion` for others.
|
|
147
|
-
Each item has independent priority control, following the same logic as `model.motion`.
|
|
184
|
+
### Parallel Motions
|
|
148
185
|
|
|
149
|
-
|
|
186
|
+
```ts
|
|
187
|
+
model.parallelMotion([
|
|
188
|
+
{ group: group1, index: index1 },
|
|
189
|
+
{ group: group2, index: index2 }
|
|
190
|
+
])
|
|
191
|
+
```
|
|
150
192
|
|
|
151
|
-
|
|
193
|
+
### Play and Freeze at the Last Frame
|
|
152
194
|
|
|
153
|
-
Single motion
|
|
195
|
+
**Single motion:**
|
|
154
196
|
|
|
155
197
|
```ts
|
|
156
|
-
|
|
198
|
+
model.motionLastFrame('group', index)
|
|
157
199
|
```
|
|
158
200
|
|
|
159
|
-
Multiple motions
|
|
201
|
+
**Multiple motions:**
|
|
160
202
|
|
|
161
203
|
```ts
|
|
162
204
|
await model.parallelLastFrame([
|
|
163
|
-
{ group:
|
|
164
|
-
{ group:
|
|
205
|
+
{ group: group1, index: index1 },
|
|
206
|
+
{ group: group2, index: index2 }
|
|
165
207
|
])
|
|
166
208
|
```
|
|
167
209
|
|
|
168
|
-
|
|
210
|
+
### Lip Sync
|
|
169
211
|
|
|
170
212
|
```ts
|
|
171
|
-
model.
|
|
172
|
-
|
|
173
|
-
const manager2 = model.internalModel.parallelMotionManager[1]!
|
|
213
|
+
model.speak('audio_file_url')
|
|
214
|
+
```
|
|
174
215
|
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
### Expressions
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
model.expression('id')
|
|
177
220
|
```
|
|
178
221
|
|
|
179
|
-
|
|
222
|
+
For more advanced usage, see
|
|
223
|
+
[pixi-live2d-display-lipsync](https://github.com/RaSan147/pixi-live2d-display)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## FAQ
|
|
228
|
+
|
|
229
|
+
### Q: Why do models stop updating when multiple models are loaded?
|
|
230
|
+
|
|
231
|
+
When using the **Cubism Modern** runtime, this issue is usually caused by insufficient work memory configured via `configureCubism`.
|
|
232
|
+
|
|
233
|
+
Try increasing `memorySizeMB` during initialization (minimum: 16MB).
|