vue-plugin-live2d 0.0.15 → 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.
Files changed (2) hide show
  1. package/README.md +70 -49
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,30 +1,28 @@
1
1
  # vue-plugin-live2d
2
2
 
3
- **Vue 3 组件适配层** [`@doki-land/live2d`](https://www.npmjs.com/package/@doki-land/live2d) 包成 `<Live2D>`
4
- ,处理挂载、模型切换、加载进度条与销毁。
3
+ A Vue 3 compatibility component for `@doki-land/live2d`.
5
4
 
6
- Live2D 的解码、渲染、动作逻辑仍在 `@doki-land/live2d`;本包只做 Vue 生命周期与 props/events 绑定。
5
+ This adapter helps existing Vue applications mount the browser-native runtime. It is not the architectural center of the
6
+ project and does not replace the framework-independent facade used by game engines and other hosts.
7
7
 
8
- ## 安装
8
+ ## ✨ Features
9
9
 
10
- ```bash
11
- npm i vue-plugin-live2d @doki-land/live2d vue
12
- ```
13
-
14
- Peer:`vue ^3.4`。
10
+ - Declarative model source.
11
+ - Configurable canvas dimensions.
12
+ - Renderer preference passthrough.
13
+ - Loading progress overlay.
14
+ - Ready, error, progress, profile, and hit events.
15
+ - Optional browser animation loop.
16
+ - Pointer tracking.
17
+ - Parameter inspection and mutation through the exposed component API.
15
18
 
16
- ## 注册组件
19
+ ## 📦 Installation
17
20
 
18
- ```ts
19
- // main.ts
20
- import { createApp } from "vue";
21
- import { Live2D } from "vue-plugin-live2d";
22
- import App from "./App.vue";
23
-
24
- createApp(App).component("Live2D", Live2D).mount("#app");
21
+ ```bash
22
+ pnpm add vue-plugin-live2d @doki-land/live2d vue
25
23
  ```
26
24
 
27
- 或在 SFC 里按需导入(无需全局注册):
25
+ ## 🚀 Quick Start
28
26
 
29
27
  ```vue
30
28
  <script setup lang="ts">
@@ -33,50 +31,73 @@ import { Live2D } from "vue-plugin-live2d";
33
31
 
34
32
  <template>
35
33
  <Live2D
36
- model="/models/wanko/Wanko.model3.json"
37
- :width="320"
38
- :height="320"
34
+ model="/models/character.model3.json"
35
+ :width="480"
36
+ :height="640"
37
+ :prefer="['webgpu', 'webgl2', 'canvas2d']"
39
38
  :autoplay="true"
40
- :show-progress="true"
39
+ :auto-sway="true"
40
+ @ready="(modelId) => console.log('ready', modelId)"
41
+ @hit="(payload) => console.log('hit', payload.area)"
42
+ @error="(error) => console.error(error)"
41
43
  />
42
44
  </template>
43
45
  ```
44
46
 
45
- ## `<Live2D>` Props
47
+ ## 🎛️ Component API
46
48
 
47
- | Prop | 类型 | 默认 | 说明 |
48
- |--------------------|-----------------------|---------------|----------------------------------------------|
49
- | `model` | `ModelSource \| null` | `null` | model3.json URL、`npm:…` 或 core 内联 source |
50
- | `width` / `height` | `number` | 320 | 容器与 Canvas 尺寸(px) |
51
- | `prefer` | `RendererKind[]` | Canvas2D 优先 | 渲染后端探测顺序 |
52
- | `autoplay` | `boolean` | `true` | 挂载后自动 RAF |
53
- | `autoSway` | `boolean` | `true` | 自动轻微摇头 |
54
- | `showProgress` | `boolean` | `true` | 内置加载进度 overlay |
49
+ Use a template ref for runtime-level controls:
55
50
 
56
- ## 事件(emit)
51
+ ```vue
52
+ <script setup lang="ts">
53
+ import { ref } from "vue";
54
+ import { Live2D } from "vue-plugin-live2d";
57
55
 
58
- 组件在加载与运行时会抛出进度、帧剖析等事件(详见组件 `defineEmits`)。典型用法:
56
+ const actor = ref<InstanceType<typeof Live2D> | null>(null);
59
57
 
60
- ```vue
61
- <Live2D
62
- model="npm:live2d-widget-model-hijiki@1.0.5/assets/hijiki.model.json"
63
- @loadprogress="(p) => console.log(p.stage, p.progress)"
64
- />
58
+ function lookLeft() {
59
+ actor.value?.setParameter("PARAM_ANGLE_X", -15);
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <Live2D ref="actor" model="/models/character.model3.json" />
65
+ <button type="button" @click="lookLeft">Look left</button>
66
+ </template>
65
67
  ```
66
68
 
67
- ## 暴露的运行时(ref)
69
+ The component exposes runtime access, parameter operations, parameter listing, manual-angle reset, and reload behavior
70
+ supported by the current implementation.
71
+
72
+ ## 🔄 Lifecycle
73
+
74
+ The component creates and destroys its runtime with the Vue component lifecycle. Model, size, renderer preference, and
75
+ autoplay changes can remount the canvas or reload the model depending on the affected state.
76
+
77
+ Avoid rapidly changing the model prop without handling loading and error states. Remote model requests may complete out
78
+ of order unless the runtime cancels stale generations.
79
+
80
+ ## 🎮 Game Engine Guidance
81
+
82
+ Do not use this adapter merely because a game editor or shell contains Vue. If the game engine already owns the canvas
83
+ and frame loop, integrate `@doki-land/live2d` directly so the engine controls scheduling, input, resize, and resource
84
+ lifetime.
85
+
86
+ ## 🧪 Development
87
+
88
+ ```bash
89
+ pnpm --filter vue-plugin-live2d typecheck
90
+ pnpm --filter vue-plugin-live2d test
91
+ ```
68
92
 
69
- 通过 `ref` 可访问底层 `Live2DRuntime`(`createLive2D` 返回值),用于 `playMotion`、`setParameter` imperative 调用。详见组件
70
- `defineExpose`。
93
+ Tests should cover repeated mount/unmount, prop-driven reloads, stale loads, pointer coordinates, event forwarding, and
94
+ resource cleanup.
71
95
 
72
- ## widget / Hexo 的区别
96
+ ## 🤝 Contributing
73
97
 
74
- | 包 | 用途 |
75
- |------------------------------|--------------------------------|
76
- | **vue-plugin-live2d** | Vue 单页应用内嵌组件 |
77
- | **@doki-land/live2d-widget** | 框架无关看板娘壳(气泡工具栏) |
78
- | **hexo-plugin-live2d** | Hexo 静态站注入,零 Vue 依赖 |
98
+ Keep the adapter thin. Shared pointer, stage, actor, animation, and rendering semantics belong in the runtime rather
99
+ than being reimplemented for Vue.
79
100
 
80
- ## 仓库
101
+ ## 📄 License
81
102
 
82
- [github.com/doki-land/live2d.ts](https://github.com/doki-land/live2d.ts) · `projects/adaptors/vue-plugin-live2d`
103
+ See the repository license.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-plugin-live2d",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Vue 3 <Live2D> component — mount @doki-land/live2d with props, progress UI, and lifecycle.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "vue": "^3.4.0"
38
38
  },
39
39
  "dependencies": {
40
- "@doki-land/live2d": "0.0.15"
40
+ "@doki-land/live2d": "0.0.16"
41
41
  },
42
42
  "sideEffects": false
43
43
  }