@voqalize/avatar 0.3.0 → 0.4.1
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/LICENSE-CC-BY-4.0 +396 -0
- package/README.md +65 -17
- package/assets/README.md +48 -0
- package/assets/tanya.glb +0 -0
- package/assets/tara.glb +0 -0
- package/assets/tushar.glb +0 -0
- package/client/AvatarClient.ts +337 -42
- package/client/arjun.ts +2 -0
- package/client/createAvatar.ts +38 -0
- package/client/index.ts +6 -1
- package/client/internal.ts +31 -3
- package/client/ishita.ts +2 -0
- package/client/kabir.ts +2 -0
- package/client/meera.ts +2 -0
- package/client/naina.ts +2 -0
- package/client/playout.ts +95 -0
- package/client/supports.ts +28 -0
- package/client/three/assets.ts +22 -0
- package/client/three/budgets.ts +27 -0
- package/client/three/holds.ts +64 -0
- package/client/three/internal.ts +54 -0
- package/client/three/motion-limits.json +116 -0
- package/client/three/sequences.ts +281 -0
- package/client/three/tanya-asset.ts +6 -0
- package/client/three/tanya.ts +69 -0
- package/client/three/tara-asset.ts +25 -0
- package/client/three/tara-rig.ts +1571 -0
- package/client/three/tara.ts +77 -0
- package/client/three/tushar-asset.ts +6 -0
- package/client/three/tushar.ts +65 -0
- package/client/types.ts +109 -20
- package/client/vikram.ts +2 -0
- package/dist/AvatarClient.d.ts +89 -11
- package/dist/AvatarClient.d.ts.map +1 -1
- package/dist/AvatarClient.js +297 -35
- package/dist/AvatarClient.js.map +1 -1
- package/dist/arjun.d.ts +1 -0
- package/dist/arjun.d.ts.map +1 -1
- package/dist/arjun.js +2 -0
- package/dist/arjun.js.map +1 -1
- package/dist/createAvatar.d.ts +36 -0
- package/dist/createAvatar.d.ts.map +1 -1
- package/dist/createAvatar.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +9 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +13 -5
- package/dist/internal.js.map +1 -1
- package/dist/ishita.d.ts +1 -0
- package/dist/ishita.d.ts.map +1 -1
- package/dist/ishita.js +2 -0
- package/dist/ishita.js.map +1 -1
- package/dist/kabir.d.ts +1 -0
- package/dist/kabir.d.ts.map +1 -1
- package/dist/kabir.js +2 -0
- package/dist/kabir.js.map +1 -1
- package/dist/meera.d.ts +1 -0
- package/dist/meera.d.ts.map +1 -1
- package/dist/meera.js +2 -0
- package/dist/meera.js.map +1 -1
- package/dist/naina.d.ts +1 -0
- package/dist/naina.d.ts.map +1 -1
- package/dist/naina.js +2 -0
- package/dist/naina.js.map +1 -1
- package/dist/playout.d.ts +42 -0
- package/dist/playout.d.ts.map +1 -0
- package/dist/playout.js +85 -0
- package/dist/playout.js.map +1 -0
- package/dist/supports.d.ts +20 -0
- package/dist/supports.d.ts.map +1 -0
- package/dist/supports.js +26 -0
- package/dist/supports.js.map +1 -0
- package/dist/three/assets.d.ts +8 -0
- package/dist/three/assets.d.ts.map +1 -0
- package/dist/three/assets.js +19 -0
- package/dist/three/assets.js.map +1 -0
- package/dist/three/budgets.d.ts +17 -0
- package/dist/three/budgets.d.ts.map +1 -0
- package/dist/three/budgets.js +21 -0
- package/dist/three/budgets.js.map +1 -0
- package/dist/three/holds.d.ts +33 -0
- package/dist/three/holds.d.ts.map +1 -0
- package/dist/three/holds.js +56 -0
- package/dist/three/holds.js.map +1 -0
- package/dist/three/internal.d.ts +52 -0
- package/dist/three/internal.d.ts.map +1 -0
- package/dist/three/internal.js +49 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/motion-limits.json +116 -0
- package/dist/three/sequences.d.ts +71 -0
- package/dist/three/sequences.d.ts.map +1 -0
- package/dist/three/sequences.js +262 -0
- package/dist/three/sequences.js.map +1 -0
- package/dist/three/tanya-asset.d.ts +7 -0
- package/dist/three/tanya-asset.d.ts.map +1 -0
- package/dist/three/tanya-asset.js +7 -0
- package/dist/three/tanya-asset.js.map +1 -0
- package/dist/three/tanya.d.ts +35 -0
- package/dist/three/tanya.d.ts.map +1 -0
- package/dist/three/tanya.js +51 -0
- package/dist/three/tanya.js.map +1 -0
- package/dist/three/tara-asset.d.ts +26 -0
- package/dist/three/tara-asset.d.ts.map +1 -0
- package/dist/three/tara-asset.js +26 -0
- package/dist/three/tara-asset.js.map +1 -0
- package/dist/three/tara-rig.d.ts +409 -0
- package/dist/three/tara-rig.d.ts.map +1 -0
- package/dist/three/tara-rig.js +1504 -0
- package/dist/three/tara-rig.js.map +1 -0
- package/dist/three/tara.d.ts +35 -0
- package/dist/three/tara.d.ts.map +1 -0
- package/dist/three/tara.js +59 -0
- package/dist/three/tara.js.map +1 -0
- package/dist/three/tushar-asset.d.ts +7 -0
- package/dist/three/tushar-asset.d.ts.map +1 -0
- package/dist/three/tushar-asset.js +7 -0
- package/dist/three/tushar-asset.js.map +1 -0
- package/dist/three/tushar.d.ts +31 -0
- package/dist/three/tushar.d.ts.map +1 -0
- package/dist/three/tushar.js +47 -0
- package/dist/three/tushar.js.map +1 -0
- package/dist/types.d.ts +65 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +58 -11
- package/dist/types.js.map +1 -1
- package/dist/vikram.d.ts +1 -0
- package/dist/vikram.d.ts.map +1 -1
- package/dist/vikram.js +2 -0
- package/dist/vikram.js.map +1 -1
- package/package.json +34 -6
- package/src/avatar.d.ts +59 -2
- package/src/avatar.js +743 -94
- package/src/behavior.d.ts +28 -12
- package/src/behavior.js +54 -42
- package/src/canvas/create-rig.js +1 -1
- package/src/canvas/src/live.js +2 -2
- package/src/conformance.js +1 -1
- package/src/emotions.js +4 -2
- package/src/gaze.js +334 -73
- package/src/head.js +134 -0
- package/src/idle.js +210 -19
- package/src/interjections.js +70 -26
- package/src/prosody.js +647 -0
- package/src/visemes.js +85 -15
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Blender avatars' own addressable motions, and their own shape for the one
|
|
3
|
+
* shared action whose keys do not fit a head that turns in degrees.
|
|
4
|
+
*
|
|
5
|
+
* These are *shapes*, authored in a rig whose pose unit is a degree, and a
|
|
6
|
+
* server addresses them by name with `cmd: "action"` when it knows which avatar
|
|
7
|
+
* is mounted. The wire's action vocabulary is open, so they need no promotion
|
|
8
|
+
* and are not trying to get one; a face without them ignores the message
|
|
9
|
+
* ([contract-wire.md](../../../docs/contract-wire.md) § Action).
|
|
10
|
+
*
|
|
11
|
+
* **Why nods get three shapes and one intent.** A 2025 ICMI motion-capture
|
|
12
|
+
* corpus of 90 attentive-listening dialogues separates nodding into three types
|
|
13
|
+
* and publishes the distribution (research-biomechanics.md § 3.3):
|
|
14
|
+
*
|
|
15
|
+
* | type | what it co-occurs with | share of nods | mean duration |
|
|
16
|
+
* |---|---|---:|---:|
|
|
17
|
+
* | `short` | continuer backchannel — "mm-hm, go on" | 49% | 0.83 s |
|
|
18
|
+
* | `long` | assessment, lexical response — "yes, that's right" | 40% | 1.42 s |
|
|
19
|
+
* | `long_p` | a cognitive shift — "ah, I see" | 12% | 1.75 s |
|
|
20
|
+
*
|
|
21
|
+
* Their gloss: "nodding co-occurring with continuer backchannel has a smaller
|
|
22
|
+
* average range of movement, whereas that co-occurring with assessment
|
|
23
|
+
* backchannel and lexical responses has a larger average range", and "nodding
|
|
24
|
+
* with swinging up is regarded to reflect a cognitive shift in the listener."
|
|
25
|
+
*
|
|
26
|
+
* That is three different things to say, not three sizes of one thing — which
|
|
27
|
+
* is exactly why they are this avatar's own names and not three spellings of
|
|
28
|
+
* one. `ACKNOWLEDGE` remains the portable "acknowledge the user" that every
|
|
29
|
+
* renderer answers, and resolves to the continuer here; a server that knows it
|
|
30
|
+
* is driving tara can say *which* nod.
|
|
31
|
+
*
|
|
32
|
+
* **How big, in degrees** (research-head-rotation.md § 2.3, peak-to-peak):
|
|
33
|
+
* a continuer 3–5°, one stroke that returns as far as it went; agreement 6–10°,
|
|
34
|
+
* single, ample and stressed; "oh, I see" 6–10°, opening upward. People's nods
|
|
35
|
+
* are narrower than they look — Blomsma 2024 measures 5.95° on average at
|
|
36
|
+
* backchannel opportunities, Kato 2026 about 4° — and a nod past them stops
|
|
37
|
+
* reading as listening and starts reading as the head dropping.
|
|
38
|
+
*
|
|
39
|
+
* **§ 3.4's structural laws hold in every clip here**, because the paper's
|
|
40
|
+
* finding is that flat repeated cycles are what real nods are not:
|
|
41
|
+
*
|
|
42
|
+
* 1. *Anticipatory rising* — a longer nod starts bigger, from the first
|
|
43
|
+
* cycle. The head knows how long the nod will be before it begins.
|
|
44
|
+
* 2. *Declination* — each cycle is smaller than the one before it, by about
|
|
45
|
+
* 0.7× (Mori 2025).
|
|
46
|
+
* 3. *Under 1.5 Hz* — above it a nod reads as impatience rather than
|
|
47
|
+
* attention, and the head's own 160 ms smoothing eats most of it anyway.
|
|
48
|
+
* People repeat nods at 2–3.5 Hz; the cap is a perceptual choice and it
|
|
49
|
+
* stays, so a repeated nod here is slower than a person's.
|
|
50
|
+
*
|
|
51
|
+
* **Amplitudes are pre-compensated and the numbers are not free.** A stroke is
|
|
52
|
+
* a target the head chases at a 160 ms time constant, so what renders is well
|
|
53
|
+
* under what is written. `test/nods.test.ts` steps the real mixer and holds
|
|
54
|
+
* each clip's rendered degrees to its band; the degrees quoted below are its.
|
|
55
|
+
*
|
|
56
|
+
* TARA-SPECIFIC: the keys are pose units, and a pose unit becomes degrees
|
|
57
|
+
* through the mounted avatar's `HEAD_DEG` — tara's is 24° of pitch at the
|
|
58
|
+
* ±1.4 clamp, 17.1° a unit. A second Blender avatar with another envelope
|
|
59
|
+
* renders these same keys at other angles, and the degrees are recorded per
|
|
60
|
+
* character where they are measured rather than here.
|
|
61
|
+
*/
|
|
62
|
+
import { ACTION_IDS, ACTIONS, CORE_ACTION_IDS } from "../internal.js";
|
|
63
|
+
import type { AvatarSupport } from "../internal.js";
|
|
64
|
+
|
|
65
|
+
type Keyframes = Record<string, [number, number][]>;
|
|
66
|
+
interface Sequence {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly label: string;
|
|
69
|
+
readonly text: string;
|
|
70
|
+
readonly duration: number;
|
|
71
|
+
readonly keys: Keyframes;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The continuer. "Go on, I'm with you" — half of all nods, and the one the
|
|
76
|
+
* avatar would be doing most if a server drove every backchannel.
|
|
77
|
+
*
|
|
78
|
+
* One stroke down and back, because a continuer is "a single small nod" (Kato
|
|
79
|
+
* 2026) and within a cycle the return is as big as the stroke (Mori 2025): no
|
|
80
|
+
* rebound above neutral, which on a head that really rotates reads as a second,
|
|
81
|
+
* upward nod. The stroke is fast and the return takes its time, which is what
|
|
82
|
+
* makes it a beat rather than a bob. 720 ms, inside the 0.5–0.8 s a single
|
|
83
|
+
* small nod lasts.
|
|
84
|
+
*
|
|
85
|
+
* **No preparatory up-beat, and that is a rate constraint rather than taste.**
|
|
86
|
+
* An earlier draft opened with a dip, which put a turning point 308 ms before
|
|
87
|
+
* the down-peak — 1.63 Hz. The corpus lists the swing-up as optional on `short`
|
|
88
|
+
* and mandatory only on `long_p`, so the one that had to go was the one never
|
|
89
|
+
* carrying meaning.
|
|
90
|
+
*
|
|
91
|
+
* The trunk sets forward a fraction and the shoulders with it — about a fifth
|
|
92
|
+
* and a third of the shared `ACK_NOD`'s — because a head that nods on a body
|
|
93
|
+
* that does not move is a head on a stick, and more than that turns "go on"
|
|
94
|
+
* into leaning in.
|
|
95
|
+
*
|
|
96
|
+
* Renders ~4° of chin-down on tara.
|
|
97
|
+
*/
|
|
98
|
+
const NOD_SMALL: Sequence = {
|
|
99
|
+
id: "NOD_SMALL", label: "nod: continuer", text: "", duration: 720,
|
|
100
|
+
keys: {
|
|
101
|
+
headPitch: [[0, 0], [0.36, 0.34], [1, 0]],
|
|
102
|
+
// The lid dip is what separates a nod from a bob: eyes stay with the user
|
|
103
|
+
// and close a fraction on the beat.
|
|
104
|
+
lidL: [[0, 0], [0.40, 0.045], [1, 0]],
|
|
105
|
+
lidR: [[0, 0], [0.40, 0.045], [1, 0]],
|
|
106
|
+
torsoLean: [[0, 0], [0.40, 0.026], [1, 0]],
|
|
107
|
+
shoulderL: [[0, 0], [0.46, 0.019], [1, 0]],
|
|
108
|
+
shoulderR: [[0, 0], [0.46, 0.019], [1, 0]],
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The assessment nod — "yes, that's right".
|
|
114
|
+
*
|
|
115
|
+
* Agreement is "single, ample and stressed" (Poggi), larger and faster than
|
|
116
|
+
* feedback (Bauer 2024), so it is one stroke with a hold at the bottom rather
|
|
117
|
+
* than the continuer made bigger: the hold is the stress, and it is what keeps
|
|
118
|
+
* a large nod from reading as a twitch. About twice the continuer's depth.
|
|
119
|
+
*
|
|
120
|
+
* It aliased the shared `ACK_NOD` until 2026-09-14. That clip is two strokes
|
|
121
|
+
* sized for a line face, and on a head that really rotates it rendered 15°,
|
|
122
|
+
* which is past every row of research § 2.3.
|
|
123
|
+
*
|
|
124
|
+
* Renders ~8° of chin-down on tara.
|
|
125
|
+
*/
|
|
126
|
+
const NOD_ASSESS: Sequence = {
|
|
127
|
+
id: "NOD_ASSESS", label: "nod: assessment", text: "", duration: 1000,
|
|
128
|
+
keys: {
|
|
129
|
+
headPitch: [[0, 0], [0.26, 0.56], [0.50, 0.50], [1, 0]],
|
|
130
|
+
lidL: [[0, 0], [0.28, 0.06], [0.55, 0.04], [1, 0]],
|
|
131
|
+
lidR: [[0, 0], [0.28, 0.06], [0.55, 0.04], [1, 0]],
|
|
132
|
+
torsoLean: [[0, 0], [0.32, 0.04], [0.60, 0.03], [1, 0]],
|
|
133
|
+
shoulderL: [[0, 0], [0.40, 0.025], [1, 0]],
|
|
134
|
+
shoulderR: [[0, 0], [0.40, 0.025], [1, 0]],
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* "Ah — I see." The realisation nod, and the only one that *starts by going
|
|
140
|
+
* up*.
|
|
141
|
+
*
|
|
142
|
+
* The swing-up is the whole gesture, not an ornament: it is what the corpus
|
|
143
|
+
* separates `long_p` from `long` by, and what makes this read as a mind
|
|
144
|
+
* changing rather than a head agreeing (Mori 2022: upward-first marks a change
|
|
145
|
+
* of state). Then two declining beats at 1.30 Hz, the second about 0.65 of the
|
|
146
|
+
* first.
|
|
147
|
+
*
|
|
148
|
+
* Longest of the three at 1.75 s, and that is the corpus mean for this type —
|
|
149
|
+
* a realisation takes longer than an agreement because something happened in
|
|
150
|
+
* between.
|
|
151
|
+
*
|
|
152
|
+
* Renders ~3.5° of chin-up, then ~6° of chin-down, on tara.
|
|
153
|
+
*/
|
|
154
|
+
const NOD_REALIZE: Sequence = {
|
|
155
|
+
id: "NOD_REALIZE", label: "nod: realisation", text: "", duration: 1750,
|
|
156
|
+
keys: {
|
|
157
|
+
// Same as the assessment nod: no trailing flourish. A −0.08 at 0.95 put two
|
|
158
|
+
// return beats 542 ms apart, 1.85 Hz, which is a twitch on the way out of a
|
|
159
|
+
// gesture whose whole point is the deliberate lift at the start.
|
|
160
|
+
headPitch: [[0, 0], [0.14, -0.30], [0.40, 0.48], [0.64, -0.12], [0.84, 0.30], [1, 0]],
|
|
161
|
+
// Brows up with the swing and down as the nod lands: the face arrives at
|
|
162
|
+
// the understanding before the head finishes agreeing with it.
|
|
163
|
+
browRaiseL: [[0, 0], [0.16, 0.42], [0.46, 0.10], [1, 0]],
|
|
164
|
+
browRaiseR: [[0, 0], [0.16, 0.38], [0.46, 0.10], [1, 0]],
|
|
165
|
+
lidL: [[0, 0], [0.14, -0.08], [0.42, 0.06], [1, 0]],
|
|
166
|
+
lidR: [[0, 0], [0.14, -0.08], [0.42, 0.06], [1, 0]],
|
|
167
|
+
// The corners come up late, on the second beat. Warmth that arrives *with*
|
|
168
|
+
// the realisation reads as having known already.
|
|
169
|
+
mouthCornerL: [[0, 0], [0.55, 0.10], [0.84, 0.26], [1, 0.12]],
|
|
170
|
+
mouthCornerR: [[0, 0], [0.55, 0.10], [0.84, 0.26], [1, 0.12]],
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* "No." The head shake, and it had to be authored for this rig rather than
|
|
176
|
+
* borrowed.
|
|
177
|
+
*
|
|
178
|
+
* `INTERNAL_CLIPS.HEAD_SHAKE` is written in pose units that mean pixels on a
|
|
179
|
+
* line face. On tara a pose unit is a degree, and that clip's +-0.55 lands at
|
|
180
|
+
* +-3.5 deg authored and about +-2 deg rendered — ambient drift, not a refusal.
|
|
181
|
+
* Two things had to change and only one of them is amplitude.
|
|
182
|
+
*
|
|
183
|
+
* **Yaw is the axis this rig is weakest on**, because the albedo is a front
|
|
184
|
+
* projection of a shallow shell: a turn parallaxes rather than re-silhouettes.
|
|
185
|
+
* Measured against the tile, though, it is not as weak as it looks — 8.7 deg
|
|
186
|
+
* moves 13% of the pixels past a 16/255 delta and carries the silhouette 6 px,
|
|
187
|
+
* which is comparable to what 5.7 deg of roll does. So a shake reads here; it
|
|
188
|
+
* just has to actually reach those angles.
|
|
189
|
+
*
|
|
190
|
+
* **And it has to be slow enough to survive the smoothing.** The borrowed clip
|
|
191
|
+
* swings at 1.42 Hz where the head returns about 0.57 of what it is asked for.
|
|
192
|
+
* At 1.05 Hz it returns ~0.71, which buys a quarter more amplitude for nothing
|
|
193
|
+
* and sits further from the impatience line a *refusal* can least afford to
|
|
194
|
+
* cross.
|
|
195
|
+
*
|
|
196
|
+
* Renders about 11 deg peak-to-peak of yaw. § 3.4's laws again: first swing
|
|
197
|
+
* biggest, every one after it smaller.
|
|
198
|
+
*/
|
|
199
|
+
const NOD_NO: Sequence = {
|
|
200
|
+
id: "NOD_NO", label: "no (head shake)", text: "", duration: 1900,
|
|
201
|
+
keys: {
|
|
202
|
+
headYaw: [[0, 0], [0.14, -1.35], [0.39, 1.15], [0.64, -0.62], [0.85, 0.24], [1, 0]],
|
|
203
|
+
// A small roll in phase with the turn, because a head that swings on one
|
|
204
|
+
// axis alone is a turret. Kept to a fifth of the yaw: more and the refusal
|
|
205
|
+
// starts reading as a wince.
|
|
206
|
+
headRoll: [[0, 0], [0.14, -0.26], [0.39, 0.22], [0.64, -0.12], [1, 0]],
|
|
207
|
+
// The set of the face is what makes it a "no" rather than a look around.
|
|
208
|
+
// A refusal over a resting smile reads as teasing.
|
|
209
|
+
mouthPress: [[0, 0], [0.18, 0.40], [0.82, 0.34], [1, 0]],
|
|
210
|
+
mouthCornerL: [[0, 0], [0.22, -0.22], [1, 0]],
|
|
211
|
+
mouthCornerR: [[0, 0], [0.22, -0.22], [1, 0]],
|
|
212
|
+
browRaiseL: [[0, 0], [0.18, -0.24], [0.86, -0.12], [1, 0]],
|
|
213
|
+
browRaiseR: [[0, 0], [0.18, -0.24], [0.86, -0.12], [1, 0]],
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* What a server may address on a Blender avatar by name, beyond the two every
|
|
219
|
+
* avatar owes it.
|
|
220
|
+
*
|
|
221
|
+
* Shared by every character in this package rather than owned by tara, because
|
|
222
|
+
* they are all driven through the same 30 channels. A character that needs its
|
|
223
|
+
* own shape of one of these overrides that entry; it does not get a second
|
|
224
|
+
* table.
|
|
225
|
+
*/
|
|
226
|
+
export const BLENDER_SEQUENCES = Object.freeze({
|
|
227
|
+
NOD_SMALL, NOD_ASSESS, NOD_REALIZE, NOD_NO,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export type BlenderSequenceId = keyof typeof BLENDER_SEQUENCES;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The Blender avatars' own shape for one of the mixer's own actions, passed to
|
|
234
|
+
* it as `actions`. Same ids, same intent; only the rendering is theirs.
|
|
235
|
+
*
|
|
236
|
+
* **`ACK_NOD` is the continuer here.** It is the nod a server sends while the
|
|
237
|
+
* user is still talking — "mm-hm, go on" — and that is half of all nods and
|
|
238
|
+
* most of what this avatar does, because it listens far more than it speaks.
|
|
239
|
+
* The shared clip is two strokes that render 15° on this head, which is past
|
|
240
|
+
* even agreement (6–10°) and is what the owner read as the head dropping. A
|
|
241
|
+
* server that means agreement or realisation, and knows a Blender avatar is
|
|
242
|
+
* mounted, asks for `NOD_ASSESS` or `NOD_REALIZE`.
|
|
243
|
+
*
|
|
244
|
+
* Aliased rather than restated, so the continuer and the portable nod cannot
|
|
245
|
+
* drift apart.
|
|
246
|
+
*
|
|
247
|
+
* The other shared clips with head keys stay shared, because they already
|
|
248
|
+
* land inside their meaning on tara: `GESTURE_APPROVE` renders 8.8° of
|
|
249
|
+
* chin-down (agreement's band), `GESTURE_GREET` 2.9° of chin-up, and
|
|
250
|
+
* `GESTURE_WAIT` 5.2° of yaw.
|
|
251
|
+
*/
|
|
252
|
+
export const BLENDER_ACTIONS = Object.freeze({
|
|
253
|
+
ACK_NOD: { ...NOD_SMALL, id: "ACK_NOD", label: "acknowledge: nod" },
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// A shape for an action the mixer already has, never a new one: the mixer
|
|
257
|
+
// refuses an id that is not its own, and this keeps the table honest at the type
|
|
258
|
+
// level too. A *new* motion goes in the table above, which is the open door.
|
|
259
|
+
void (BLENDER_ACTIONS satisfies Partial<Record<keyof typeof ACTIONS, Sequence>>);
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* What every character in this package answers to — each one's `supports`, the
|
|
263
|
+
* optional declaration a driving UI reads (`AvatarSupport`).
|
|
264
|
+
*
|
|
265
|
+
* Derived rather than written down, because the three parts already exist: the
|
|
266
|
+
* two ids every avatar owes a server, the mixer's own clip catalogue these
|
|
267
|
+
* characters inherit whole, and this file's own names. A hand-kept fourth copy
|
|
268
|
+
* would only be able to disagree with them. `BLENDER_ACTIONS` adds nothing —
|
|
269
|
+
* it re-shapes an id the mixer already has.
|
|
270
|
+
*
|
|
271
|
+
* It is one list for tara, tushar and tanya for the same reason the tables are:
|
|
272
|
+
* they are one rig driven through one set of channels. A character that stops
|
|
273
|
+
* being able to do one of these owes its own `supports`, not an edit here.
|
|
274
|
+
*/
|
|
275
|
+
export const BLENDER_SUPPORTS: AvatarSupport = Object.freeze({
|
|
276
|
+
actions: Object.freeze([
|
|
277
|
+
...CORE_ACTION_IDS,
|
|
278
|
+
...ACTION_IDS.filter((id) => !(CORE_ACTION_IDS as readonly string[]).includes(id)),
|
|
279
|
+
...Object.keys(BLENDER_SEQUENCES),
|
|
280
|
+
]),
|
|
281
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where tanya's compiled GLB is. One character, one module — see
|
|
3
|
+
* [tara-asset.ts](./tara-asset.ts) for why that separation is load-bearing and
|
|
4
|
+
* why the `new URL` literal is spelled exactly this way.
|
|
5
|
+
*/
|
|
6
|
+
export const TANYA_GLB = new URL("../../assets/tanya.glb", import.meta.url).href;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tanya — the third 3-D character, and like `tushar.ts` a copy of `tara.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Her GLB is tara's scripts run with her landmarks and atlas layout in place of
|
|
5
|
+
* hers (`characters/tanya/`, whose README has the provenance and the commands),
|
|
6
|
+
* so the rig, the mixer, the sequences and her tuning are all hers, unmodified;
|
|
7
|
+
* the one seam is `TaraRigOptions.url`.
|
|
8
|
+
*
|
|
9
|
+
* She is the first character whose atlas is not tara's window. Her hair is the
|
|
10
|
+
* silhouette down past the jaw, out to |u| 0.761 where tara's window stops at
|
|
11
|
+
* 0.64, so `characters/tanya/face_texture.py` widens it to 1408x1568 at the same
|
|
12
|
+
* 800 pixels per face height. That is a fact about the asset and costs this file
|
|
13
|
+
* nothing — the rig reads the window from the GLB.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { PipecatClient } from "@pipecat-ai/client-js";
|
|
17
|
+
import { AvatarClient, createSvgAvatar } from "../internal.js";
|
|
18
|
+
import { TANYA_GLB } from "./tanya-asset.js";
|
|
19
|
+
import { BLENDER_ACTIONS, BLENDER_SEQUENCES, BLENDER_SUPPORTS } from "./sequences.js";
|
|
20
|
+
import { headHold } from "./holds.js";
|
|
21
|
+
import { createTaraRig, TARA_TUNING } from "./tara-rig.js";
|
|
22
|
+
import type { TaraRigOptions } from "./tara-rig.js";
|
|
23
|
+
|
|
24
|
+
export interface AvatarOptions {
|
|
25
|
+
readonly mount: HTMLElement;
|
|
26
|
+
readonly client: PipecatClient;
|
|
27
|
+
/** Viseme amplitude, 0..2. `1` is as authored. */
|
|
28
|
+
readonly mouthGain?: number;
|
|
29
|
+
/** Gesture-clip amplitude, 0..2. */
|
|
30
|
+
readonly gestureGain?: number;
|
|
31
|
+
/** Idle/liveness amplitude, 0..2. */
|
|
32
|
+
readonly motionGain?: number;
|
|
33
|
+
/** Fires when the GLB is in the scene — for a capture tool, not a consumer. */
|
|
34
|
+
readonly onReady?: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface AvatarInstance { destroy(): void; }
|
|
38
|
+
|
|
39
|
+
/** The optional driving-UI declaration; one list for all three characters
|
|
40
|
+
* (`sequences.ts`), because they are one rig. */
|
|
41
|
+
export const supports = BLENDER_SUPPORTS;
|
|
42
|
+
|
|
43
|
+
export function createAvatar(options: AvatarOptions): AvatarInstance {
|
|
44
|
+
const { mount, client, onReady, ...gains } = options;
|
|
45
|
+
if (!mount) throw new TypeError("createAvatar: `mount` is required");
|
|
46
|
+
if (!client) throw new TypeError("createAvatar: `client` is required");
|
|
47
|
+
|
|
48
|
+
const rigOptions: TaraRigOptions = { onReady, url: TANYA_GLB };
|
|
49
|
+
// TARA-SPECIFIC, kept on purpose: `TARA_TUNING` (her mouth and motion gains)
|
|
50
|
+
// is the first thing to question if she reads wrong in a call.
|
|
51
|
+
const widget = createSvgAvatar({
|
|
52
|
+
mount, rig: createTaraRig, rigOptions, hand: false,
|
|
53
|
+
sequences: BLENDER_SEQUENCES, actions: BLENDER_ACTIONS, ...TARA_TUNING,
|
|
54
|
+
headHold: headHold("tanya"), ...gains,
|
|
55
|
+
});
|
|
56
|
+
const driver = new AvatarClient(widget);
|
|
57
|
+
const detach = driver.attach(client);
|
|
58
|
+
|
|
59
|
+
let destroyed = false;
|
|
60
|
+
return {
|
|
61
|
+
destroy() {
|
|
62
|
+
if (destroyed) return;
|
|
63
|
+
destroyed = true;
|
|
64
|
+
detach();
|
|
65
|
+
driver.destroy();
|
|
66
|
+
widget.destroy();
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where tara's compiled GLB is — one character, one module, on purpose.
|
|
3
|
+
*
|
|
4
|
+
* `new URL(…, import.meta.url)` and not a bundler's asset import: these files
|
|
5
|
+
* are fetched at runtime by a consumer's app, and the spelling has to survive
|
|
6
|
+
* Vite, webpack, Rollup, esbuild, a plain `tsc` output and a browser loading the
|
|
7
|
+
* module directly. The query-suffix form this used to carry is Vite syntax —
|
|
8
|
+
* every other toolchain, including the compiler that now builds this directory,
|
|
9
|
+
* passes it through verbatim and produces an import of a file that is not there.
|
|
10
|
+
*
|
|
11
|
+
* The depth is the same from the source tree and from the compiled one
|
|
12
|
+
* (`client/three/` and `dist/three/` are siblings), so one literal is correct in
|
|
13
|
+
* both — and literal is load-bearing, because a bundler can only follow this
|
|
14
|
+
* pattern when it can read the path without running anything.
|
|
15
|
+
*
|
|
16
|
+
* **One module per character is the whole point, and it is a bundling fact, not
|
|
17
|
+
* tidiness.** A bundler that can follow `new URL` emits the file it names, and
|
|
18
|
+
* it decides what to emit per *module*: three literals in one object meant a
|
|
19
|
+
* consumer who imported one character shipped all three GLBs — ~1.3 MB of a
|
|
20
|
+
* character they never mount, in every build we checked. Splitting them is what
|
|
21
|
+
* makes `@voqalize/avatar/avatars/tara` cost tara. Nothing that a character
|
|
22
|
+
* module loads may reach for another character's URL, which is also why the rig
|
|
23
|
+
* takes its `url` from its caller instead of defaulting to tara's.
|
|
24
|
+
*/
|
|
25
|
+
export const TARA_GLB = new URL("../../assets/tara.glb", import.meta.url).href;
|