@charivo/render-live2d 0.6.6 → 0.8.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Character, type GazeCoordinates, type Message, type Renderer } from "@charivo/core";
|
|
2
|
-
import { type MouseCoordinates, type MouseTrackable } from "@charivo/render";
|
|
2
|
+
import { type GazeOrigin, type MouseCoordinates, type MouseTrackable } from "@charivo/render";
|
|
3
3
|
import { type Live2DRenderer, type Live2DRendererOptions } from "./renderer";
|
|
4
4
|
export declare class Live2DRendererImpl implements Renderer, MouseTrackable, Live2DRenderer {
|
|
5
5
|
private static cubismStarted;
|
|
@@ -7,6 +7,10 @@ export declare class Live2DRendererImpl implements Renderer, MouseTrackable, Liv
|
|
|
7
7
|
private host?;
|
|
8
8
|
private model?;
|
|
9
9
|
private lastModelPath?;
|
|
10
|
+
/** Counts model loads, so one a later load overtook can tell. */
|
|
11
|
+
private loadCount;
|
|
12
|
+
/** Where the mouse gaze is measured from; unset = the view's centre. */
|
|
13
|
+
private gazeOrigin?;
|
|
10
14
|
private teardownResize?;
|
|
11
15
|
private teardownBrowserLifecycle?;
|
|
12
16
|
private animationFrameId?;
|
|
@@ -18,6 +22,13 @@ export declare class Live2DRendererImpl implements Renderer, MouseTrackable, Liv
|
|
|
18
22
|
constructor(options?: Live2DRendererOptions);
|
|
19
23
|
initialize(): Promise<void>;
|
|
20
24
|
loadModel(modelPath: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Load a model for `host`. Resolves undefined, with the model released, when
|
|
27
|
+
* it is no longer the one wanted by the time it is ready: a later load began
|
|
28
|
+
* (the latest call wins, however late this one lands), or the host it was
|
|
29
|
+
* built for is gone (destroy(), or a context restore).
|
|
30
|
+
*/
|
|
31
|
+
private loadLatest;
|
|
21
32
|
render(_message: Message, _character?: Character): Promise<void>;
|
|
22
33
|
/**
|
|
23
34
|
* Set realtime lip sync mode (controlled by RenderManager)
|
|
@@ -57,6 +68,26 @@ export declare class Live2DRendererImpl implements Renderer, MouseTrackable, Liv
|
|
|
57
68
|
private resizeCanvas;
|
|
58
69
|
private updateViewMatrices;
|
|
59
70
|
updateViewWithMouse(coords: MouseCoordinates): void;
|
|
71
|
+
/**
|
|
72
|
+
* `MouseTrackable.setGazeOrigin`: measure the mouse drag from a point of the
|
|
73
|
+
* model's canvas (fractions, top-left to bottom-right) instead of the view's
|
|
74
|
+
* centre. Throws on a non-finite `x` or `y`: kept, it would hand the model a
|
|
75
|
+
* NaN drag on every pointer move.
|
|
76
|
+
*/
|
|
77
|
+
setGazeOrigin(origin?: GazeOrigin): void;
|
|
78
|
+
/**
|
|
79
|
+
* Where the gaze origin sits in view coordinates, the space a drag and a
|
|
80
|
+
* hit test are given in and the model matrix maps the model into: the
|
|
81
|
+
* fractions become model units (origin at the canvas's centre, +y up) and
|
|
82
|
+
* go through that matrix, read at each call because the frame loop refits
|
|
83
|
+
* it to the canvas. The view's centre when no origin is set.
|
|
84
|
+
*/
|
|
85
|
+
private gazeOriginInView;
|
|
86
|
+
/**
|
|
87
|
+
* True when the frame loop fits the model to the canvas's width rather than
|
|
88
|
+
* its height: a model wider than one unit on a portrait canvas.
|
|
89
|
+
*/
|
|
90
|
+
private fitsModelToWidth;
|
|
60
91
|
handleMouseTap(coords: MouseCoordinates): void;
|
|
61
92
|
private toViewCoordinates;
|
|
62
93
|
private bindCanvasLifecycle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live2d-renderer.d.ts","sourceRoot":"","sources":["../../src/live2d-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"live2d-renderer.d.ts","sourceRoot":"","sources":["../../src/live2d-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EA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EF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE7B;IAEF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE7B;IAEF,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,gBAAgB;YAQV,uBAAuB;CA6BtC"}
|
package/dist/src/renderer.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type GazeCoordinates, type Renderer } from "@charivo/core";
|
|
2
|
-
import { type MouseTrackable } from "@charivo/render";
|
|
2
|
+
import { type GazeOrigin, type MouseTrackable } from "@charivo/render";
|
|
3
3
|
export interface Live2DRendererOptions {
|
|
4
4
|
canvas?: HTMLCanvasElement;
|
|
5
5
|
}
|
|
6
6
|
export interface Live2DRenderer extends Renderer, MouseTrackable {
|
|
7
|
+
loadModel(modelPath: string): Promise<void>;
|
|
7
8
|
playExpression(expressionId: string): void;
|
|
8
9
|
stopExpression(): void;
|
|
9
10
|
playMotionByGroup(group: string, index: number, options?: {
|
|
10
11
|
muteSound?: boolean;
|
|
11
12
|
}): void;
|
|
12
13
|
lookAt(coords: GazeCoordinates): void;
|
|
14
|
+
setGazeOrigin(origin?: GazeOrigin): void;
|
|
13
15
|
getAvailableExpressions(): string[];
|
|
14
16
|
getAvailableMotionGroups(): Record<string, number>;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIvE,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,cAAe,SAAQ,QAAQ,EAAE,cAAc;IAC9D,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,cAAc,IAAI,IAAI,CAAC;IACvB,iBAAiB,CACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAChC,IAAI,CAAC;IACR,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACzC,uBAAuB,IAAI,MAAM,EAAE,CAAC;IACpC,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpD;AAED,wBAAgB,oBAAoB,CAClC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,cAAc,CAEhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charivo/render-live2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Live2D rendering engine for Charivo",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/renderer.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"lipsync"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@charivo/core": "^0.
|
|
35
|
-
"@charivo/render": "^0.
|
|
34
|
+
"@charivo/core": "^0.38.0",
|
|
35
|
+
"@charivo/render": "^0.12.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsup": "^8.5.0",
|