@doki-land/live2d 0.0.6 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doki-land/live2d",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "keywords": [
5
5
  "live2d",
6
6
  "pixi",
package/src/fs/index.ts CHANGED
@@ -45,17 +45,20 @@ export function allowShowLive2D(currentPath: string, includePaths: string[], exc
45
45
  */
46
46
  export function findAllModels(folder: string, depth: number = 99): string[] {
47
47
  const models: string[] = [];
48
- for (const file of fs.readdirSync(folder)) {
49
- const filePath = path.join(folder, file);
50
- const stat = fs.statSync(filePath);
51
- if (stat.isDirectory()) {
52
- if (depth > 0) {
53
- models.push(...findAllModels(filePath, depth - 1));
48
+ if (fs.existsSync(folder)) {
49
+ for (const file of fs.readdirSync(folder)) {
50
+ const filePath = path.join(folder, file);
51
+ const stat = fs.statSync(filePath);
52
+ if (stat.isDirectory()) {
53
+ if (depth > 0) {
54
+ models.push(...findAllModels(filePath, depth - 1));
55
+ }
56
+ } else if (file.endsWith('.model.json') || file.endsWith('.model3.json')) {
57
+ models.push(filePath);
54
58
  }
55
- } else if (file.endsWith('.model.json') || file.endsWith('.model3.json')) {
56
- models.push(filePath);
57
59
  }
58
- }
60
+ }
61
+
59
62
  return models;
60
63
  }
61
64
 
@@ -73,14 +76,16 @@ export function findAllModels(folder: string, depth: number = 99): string[] {
73
76
  *
74
77
  * 本地模型的优先级更高, 本地模型根据自然序(Natural Sort)排列
75
78
  */
76
- export function mergeModels(base: string, local: string[], remote: ModelOptions[]): string[] {
77
- const models: string[] = [];
79
+ export function mergeModels(base: string, local: string[], remote: ModelOptions[]): ModelOptions[] {
80
+ const models: ModelOptions[] = [];
78
81
  const url = new URL(base);
79
82
  for (const model of local) {
80
- models.push(new URL(model, url).href);
83
+ models.push({
84
+ model_url: new URL(model, url).href,
85
+ });
81
86
  }
82
87
  for (const model of remote) {
83
- models.push(model.model_url);
88
+ models.push(model);
84
89
  }
85
90
  return models
86
91
  }
package/src/index.ts CHANGED
@@ -50,8 +50,9 @@ export async function createLive2D(options: Live2dOptions): Promise<Live2DModel>
50
50
  });
51
51
 
52
52
  // 加载模型
53
- const model = await Live2DModel.from(models[0].model_url);
54
-
53
+ const model = await Live2DModel.from(models[0].model_url, {
54
+ ticker: Ticker.system,
55
+ });
55
56
  // 添加模型到舞台
56
57
  app.stage.addChild(model);
57
58
 
@@ -194,11 +195,6 @@ export async function initializeLive2D() {
194
195
  // @ts-ignore
195
196
  // window.Live2DCubismCore = cubism5 || Cubism5().Live2DCubismCore;
196
197
 
197
- // 最后初始化 PIXI 相关功能
198
- // 为 Live2DModel 注册 Ticker
199
- Live2DModel.registerTicker(Ticker);
200
- // 为 Application 注册 Ticker
201
- PIXI.extensions.add(TickerPlugin);
202
198
  // 注册 InteractionManager 以支持 Live2D 模型的自动交互
203
199
  // PIXI.extensions.add(InteractionManager);
204
200
  }