@doki-land/live2d-widget 0.0.13 → 0.0.15
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 +71 -1
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
1
|
# @doki-land/live2d-widget
|
|
2
2
|
|
|
3
|
-
live2d
|
|
3
|
+
**看板娘产品壳** — 在 `@doki-land/live2d` 之上提供「挂到页面就能用」的 DOM 包装:固定尺寸 Canvas、可选 RAF
|
|
4
|
+
自动播放、鼠标视线跟踪、加载进度、以及气泡 + 简易工具栏(一言 / 照片 / 离开)。
|
|
5
|
+
|
|
6
|
+
这不是「更简化的 live2d API」;引擎级集成(Cocos、自研游戏循环)应直接用 `@doki-land/live2d` 的 Stage / Actor。
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @doki-land/live2d-widget @doki-land/live2d
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 一行挂载
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {mountWidget} from "@doki-land/live2d-widget";
|
|
18
|
+
|
|
19
|
+
await mountWidget({
|
|
20
|
+
target: "#live2d",
|
|
21
|
+
model: "npm:live2d-widget-model-hijiki@1.0.5/assets/hijiki.model.json",
|
|
22
|
+
width: 280,
|
|
23
|
+
height: 400,
|
|
24
|
+
chrome: true, // 气泡 + 工具栏
|
|
25
|
+
autoplay: true, // 内部 RAF + 轻微 autoSway
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 类 API
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {Live2DWidget} from "@doki-land/live2d-widget";
|
|
33
|
+
|
|
34
|
+
const widget = new Live2DWidget();
|
|
35
|
+
await widget.mount({
|
|
36
|
+
target: document.body,
|
|
37
|
+
model: "/models/local.model3.json",
|
|
38
|
+
prefer: ["webgpu", "webgl2", "canvas2d"],
|
|
39
|
+
onHit: ({area, x, y}) => console.log("hit", area),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 销毁
|
|
43
|
+
widget.destroy();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 选项说明
|
|
47
|
+
|
|
48
|
+
| 选项 | 默认 | 说明 |
|
|
49
|
+
|--------------------|----------------------------|-----------------------------------------|
|
|
50
|
+
| `target` | — | CSS 选择器或 HTMLElement(必填) |
|
|
51
|
+
| `model` | — | model.json / model3.json URL 或 `npm:…` |
|
|
52
|
+
| `width` / `height` | 280 × 400 | Canvas 像素尺寸 |
|
|
53
|
+
| `autoplay` | `true` | 挂载后自动 `requestAnimationFrame` 循环 |
|
|
54
|
+
| `autoSway` | `true` | 播放时用正弦驱动 `PARAM_ANGLE_X` |
|
|
55
|
+
| `chrome` | — | `true` 或配置对象:欢迎语、工具按钮等 |
|
|
56
|
+
| `prefer` | webgpu → webgl2 → canvas2d | 与 `createLive2D` 相同 |
|
|
57
|
+
|
|
58
|
+
`chrome` 相关:`mountChrome`、`createTipMessage`、`DEFAULT_WELCOME`。
|
|
59
|
+
|
|
60
|
+
## 与 Hexo 插件的关系
|
|
61
|
+
|
|
62
|
+
[`hexo-plugin-live2d`](https://www.npmjs.com/package/hexo-plugin-live2d) 在构建时把本包 + `@doki-land/live2d`
|
|
63
|
+
打进站点静态资源,并在 `_config.yml` 里配置 `live2d.model`。博客作者通常 **不需要**手动 import 本包。
|
|
64
|
+
|
|
65
|
+
## 边界(本包不做的事)
|
|
66
|
+
|
|
67
|
+
- 多角色 Stage、游戏 manual 帧循环 → `@doki-land/live2d`
|
|
68
|
+
- Vue 组件 → `vue-plugin-live2d`
|
|
69
|
+
- VMZ Custom Element `<live2d>` → 未来官方产品面(当前预览用 widget / adaptor)
|
|
70
|
+
|
|
71
|
+
## 仓库
|
|
72
|
+
|
|
73
|
+
[github.com/doki-land/live2d.ts](https://github.com/doki-land/live2d.ts) · `projects/live2d-widget`
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doki-land/live2d-widget",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.15",
|
|
4
|
+
"description": "Live2D page widget — canvas shell, autoplay, optional tips chrome; built on @doki-land/live2d.",
|
|
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/live2d-widget"
|
|
12
|
+
},
|
|
8
13
|
"keywords": [
|
|
9
14
|
"live2d",
|
|
10
15
|
"widget",
|
|
@@ -17,7 +22,8 @@
|
|
|
17
22
|
},
|
|
18
23
|
"files": [
|
|
19
24
|
"dist",
|
|
20
|
-
"src"
|
|
25
|
+
"src",
|
|
26
|
+
"README.md"
|
|
21
27
|
],
|
|
22
28
|
"publishConfig": {
|
|
23
29
|
"access": "public",
|
|
@@ -36,11 +42,7 @@
|
|
|
36
42
|
"test": "vitest run --passWithNoTests"
|
|
37
43
|
},
|
|
38
44
|
"dependencies": {
|
|
39
|
-
"@doki-land/live2d": "0.0.
|
|
45
|
+
"@doki-land/live2d": "0.0.15"
|
|
40
46
|
},
|
|
41
|
-
"sideEffects": false
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/doki-land/live2d.ts.git"
|
|
45
|
-
}
|
|
47
|
+
"sideEffects": false
|
|
46
48
|
}
|