@seayoo-web/pixi-live2d 0.0.4 → 0.0.7

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/index.js CHANGED
@@ -21673,10 +21673,23 @@ class Th {
21673
21673
  }
21674
21674
  /** 设置点击交互 */
21675
21675
  setupInteraction() {
21676
- this.model && (this.model.interactive = this.options.enableMouseTracking !== !1, this.model.on("pointertap", () => {
21677
- this.model?.motion("TapBody");
21676
+ this.model && (this.model.interactive = this.options.interactive || !0, this.options.interactive === !1 && this.lockHeadAngle(), this.model.on("pointertap", () => {
21677
+ this.options.enableTapBody !== !1 && this.model?.motion("TapBody");
21678
21678
  }));
21679
21679
  }
21680
+ /**
21681
+ * 锁定头部角度参数,防止 motion 驱动头部晃动
21682
+ * 在 ticker 里 motion 更新之后强制覆盖为 0
21683
+ */
21684
+ lockHeadAngle() {
21685
+ if (!this.model) return;
21686
+ const e = ["EyeTracking_ParamAngleX", "EyeTracking_ParamAngleY", "ParamAngleZ"], r = this.model.internalModel.coreModel;
21687
+ this.app.ticker.add(() => {
21688
+ if (r)
21689
+ for (const i of e)
21690
+ r.setParameterValueById(i, 0);
21691
+ });
21692
+ }
21680
21693
  /** 窗口大小改变的处理函数 */
21681
21694
  handleResize = () => {
21682
21695
  this.resize();
@@ -21777,6 +21790,7 @@ function JT(t) {
21777
21790
  return t instanceof Error ? t : new Error(String(t));
21778
21791
  }
21779
21792
  export {
21793
+ hp as Live2DModel,
21780
21794
  Th as Live2DViewer,
21781
21795
  Oa as MotionPriority
21782
21796
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@seayoo-web/pixi-live2d",
3
3
  "description": "pixi-live2d viewer",
4
- "version": "0.0.4",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -20,15 +20,6 @@
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
23
- "scripts": {
24
- "build": "vite build && tsc --build --force --emitDeclarationOnly",
25
- "type-check": "tsc --noEmit",
26
- "lint": "eslint ./**/*.ts",
27
- "lint:fix": "eslint ./**/*.ts --fix",
28
- "prepublish": "pnpm lint:fix && pnpm build",
29
- "test": "vitest --dom",
30
- "coverage": "vitest run --coverage"
31
- },
32
23
  "keywords": [
33
24
  "pixi-live2d"
34
25
  ],
@@ -50,8 +41,17 @@
50
41
  "pixi.js": "6.5.2"
51
42
  },
52
43
  "devDependencies": {
53
- "@seayoo-web/tsconfig": "workspace:^",
54
- "@seayoo-web/utils": "workspace:^",
55
- "@types/node": "^22.13.1"
44
+ "@types/node": "^22.13.1",
45
+ "@seayoo-web/tsconfig": "^1.0.6",
46
+ "@seayoo-web/utils": "^4.4.1"
47
+ },
48
+ "scripts": {
49
+ "build": "vite build && tsc --build --force --emitDeclarationOnly",
50
+ "type-check": "tsc --noEmit",
51
+ "lint": "eslint ./**/*.ts",
52
+ "lint:fix": "eslint ./**/*.ts --fix",
53
+ "prepublish": "pnpm lint:fix && pnpm build",
54
+ "test": "vitest --dom",
55
+ "coverage": "vitest run --coverage"
56
56
  }
57
- }
57
+ }
package/types/index.d.ts CHANGED
@@ -24,13 +24,16 @@ export interface Live2DViewerOptions {
24
24
  /** Cubism Core 库的加载 URL */
25
25
  cubismCoreUrl?: string;
26
26
  /** 是否响应鼠标/触摸移动进行跟随动画,默认为 true */
27
- enableMouseTracking?: boolean;
27
+ interactive?: boolean;
28
+ /** 是否响应点击事件触发 TapBody 动作,默认为 true */
29
+ enableTapBody?: boolean;
28
30
  /** 模型加载完成后的回调函数 */
29
31
  onModelLoaded?: (model: Live2DModel<InternalModel>) => void;
30
32
  /** 模型加载失败的回调函数 */
31
33
  onModelError?: (error: Error) => void;
32
34
  }
33
35
  export { MotionPriority } from "pixi-live2d-display/cubism4";
36
+ export { Live2DModel } from "pixi-live2d-display/cubism4";
34
37
  export declare class Live2DViewer {
35
38
  /** 引擎加载状态 Promise,用于确保全局只加载一次 Core 库 */
36
39
  private static coreLoadingPromise;
@@ -55,6 +58,11 @@ export declare class Live2DViewer {
55
58
  private init;
56
59
  /** 设置点击交互 */
57
60
  private setupInteraction;
61
+ /**
62
+ * 锁定头部角度参数,防止 motion 驱动头部晃动
63
+ * 在 ticker 里 motion 更新之后强制覆盖为 0
64
+ */
65
+ lockHeadAngle(): void;
58
66
  /** 窗口大小改变的处理函数 */
59
67
  private handleResize;
60
68
  /** 重新计算布局和缩放 */