pixi-live2d-display-advanced 0.5.5 → 1.0.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/LICENSE +21 -21
- package/README.md +89 -64
- package/README.zh.md +78 -80
- package/dist/cubism2.es.js +1 -4
- package/dist/cubism2.js +1 -4
- package/dist/cubism2.min.js +1 -1
- package/dist/cubism4.es.js +77 -60
- package/dist/cubism4.js +77 -60
- package/dist/cubism4.min.js +1 -1
- package/dist/index.es.js +76 -59
- package/dist/index.js +76 -59
- package/dist/index.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +14 -13
package/LICENSE
CHANGED
|
@@ -1,21 +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.
|
|
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
CHANGED
|
@@ -3,104 +3,135 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
A Live2D plugin for [PixiJS](https://github.com/pixijs/pixi.js) v7
|
|
6
|
+
A Live2D plugin for [PixiJS](https://github.com/pixijs/pixi.js) v7.
|
|
7
7
|
|
|
8
|
-
This project
|
|
9
|
-
|
|
10
|
-
allowing you to control Live2D models at a high level without needing to understand the internals.
|
|
8
|
+
This project provides a **unified and simplified API** for controlling Live2D models on the web.
|
|
9
|
+
Compared to the official Live2D SDKs, this library is easier to use, more reliable, and more maintainable.
|
|
11
10
|
|
|
12
|
-
Compared to [pixi-live2d-display-mulmotion](https://www.npmjs.com/package/pixi-live2d-display-mulmotion), this project
|
|
13
|
-
playing the last frame of motions
|
|
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.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
---
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
## Features
|
|
18
19
|
|
|
19
|
-
- Supports all versions of Live2D models
|
|
20
|
-
-
|
|
21
|
-
- Pixi.js style transform API: position
|
|
20
|
+
- Supports all versions of Live2D models (Cubism 2.1, 3, 4)
|
|
21
|
+
- Compatible with `PIXI.RenderTexture` and `PIXI.Filter`
|
|
22
|
+
- Familiar Pixi.js style transform API: `position`, `scale`, `rotation`, `skew`, `anchor`
|
|
22
23
|
- Automatic interaction: mouse tracking, hit detection on click
|
|
23
|
-
-
|
|
24
|
-
- Load from uploaded files or zip
|
|
25
|
-
- Complete type definitions
|
|
24
|
+
- Enhanced motion reservation logic compared to the official framework
|
|
25
|
+
- Load models from uploaded files or zip archives (experimental)
|
|
26
|
+
- Complete TypeScript type definitions
|
|
26
27
|
- Real-time lip sync
|
|
27
28
|
- Play multiple motions simultaneously
|
|
28
29
|
- Play the last frame of motions
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
---
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
- Cubism core: 2.1 or 4
|
|
34
|
-
- Browser: WebGL, ES6
|
|
33
|
+
## Requirements
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
- **PixiJS**: 7.x
|
|
36
|
+
- **Cubism Core**: 2.1 or 4
|
|
37
|
+
- **Browser**: WebGL, ES6
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
- [Basic Example](#basic-usage)
|
|
39
44
|
- [Interaction Example](https://codepen.io/guansss/pen/KKgXBOP/left?editors=0010)
|
|
40
45
|
- [Render Texture & Filter Example](https://codepen.io/guansss/pen/qBaMNQV/left?editors=1010)
|
|
41
46
|
- [Live2D Viewer Online](https://guansss.github.io/live2d-viewer-web/)
|
|
42
47
|
- [Parallel Motions Example](#parallel-motions)
|
|
43
48
|
- [Play Motion Last Frame](#play-motion-last-frame)
|
|
44
49
|
|
|
45
|
-
|
|
50
|
+
Documentation:
|
|
51
|
+
|
|
52
|
+
- [User Guide](https://guansss.github.io/pixi-live2d-display)
|
|
53
|
+
- [API Reference](https://guansss.github.io/pixi-live2d-display/api/index.html)
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
- [API Docs](https://guansss.github.io/pixi-live2d-display/api/index.html)
|
|
55
|
+
---
|
|
49
56
|
|
|
50
|
-
## Cubism
|
|
57
|
+
## Cubism Runtime
|
|
51
58
|
|
|
52
|
-
Cubism is the name of the Live2D SDK.
|
|
59
|
+
Cubism is the official name of the Live2D SDK.
|
|
60
|
+
Currently, there are three versions: **Cubism 2.1**, **Cubism 3**, and **Cubism 4** (Cubism 4 is backward-compatible
|
|
61
|
+
with Cubism 3).
|
|
53
62
|
|
|
54
|
-
This plugin supports Cubism 2.1 and Cubism 4
|
|
63
|
+
This plugin supports **Cubism 2.1 and Cubism 4**, covering all versions of Live2D models.
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
### Load Cubism Core
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
- **Cubism 4**: `live2dcubismcore.min.js`
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(_Note: this link may occasionally be unavailable, do not use it in production!_)
|
|
69
|
+
- Download from the [Cubism 4 SDK](https://www.live2d.com/download/cubism-sdk/download-web/)
|
|
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)_
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
the official website no longer provides this version of the SDK, but you can find it [here](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib),
|
|
67
|
-
or use this [CDN link](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js).
|
|
73
|
+
- **Cubism 2.1**: `live2d.min.js`
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
- The official site no longer provides it since [September 4, 2019](https://help.live2d.com/en/other/other_20/)
|
|
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)
|
|
70
78
|
|
|
71
|
-
|
|
79
|
+
### Bundled Files
|
|
72
80
|
|
|
73
|
-
|
|
81
|
+
This plugin provides **separate builds** for different Cubism versions:
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
- `cubism2.js` + `live2d.min.js` → supports Cubism 2.1 models
|
|
84
|
+
- `cubism4.js` + `live2dcubismcore.min.js` → supports Cubism 3 & 4 models
|
|
85
|
+
- `index.js` + both runtimes → supports all versions
|
|
76
86
|
|
|
77
|
-
|
|
87
|
+
> [!WARNING]
|
|
88
|
+
> Do **not** use `cubism2.js` and `cubism4.js` together. Use `index.js` instead if you need both.
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
- Use `cubism4.js` + `live2dcubismcore.min.js` to support Cubism 3 and Cubism 4 models
|
|
81
|
-
- Use `index.js` + `live2d.min.js` + `live2dcubismcore.min.js` to support all versions of models
|
|
90
|
+
---
|
|
82
91
|
|
|
83
92
|
## Installation
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
Via npm:
|
|
86
95
|
|
|
87
96
|
```sh
|
|
88
97
|
npm install pixi-live2d-display-advanced
|
|
89
98
|
```
|
|
90
99
|
|
|
91
|
-
|
|
100
|
+
Usage:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
92
103
|
import { Live2DModel } from 'pixi-live2d-display-advanced'
|
|
93
104
|
|
|
94
|
-
//
|
|
105
|
+
// Only Cubism 2.1
|
|
95
106
|
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism2'
|
|
96
107
|
|
|
97
|
-
//
|
|
108
|
+
// Only Cubism 4
|
|
98
109
|
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism4'
|
|
99
110
|
```
|
|
100
111
|
|
|
112
|
+
---
|
|
113
|
+
|
|
101
114
|
## Basic Usage
|
|
102
115
|
|
|
103
|
-
See
|
|
116
|
+
See example project: [pixi-live2d-display-lipsync](https://github.com/RaSan147/pixi-live2d-display)
|
|
117
|
+
|
|
118
|
+
When using the Cubism 4 module, you need to call configureCubism4() once before loading models.
|
|
119
|
+
This is required to fix potential issues with model updates.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { Live2DModel, configureCubism4 } from 'pixi-live2d-display-advanced/cubism4'
|
|
123
|
+
|
|
124
|
+
// Configure Cubism runtime (only needs to be called once)
|
|
125
|
+
configureCubism4({
|
|
126
|
+
memorySizeMB: 128
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// Load a model
|
|
130
|
+
const model = await Live2DModel.from('mymodel.model3.json')
|
|
131
|
+
app.stage.addChild(model)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
104
135
|
|
|
105
136
|
## Parallel Motions
|
|
106
137
|
|
|
@@ -111,18 +142,21 @@ model.parallelMotion([
|
|
|
111
142
|
])
|
|
112
143
|
```
|
|
113
144
|
|
|
114
|
-
|
|
115
|
-
|
|
145
|
+
For syncing motions with expressions/sounds, use `model.motion` or `model.speak` for one motion, and
|
|
146
|
+
`model.parallelMotion` for others.
|
|
147
|
+
Each item has independent priority control, following the same logic as `model.motion`.
|
|
148
|
+
|
|
149
|
+
---
|
|
116
150
|
|
|
117
151
|
## Play Motion Last Frame
|
|
118
152
|
|
|
119
|
-
|
|
153
|
+
Single motion:
|
|
120
154
|
|
|
121
155
|
```ts
|
|
122
156
|
await model.motionLastFrame('w-cute12-tilthead', 0)
|
|
123
157
|
```
|
|
124
158
|
|
|
125
|
-
|
|
159
|
+
Multiple motions:
|
|
126
160
|
|
|
127
161
|
```ts
|
|
128
162
|
await model.parallelLastFrame([
|
|
@@ -131,24 +165,15 @@ await model.parallelLastFrame([
|
|
|
131
165
|
])
|
|
132
166
|
```
|
|
133
167
|
|
|
134
|
-
Or:
|
|
168
|
+
Or with manual parallel motion managers:
|
|
135
169
|
|
|
136
170
|
```ts
|
|
137
171
|
model.internalModel.extendParallelMotionManager(2)
|
|
138
172
|
const manager1 = model.internalModel.parallelMotionManager[0]!
|
|
139
173
|
const manager2 = model.internalModel.parallelMotionManager[1]!
|
|
174
|
+
|
|
140
175
|
manager1.playMotionLastFrame('w-cute12-tilthead', 0)
|
|
141
176
|
manager2.playMotionLastFrame('face_worry_01', 0)
|
|
142
177
|
```
|
|
143
178
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## v1.0.0 TODOs
|
|
147
|
-
|
|
148
|
-
- [ ] Improve documentation
|
|
149
|
-
- [ ] Update tests
|
|
150
|
-
- [ ] Automate build scripts
|
|
151
|
-
|
|
152
|
-
In v2.0.0, the project plans to upgrade to pixi.js v8.
|
|
153
|
-
|
|
154
|
-
# For more documentation, please refer to: [Documentation](https://guansss.github.io/pixi-live2d-display/)
|
|
179
|
+
Both approaches are equivalent — the first is syntactic sugar for the second.
|
package/README.zh.md
CHANGED
|
@@ -1,108 +1,116 @@
|
|
|
1
|
-
# pixi-live2d-display-advanced
|
|
1
|
+
# pixi-live2d-display-advanced(高级版)
|
|
2
2
|
|
|
3
|
-

|
|
4
|
+

|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
一款适用于 [PixiJS](https://github.com/pixijs/pixi.js) v7 的 Live2D 插件。
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
由于 Live2D 的官方框架非常复杂且不可靠,这个项目已将其重写以提供统一且简单的 API,
|
|
10
|
-
使你可以从较高的层次来控制 Live2D 模型而无需了解其内部的工作原理
|
|
8
|
+
该项目为在网页端控制 Live2D 模型提供了**统一且简化的 API**。与官方 Live2D SDK 相比,本库使用更简便、稳定性更高且更易于维护。
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
播放动作最末帧的支持。在 Project SEKAI like 项目中大幅地缩短了再次应用动作的时间。
|
|
10
|
+
与 [pixi-live2d-display-mulmotion](https://www.npmjs.com/package/pixi-live2d-display-mulmotion) 相比,该项目额外支持**播放动作的最后一帧**——这在**类 Project SEKAI(世界计划)项目**中尤为实用(此类项目需频繁重新应用动画);同时,本项目采用 `@pixi/sound` 作为音频后端,修复了模型更新、显示异常等诸多问题。
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
## 功能特性
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- 从上传的文件或 zip 文件中加载 (实验性功能)
|
|
25
|
-
- 完善的类型定义 - 我们都喜欢类型!
|
|
14
|
+
- 支持所有版本的 Live2D 模型(Cubism 2.1、3、4)
|
|
15
|
+
- 兼容 `PIXI.RenderTexture`(渲染纹理)与 `PIXI.Filter`(滤镜)
|
|
16
|
+
- 熟悉的 Pixi.js 风格变换 API:`position`(位置)、`scale`(缩放)、`rotation`(旋转)、`skew`(倾斜)、`anchor`(锚点)
|
|
17
|
+
- 自动交互功能:鼠标追踪、点击命中检测
|
|
18
|
+
- 相比官方框架,优化了动作预约逻辑
|
|
19
|
+
- 支持从上传文件或压缩包中加载模型(实验性功能)
|
|
20
|
+
- 完整的 TypeScript 类型定义
|
|
26
21
|
- 实时口型同步
|
|
27
|
-
-
|
|
28
|
-
-
|
|
22
|
+
- 支持同时播放多个动作
|
|
23
|
+
- 支持播放动作的最后一帧
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
## 依赖要求
|
|
31
26
|
|
|
32
|
-
- PixiJS
|
|
33
|
-
- Cubism
|
|
34
|
-
-
|
|
27
|
+
- **PixiJS**:7.x 版本
|
|
28
|
+
- **Cubism 核心**:2.1 或 4 版本
|
|
29
|
+
- **浏览器**:需支持 WebGL 和 ES6 语法
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
## 示例演示
|
|
37
32
|
|
|
38
|
-
- [基础示例](
|
|
33
|
+
- [基础示例](#基础用法)
|
|
39
34
|
- [交互示例](https://codepen.io/guansss/pen/KKgXBOP/left?editors=0010)
|
|
40
35
|
- [渲染纹理与滤镜示例](https://codepen.io/guansss/pen/qBaMNQV/left?editors=1010)
|
|
41
|
-
- [Live2D
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
44
|
-
|
|
45
|
-
#### 文档
|
|
36
|
+
- [在线 Live2D 查看器](https://guansss.github.io/live2d-viewer-web/)
|
|
37
|
+
- [并行动作示例](#并行动作)
|
|
38
|
+
- [播放动作最后一帧示例](#播放动作最后一帧)
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
- [API 文档](https://guansss.github.io/pixi-live2d-display/api/index.html)
|
|
40
|
+
文档资料:
|
|
49
41
|
|
|
50
|
-
|
|
42
|
+
- [用户指南](https://guansss.github.io/pixi-live2d-display)
|
|
43
|
+
- [API 参考](https://guansss.github.io/pixi-live2d-display/api/index.html)
|
|
51
44
|
|
|
52
|
-
|
|
45
|
+
## Cubism 运行时
|
|
53
46
|
|
|
54
|
-
|
|
47
|
+
Cubism 是 Live2D SDK 的官方名称。目前共有三个版本:**Cubism 2.1**、**Cubism 3** 和 **Cubism 4**(其中 Cubism 4 向下兼容 Cubism 3)。
|
|
55
48
|
|
|
56
|
-
|
|
49
|
+
本插件支持 **Cubism 2.1 和 Cubism 4**,可覆盖所有版本的 Live2D 模型。
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
### 加载 Cubism 核心文件
|
|
59
52
|
|
|
60
|
-
Cubism 4
|
|
61
|
-
,可以从 [Cubism 4 SDK](https://www.live2d.com/download/cubism-sdk/download-web/)
|
|
62
|
-
里解压出来,或者直接引用[这个链接](https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js)
|
|
63
|
-
(_链接偶尔会挂掉,不要在生产版本中使用!_)
|
|
53
|
+
- **Cubism 4**:`live2dcubismcore.min.js`
|
|
64
54
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
找到,以及你大概想要的 [CDN 链接](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js)
|
|
55
|
+
- 可从 [Cubism 4 SDK](https://www.live2d.com/download/cubism-sdk/download-web/) 下载
|
|
56
|
+
- 也可使用此链接([link](https://cubism.live2d.com/sdk-web/cubismcore/live2dcubismcore.min.js))_(不保证长期可用,请勿用于生产环境)_
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
- **Cubism 2.1**:`live2d.min.js`
|
|
59
|
+
- 官方网站自 [2019 年 9 月 4 日](https://help.live2d.com/en/other/other_20/) 起不再提供该文件
|
|
60
|
+
- 可在 [GitHub](https://github.com/dylanNew/live2d/tree/master/webgl/Live2D/lib) 上获取
|
|
61
|
+
- 也可通过 [jsDelivr 内容分发网络](https://cdn.jsdelivr.net/gh/dylanNew/live2d/webgl/Live2D/lib/live2d.min.js) 获取
|
|
70
62
|
|
|
71
|
-
|
|
63
|
+
### 打包文件
|
|
72
64
|
|
|
73
|
-
|
|
65
|
+
本插件为不同 Cubism 版本提供了**独立的构建文件**:
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
- `cubism2.js` + `live2d.min.js` → 支持 Cubism 2.1 模型
|
|
68
|
+
- `cubism4.js` + `live2dcubismcore.min.js` → 支持 Cubism 3 和 4 模型
|
|
69
|
+
- `index.js` + 两种运行时 → 支持所有版本的模型
|
|
76
70
|
|
|
77
|
-
|
|
71
|
+
> [!Warning]
|
|
72
|
+
> 请勿同时使用 `cubism2.js` 和 `cubism4.js`。若需同时支持两种版本,请使用 `index.js`。
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
- 使用 `cubism4.js`+`live2dcubismcore.min.js` 以支持 Cubism 3 和 Cubism 4 模型
|
|
81
|
-
- 使用 `index.js`+`live2d.min.js`+`live2dcubismcore.min.js` 以支持所有版本的模型
|
|
74
|
+
## 安装方式
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#### 通过 npm
|
|
76
|
+
通过 npm 安装:
|
|
86
77
|
|
|
87
78
|
```sh
|
|
88
79
|
npm install pixi-live2d-display-advanced
|
|
89
80
|
```
|
|
90
81
|
|
|
91
|
-
|
|
82
|
+
使用方式:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
92
85
|
import { Live2DModel } from 'pixi-live2d-display-advanced'
|
|
93
86
|
|
|
94
|
-
//
|
|
87
|
+
// 仅支持 Cubism 2.1
|
|
95
88
|
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism2'
|
|
96
89
|
|
|
97
|
-
//
|
|
90
|
+
// 仅支持 Cubism 4
|
|
98
91
|
import { Live2DModel } from 'pixi-live2d-display-advanced/cubism4'
|
|
99
92
|
```
|
|
100
93
|
|
|
101
|
-
##
|
|
94
|
+
## 基础用法
|
|
95
|
+
|
|
96
|
+
参考示例项目:[pixi-live2d-display-lipsync](https://github.com/RaSan147/pixi-live2d-display)
|
|
97
|
+
|
|
98
|
+
使用 Cubism 4 模块时,需在加载模型前调用一次 `configureCubism4()` 方法。此操作是修复模型更新潜在问题的必要步骤。
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { Live2DModel, configureCubism4 } from 'pixi-live2d-display-advanced/cubism4'
|
|
102
|
+
|
|
103
|
+
// 配置 Cubism 运行时(仅需调用一次)
|
|
104
|
+
configureCubism4({
|
|
105
|
+
memorySizeMB: 128 // 内存大小(单位:MB)
|
|
106
|
+
})
|
|
102
107
|
|
|
103
|
-
|
|
108
|
+
// 加载模型
|
|
109
|
+
const model = await Live2DModel.from('mymodel.model3.json')
|
|
110
|
+
app.stage.addChild(model)
|
|
111
|
+
```
|
|
104
112
|
|
|
105
|
-
##
|
|
113
|
+
## 并行动作
|
|
106
114
|
|
|
107
115
|
```ts
|
|
108
116
|
model.parallelMotion([
|
|
@@ -111,18 +119,17 @@ model.parallelMotion([
|
|
|
111
119
|
])
|
|
112
120
|
```
|
|
113
121
|
|
|
114
|
-
|
|
115
|
-
列表中按照 index 每一项都有独立的优先级控制,和`model.motion`逻辑一致。
|
|
122
|
+
若需将动作与表情/声音同步:单个动作可使用 `model.motion` 或 `model.speak` 方法,其他动作可使用 `model.parallelMotion` 方法。每个动作项都拥有独立的优先级控制,其逻辑与 `model.motion` 一致。
|
|
116
123
|
|
|
117
|
-
##
|
|
124
|
+
## 播放动作最后一帧
|
|
118
125
|
|
|
119
|
-
|
|
126
|
+
单个动作:
|
|
120
127
|
|
|
121
128
|
```ts
|
|
122
129
|
await model.motionLastFrame('w-cute12-tilthead', 0)
|
|
123
130
|
```
|
|
124
131
|
|
|
125
|
-
|
|
132
|
+
多个动作:
|
|
126
133
|
|
|
127
134
|
```ts
|
|
128
135
|
await model.parallelLastFrame([
|
|
@@ -131,24 +138,15 @@ await model.parallelLastFrame([
|
|
|
131
138
|
])
|
|
132
139
|
```
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
或使用手动并行动作管理器:
|
|
135
142
|
|
|
136
143
|
```ts
|
|
137
144
|
model.internalModel.extendParallelMotionManager(2)
|
|
138
145
|
const manager1 = model.internalModel.parallelMotionManager[0]!
|
|
139
146
|
const manager2 = model.internalModel.parallelMotionManager[1]!
|
|
147
|
+
|
|
140
148
|
manager1.playMotionLastFrame('w-cute12-tilthead', 0)
|
|
141
149
|
manager2.playMotionLastFrame('face_worry_01', 0)
|
|
142
150
|
```
|
|
143
151
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## v1.0.0 TODOs
|
|
147
|
-
|
|
148
|
-
- [ ] 完善文档
|
|
149
|
-
- [ ] 更改测试
|
|
150
|
-
- [ ] 自动化构建脚本
|
|
151
|
-
|
|
152
|
-
拟在 v2.0.0 中,项目升级到 pixi.js v8
|
|
153
|
-
|
|
154
|
-
# 请参阅此处了解更多文档: [文档](https://guansss.github.io/pixi-live2d-display/)
|
|
152
|
+
以上两种方式效果相同——第一种是第二种的语法糖(简化写法)。
|
package/dist/cubism2.es.js
CHANGED
|
@@ -78,7 +78,7 @@ const config = {
|
|
|
78
78
|
preserveExpressionOnMotion: true,
|
|
79
79
|
cubism4: CubismConfig
|
|
80
80
|
};
|
|
81
|
-
const VERSION = "
|
|
81
|
+
const VERSION = "v1.0.0";
|
|
82
82
|
const logger = {
|
|
83
83
|
log(tag, ...messages) {
|
|
84
84
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -5783,9 +5783,6 @@ class Live2DModel extends Container {
|
|
|
5783
5783
|
this.deltaTime = 0;
|
|
5784
5784
|
}
|
|
5785
5785
|
const internalTransform = tempMatrix.copyFrom(renderer.projection.projectionMatrix).append(this.worldTransform);
|
|
5786
|
-
if (this.filters && this.filters.length > 0) {
|
|
5787
|
-
internalTransform.scale(-1, 1);
|
|
5788
|
-
}
|
|
5789
5786
|
this.internalModel.updateTransform(internalTransform);
|
|
5790
5787
|
this.internalModel.draw(renderer.gl);
|
|
5791
5788
|
renderer.state.reset();
|
package/dist/cubism2.js
CHANGED
|
@@ -79,7 +79,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
79
|
preserveExpressionOnMotion: true,
|
|
80
80
|
cubism4: CubismConfig
|
|
81
81
|
};
|
|
82
|
-
const VERSION = "
|
|
82
|
+
const VERSION = "v1.0.0";
|
|
83
83
|
const logger = {
|
|
84
84
|
log(tag, ...messages) {
|
|
85
85
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -5784,9 +5784,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5784
5784
|
this.deltaTime = 0;
|
|
5785
5785
|
}
|
|
5786
5786
|
const internalTransform = tempMatrix.copyFrom(renderer.projection.projectionMatrix).append(this.worldTransform);
|
|
5787
|
-
if (this.filters && this.filters.length > 0) {
|
|
5788
|
-
internalTransform.scale(-1, 1);
|
|
5789
|
-
}
|
|
5790
5787
|
this.internalModel.updateTransform(internalTransform);
|
|
5791
5788
|
this.internalModel.draw(renderer.gl);
|
|
5792
5789
|
renderer.state.reset();
|