untitled-pixi-live2d-engine 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/cubism-legacy.es.js +4203 -0
- package/dist/cubism-legacy.js +4205 -0
- package/dist/cubism-legacy.min.js +1 -0
- package/dist/cubism.es.js +15689 -0
- package/dist/cubism.js +15690 -0
- package/dist/cubism.min.js +1 -0
- package/dist/extra.es.js +79 -0
- package/dist/extra.js +82 -0
- package/dist/extra.min.js +1 -0
- package/dist/index.es.js +16479 -0
- package/dist/index.js +16481 -0
- package/dist/index.min.js +1 -0
- package/package.json +93 -0
- package/types/extra.d.ts +17 -0
- package/types/index.d.ts +6812 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GuangChen2333
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# untitled-pixi-live2d-engine
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
**English (Current)** | [**简体中文**](README-ZH.md)
|
|
7
|
+
|
|
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
|
+
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
|
+
> ```shell
|
|
25
|
+
> npm install untitled-pixi-live2d-engine@prerelease
|
|
26
|
+
> ```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Supports **all versions** of Live2D models (Cubism 2 / 3 / 4 / 5)
|
|
33
|
+
- Compatible with `PIXI.RenderTexture` and `PIXI.Filter`
|
|
34
|
+
- Provides a complete **PixiJS-style transform API**
|
|
35
|
+
- `position`
|
|
36
|
+
- `scale`
|
|
37
|
+
- `rotation`
|
|
38
|
+
- `skew`
|
|
39
|
+
- `anchor`
|
|
40
|
+
|
|
41
|
+
- Built-in interaction support
|
|
42
|
+
- Mouse tracking
|
|
43
|
+
- Hit area detection
|
|
44
|
+
|
|
45
|
+
- Improved **motion scheduling and reservation logic** compared to the official SDK
|
|
46
|
+
- Complete and strict **TypeScript type definitions**
|
|
47
|
+
- Real-time lip sync support
|
|
48
|
+
- **Parallel motion playback**
|
|
49
|
+
- Support for **freezing at the last frame of motions**
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
|
|
55
|
+
- **PixiJS**: `8.x`
|
|
56
|
+
- **Cubism runtime**: `2.1` or `5`
|
|
57
|
+
- **Browser**: Must support `WebGL` and `ES6`
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
### Using npm / pnpm
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm add untitled-pixi-live2d-engine
|
|
67
|
+
# or
|
|
68
|
+
npm install untitled-pixi-live2d-engine
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { Live2DModel } from 'untitled-pixi-live2d-engine'
|
|
73
|
+
|
|
74
|
+
// Cubism Legacy only (Cubism 2.1)
|
|
75
|
+
import { Live2DModel } from 'untitled-pixi-live2d-engine/cubism-legacy'
|
|
76
|
+
|
|
77
|
+
// Cubism Modern only (Cubism 3 / 4 / 5)
|
|
78
|
+
import { Live2DModel } from 'untitled-pixi-live2d-engine/cubism'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Cubism Runtime Overview
|
|
84
|
+
|
|
85
|
+
This project supports **all versions of Live2D models**, which can be categorized by Cubism architecture:
|
|
86
|
+
|
|
87
|
+
- **Cubism Legacy**: Cubism 2.1
|
|
88
|
+
- **Cubism Modern**: Cubism 3 / 4 / 5
|
|
89
|
+
|
|
90
|
+
Choose the appropriate runtime entry based on the model you are using.
|
|
91
|
+
|
|
92
|
+
### Using Cubism Legacy and Cubism Modern Together
|
|
93
|
+
|
|
94
|
+
#### Bundle entry
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
index.js
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> Use this unified entry when your project needs to load both Cubism 2 and Cubism 3+ models.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### Cubism Legacy Only (Cubism 2.1)
|
|
105
|
+
|
|
106
|
+
#### Prerequisites
|
|
107
|
+
|
|
108
|
+
You must manually include `live2d.min.js`:
|
|
109
|
+
|
|
110
|
+
- Official distribution was discontinued on
|
|
111
|
+
[September 4, 2019](https://help.live2d.com/en/other/other_20/)
|
|
112
|
+
- Available from:
|
|
113
|
+
- GitHub:
|
|
114
|
+
[https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib)
|
|
115
|
+
- jsDelivr CDN:
|
|
116
|
+
[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)
|
|
117
|
+
|
|
118
|
+
#### Bundle entry
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
cubism-legacy.js
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Cubism Modern Only (Cubism 3 / 4 / 5)
|
|
127
|
+
|
|
128
|
+
#### Prerequisites
|
|
129
|
+
|
|
130
|
+
You must include `live2dcubismcore.min.js`:
|
|
131
|
+
|
|
132
|
+
- Downloadable from the official **Cubism 5 SDK**
|
|
133
|
+
[https://www.live2d.com/download/cubism-sdk/download-web/](https://www.live2d.com/download/cubism-sdk/download-web/)
|
|
134
|
+
|
|
135
|
+
#### Bundle entry
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
cubism.js
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Quick Start
|
|
144
|
+
|
|
145
|
+
The following example is based on **PixiJS v8** and supports both Cubism Legacy and Cubism Modern.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { Application } from 'pixi.js'
|
|
149
|
+
import { configureCubism, Live2DModel } from 'untitled-pixi-live2d-engine'
|
|
150
|
+
|
|
151
|
+
const app = new Application()
|
|
152
|
+
await app.init({
|
|
153
|
+
resizeTo: window,
|
|
154
|
+
preference: 'webgl',
|
|
155
|
+
autoDensity: true,
|
|
156
|
+
resolution: window.devicePixelRatio
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
document.body.appendChild(app.canvas)
|
|
160
|
+
|
|
161
|
+
// Configure Cubism Modern work memory (optional, default is 16MB)
|
|
162
|
+
// Increase this value when loading multiple or high-complexity models
|
|
163
|
+
// configureCubismSDK({
|
|
164
|
+
// memorySizeMB: 32
|
|
165
|
+
// })
|
|
166
|
+
|
|
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
|
+
|
|
171
|
+
app.stage.addChild(model)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Common API Examples
|
|
177
|
+
|
|
178
|
+
### Play a Motion
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
model.motion('group', index)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Parallel Motions
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
model.parallelMotion([
|
|
188
|
+
{ group: group1, index: index1 },
|
|
189
|
+
{ group: group2, index: index2 }
|
|
190
|
+
])
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Play and Freeze at the Last Frame
|
|
194
|
+
|
|
195
|
+
**Single motion:**
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
model.motionLastFrame('group', index)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Multiple motions:**
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
await model.parallelLastFrame([
|
|
205
|
+
{ group: group1, index: index1 },
|
|
206
|
+
{ group: group2, index: index2 }
|
|
207
|
+
])
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Lip Sync
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
model.speak('audio_file_url')
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Expressions
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
model.expression('id')
|
|
220
|
+
```
|
|
221
|
+
|
|
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).
|