mesh-avatar 0.3.1 → 0.4.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.
- package/README.md +4 -1
- package/dist/engine/createMeshAvatar.d.ts +2 -0
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/overlays.d.ts +15 -0
- package/dist/index.js +1519 -1441
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,9 @@ avatar.setVoiceLevel(0.6);
|
|
|
68
68
|
avatar.setEmotion('happy', { playMotion: false });
|
|
69
69
|
avatar.setExpression('smile');
|
|
70
70
|
|
|
71
|
+
// Show optional overlay layers (such as glasses) by name; [] hides them all.
|
|
72
|
+
avatar.setOverlays(['glasses']);
|
|
73
|
+
|
|
71
74
|
// Apply tracked or posed parameters. Each call replaces the supplied overrides.
|
|
72
75
|
avatar.setParameters({ angleX: 10, gazeX: 0.25 }, 1);
|
|
73
76
|
|
|
@@ -82,7 +85,7 @@ avatar.setParameters({});
|
|
|
82
85
|
avatar.destroy();
|
|
83
86
|
```
|
|
84
87
|
|
|
85
|
-
Emotion tags are `happy`, `sad`, `angry`, `surprised`, `relaxed` and `neutral` (or `null` to reset). Expressions are `neutral`, `smile`, `shy`, `surprise`, `halfLidded`, `angry`, `sad` and `wink`; `LIVE_EXPRESSIONS` exports that list. `PARAMS` exports the parameter IDs, ranges and defaults. Voice methods animate the avatar; your app handles audio playback.
|
|
88
|
+
Emotion tags are `happy`, `sad`, `angry`, `surprised`, `relaxed` and `neutral` (or `null` to reset). Expressions are `neutral`, `smile`, `shy`, `surprise`, `halfLidded`, `angry`, `sad` and `wink`; `LIVE_EXPRESSIONS` exports that list. `PARAMS` exports the parameter IDs, ranges and defaults. Overlay names come from the avatar's optional `built/overlays/overlays.json`; unknown names are ignored. Voice methods animate the avatar; your app handles audio playback.
|
|
86
89
|
|
|
87
90
|
`loadMeshAvatar` releases archives it opens on `destroy()` or load failure; when passed an existing `AvatarPackage` from `openAvatar`, the caller owns it and must call `release()` after its last user is destroyed.
|
|
88
91
|
|
|
@@ -18,6 +18,8 @@ export function createMeshAvatarImpl(canvas: HTMLCanvasElement, options: import(
|
|
|
18
18
|
setEmotion(tag: any, opts: any): void;
|
|
19
19
|
/** Live expression layered over tracking (see OVERLAY_EXPRESSIONS); 'neutral' clears it. */
|
|
20
20
|
setExpression(name: any): void;
|
|
21
|
+
/** Show the named overlay layers (built/overlays/overlays.json) and hide the others. */
|
|
22
|
+
setOverlays(names: any): void;
|
|
21
23
|
getExpression(): {
|
|
22
24
|
name: "smile" | "shy" | "surprise" | "wink" | "neutral" | "halfLidded" | "angry" | "sad";
|
|
23
25
|
active: boolean;
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface MeshAvatar {
|
|
|
37
37
|
playMotion?: boolean;
|
|
38
38
|
}): void;
|
|
39
39
|
setExpression(name: LiveExpression): void;
|
|
40
|
+
/** Show the named overlay layers from built/overlays/overlays.json and hide the rest; unknown names are ignored. */
|
|
41
|
+
setOverlays(names: string[]): void;
|
|
40
42
|
getExpression(): {
|
|
41
43
|
name: LiveExpression;
|
|
42
44
|
active: boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** [x, y, w, h] around the opaque pixels (alpha > 3) plus `pad`, or null when fully transparent. */
|
|
2
|
+
export function opaqueRect(alpha: any, width: any, height: any, pad?: number): number[] | null;
|
|
3
|
+
/**
|
|
4
|
+
* Builds one layer per overlay. Like the sprites, only the opaque part of each drawing gets a
|
|
5
|
+
* grid: a grid over the whole image would move every transparent vertex each frame (about
|
|
6
|
+
* 100k vertices for a 1254 x 1254 image at 4 px, ~12 ms per frame on a mid-range phone).
|
|
7
|
+
* `crop(img, rect)` returns that part of the image (a canvas, for example) for the texture.
|
|
8
|
+
* Brows and jaw do not move an accessory, so their weights are zeroed; hair weight is 0 as for
|
|
9
|
+
* the sprites.
|
|
10
|
+
*/
|
|
11
|
+
export function createOverlayLayers(renderer: any, sheet: any, images: any, buildGrid: any, alphaOf: any, baseWeights: any, cell: number | undefined, width: any, height: any, crop: any): {
|
|
12
|
+
/** Shows the named overlays and hides the rest. Unknown names are ignored. */
|
|
13
|
+
set(names: any): void;
|
|
14
|
+
update(P: any, phys: any, deformBase: any, out: any): void;
|
|
15
|
+
};
|