cocos-plugin-live2d 0.0.14 → 0.0.16
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 +57 -19
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -1,41 +1,79 @@
|
|
|
1
1
|
# cocos-plugin-live2d
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Cocos Creator 适配包** — 在 Creator 组件里挂载 Live2D,会话 / 求值 / 渲染仍由 [
|
|
4
|
+
`@doki-land/live2d`](https://www.npmjs.com/package/@doki-land/live2d) 负责。
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
| --- | --- | --- |
|
|
7
|
-
| `cocos-plugin-live2d` or `…/creator3` | `src/creator3` | Creator **3.x** Web runtime |
|
|
8
|
-
| `cocos-plugin-live2d/creator2` | `src/creator2` | Creator **2.4** scaffold (component shell only) |
|
|
6
|
+
一个 npm 包、两个入口,分别对应 Creator 3.x 与 2.4 脚手架。
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
在 Cocos 项目的 `package.json` 中添加依赖后执行 Creator 的扩展安装流程(或 npm/pnpm 安装到项目):
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i cocos-plugin-live2d @doki-land/live2d
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 选择入口
|
|
17
|
+
|
|
18
|
+
| import | Creator 版本 | 状态 |
|
|
19
|
+
|---------------------------------------------------------|--------------|--------------------------------------------|
|
|
20
|
+
| `cocos-plugin-live2d` 或 `cocos-plugin-live2d/creator3` | **3.x** | 可用:Web 运行时 + offscreen canvas |
|
|
21
|
+
| `cocos-plugin-live2d/creator2` | **2.4** | 脚手架:`cc.Component` 壳,尚未接线 live2d |
|
|
22
|
+
|
|
23
|
+
验证当前解析到的 API 版本:
|
|
11
24
|
|
|
12
25
|
```ts
|
|
13
26
|
import { COCOS_CREATOR_API, Live2D } from "cocos-plugin-live2d/creator3";
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
import { COCOS_CREATOR_API, Live2D } from "cocos-plugin-live2d/creator2";
|
|
17
|
-
// → COCOS_CREATOR_API === 2
|
|
27
|
+
// COCOS_CREATOR_API === 3
|
|
18
28
|
```
|
|
19
29
|
|
|
20
|
-
## Creator 3
|
|
30
|
+
## Creator 3.x 用法
|
|
21
31
|
|
|
22
32
|
```ts
|
|
33
|
+
import { _decorator, Component } from "cc";
|
|
23
34
|
import { Live2D } from "cocos-plugin-live2d/creator3";
|
|
24
35
|
|
|
25
|
-
const
|
|
26
|
-
|
|
36
|
+
const { ccclass, property } = _decorator;
|
|
37
|
+
|
|
38
|
+
@ccclass("MyLive2D")
|
|
39
|
+
export class MyLive2D extends Live2D {
|
|
40
|
+
start() {
|
|
41
|
+
this.model = "https://example.com/model/Wanko.model3.json";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
27
44
|
```
|
|
28
45
|
|
|
29
|
-
|
|
46
|
+
或在编辑器里给节点添加 `Live2D` 组件,在属性检查器填写 `model` URL(`model3.json` / `model.json` / `npm:…`)。
|
|
47
|
+
|
|
48
|
+
组件内部会:
|
|
49
|
+
|
|
50
|
+
1. 创建离屏 Canvas
|
|
51
|
+
2. `createLive2D()` + `mount`
|
|
52
|
+
3. 在 Creator 更新循环里驱动 `update` / `render`(与引擎帧同步)
|
|
53
|
+
|
|
54
|
+
## Creator 2.4(当前限制)
|
|
30
55
|
|
|
31
56
|
```ts
|
|
32
57
|
import { Live2D } from "cocos-plugin-live2d/creator2";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`creator2` 入口仅挂载空组件并在 `start()` 打印警告: **尚未**连接 `@doki-land/live2d`。用于验证包解析与 `/creator2` 导出;完整
|
|
61
|
+
2.4 支持在后续版本。
|
|
62
|
+
|
|
63
|
+
## 不包含
|
|
64
|
+
|
|
65
|
+
- 原生 Android / iOS Live2D SDK 封装
|
|
66
|
+
- 看板娘气泡 / 一言(在 `@doki-land/live2d-widget`,Cocos 游戏一般不用)
|
|
67
|
+
- 多角色 Stage API 的编辑器示例(可直接使用 `@doki-land/live2d` 的 `createLive2dStage`)
|
|
68
|
+
|
|
69
|
+
## 与其他包
|
|
33
70
|
|
|
34
|
-
|
|
71
|
+
```text
|
|
72
|
+
cocos-plugin-live2d → Cocos 组件生命周期
|
|
73
|
+
@doki-land/live2d → 模型加载、参数、渲染
|
|
74
|
+
@doki-land/live2d-renderer → WebGPU / WebGL2 / Canvas2D
|
|
35
75
|
```
|
|
36
76
|
|
|
37
|
-
|
|
38
|
-
no offscreen canvas / `@doki-land/live2d` wiring yet. Use it to verify the project
|
|
39
|
-
resolves this package and the `/creator2` export.
|
|
77
|
+
## 仓库
|
|
40
78
|
|
|
41
|
-
|
|
79
|
+
[github.com/doki-land/live2d.ts](https://github.com/doki-land/live2d.ts) · `projects/adaptors/cocos-plugin-live2d`
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cocos-plugin-live2d",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Cocos Creator Live2D
|
|
3
|
+
"version": "0.0.16",
|
|
4
|
+
"description": "Cocos Creator Live2D component — Creator 3.x Web runtime; Creator 2.4 scaffold entry.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
7
|
+
"homepage": "https://github.com/doki-land/live2d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/doki-land/live2d.ts.git",
|
|
11
|
+
"directory": "projects/adaptors/cocos-plugin-live2d"
|
|
12
|
+
},
|
|
8
13
|
"keywords": [
|
|
9
14
|
"live2d",
|
|
10
15
|
"cocos",
|
|
@@ -34,11 +39,7 @@
|
|
|
34
39
|
"test": "vitest run"
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
37
|
-
"@doki-land/live2d": "0.0.
|
|
42
|
+
"@doki-land/live2d": "0.0.16"
|
|
38
43
|
},
|
|
39
|
-
"sideEffects": false
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "git+https://github.com/doki-land/live2d.ts.git"
|
|
43
|
-
}
|
|
44
|
+
"sideEffects": false
|
|
44
45
|
}
|