@doki-land/live2d 0.0.9 → 0.0.10
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/dist/l2d.umd.js +1 -1
- package/dist/l2d.umd.js.map +1 -1
- package/dist/live2d.css +1 -1
- package/package.json +6 -14
- package/src/fs/index.ts +1 -1
- package/src/helper/index.ts +2 -2
- package/src/icons/style.css +6 -0
- package/src/index.ts +9 -19
- package/src/types/Live2dOptions.ts +1 -1
- package/src/types/Resolve.ts +1 -1
- package/src/types/index.ts +3 -3
package/dist/live2d.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.live2d-icon-panel{position:fixed;right:10px;bottom:150px;z-index:10000;display:flex;flex-direction:column;gap:10px;opacity:0;transition:opacity .3s ease}.live2d-icon-panel.visible{opacity:1}.live2d-icon{width:40px;height:40px;background-color:#fffc;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer;box-shadow:0 2px 5px #0003;transition:transform .2s ease}.live2d-icon:hover{transform:scale(1.1)}.live2d-icon svg{width:24px;height:24px;fill:#666}
|
|
1
|
+
.live2d-icon-panel{position:fixed;right:10px;bottom:150px;z-index:10000;display:flex;flex-direction:column;gap:10px;opacity:0;transition:opacity .3s ease}.live2d-icon-panel.visible{opacity:1}.live2d-icon{width:40px;height:40px;background-color:#fffc;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer;box-shadow:0 2px 5px #0003;transition:transform .2s ease}.live2d-icon:hover{transform:scale(1.1)}.live2d-icon svg{width:24px;height:24px;fill:#666}.live2d-canvas{position:absolute;z-index:9999;display:block}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doki-land/live2d",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"live2d",
|
|
6
6
|
"pixi",
|
|
@@ -13,20 +13,12 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./src/index.ts",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"import": "./src/index.ts",
|
|
17
|
+
"require": "./dist/l2d.umd.js"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
20
|
-
"types": "./src
|
|
21
|
-
"import": "./src
|
|
22
|
-
},
|
|
23
|
-
"./helper": {
|
|
24
|
-
"types": "./src/helper/index.ts",
|
|
25
|
-
"import": "./src/helper/index.ts"
|
|
26
|
-
},
|
|
27
|
-
"./fs": {
|
|
28
|
-
"types": "./src/fs/index.ts",
|
|
29
|
-
"import": "./src/fs/index.ts"
|
|
19
|
+
"./*": {
|
|
20
|
+
"types": "./src/*/index.ts",
|
|
21
|
+
"import": "./src/*/index.ts"
|
|
30
22
|
}
|
|
31
23
|
},
|
|
32
24
|
"files": [
|
package/src/fs/index.ts
CHANGED
package/src/helper/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {findAllModels, mergeModels} from "
|
|
2
|
-
import {ResolveCdn, ResolveElementId, ResolveModels} from "
|
|
1
|
+
import {findAllModels, mergeModels} from "@doki-land/live2d/fs";
|
|
2
|
+
import {ResolveCdn, ResolveElementId, ResolveModels} from "@doki-land/live2d/types";
|
|
3
3
|
|
|
4
4
|
export function generateModelList(options: ResolveModels) {
|
|
5
5
|
const models = mergeModels(options.domain || 'https://localhost:8080', findAllModels(options.models_folder || 'public/live2d'), options.models || []);
|
package/src/icons/style.css
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import '../lib/cubism2.min.js';
|
|
2
2
|
import '../lib/cubism5.min.js';
|
|
3
3
|
import * as PIXI from 'pixi.js';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
Live2DModel,
|
|
8
|
-
MotionManager,
|
|
9
|
-
SoundManager
|
|
10
|
-
} from 'pixi-live2d-display-lipsyncpatch';
|
|
11
|
-
import { Application, } from 'pixi.js';
|
|
4
|
+
import {Application} from 'pixi.js';
|
|
5
|
+
import {Ticker} from '@pixi/ticker';
|
|
6
|
+
import {Live2DModel, MotionManager, SoundManager} from 'pixi-live2d-display-lipsyncpatch';
|
|
12
7
|
import './icons/style.css';
|
|
13
|
-
import {
|
|
8
|
+
import {Live2dOptions} from '@doki-land/live2d/types';
|
|
14
9
|
|
|
15
10
|
export {MotionManager, SoundManager, Live2DModel, PIXI};
|
|
16
11
|
|
|
@@ -50,7 +45,7 @@ export async function createLive2D(options: Live2dOptions): Promise<Live2DModel>
|
|
|
50
45
|
});
|
|
51
46
|
|
|
52
47
|
// 加载模型
|
|
53
|
-
const model = await Live2DModel.from(models[0].model_url,
|
|
48
|
+
const model = await Live2DModel.from(models[0].model_url, {
|
|
54
49
|
ticker: Ticker.system,
|
|
55
50
|
});
|
|
56
51
|
// 添加模型到舞台
|
|
@@ -76,7 +71,7 @@ export async function createLive2D(options: Live2dOptions): Promise<Live2DModel>
|
|
|
76
71
|
if (auto_motion) {
|
|
77
72
|
await startIdleAnimation(model);
|
|
78
73
|
}
|
|
79
|
-
|
|
74
|
+
|
|
80
75
|
// 创建右侧图标栏
|
|
81
76
|
// createIconPanel(model, element);
|
|
82
77
|
|
|
@@ -88,15 +83,10 @@ function findOrCreateCanvas(id: string, options: Live2dOptions): HTMLCanvasEleme
|
|
|
88
83
|
if (!canvas) {
|
|
89
84
|
canvas = document.createElement('canvas');
|
|
90
85
|
canvas.id = id;
|
|
91
|
-
|
|
92
|
-
canvas.style.display = 'none';
|
|
93
|
-
canvas.style.position = 'fixed';
|
|
94
|
-
// 设置画布样式
|
|
95
|
-
canvas.style.display = 'block';
|
|
96
|
-
canvas.style.position = 'absolute';
|
|
86
|
+
canvas.classList.add('live2d-canvas')
|
|
97
87
|
canvas.style.bottom = `${options.spacing_y || 0}px`;
|
|
98
88
|
canvas.style[options.position === 'left' ? 'left' : 'right'] = `${options.spacing_x || 0}px`;
|
|
99
|
-
|
|
89
|
+
document.body.appendChild(canvas);
|
|
100
90
|
}
|
|
101
91
|
return canvas;
|
|
102
92
|
}
|
|
@@ -124,7 +114,7 @@ function enableMouseTracking(model: Live2DModel, canvas: any) {
|
|
|
124
114
|
model.internalModel.focusController?.focus(mouseX, mouseY);
|
|
125
115
|
}
|
|
126
116
|
});
|
|
127
|
-
|
|
117
|
+
|
|
128
118
|
// 添加点击模型触发动作的交互
|
|
129
119
|
canvas.addEventListener('click', () => {
|
|
130
120
|
// 尝试播放tap_body动作,如果没有则尝试其他可用动作
|
package/src/types/Resolve.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Live2dOptions.
|
|
2
|
-
export * from './ModelOptions.
|
|
3
|
-
export * from './Resolve.
|
|
1
|
+
export * from './Live2dOptions.ts';
|
|
2
|
+
export * from './ModelOptions.ts';
|
|
3
|
+
export * from './Resolve.ts';
|