mesh-avatar 0.6.1 → 0.7.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 CHANGED
@@ -123,6 +123,11 @@ Avatars saved or exported in Studio carry these settings in `avatar.json.lipSync
123
123
  saved values. `setLipSync` is a partial update and works during playback. The optional
124
124
  `preset` field records the editor selection only; playback uses the three numbers.
125
125
 
126
+ Live expressions can set their resting mouth opening in `avatar.json.expressions` or with the
127
+ `expressions` option, for example `{ surprise: { mouthOpen: 0.45 } }` (the built-in value for
128
+ surprise is 0.6). `loadMeshAvatar` applies the saved values; explicit option fields override them.
129
+ An entry for `neutral` has no effect and is ignored.
130
+
126
131
  ## License
127
132
 
128
133
  The runtime is MIT licensed; see [LICENSE](./LICENSE). The browser bundle includes [fflate](https://github.com/101arrowz/fflate), with its MIT notice retained in the bundle.
@@ -1,4 +1,10 @@
1
- export function overlayTarget(name: any): {
1
+ /**
2
+ * @param {string} name
3
+ * @param {Record<string, { mouthOpen?: number }>} [settings] optional per-expression values (see expression-settings.ts)
4
+ */
5
+ export function overlayTarget(name: string, settings?: Record<string, {
6
+ mouthOpen?: number;
7
+ }>): {
2
8
  eyeOpen: any;
3
9
  eyeOpenL: any;
4
10
  eyeSmile: any;
@@ -26,6 +32,10 @@ export namespace OVERLAY_EXPRESSIONS {
26
32
  }
27
33
  /** Smoothed switching. While neutral and settled the parameters pass through untouched. */
28
34
  export class ExpressionOverlay {
35
+ /** @param {Record<string, { mouthOpen?: number }>} [settings] parsed per-expression settings */
36
+ constructor(settings?: Record<string, {
37
+ mouthOpen?: number;
38
+ }>);
29
39
  /** @type {keyof typeof OVERLAY_EXPRESSIONS} */
30
40
  name: keyof typeof OVERLAY_EXPRESSIONS;
31
41
  mix: {
@@ -42,6 +52,9 @@ export class ExpressionOverlay {
42
52
  gy: 0;
43
53
  pitch: 0;
44
54
  };
55
+ settings: Record<string, {
56
+ mouthOpen?: number;
57
+ }>;
45
58
  /** @param {string} name */
46
59
  set(name: string): void;
47
60
  /** True while an expression is shown or still fading out. */
@@ -0,0 +1,11 @@
1
+ import { OVERLAY_EXPRESSIONS } from './expression-overlay.js';
2
+ /** Per-expression settings for a live expression shown with `setExpression`. */
3
+ export interface ExpressionMouthSettings {
4
+ /** Resting mouth opening, 0–1. Replaces the built-in value (surprise 0.6, the others 0). */
5
+ mouthOpen?: number;
6
+ }
7
+ /** Optional settings keyed by live expression name; an entry for `neutral` is ignored. */
8
+ export type ExpressionSettings = Partial<Record<Exclude<keyof typeof OVERLAY_EXPRESSIONS, 'neutral'>, ExpressionMouthSettings>>;
9
+ export declare function parseExpressionSettings(input: unknown): ExpressionSettings;
10
+ /** Explicit settings override saved ones for each expression and field. */
11
+ export declare function mergeExpressionSettings(saved?: ExpressionSettings, explicit?: ExpressionSettings): ExpressionSettings;
@@ -2,6 +2,7 @@ import type { LightingSettings } from '../lighting/settings.js';
2
2
  import type { Rig, ClothTuning } from '../rig/types.js';
3
3
  import { OVERLAY_EXPRESSIONS } from './expression-overlay.js';
4
4
  import type { LipSyncSettings } from './lip-sync.js';
5
+ import type { ExpressionSettings } from './expression-settings.js';
5
6
  export type LiveExpression = keyof typeof OVERLAY_EXPRESSIONS;
6
7
  export declare const LIVE_EXPRESSIONS: LiveExpression[];
7
8
  export interface MeshAvatarOptions {
@@ -14,6 +15,8 @@ export interface MeshAvatarOptions {
14
15
  fit?: 'contain' | 'cover';
15
16
  preserveMouthForm?: boolean;
16
17
  lipSync?: LipSyncSettings;
18
+ /** Optional per-expression settings for live expressions, such as `{ surprise: { mouthOpen: 0.45 } }`. */
19
+ expressions?: ExpressionSettings;
17
20
  }
18
21
  export interface MeshAvatar {
19
22
  readonly motions: {
@@ -1,4 +1,5 @@
1
1
  import { type LipSyncSettings } from '../engine/lip-sync.js';
2
+ import { type ExpressionSettings } from '../engine/expression-settings.js';
2
3
  export interface AvatarManifest {
3
4
  format: 'mesh-avatar';
4
5
  version: 1;
@@ -11,6 +12,7 @@ export interface AvatarManifest {
11
12
  version: string;
12
13
  };
13
14
  lipSync?: LipSyncSettings;
15
+ expressions?: ExpressionSettings;
14
16
  }
15
17
  export declare function parseManifest(input: unknown): AvatarManifest;
16
18
  export declare function defaultManifest(name: string): AvatarManifest;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { createMeshAvatar, LIVE_EXPRESSIONS } from './engine/index.js';
2
2
  export type { MeshAvatar, MeshAvatarOptions, LiveExpression } from './engine/index.js';
3
3
  export type { LipSyncSettings } from './engine/lip-sync.js';
4
+ export type { ExpressionSettings, ExpressionMouthSettings } from './engine/expression-settings.js';
4
5
  export type { Rig, Eye, Strand, Accessory, Hand, Arm, Arms, Leg, Legs, Cloth, ClothTuning, Ellipse, Point, Band } from './rig/types.js';
5
6
  export { validateRig, parseRig } from './rig/validate.js';
6
7
  export { PARAMS } from './engine/rig.js';