aaavatars 2.0.0 → 3.0.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 +108 -13
- package/dist/Avatar.d.ts +14 -4
- package/dist/Avatar.js +166 -37
- package/dist/animations.d.ts +28 -3
- package/dist/animations.js +334 -99
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/parts.d.ts +6 -2
- package/dist/parts.js +107 -13
- package/dist/pointer.d.ts +2 -0
- package/dist/pointer.js +95 -0
- package/dist/spec.d.ts +2 -0
- package/dist/spec.js +9 -0
- package/dist/styles.d.ts +1 -1
- package/dist/styles.js +235 -40
- package/dist/visibility.d.ts +1 -0
- package/dist/visibility.js +26 -0
- package/package.json +1 -1
- package/dist/value.d.ts +0 -20
- package/dist/value.js +0 -66
package/dist/animations.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
export const AVATAR_EVENTS = [
|
|
2
2
|
"acknowledge",
|
|
3
3
|
"handoff",
|
|
4
|
-
"done",
|
|
5
4
|
"success",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"warning",
|
|
6
|
+
"error",
|
|
7
|
+
"surprised",
|
|
8
|
+
"sigh",
|
|
9
|
+
"yawn",
|
|
9
10
|
];
|
|
11
|
+
export const EASE_OUT = "cubic-bezier(.22,1,.36,1)";
|
|
12
|
+
export const EASE_IN_OUT = "cubic-bezier(.65,0,.35,1)";
|
|
13
|
+
export const EASE_HEAD = "cubic-bezier(.16,1,.3,1)";
|
|
14
|
+
export const EASE_SINE = "cubic-bezier(.37,0,.63,1)";
|
|
15
|
+
const EASE_SINK = "cubic-bezier(.32,0,.24,1)";
|
|
16
|
+
export const PREP_MS = 500;
|
|
17
|
+
const SETTLE_MS = 180;
|
|
10
18
|
function hold(transform, from, to) {
|
|
11
19
|
return [
|
|
12
20
|
{ transform, offset: from },
|
|
@@ -16,6 +24,52 @@ function hold(transform, from, to) {
|
|
|
16
24
|
function stalk(frames) {
|
|
17
25
|
return { antenna: frames, sprout: frames };
|
|
18
26
|
}
|
|
27
|
+
function sample(from, to, steps, frame) {
|
|
28
|
+
return Array.from({ length: steps + 1 }, (_, index) => {
|
|
29
|
+
const t = index / steps;
|
|
30
|
+
return { ...frame(t), offset: from + (to - from) * t, easing: "linear" };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function withOffsets(frames) {
|
|
34
|
+
const offsets = frames.map((frame, index) => frame.offset ?? (index === 0 ? 0 : index === frames.length - 1 ? 1 : null));
|
|
35
|
+
for (let index = 0; index < offsets.length; index += 1) {
|
|
36
|
+
if (offsets[index] != null)
|
|
37
|
+
continue;
|
|
38
|
+
const start = index - 1;
|
|
39
|
+
let end = index;
|
|
40
|
+
while (offsets[end] == null)
|
|
41
|
+
end += 1;
|
|
42
|
+
const from = offsets[start];
|
|
43
|
+
const to = offsets[end];
|
|
44
|
+
for (let gap = index; gap < end; gap += 1) {
|
|
45
|
+
offsets[gap] = from + ((to - from) * (gap - start)) / (end - start);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return frames.map((frame, index) => ({ ...frame, offset: offsets[index] }));
|
|
49
|
+
}
|
|
50
|
+
export function stage(frames, duration, prep, current = {}) {
|
|
51
|
+
const timed = withOffsets(frames).map((frame) => ({ easing: EASE_OUT, ...frame }));
|
|
52
|
+
if (!prep)
|
|
53
|
+
return timed;
|
|
54
|
+
const total = prep + duration;
|
|
55
|
+
const shifted = timed.map((frame) => ({
|
|
56
|
+
...frame,
|
|
57
|
+
offset: (prep + frame.offset * duration) / total,
|
|
58
|
+
}));
|
|
59
|
+
if (!timed.some((frame) => "transform" in frame)) {
|
|
60
|
+
return [
|
|
61
|
+
{ ...current, offset: 0 },
|
|
62
|
+
{ ...current, offset: prep / total },
|
|
63
|
+
...shifted,
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
return [
|
|
67
|
+
{ ...current, offset: 0, easing: EASE_OUT },
|
|
68
|
+
{ ...current, offset: Math.min(SETTLE_MS, prep) / total, transform: "none", easing: "linear" },
|
|
69
|
+
{ ...current, offset: prep / total, transform: "none", easing: EASE_OUT },
|
|
70
|
+
...shifted,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
19
73
|
export const MOOD_SWAP_REST = [
|
|
20
74
|
{ opacity: 0, offset: 0.12 },
|
|
21
75
|
{ opacity: 0, offset: 0.88 },
|
|
@@ -24,6 +78,38 @@ export const MOOD_SWAP_SHOW = [
|
|
|
24
78
|
{ opacity: 1, offset: 0.12 },
|
|
25
79
|
{ opacity: 1, offset: 0.88 },
|
|
26
80
|
];
|
|
81
|
+
const REST = { offset: 1 };
|
|
82
|
+
function nodDepth(ms) {
|
|
83
|
+
if (ms < 150)
|
|
84
|
+
return ms / 150;
|
|
85
|
+
if (ms < 300)
|
|
86
|
+
return 1 - (ms - 150) / 150;
|
|
87
|
+
if (ms < 450)
|
|
88
|
+
return (ms - 300) / 150;
|
|
89
|
+
return Math.max(0, 1 - (ms - 450) / 310);
|
|
90
|
+
}
|
|
91
|
+
function bob(amplitude) {
|
|
92
|
+
return (t) => ({
|
|
93
|
+
transform: `translateY(${(Math.sin(t * Math.PI * 4) * amplitude * (1 - 0.38 * t)).toFixed(2)}px)`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function sweep(t) {
|
|
97
|
+
const points = [
|
|
98
|
+
[0, 0],
|
|
99
|
+
[0.16, -1],
|
|
100
|
+
[0.4, 1],
|
|
101
|
+
[0.64, -0.88],
|
|
102
|
+
[0.84, 0.58],
|
|
103
|
+
[1, 0],
|
|
104
|
+
];
|
|
105
|
+
const index = points.findIndex(([at]) => at >= t);
|
|
106
|
+
if (index <= 0)
|
|
107
|
+
return 0;
|
|
108
|
+
const [fromAt, from] = points[index - 1];
|
|
109
|
+
const [toAt, to] = points[index];
|
|
110
|
+
const local = (t - fromAt) / (toAt - fromAt);
|
|
111
|
+
return from + (to - from) * local * local * (3 - 2 * local);
|
|
112
|
+
}
|
|
27
113
|
export const EVENT_ANIMATIONS = {
|
|
28
114
|
acknowledge: {
|
|
29
115
|
mouth: [{ transform: "scaleY(0.5)", offset: 0.35 }],
|
|
@@ -36,14 +122,19 @@ export const EVENT_ANIMATIONS = {
|
|
|
36
122
|
glasses: [{ transform: "translateY(-2px)", offset: 0.35 }],
|
|
37
123
|
bowtie: [{ transform: "scale(1.25)", offset: 0.35 }],
|
|
38
124
|
},
|
|
39
|
-
duration:
|
|
125
|
+
duration: 920,
|
|
40
126
|
body: [
|
|
41
|
-
{ transform: "
|
|
42
|
-
{ transform: "
|
|
43
|
-
|
|
44
|
-
|
|
127
|
+
{ transform: "translateY(0)", offset: 0, easing: EASE_HEAD },
|
|
128
|
+
{ transform: "translateY(2px)", offset: 0.52, easing: EASE_HEAD },
|
|
129
|
+
REST,
|
|
130
|
+
],
|
|
131
|
+
eyes: [
|
|
132
|
+
...sample(0, 760 / 920, 16, (t) => {
|
|
133
|
+
const depth = nodDepth(t * 760);
|
|
134
|
+
return { transform: `translateY(${(depth * 6).toFixed(2)}px) scaleY(${(1 - 0.3 * depth).toFixed(3)})` };
|
|
135
|
+
}),
|
|
136
|
+
REST,
|
|
45
137
|
],
|
|
46
|
-
eyes: [{ transform: "scaleY(1)" }, { transform: "scaleY(0.2)" }, { transform: "scaleY(1)" }],
|
|
47
138
|
},
|
|
48
139
|
handoff: {
|
|
49
140
|
mouth: hold("translateX(5px)", 0.35, 0.65),
|
|
@@ -55,40 +146,16 @@ export const EVENT_ANIMATIONS = {
|
|
|
55
146
|
},
|
|
56
147
|
duration: 900,
|
|
57
148
|
body: [
|
|
58
|
-
{ transform: "translateX(0)" },
|
|
59
|
-
{ transform: "translateX(
|
|
60
|
-
{ transform: "translateX(
|
|
61
|
-
|
|
149
|
+
{ transform: "translateX(0)", easing: EASE_IN_OUT },
|
|
150
|
+
{ transform: "translateX(6px)", offset: 0.35 },
|
|
151
|
+
{ transform: "translateX(6px)", offset: 0.65, easing: EASE_IN_OUT },
|
|
152
|
+
REST,
|
|
62
153
|
],
|
|
63
154
|
eyes: [
|
|
64
155
|
{ transform: "translateX(0)" },
|
|
65
|
-
{ transform: "translateX(6px)", offset: 0.
|
|
66
|
-
{ transform: "translateX(6px)", offset: 0.7 },
|
|
67
|
-
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
done: {
|
|
71
|
-
mood: { name: "happy" },
|
|
72
|
-
accessory: {
|
|
73
|
-
antenna: [{ transform: "scaleY(1.25)", offset: 0.3 }],
|
|
74
|
-
sprout: [{ transform: "scale(1.25)", offset: 0.3 }],
|
|
75
|
-
hat: hold("translateY(-3px) rotate(-10deg)", 0.3, 0.7),
|
|
76
|
-
glasses: [{ transform: "translateY(-3px)", offset: 0.3 }],
|
|
77
|
-
bowtie: [{ transform: "scale(1.3)", offset: 0.3 }],
|
|
78
|
-
},
|
|
79
|
-
duration: 700,
|
|
80
|
-
body: [
|
|
81
|
-
{ transform: "translateY(0)" },
|
|
82
|
-
{ transform: "translateY(-9px)", offset: 0.3 },
|
|
83
|
-
{ transform: "translateY(0)", offset: 0.6 },
|
|
84
|
-
{ transform: "translateY(-4px)", offset: 0.8 },
|
|
85
|
-
{ transform: "translateY(0)" },
|
|
86
|
-
],
|
|
87
|
-
eyes: [
|
|
88
|
-
{ transform: "scaleY(1)" },
|
|
89
|
-
{ transform: "scaleY(0.45)", offset: 0.25 },
|
|
90
|
-
{ transform: "scaleY(0.45)", offset: 0.75 },
|
|
91
|
-
{ transform: "scaleY(1)" },
|
|
156
|
+
{ transform: "translateX(6px)", offset: 0.2 },
|
|
157
|
+
{ transform: "translateX(6px)", offset: 0.7, easing: EASE_IN_OUT },
|
|
158
|
+
REST,
|
|
92
159
|
],
|
|
93
160
|
},
|
|
94
161
|
success: {
|
|
@@ -110,21 +177,22 @@ export const EVENT_ANIMATIONS = {
|
|
|
110
177
|
glasses: hold("translateY(-4px)", 0.3, 0.7),
|
|
111
178
|
bowtie: hold("scale(1.35)", 0.3, 0.7),
|
|
112
179
|
},
|
|
113
|
-
duration:
|
|
180
|
+
duration: 1500,
|
|
114
181
|
body: [
|
|
115
|
-
{ transform: "translateY(0)
|
|
116
|
-
{ transform: "translateY(-
|
|
117
|
-
{ transform: "translateY(
|
|
118
|
-
|
|
182
|
+
{ transform: "translateY(0)", offset: 0, easing: EASE_HEAD },
|
|
183
|
+
{ transform: "translateY(-1.2px)", offset: 0.21, easing: EASE_HEAD },
|
|
184
|
+
{ transform: "translateY(0)", offset: 0.51 },
|
|
185
|
+
REST,
|
|
119
186
|
],
|
|
120
|
-
eyes: [
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
{
|
|
124
|
-
{
|
|
187
|
+
eyes: [...sample(0.147, 0.56, 16, bob(2.5)), REST],
|
|
188
|
+
lids: [
|
|
189
|
+
{ offset: 0, top: 0, bottom: 0 },
|
|
190
|
+
{ offset: 0.147, top: 0, bottom: 1 },
|
|
191
|
+
{ offset: 0.653, top: 0, bottom: 1, easing: EASE_OUT },
|
|
192
|
+
{ offset: 1 },
|
|
125
193
|
],
|
|
126
194
|
},
|
|
127
|
-
|
|
195
|
+
error: {
|
|
128
196
|
mood: { name: "sad" },
|
|
129
197
|
accessory: {
|
|
130
198
|
...stalk(hold("rotate(30deg)", 0.2, 0.85)),
|
|
@@ -132,32 +200,31 @@ export const EVENT_ANIMATIONS = {
|
|
|
132
200
|
glasses: hold("translateY(3px) rotate(10deg)", 0.2, 0.85),
|
|
133
201
|
bowtie: hold("rotate(20deg)", 0.2, 0.85),
|
|
134
202
|
},
|
|
135
|
-
duration:
|
|
203
|
+
duration: 2280,
|
|
136
204
|
body: [
|
|
137
|
-
{ transform: "
|
|
138
|
-
{ transform: "
|
|
139
|
-
{ transform: "
|
|
140
|
-
|
|
141
|
-
{ transform: "translateX(4px)", offset: 0.6 },
|
|
142
|
-
{ transform: "translateX(0)" },
|
|
205
|
+
{ transform: "translateY(0)", offset: 0.14, easing: EASE_SINK },
|
|
206
|
+
{ transform: "translateY(2.75px)", offset: 0.456 },
|
|
207
|
+
{ transform: "translateY(2.75px)", offset: 0.772, easing: EASE_SINK },
|
|
208
|
+
REST,
|
|
143
209
|
],
|
|
144
210
|
eyes: [
|
|
145
|
-
{ transform: "translateY(0)
|
|
146
|
-
{ transform: "translateY(
|
|
147
|
-
{ transform: "translateY(
|
|
148
|
-
|
|
211
|
+
{ transform: "translateY(0)", offset: 0.14, easing: EASE_SINE },
|
|
212
|
+
{ transform: "translateY(2px)", offset: 0.456 },
|
|
213
|
+
{ transform: "translateY(2px)", offset: 0.772, easing: EASE_SINE },
|
|
214
|
+
REST,
|
|
149
215
|
],
|
|
216
|
+
pose: "cross",
|
|
150
217
|
},
|
|
151
|
-
|
|
218
|
+
surprised: {
|
|
152
219
|
mood: {
|
|
153
220
|
name: "o",
|
|
154
221
|
frames: [
|
|
155
|
-
{ opacity: 1, transform: "scale(1.3)", offset: 0.
|
|
156
|
-
{ opacity: 1, transform: "scale(1.3)", offset: 0.
|
|
222
|
+
{ opacity: 1, transform: "scale(1.3)", offset: 0.19 },
|
|
223
|
+
{ opacity: 1, transform: "scale(1.3)", offset: 0.66 },
|
|
157
224
|
{ opacity: 0, offset: 0.9 },
|
|
158
225
|
],
|
|
159
226
|
rest: [
|
|
160
|
-
{ opacity: 0, offset: 0.
|
|
227
|
+
{ opacity: 0, offset: 0.19 },
|
|
161
228
|
{ opacity: 0, offset: 0.8 },
|
|
162
229
|
],
|
|
163
230
|
},
|
|
@@ -168,55 +235,223 @@ export const EVENT_ANIMATIONS = {
|
|
|
168
235
|
glasses: hold("translateY(-5px)", 0.2, 0.7),
|
|
169
236
|
bowtie: hold("scale(1.3)", 0.2, 0.7),
|
|
170
237
|
},
|
|
171
|
-
duration:
|
|
238
|
+
duration: 1260,
|
|
172
239
|
body: [
|
|
173
|
-
{ transform: "
|
|
174
|
-
{ transform: "
|
|
175
|
-
{ transform: "
|
|
176
|
-
|
|
240
|
+
{ transform: "scale(1)", offset: 0.187, easing: EASE_OUT },
|
|
241
|
+
{ transform: "scale(1.035)", offset: 0.325 },
|
|
242
|
+
{ transform: "scale(1.035)", offset: 0.658, easing: EASE_OUT },
|
|
243
|
+
REST,
|
|
177
244
|
],
|
|
178
245
|
eyes: [
|
|
179
|
-
{ transform: "scale(1)" },
|
|
180
|
-
{ transform: "scale(
|
|
181
|
-
|
|
182
|
-
|
|
246
|
+
{ transform: "scale(1)", offset: 0, easing: EASE_IN_OUT },
|
|
247
|
+
{ transform: "scale(0.63)", offset: 0.187, easing: EASE_OUT },
|
|
248
|
+
...sample(0.325, 0.658, 12, (t) => ({
|
|
249
|
+
transform: `scale(${(1.26 * (1 + 0.022 * Math.sin(t * Math.PI * 8) * (1 - 0.18 * t))).toFixed(4)})`,
|
|
250
|
+
})),
|
|
251
|
+
{ ...REST, easing: EASE_OUT },
|
|
183
252
|
],
|
|
184
253
|
},
|
|
185
|
-
|
|
254
|
+
warning: {
|
|
255
|
+
duration: 3327,
|
|
256
|
+
body: [
|
|
257
|
+
{ transform: "translateY(0)", offset: 0.301, easing: EASE_SINE },
|
|
258
|
+
{ transform: "translateY(2.5px)", offset: 0.361 },
|
|
259
|
+
{ transform: "translateY(2.5px)", offset: 0.451, easing: EASE_SINE },
|
|
260
|
+
{ transform: "translateY(-2px)", offset: 0.511 },
|
|
261
|
+
{ transform: "translateY(-2px)", offset: 0.661, easing: EASE_SINE },
|
|
262
|
+
{ transform: "translateY(0)", offset: 0.691 },
|
|
263
|
+
REST,
|
|
264
|
+
],
|
|
265
|
+
eyes: [],
|
|
266
|
+
eye: (side, { gap }) => {
|
|
267
|
+
const near = side === -1;
|
|
268
|
+
const lean = near
|
|
269
|
+
? `translate(${((16 / 34) * gap).toFixed(2)}px,0px) rotate(-6.5deg) scale(1.37,1.4)`
|
|
270
|
+
: `translate(${((20.5 / 34) * gap).toFixed(2)}px,${((7.5 / 34) * gap).toFixed(2)}px) rotate(7.5deg) scale(.68,.99)`;
|
|
271
|
+
const sunk = near
|
|
272
|
+
? lean
|
|
273
|
+
: `translate(${((20.5 / 34) * gap).toFixed(2)}px,${((9.9 / 34) * gap).toFixed(2)}px) rotate(7.5deg) scale(.68,.99)`;
|
|
274
|
+
return [
|
|
275
|
+
{ transform: "none", offset: 0, easing: EASE_SINE },
|
|
276
|
+
{ transform: lean, offset: 0.12 },
|
|
277
|
+
{ transform: lean, offset: 0.301, easing: EASE_SINE },
|
|
278
|
+
{ transform: sunk, offset: 0.361 },
|
|
279
|
+
{ transform: sunk, offset: 0.451, easing: EASE_SINE },
|
|
280
|
+
{ transform: lean, offset: 0.511 },
|
|
281
|
+
{ transform: lean, offset: 0.932, easing: EASE_SINE },
|
|
282
|
+
REST,
|
|
283
|
+
];
|
|
284
|
+
},
|
|
285
|
+
lids: [
|
|
286
|
+
{ offset: 0, top: 0, bottom: 0, easing: EASE_SINE },
|
|
287
|
+
{ offset: 0.12, top: 0.69, bottom: 0, tilt: -21, easing: EASE_SINE },
|
|
288
|
+
{ offset: 0.156, top: 0.835, bottom: 0, tilt: -21 },
|
|
289
|
+
{ offset: 0.301, top: 0.835, bottom: 0, tilt: -21, easing: EASE_SINE },
|
|
290
|
+
{ offset: 0.361, top: 1.46, bottom: 0, tilt: -21 },
|
|
291
|
+
{ offset: 0.451, top: 1.46, bottom: 0, tilt: -21, easing: EASE_SINE },
|
|
292
|
+
{ offset: 0.511, top: 0.466, bottom: 0, tilt: -21 },
|
|
293
|
+
{ offset: 0.661, top: 0.466, bottom: 0, tilt: -21, easing: EASE_SINE },
|
|
294
|
+
{ offset: 0.691, top: 0.835, bottom: 0, tilt: -21 },
|
|
295
|
+
{ offset: 0.932, top: 0.835, bottom: 0, tilt: -21, easing: EASE_SINE },
|
|
296
|
+
{ offset: 1 },
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
sigh: {
|
|
186
300
|
mood: {
|
|
187
301
|
name: "o",
|
|
188
302
|
frames: [
|
|
189
|
-
{ opacity:
|
|
190
|
-
{ opacity: 1, transform: "scale(
|
|
191
|
-
{ opacity:
|
|
303
|
+
{ opacity: 0, transform: "scale(.5)", offset: 0.3 },
|
|
304
|
+
{ opacity: 1, transform: "scale(.7)", offset: 0.42 },
|
|
305
|
+
{ opacity: 1, transform: "scale(.45)", offset: 0.7 },
|
|
306
|
+
{ opacity: 0, offset: 0.82 },
|
|
192
307
|
],
|
|
193
308
|
rest: [
|
|
194
|
-
{ opacity: 0, offset: 0.
|
|
195
|
-
{ opacity: 0, offset: 0.
|
|
309
|
+
{ opacity: 0, offset: 0.3 },
|
|
310
|
+
{ opacity: 0, offset: 0.82 },
|
|
196
311
|
],
|
|
197
312
|
},
|
|
198
313
|
accessory: {
|
|
199
|
-
...stalk(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
]),
|
|
204
|
-
hat: hold("translateY(5px)", 0.05, 0.35),
|
|
205
|
-
glasses: hold("translateY(4px)", 0.05, 0.35),
|
|
206
|
-
bowtie: hold("rotate(15deg)", 0.05, 0.35),
|
|
314
|
+
...stalk(hold("rotate(18deg)", 0.4, 0.75)),
|
|
315
|
+
hat: hold("translateY(3px)", 0.4, 0.75),
|
|
316
|
+
glasses: hold("translateY(2px)", 0.4, 0.75),
|
|
317
|
+
bowtie: hold("rotate(10deg)", 0.4, 0.75),
|
|
207
318
|
},
|
|
208
|
-
duration:
|
|
319
|
+
duration: 2100,
|
|
209
320
|
body: [
|
|
210
|
-
{ transform: "scale(1
|
|
211
|
-
{ transform: "scale(
|
|
212
|
-
{ transform: "scale(1.
|
|
213
|
-
{ transform: "scale(1
|
|
321
|
+
{ transform: "translateY(0) scale(1)", offset: 0, easing: EASE_SINE },
|
|
322
|
+
{ transform: "translateY(-1.5px) scale(1.02,1.03)", offset: 0.3, easing: EASE_SINK },
|
|
323
|
+
{ transform: "translateY(3px) scale(1.03,.95)", offset: 0.55 },
|
|
324
|
+
{ transform: "translateY(3px) scale(1.03,.95)", offset: 0.75, easing: EASE_SINE },
|
|
325
|
+
REST,
|
|
214
326
|
],
|
|
215
327
|
eyes: [
|
|
216
|
-
{ transform: "
|
|
217
|
-
{ transform: "
|
|
218
|
-
{ transform: "
|
|
219
|
-
|
|
328
|
+
{ transform: "translateY(0)", offset: 0.3, easing: EASE_SINK },
|
|
329
|
+
{ transform: "translateY(2px)", offset: 0.55 },
|
|
330
|
+
{ transform: "translateY(2px)", offset: 0.75, easing: EASE_SINE },
|
|
331
|
+
REST,
|
|
332
|
+
],
|
|
333
|
+
lids: [
|
|
334
|
+
{ offset: 0, top: 0, bottom: 0 },
|
|
335
|
+
{ offset: 0.3, top: 0.2, bottom: 0, easing: EASE_SINK },
|
|
336
|
+
{ offset: 0.5, top: 0.65, bottom: 0 },
|
|
337
|
+
{ offset: 0.78, top: 0.65, bottom: 0, easing: EASE_OUT },
|
|
338
|
+
{ offset: 1 },
|
|
220
339
|
],
|
|
221
340
|
},
|
|
341
|
+
yawn: {
|
|
342
|
+
mood: {
|
|
343
|
+
name: "o",
|
|
344
|
+
frames: [
|
|
345
|
+
{ opacity: 1, transform: "scale(.6,.5)", offset: 0.1 },
|
|
346
|
+
{ opacity: 1, transform: "scale(1.15,1.6)", offset: 0.4 },
|
|
347
|
+
{ opacity: 1, transform: "scale(1.15,1.6)", offset: 0.58 },
|
|
348
|
+
{ opacity: 0, transform: "scale(.6,.5)", offset: 0.75 },
|
|
349
|
+
],
|
|
350
|
+
rest: [
|
|
351
|
+
{ opacity: 0, offset: 0.1 },
|
|
352
|
+
{ opacity: 0, offset: 0.75 },
|
|
353
|
+
],
|
|
354
|
+
},
|
|
355
|
+
accessory: {
|
|
356
|
+
...stalk(hold("rotate(-10deg)", 0.2, 0.65)),
|
|
357
|
+
hat: hold("translateY(-3px)", 0.2, 0.65),
|
|
358
|
+
glasses: hold("translateY(-3px)", 0.2, 0.65),
|
|
359
|
+
bowtie: hold("scale(1.15)", 0.2, 0.65),
|
|
360
|
+
},
|
|
361
|
+
duration: 2700,
|
|
362
|
+
body: [
|
|
363
|
+
{ transform: "scale(1)", offset: 0, easing: EASE_SINE },
|
|
364
|
+
{ transform: "translateY(-2px) scale(.95,1.07)", offset: 0.4 },
|
|
365
|
+
{ transform: "translateY(-2px) scale(.95,1.07)", offset: 0.58, easing: EASE_SINE },
|
|
366
|
+
{ transform: "translateY(0) scale(1.02,.98)", offset: 0.74, easing: EASE_OUT },
|
|
367
|
+
REST,
|
|
368
|
+
],
|
|
369
|
+
eyes: [],
|
|
370
|
+
lids: [
|
|
371
|
+
{ offset: 0, top: 0, bottom: 0, easing: EASE_SINE },
|
|
372
|
+
{ offset: 0.38, top: 0.95, bottom: 0.9 },
|
|
373
|
+
{ offset: 0.6, top: 0.95, bottom: 0.9, easing: EASE_IN_OUT },
|
|
374
|
+
{ offset: 0.72, top: 0.45, bottom: 0 },
|
|
375
|
+
{ offset: 0.8, top: 1, bottom: 1, easing: EASE_OUT },
|
|
376
|
+
{ offset: 0.88, top: 0, bottom: 0 },
|
|
377
|
+
{ offset: 1 },
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
export const WAKE_ANIMATION = {
|
|
382
|
+
mood: {
|
|
383
|
+
name: "o",
|
|
384
|
+
frames: [
|
|
385
|
+
{ opacity: 1, offset: 0.1 },
|
|
386
|
+
{ opacity: 1, transform: "scale(1.2)", offset: 0.45 },
|
|
387
|
+
{ opacity: 0, offset: 0.65 },
|
|
388
|
+
],
|
|
389
|
+
rest: [
|
|
390
|
+
{ opacity: 0, offset: 0.1 },
|
|
391
|
+
{ opacity: 0, offset: 0.6 },
|
|
392
|
+
],
|
|
393
|
+
},
|
|
394
|
+
accessory: {
|
|
395
|
+
...stalk([
|
|
396
|
+
{ transform: "rotate(-35deg)", offset: 0 },
|
|
397
|
+
{ transform: "rotate(-35deg)", offset: 0.32 },
|
|
398
|
+
{ transform: "rotate(8deg)", offset: 0.6 },
|
|
399
|
+
]),
|
|
400
|
+
hat: hold("translateY(5px)", 0, 0.32),
|
|
401
|
+
glasses: hold("translateY(4px)", 0, 0.32),
|
|
402
|
+
bowtie: hold("rotate(15deg)", 0, 0.32),
|
|
403
|
+
},
|
|
404
|
+
prep: 0,
|
|
405
|
+
duration: 750,
|
|
406
|
+
body: [
|
|
407
|
+
{ transform: "translateY(3px) scale(1)", offset: 0, easing: EASE_HEAD },
|
|
408
|
+
{ transform: "translateY(-2px) scale(1.015)", offset: 0.367, easing: EASE_HEAD },
|
|
409
|
+
{ transform: "translateY(0) scale(1)", offset: 0.667 },
|
|
410
|
+
REST,
|
|
411
|
+
],
|
|
412
|
+
eyes: [
|
|
413
|
+
{ transform: "scale(1)", offset: 0.32, easing: EASE_OUT },
|
|
414
|
+
{ transform: "scale(1.26)", offset: 0.48 },
|
|
415
|
+
{ transform: "scale(1.26)", offset: 0.6, easing: EASE_OUT },
|
|
416
|
+
REST,
|
|
417
|
+
],
|
|
418
|
+
lids: [
|
|
419
|
+
{ offset: 0, top: 0.85, bottom: 0.85 },
|
|
420
|
+
{ offset: 0.32, top: 1, bottom: 0 },
|
|
421
|
+
{ offset: 0.48, top: 0, bottom: 0 },
|
|
422
|
+
{ offset: 0.6, top: 0, bottom: 0 },
|
|
423
|
+
{ offset: 1 },
|
|
424
|
+
],
|
|
425
|
+
};
|
|
426
|
+
export const SLEEP_ANIMATION = {
|
|
427
|
+
prep: 0,
|
|
428
|
+
duration: 2970,
|
|
429
|
+
body: [
|
|
430
|
+
{ transform: "translateY(0)", offset: 0 },
|
|
431
|
+
{ transform: "translateY(0)", offset: 0.67, easing: EASE_IN_OUT },
|
|
432
|
+
REST,
|
|
433
|
+
],
|
|
434
|
+
eyes: [],
|
|
435
|
+
lids: [
|
|
436
|
+
{ offset: 0, top: 0, bottom: 0, easing: EASE_IN_OUT },
|
|
437
|
+
{ offset: 0.32, top: 1, bottom: 0, easing: EASE_OUT },
|
|
438
|
+
{ offset: 0.355, top: 0.24, bottom: 0, easing: EASE_IN_OUT },
|
|
439
|
+
{ offset: 0.63, top: 1, bottom: 0 },
|
|
440
|
+
{ offset: 0.67, top: 1, bottom: 0, easing: EASE_IN_OUT },
|
|
441
|
+
{ offset: 1 },
|
|
442
|
+
],
|
|
443
|
+
};
|
|
444
|
+
export const STUCK_ANIMATION = {
|
|
445
|
+
prep: 420,
|
|
446
|
+
duration: 1380,
|
|
447
|
+
body: [
|
|
448
|
+
{ transform: "translateX(0)", offset: 0, easing: "cubic-bezier(.38,0,.28,1)" },
|
|
449
|
+
{ transform: "translateX(-2px)", offset: 0.34, easing: "cubic-bezier(.35,0,.22,1)" },
|
|
450
|
+
{ transform: "translateX(2px)", offset: 0.72, easing: "cubic-bezier(.35,0,.22,1)" },
|
|
451
|
+
REST,
|
|
452
|
+
],
|
|
453
|
+
eyes: [
|
|
454
|
+
...sample(0, 980 / 1380, 20, (t) => ({ transform: `translateX(${(sweep(t) * 6).toFixed(2)}px)` })),
|
|
455
|
+
REST,
|
|
456
|
+
],
|
|
222
457
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { AVATAR_EVENTS, type AvatarEvent } from "./animations.js";
|
|
2
|
-
export {
|
|
2
|
+
export { ACTIVITIES, type Activity, Avatar, type AvatarContent, type AvatarHandle, type AvatarProps, EVENT_LAYERS, EXPRESSIONS, type Expression, GAZES, type Gaze, } from "./Avatar.js";
|
|
3
3
|
export { AvatarGroup, type AvatarGroupProps } from "./AvatarGroup.js";
|
|
4
4
|
export type { MouthSlot, RenderMouth } from "./parts.js";
|
|
5
5
|
export { ACCESSORIES, type Accessory, type AvatarSpec, DEFAULT_COLORS, EYES, type Eyes, FILLS, type Fill, MOUTHS, type Mouth, SHAPES, type Shape, type SpecOptions, createSpec, } from "./spec.js";
|
|
6
|
-
export { AVATAR_VALUE_MAX_LENGTH, type AvatarValue, type ParsedAvatarValue, formatAvatarValue, parseAvatarValue, } from "./value.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { AVATAR_EVENTS } from "./animations.js";
|
|
2
|
-
export {
|
|
2
|
+
export { ACTIVITIES, Avatar, EVENT_LAYERS, EXPRESSIONS, GAZES, } from "./Avatar.js";
|
|
3
3
|
export { AvatarGroup } from "./AvatarGroup.js";
|
|
4
4
|
export { ACCESSORIES, DEFAULT_COLORS, EYES, FILLS, MOUTHS, SHAPES, createSpec, } from "./spec.js";
|
|
5
|
-
export { AVATAR_VALUE_MAX_LENGTH, formatAvatarValue, parseAvatarValue, } from "./value.js";
|
package/dist/parts.d.ts
CHANGED
|
@@ -9,16 +9,20 @@ export interface MouthSlot {
|
|
|
9
9
|
}
|
|
10
10
|
export type RenderMouth = (mouth: MouthSlot) => ReactNode;
|
|
11
11
|
export declare function mouthSlot(geometry: ShapeGeometry, color: string): MouthSlot;
|
|
12
|
-
export
|
|
12
|
+
export type EyePose = "eye" | "prompt" | "cross" | "cursor";
|
|
13
|
+
export declare function eyePath(eyes: Eyes, pose: EyePose, side: -1 | 1, gap: number): string;
|
|
14
|
+
export declare function EyePair({ eyes, gap, id, pose, y, }: {
|
|
13
15
|
eyes: Eyes;
|
|
14
16
|
gap: number;
|
|
17
|
+
id: string;
|
|
18
|
+
pose: EyePose;
|
|
15
19
|
y: number;
|
|
16
20
|
}): import("react").JSX.Element;
|
|
17
21
|
export declare function MouthShape({ mouth, slot }: {
|
|
18
22
|
mouth: Mouth;
|
|
19
23
|
slot: MouthSlot;
|
|
20
24
|
}): import("react").JSX.Element | null;
|
|
21
|
-
export declare const MOODS: readonly ["happy", "sad", "o", "small"];
|
|
25
|
+
export declare const MOODS: readonly ["happy", "sad", "o", "small", "flat"];
|
|
22
26
|
export type Mood = (typeof MOODS)[number];
|
|
23
27
|
export declare function MoodMouths({ slot }: {
|
|
24
28
|
slot: MouthSlot;
|