@plupin/character 0.2.0 → 0.3.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/dist/anime-face.d.ts +42 -0
- package/dist/anime-face.js +14 -0
- package/dist/blob.d.ts +32 -0
- package/dist/blob.js +18 -0
- package/dist/body-presets.d.ts +85 -0
- package/dist/canvas.js +7 -7
- package/dist/chunk-09c5tps4.js +337 -0
- package/dist/chunk-60p135hw.js +103 -0
- package/dist/chunk-dpb0rnw9.js +37 -0
- package/dist/chunk-g1c0wdcj.js +825 -0
- package/dist/chunk-kber92gm.js +415 -0
- package/dist/{chunk-k5gwaq6t.js → chunk-sa2r1cxz.js} +30 -3
- package/dist/chunk-yd5zzkkg.js +313 -0
- package/dist/clips.d.ts +40 -0
- package/dist/dress.d.ts +4 -0
- package/dist/emote.d.ts +5 -3
- package/dist/gaze.d.ts +81 -0
- package/dist/gaze.js +113 -0
- package/dist/hair3d.d.ts +3 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +84 -10
- package/dist/listing.d.ts +1 -1
- package/dist/listing.js +16 -6
- package/dist/platform-body-data.d.ts +9 -0
- package/dist/platform-body.d.ts +91 -0
- package/dist/plup3d.d.ts +75 -27
- package/dist/png.d.ts +19 -2
- package/dist/pose.d.ts +7 -1
- package/dist/pose.js +1 -1
- package/dist/proportions.d.ts +31 -0
- package/dist/ragdoll.d.ts +51 -0
- package/dist/resolution.d.ts +21 -0
- package/dist/skin-map.d.ts +155 -0
- package/dist/skin-map.js +55 -0
- package/dist/skin-native.d.ts +55 -6
- package/dist/texture.d.ts +8 -0
- package/dist/three.d.ts +3 -0
- package/dist/three.js +1909 -188
- package/dist/wear3d.d.ts +99 -0
- package/dist/wearables.d.ts +203 -0
- package/dist/wearables.js +26 -0
- package/package.json +21 -1
- package/dist/chunk-ae7gp5cc.js +0 -101
- package/dist/chunk-wpbgtn0y.js +0 -179
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
// src/clips.ts
|
|
2
|
+
var AUTHORED_BONES = [
|
|
3
|
+
"armL",
|
|
4
|
+
"armR",
|
|
5
|
+
"legL",
|
|
6
|
+
"legR",
|
|
7
|
+
"torso",
|
|
8
|
+
"head"
|
|
9
|
+
];
|
|
10
|
+
var AUTHORED_CLIP_NAMES = [
|
|
11
|
+
"recoil",
|
|
12
|
+
"flail",
|
|
13
|
+
"topple",
|
|
14
|
+
"collapse",
|
|
15
|
+
"sneak",
|
|
16
|
+
"cheer",
|
|
17
|
+
"laugh",
|
|
18
|
+
"pose",
|
|
19
|
+
"rage",
|
|
20
|
+
"sob",
|
|
21
|
+
"nod"
|
|
22
|
+
];
|
|
23
|
+
var FPS = 20;
|
|
24
|
+
var round = (value) => Math.round(value * 100) / 100;
|
|
25
|
+
var lerp = (from, to, t) => from + (to - from) * t;
|
|
26
|
+
function keyframes(loop, keys) {
|
|
27
|
+
const last = keys[keys.length - 1];
|
|
28
|
+
if (!last)
|
|
29
|
+
throw new Error("A clip needs at least one keyed pose.");
|
|
30
|
+
const count = Math.max(2, Math.round(last.at * FPS) + 1);
|
|
31
|
+
const at = (seconds) => {
|
|
32
|
+
let index = 0;
|
|
33
|
+
while (index < keys.length - 2 && (keys[index + 1]?.at ?? 0) <= seconds)
|
|
34
|
+
index += 1;
|
|
35
|
+
const from = keys[index];
|
|
36
|
+
const to = keys[index + 1] ?? from;
|
|
37
|
+
const span = to.at - from.at;
|
|
38
|
+
const t = span > 0 ? Math.min(1, Math.max(0, (seconds - from.at) / span)) : 0;
|
|
39
|
+
const frame = [];
|
|
40
|
+
for (const bone of AUTHORED_BONES) {
|
|
41
|
+
const a = from.pose[bone] ?? {};
|
|
42
|
+
const b = to.pose[bone] ?? {};
|
|
43
|
+
frame.push(round(lerp(a.x ?? 0, b.x ?? 0, t)));
|
|
44
|
+
frame.push(round(lerp(a.y ?? 0, b.y ?? 0, t)));
|
|
45
|
+
frame.push(round(lerp(a.z ?? 0, b.z ?? 0, t)));
|
|
46
|
+
}
|
|
47
|
+
frame.push(round(lerp(from.lift ?? 0, to.lift ?? 0, t)));
|
|
48
|
+
return frame;
|
|
49
|
+
};
|
|
50
|
+
const frames = Array.from({ length: count }, (_, step) => at(step / FPS));
|
|
51
|
+
return { fps: FPS, loop, bones: [...AUTHORED_BONES], frames };
|
|
52
|
+
}
|
|
53
|
+
var AUTHORED_CLIPS = {
|
|
54
|
+
recoil: keyframes(false, [
|
|
55
|
+
{ at: 0, pose: {} },
|
|
56
|
+
{
|
|
57
|
+
at: 0.08,
|
|
58
|
+
pose: {
|
|
59
|
+
torso: { x: -0.35 },
|
|
60
|
+
head: { x: -0.3 },
|
|
61
|
+
armL: { z: -2.3 },
|
|
62
|
+
armR: { z: 2.3 },
|
|
63
|
+
legL: { x: -0.25 },
|
|
64
|
+
legR: { x: -0.15 }
|
|
65
|
+
},
|
|
66
|
+
lift: 0.22
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
at: 0.18,
|
|
70
|
+
pose: {
|
|
71
|
+
torso: { x: -0.48 },
|
|
72
|
+
head: { x: -0.38 },
|
|
73
|
+
armL: { z: -2.6 },
|
|
74
|
+
armR: { z: 2.6 },
|
|
75
|
+
legL: { x: -0.35 },
|
|
76
|
+
legR: { x: -0.2 }
|
|
77
|
+
},
|
|
78
|
+
lift: 0.3
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
at: 0.36,
|
|
82
|
+
pose: {
|
|
83
|
+
torso: { x: -0.18 },
|
|
84
|
+
head: { x: -0.12 },
|
|
85
|
+
armL: { z: -1.1 },
|
|
86
|
+
armR: { z: 1.1 }
|
|
87
|
+
},
|
|
88
|
+
lift: 0.06
|
|
89
|
+
},
|
|
90
|
+
{ at: 0.7, pose: {} }
|
|
91
|
+
]),
|
|
92
|
+
flail: keyframes(true, [
|
|
93
|
+
{
|
|
94
|
+
at: 0,
|
|
95
|
+
pose: {
|
|
96
|
+
torso: { x: -0.2 },
|
|
97
|
+
head: { x: -0.15 },
|
|
98
|
+
armL: { x: -1.35, z: -0.5 },
|
|
99
|
+
armR: { x: 1.35, z: 0.5 },
|
|
100
|
+
legL: { x: -0.55 },
|
|
101
|
+
legR: { x: 0.45 }
|
|
102
|
+
},
|
|
103
|
+
lift: 1.1
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
at: 0.225,
|
|
107
|
+
pose: {
|
|
108
|
+
torso: { x: 0.1 },
|
|
109
|
+
armL: { x: 1.3, z: -1.2 },
|
|
110
|
+
armR: { x: -1.3, z: 1.2 },
|
|
111
|
+
legL: { x: 0.5 },
|
|
112
|
+
legR: { x: -0.4 }
|
|
113
|
+
},
|
|
114
|
+
lift: 1.25
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
at: 0.45,
|
|
118
|
+
pose: {
|
|
119
|
+
torso: { x: -0.2 },
|
|
120
|
+
head: { x: -0.15 },
|
|
121
|
+
armL: { x: -1.35, z: -0.5 },
|
|
122
|
+
armR: { x: 1.35, z: 0.5 },
|
|
123
|
+
legL: { x: -0.55 },
|
|
124
|
+
legR: { x: 0.45 }
|
|
125
|
+
},
|
|
126
|
+
lift: 1.1
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
at: 0.675,
|
|
130
|
+
pose: {
|
|
131
|
+
torso: { x: 0.1 },
|
|
132
|
+
armL: { x: 1.3, z: -1.2 },
|
|
133
|
+
armR: { x: -1.3, z: 1.2 },
|
|
134
|
+
legL: { x: 0.5 },
|
|
135
|
+
legR: { x: -0.4 }
|
|
136
|
+
},
|
|
137
|
+
lift: 1.25
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
at: 0.9,
|
|
141
|
+
pose: {
|
|
142
|
+
torso: { x: -0.2 },
|
|
143
|
+
head: { x: -0.15 },
|
|
144
|
+
armL: { x: -1.35, z: -0.5 },
|
|
145
|
+
armR: { x: 1.35, z: 0.5 },
|
|
146
|
+
legL: { x: -0.55 },
|
|
147
|
+
legR: { x: 0.45 }
|
|
148
|
+
},
|
|
149
|
+
lift: 1.1
|
|
150
|
+
}
|
|
151
|
+
]),
|
|
152
|
+
topple: keyframes(false, [
|
|
153
|
+
{ at: 0, pose: {} },
|
|
154
|
+
{
|
|
155
|
+
at: 0.15,
|
|
156
|
+
pose: {
|
|
157
|
+
torso: { z: 0.3 },
|
|
158
|
+
head: { z: 0.2 },
|
|
159
|
+
armL: { z: -1.4 },
|
|
160
|
+
armR: { z: 1.4 },
|
|
161
|
+
legL: { z: 0.1 },
|
|
162
|
+
legR: { z: -0.1 }
|
|
163
|
+
},
|
|
164
|
+
lift: 0.05
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
at: 0.45,
|
|
168
|
+
pose: {
|
|
169
|
+
torso: { z: 0.95 },
|
|
170
|
+
head: { z: 0.35 },
|
|
171
|
+
armL: { z: -2.1 },
|
|
172
|
+
armR: { z: 2.1 },
|
|
173
|
+
legL: { z: 0.35 },
|
|
174
|
+
legR: { z: -0.25 }
|
|
175
|
+
},
|
|
176
|
+
lift: 0.02
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
at: 0.75,
|
|
180
|
+
pose: {
|
|
181
|
+
torso: { z: 1.45 },
|
|
182
|
+
head: { z: 0.45 },
|
|
183
|
+
armL: { z: -2.4 },
|
|
184
|
+
armR: { z: 1.2 },
|
|
185
|
+
legL: { z: 0.55 },
|
|
186
|
+
legR: { z: -0.45 }
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
at: 1.2,
|
|
191
|
+
pose: {
|
|
192
|
+
torso: { z: 1.5 },
|
|
193
|
+
head: { z: 0.3 },
|
|
194
|
+
armL: { z: -2.45 },
|
|
195
|
+
armR: { z: 0.9 },
|
|
196
|
+
legL: { z: 0.6 },
|
|
197
|
+
legR: { z: -0.5 }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
]),
|
|
201
|
+
collapse: keyframes(false, [
|
|
202
|
+
{ at: 0, pose: {} },
|
|
203
|
+
{
|
|
204
|
+
at: 0.2,
|
|
205
|
+
pose: {
|
|
206
|
+
torso: { x: 0.3 },
|
|
207
|
+
head: { x: 0.2 },
|
|
208
|
+
legL: { x: -0.45 },
|
|
209
|
+
legR: { x: 0.3 },
|
|
210
|
+
armL: { z: -0.4 },
|
|
211
|
+
armR: { z: 0.4 }
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
at: 0.55,
|
|
216
|
+
pose: {
|
|
217
|
+
torso: { x: 0.75 },
|
|
218
|
+
head: { x: 0.45 },
|
|
219
|
+
legL: { x: -0.75 },
|
|
220
|
+
legR: { x: 0.55 },
|
|
221
|
+
armL: { x: 0.5, z: -0.3 },
|
|
222
|
+
armR: { x: 0.5, z: 0.3 }
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
at: 0.95,
|
|
227
|
+
pose: {
|
|
228
|
+
torso: { x: 1.15 },
|
|
229
|
+
head: { x: 0.55 },
|
|
230
|
+
legL: { x: -0.95 },
|
|
231
|
+
legR: { x: 0.75 },
|
|
232
|
+
armL: { x: 0.9, z: -0.2 },
|
|
233
|
+
armR: { x: 0.9, z: 0.2 }
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
at: 1.4,
|
|
238
|
+
pose: {
|
|
239
|
+
torso: { x: 1.25 },
|
|
240
|
+
head: { x: 0.55 },
|
|
241
|
+
legL: { x: -1 },
|
|
242
|
+
legR: { x: 0.8 },
|
|
243
|
+
armL: { x: 1, z: -0.15 },
|
|
244
|
+
armR: { x: 1, z: 0.15 }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
]),
|
|
248
|
+
sneak: keyframes(true, [
|
|
249
|
+
{
|
|
250
|
+
at: 0,
|
|
251
|
+
pose: {
|
|
252
|
+
torso: { x: 0.38 },
|
|
253
|
+
head: { y: 0.45, x: 0.1 },
|
|
254
|
+
armL: { x: -0.85, z: -0.55 },
|
|
255
|
+
armR: { x: -0.85, z: 0.55 },
|
|
256
|
+
legL: { x: -0.35 },
|
|
257
|
+
legR: { x: 0.35 }
|
|
258
|
+
},
|
|
259
|
+
lift: 0.02
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
at: 0.3,
|
|
263
|
+
pose: {
|
|
264
|
+
torso: { x: 0.42 },
|
|
265
|
+
head: { y: 0.15, x: 0.1 },
|
|
266
|
+
armL: { x: -0.95, z: -0.45 },
|
|
267
|
+
armR: { x: -0.75, z: 0.65 },
|
|
268
|
+
legL: { x: 0.3 },
|
|
269
|
+
legR: { x: -0.3 }
|
|
270
|
+
},
|
|
271
|
+
lift: 0.1
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
at: 0.6,
|
|
275
|
+
pose: {
|
|
276
|
+
torso: { x: 0.38 },
|
|
277
|
+
head: { y: -0.45, x: 0.1 },
|
|
278
|
+
armL: { x: -0.75, z: -0.65 },
|
|
279
|
+
armR: { x: -0.95, z: 0.45 },
|
|
280
|
+
legL: { x: -0.35 },
|
|
281
|
+
legR: { x: 0.35 }
|
|
282
|
+
},
|
|
283
|
+
lift: 0.02
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
at: 0.9,
|
|
287
|
+
pose: {
|
|
288
|
+
torso: { x: 0.42 },
|
|
289
|
+
head: { y: -0.15, x: 0.1 },
|
|
290
|
+
armL: { x: -0.85, z: -0.55 },
|
|
291
|
+
armR: { x: -0.85, z: 0.55 },
|
|
292
|
+
legL: { x: 0.3 },
|
|
293
|
+
legR: { x: -0.3 }
|
|
294
|
+
},
|
|
295
|
+
lift: 0.1
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
at: 1.2,
|
|
299
|
+
pose: {
|
|
300
|
+
torso: { x: 0.38 },
|
|
301
|
+
head: { y: 0.45, x: 0.1 },
|
|
302
|
+
armL: { x: -0.85, z: -0.55 },
|
|
303
|
+
armR: { x: -0.85, z: 0.55 },
|
|
304
|
+
legL: { x: -0.35 },
|
|
305
|
+
legR: { x: 0.35 }
|
|
306
|
+
},
|
|
307
|
+
lift: 0.02
|
|
308
|
+
}
|
|
309
|
+
]),
|
|
310
|
+
cheer: keyframes(true, [
|
|
311
|
+
{
|
|
312
|
+
at: 0,
|
|
313
|
+
pose: {
|
|
314
|
+
torso: { x: -0.1 },
|
|
315
|
+
head: { x: -0.18 },
|
|
316
|
+
armL: { z: -2.45 },
|
|
317
|
+
armR: { z: 2.45 },
|
|
318
|
+
legL: { x: -0.1 },
|
|
319
|
+
legR: { x: 0.1 }
|
|
320
|
+
},
|
|
321
|
+
lift: 0.05
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
at: 0.25,
|
|
325
|
+
pose: {
|
|
326
|
+
torso: { x: -0.16 },
|
|
327
|
+
head: { x: -0.22 },
|
|
328
|
+
armL: { z: -2.8 },
|
|
329
|
+
armR: { z: 2.8 },
|
|
330
|
+
legL: { x: -0.25 },
|
|
331
|
+
legR: { x: 0.25 }
|
|
332
|
+
},
|
|
333
|
+
lift: 0.28
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
at: 0.5,
|
|
337
|
+
pose: {
|
|
338
|
+
torso: { x: -0.1 },
|
|
339
|
+
head: { x: -0.18 },
|
|
340
|
+
armL: { z: -2.45 },
|
|
341
|
+
armR: { z: 2.45 },
|
|
342
|
+
legL: { x: -0.1 },
|
|
343
|
+
legR: { x: 0.1 }
|
|
344
|
+
},
|
|
345
|
+
lift: 0.05
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
at: 0.75,
|
|
349
|
+
pose: {
|
|
350
|
+
torso: { x: -0.16 },
|
|
351
|
+
head: { x: -0.22 },
|
|
352
|
+
armL: { z: -2.6 },
|
|
353
|
+
armR: { z: 2.6 },
|
|
354
|
+
legL: { x: -0.25 },
|
|
355
|
+
legR: { x: 0.25 }
|
|
356
|
+
},
|
|
357
|
+
lift: 0.28
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
at: 1,
|
|
361
|
+
pose: {
|
|
362
|
+
torso: { x: -0.1 },
|
|
363
|
+
head: { x: -0.18 },
|
|
364
|
+
armL: { z: -2.45 },
|
|
365
|
+
armR: { z: 2.45 },
|
|
366
|
+
legL: { x: -0.1 },
|
|
367
|
+
legR: { x: 0.1 }
|
|
368
|
+
},
|
|
369
|
+
lift: 0.05
|
|
370
|
+
}
|
|
371
|
+
]),
|
|
372
|
+
laugh: keyframes(true, [
|
|
373
|
+
{
|
|
374
|
+
at: 0,
|
|
375
|
+
pose: {
|
|
376
|
+
torso: { x: 0.32 },
|
|
377
|
+
head: { x: 0.22 },
|
|
378
|
+
armL: { x: 0.75, z: -0.85 },
|
|
379
|
+
armR: { x: 0.75, z: 0.85 },
|
|
380
|
+
legL: { x: -0.1 },
|
|
381
|
+
legR: { x: 0.1 }
|
|
382
|
+
},
|
|
383
|
+
lift: 0.02
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
at: 0.25,
|
|
387
|
+
pose: {
|
|
388
|
+
torso: { x: 0.45 },
|
|
389
|
+
head: { x: 0.34 },
|
|
390
|
+
armL: { x: 0.85, z: -0.95 },
|
|
391
|
+
armR: { x: 0.85, z: 0.95 },
|
|
392
|
+
legL: { x: -0.18 },
|
|
393
|
+
legR: { x: 0.18 }
|
|
394
|
+
},
|
|
395
|
+
lift: 0.08
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
at: 0.5,
|
|
399
|
+
pose: {
|
|
400
|
+
torso: { x: 0.28 },
|
|
401
|
+
head: { x: 0.18 },
|
|
402
|
+
armL: { x: 0.7, z: -0.8 },
|
|
403
|
+
armR: { x: 0.7, z: 0.8 },
|
|
404
|
+
legL: { x: -0.1 },
|
|
405
|
+
legR: { x: 0.1 }
|
|
406
|
+
},
|
|
407
|
+
lift: 0.02
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
at: 0.75,
|
|
411
|
+
pose: {
|
|
412
|
+
torso: { x: 0.45 },
|
|
413
|
+
head: { x: 0.34 },
|
|
414
|
+
armL: { x: 0.85, z: -0.95 },
|
|
415
|
+
armR: { x: 0.85, z: 0.95 },
|
|
416
|
+
legL: { x: -0.18 },
|
|
417
|
+
legR: { x: 0.18 }
|
|
418
|
+
},
|
|
419
|
+
lift: 0.08
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
at: 1,
|
|
423
|
+
pose: {
|
|
424
|
+
torso: { x: 0.32 },
|
|
425
|
+
head: { x: 0.22 },
|
|
426
|
+
armL: { x: 0.75, z: -0.85 },
|
|
427
|
+
armR: { x: 0.75, z: 0.85 },
|
|
428
|
+
legL: { x: -0.1 },
|
|
429
|
+
legR: { x: 0.1 }
|
|
430
|
+
},
|
|
431
|
+
lift: 0.02
|
|
432
|
+
}
|
|
433
|
+
]),
|
|
434
|
+
pose: keyframes(true, [
|
|
435
|
+
{
|
|
436
|
+
at: 0,
|
|
437
|
+
pose: {
|
|
438
|
+
torso: { z: 0.06 },
|
|
439
|
+
head: { z: -0.15, y: 0.1 },
|
|
440
|
+
armR: { z: 1.15, x: 0.2 },
|
|
441
|
+
armL: { z: -0.25 },
|
|
442
|
+
legL: { x: -0.08 },
|
|
443
|
+
legR: { x: 0.08 }
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
at: 0.35,
|
|
448
|
+
pose: {
|
|
449
|
+
torso: { z: 0.1 },
|
|
450
|
+
head: { z: -0.2, y: 0.1 },
|
|
451
|
+
armR: { z: 1.25, x: 0.2 },
|
|
452
|
+
armL: { z: -0.3 },
|
|
453
|
+
legL: { x: -0.08 },
|
|
454
|
+
legR: { x: 0.08 }
|
|
455
|
+
},
|
|
456
|
+
lift: 0.02
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
at: 0.7,
|
|
460
|
+
pose: {
|
|
461
|
+
torso: { z: 0.04 },
|
|
462
|
+
head: { z: -0.1, y: -0.1 },
|
|
463
|
+
armR: { z: 1.1, x: 0.2 },
|
|
464
|
+
armL: { z: -0.2 },
|
|
465
|
+
legL: { x: -0.08 },
|
|
466
|
+
legR: { x: 0.08 }
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
at: 1.05,
|
|
471
|
+
pose: {
|
|
472
|
+
torso: { z: 0.1 },
|
|
473
|
+
head: { z: -0.2, y: -0.1 },
|
|
474
|
+
armR: { z: 1.25, x: 0.2 },
|
|
475
|
+
armL: { z: -0.3 },
|
|
476
|
+
legL: { x: -0.08 },
|
|
477
|
+
legR: { x: 0.08 }
|
|
478
|
+
},
|
|
479
|
+
lift: 0.02
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
at: 1.4,
|
|
483
|
+
pose: {
|
|
484
|
+
torso: { z: 0.06 },
|
|
485
|
+
head: { z: -0.15, y: 0.1 },
|
|
486
|
+
armR: { z: 1.15, x: 0.2 },
|
|
487
|
+
armL: { z: -0.25 },
|
|
488
|
+
legL: { x: -0.08 },
|
|
489
|
+
legR: { x: 0.08 }
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
]),
|
|
493
|
+
rage: keyframes(true, [
|
|
494
|
+
{
|
|
495
|
+
at: 0,
|
|
496
|
+
pose: {
|
|
497
|
+
torso: { x: 0.22 },
|
|
498
|
+
head: { x: 0.12, y: 0.2 },
|
|
499
|
+
armL: { x: -0.45, z: -0.55 },
|
|
500
|
+
armR: { x: -0.45, z: 0.55 },
|
|
501
|
+
legL: { x: -0.28 },
|
|
502
|
+
legR: { x: 0.18 }
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
at: 0.225,
|
|
507
|
+
pose: {
|
|
508
|
+
torso: { x: 0.26 },
|
|
509
|
+
head: { x: 0.12, y: -0.2 },
|
|
510
|
+
armL: { x: -0.6, z: -0.55 },
|
|
511
|
+
armR: { x: -0.3, z: 0.55 },
|
|
512
|
+
legL: { x: 0.18 },
|
|
513
|
+
legR: { x: -0.28 }
|
|
514
|
+
},
|
|
515
|
+
lift: 0.06
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
at: 0.45,
|
|
519
|
+
pose: {
|
|
520
|
+
torso: { x: 0.22 },
|
|
521
|
+
head: { x: 0.12, y: 0.2 },
|
|
522
|
+
armL: { x: -0.45, z: -0.55 },
|
|
523
|
+
armR: { x: -0.45, z: 0.55 },
|
|
524
|
+
legL: { x: -0.28 },
|
|
525
|
+
legR: { x: 0.18 }
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
at: 0.675,
|
|
530
|
+
pose: {
|
|
531
|
+
torso: { x: 0.26 },
|
|
532
|
+
head: { x: 0.12, y: -0.2 },
|
|
533
|
+
armL: { x: -0.3, z: -0.55 },
|
|
534
|
+
armR: { x: -0.6, z: 0.55 },
|
|
535
|
+
legL: { x: 0.18 },
|
|
536
|
+
legR: { x: -0.28 }
|
|
537
|
+
},
|
|
538
|
+
lift: 0.06
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
at: 0.9,
|
|
542
|
+
pose: {
|
|
543
|
+
torso: { x: 0.22 },
|
|
544
|
+
head: { x: 0.12, y: 0.2 },
|
|
545
|
+
armL: { x: -0.45, z: -0.55 },
|
|
546
|
+
armR: { x: -0.45, z: 0.55 },
|
|
547
|
+
legL: { x: -0.28 },
|
|
548
|
+
legR: { x: 0.18 }
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
]),
|
|
552
|
+
sob: keyframes(true, [
|
|
553
|
+
{
|
|
554
|
+
at: 0,
|
|
555
|
+
pose: {
|
|
556
|
+
torso: { x: 0.35 },
|
|
557
|
+
head: { x: 0.3 },
|
|
558
|
+
armL: { x: -0.35, z: -1.85 },
|
|
559
|
+
armR: { x: -0.35, z: 1.85 },
|
|
560
|
+
legL: { x: -0.05 },
|
|
561
|
+
legR: { x: 0.05 }
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
at: 0.3,
|
|
566
|
+
pose: {
|
|
567
|
+
torso: { x: 0.48 },
|
|
568
|
+
head: { x: 0.4 },
|
|
569
|
+
armL: { x: -0.35, z: -1.95 },
|
|
570
|
+
armR: { x: -0.35, z: 1.95 },
|
|
571
|
+
legL: { x: -0.05 },
|
|
572
|
+
legR: { x: 0.05 }
|
|
573
|
+
},
|
|
574
|
+
lift: 0.04
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
at: 0.6,
|
|
578
|
+
pose: {
|
|
579
|
+
torso: { x: 0.32 },
|
|
580
|
+
head: { x: 0.26 },
|
|
581
|
+
armL: { x: -0.35, z: -1.8 },
|
|
582
|
+
armR: { x: -0.35, z: 1.8 },
|
|
583
|
+
legL: { x: -0.05 },
|
|
584
|
+
legR: { x: 0.05 }
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
at: 0.9,
|
|
589
|
+
pose: {
|
|
590
|
+
torso: { x: 0.48 },
|
|
591
|
+
head: { x: 0.4 },
|
|
592
|
+
armL: { x: -0.35, z: -1.95 },
|
|
593
|
+
armR: { x: -0.35, z: 1.95 },
|
|
594
|
+
legL: { x: -0.05 },
|
|
595
|
+
legR: { x: 0.05 }
|
|
596
|
+
},
|
|
597
|
+
lift: 0.04
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
at: 1.2,
|
|
601
|
+
pose: {
|
|
602
|
+
torso: { x: 0.35 },
|
|
603
|
+
head: { x: 0.3 },
|
|
604
|
+
armL: { x: -0.35, z: -1.85 },
|
|
605
|
+
armR: { x: -0.35, z: 1.85 },
|
|
606
|
+
legL: { x: -0.05 },
|
|
607
|
+
legR: { x: 0.05 }
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
]),
|
|
611
|
+
nod: keyframes(true, [
|
|
612
|
+
{
|
|
613
|
+
at: 0,
|
|
614
|
+
pose: { torso: { x: 0.04 }, head: { x: 0.02 }, armL: { z: -0.1 }, armR: { z: 0.1 } }
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
at: 0.4,
|
|
618
|
+
pose: { torso: { x: 0.08 }, head: { x: 0.3 }, armL: { z: -0.1 }, armR: { z: 0.1 } }
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
at: 0.8,
|
|
622
|
+
pose: { torso: { x: 0.04 }, head: { x: 0.05 }, armL: { z: -0.1 }, armR: { z: 0.1 } }
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
at: 1.2,
|
|
626
|
+
pose: { torso: { x: 0.08 }, head: { x: 0.26 }, armL: { z: -0.1 }, armR: { z: 0.1 } }
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
at: 1.6,
|
|
630
|
+
pose: { torso: { x: 0.04 }, head: { x: 0.02 }, armL: { z: -0.1 }, armR: { z: 0.1 } }
|
|
631
|
+
}
|
|
632
|
+
])
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
// src/rig.ts
|
|
636
|
+
var box = (name, parent, joint, size, center = [0, 0, 0]) => ({ name, parent, joint, size, center });
|
|
637
|
+
var R6 = {
|
|
638
|
+
id: "r6",
|
|
639
|
+
height: 5,
|
|
640
|
+
bones: [
|
|
641
|
+
box("Torso", null, [0, 3, 0], [2, 2, 1]),
|
|
642
|
+
box("Head", "Torso", [0, 1, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
643
|
+
box("LeftArm", "Torso", [-1, 1, 0], [1, 2, 1], [-0.5, -1, 0]),
|
|
644
|
+
box("RightArm", "Torso", [1, 1, 0], [1, 2, 1], [0.5, -1, 0]),
|
|
645
|
+
box("LeftLeg", "Torso", [-0.5, -1, 0], [1, 2, 1], [0, -1, 0]),
|
|
646
|
+
box("RightLeg", "Torso", [0.5, -1, 0], [1, 2, 1], [0, -1, 0])
|
|
647
|
+
],
|
|
648
|
+
aliases: {
|
|
649
|
+
head: "Head",
|
|
650
|
+
torso: "Torso",
|
|
651
|
+
armL: "LeftArm",
|
|
652
|
+
armR: "RightArm",
|
|
653
|
+
legL: "LeftLeg",
|
|
654
|
+
legR: "RightLeg"
|
|
655
|
+
},
|
|
656
|
+
lower: {}
|
|
657
|
+
};
|
|
658
|
+
var R15 = {
|
|
659
|
+
id: "r15",
|
|
660
|
+
height: 5,
|
|
661
|
+
bones: [
|
|
662
|
+
box("LowerTorso", null, [0, 2.4, 0], [2, 0.4, 1], [0, -0.2, 0]),
|
|
663
|
+
box("UpperTorso", "LowerTorso", [0, -0, 0], [2, 1.6, 1], [0, 0.8, 0]),
|
|
664
|
+
box("Head", "UpperTorso", [0, 1.6, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
665
|
+
box("LeftUpperArm", "UpperTorso", [-1, 1.6, 0], [1, 1, 1], [-0.5, -0.5, 0]),
|
|
666
|
+
box("LeftLowerArm", "LeftUpperArm", [-0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
667
|
+
box("LeftHand", "LeftLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
668
|
+
box("RightUpperArm", "UpperTorso", [1, 1.6, 0], [1, 1, 1], [0.5, -0.5, 0]),
|
|
669
|
+
box("RightLowerArm", "RightUpperArm", [0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
670
|
+
box("RightHand", "RightLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
671
|
+
box("LeftUpperLeg", "LowerTorso", [-0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
672
|
+
box("LeftLowerLeg", "LeftUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
673
|
+
box("LeftFoot", "LeftLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
674
|
+
box("RightUpperLeg", "LowerTorso", [0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
675
|
+
box("RightLowerLeg", "RightUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
676
|
+
box("RightFoot", "RightLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0])
|
|
677
|
+
],
|
|
678
|
+
aliases: {
|
|
679
|
+
head: "Head",
|
|
680
|
+
torso: "UpperTorso",
|
|
681
|
+
armL: "LeftUpperArm",
|
|
682
|
+
armR: "RightUpperArm",
|
|
683
|
+
legL: "LeftUpperLeg",
|
|
684
|
+
legR: "RightUpperLeg"
|
|
685
|
+
},
|
|
686
|
+
lower: {
|
|
687
|
+
armL: "LeftLowerArm",
|
|
688
|
+
armR: "RightLowerArm",
|
|
689
|
+
legL: "LeftLowerLeg",
|
|
690
|
+
legR: "RightLowerLeg"
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
var PLUP = {
|
|
694
|
+
id: "plup",
|
|
695
|
+
height: 3.4,
|
|
696
|
+
bones: [
|
|
697
|
+
box("Body", null, [0, 1.1, 0], [2.6, 2.3, 2], [0, 1, 0]),
|
|
698
|
+
box("LeftArm", "Body", [-1.3, 1, 0], [0.5, 0.9, 0.5], [-0.2, -0.45, 0]),
|
|
699
|
+
box("RightArm", "Body", [1.3, 1, 0], [0.5, 0.9, 0.5], [0.2, -0.45, 0]),
|
|
700
|
+
box("LeftLeg", "Body", [-0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0]),
|
|
701
|
+
box("RightLeg", "Body", [0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0])
|
|
702
|
+
],
|
|
703
|
+
aliases: {
|
|
704
|
+
head: "Body",
|
|
705
|
+
torso: "Body",
|
|
706
|
+
armL: "LeftArm",
|
|
707
|
+
armR: "RightArm",
|
|
708
|
+
legL: "LeftLeg",
|
|
709
|
+
legR: "RightLeg"
|
|
710
|
+
},
|
|
711
|
+
lower: {}
|
|
712
|
+
};
|
|
713
|
+
var RIGS = { plup: PLUP, r6: R6, r15: R15 };
|
|
714
|
+
function boneOf(rig, name) {
|
|
715
|
+
const resolved = rig.aliases[name] ?? name;
|
|
716
|
+
return rig.bones.find((bone) => bone.name === resolved);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/pose.ts
|
|
720
|
+
var sin = (t, rate, phase = 0) => Math.sin(t * rate * Math.PI * 2 + phase);
|
|
721
|
+
var stride = (t, rate, swing) => ({
|
|
722
|
+
armL: { x: sin(t, rate) * swing * 0.9 },
|
|
723
|
+
armR: { x: -sin(t, rate) * swing * 0.9 },
|
|
724
|
+
legL: { x: -sin(t, rate) * swing },
|
|
725
|
+
legR: { x: sin(t, rate) * swing },
|
|
726
|
+
lift: Math.abs(sin(t, rate)) * 0.08
|
|
727
|
+
});
|
|
728
|
+
var authored = (name) => (t) => sampleCustom(AUTHORED_CLIPS[name], t);
|
|
729
|
+
var CLIPS = {
|
|
730
|
+
idle: (t) => ({
|
|
731
|
+
armL: { z: -0.06 + sin(t, 0.4) * 0.03 },
|
|
732
|
+
armR: { z: 0.06 - sin(t, 0.4) * 0.03 },
|
|
733
|
+
head: { y: sin(t, 0.15) * 0.12 },
|
|
734
|
+
lift: sin(t, 0.4) * 0.02
|
|
735
|
+
}),
|
|
736
|
+
walk: (t) => stride(t, 1.4, 0.65),
|
|
737
|
+
run: (t) => ({ ...stride(t, 2.4, 1.05), torso: { x: 0.12 } }),
|
|
738
|
+
jump: (t) => {
|
|
739
|
+
const air = Math.max(0, Math.sin(Math.min(t, 1) * Math.PI));
|
|
740
|
+
return {
|
|
741
|
+
armL: { z: -0.5 - air * 1.8 },
|
|
742
|
+
armR: { z: 0.5 + air * 1.8 },
|
|
743
|
+
legL: { x: air * 0.5 },
|
|
744
|
+
legR: { x: -air * 0.3 },
|
|
745
|
+
lift: air * 1.6
|
|
746
|
+
};
|
|
747
|
+
},
|
|
748
|
+
wave: (t) => ({ armR: { z: 2.6 + sin(t, 2) * 0.35 }, head: { y: 0.15 } }),
|
|
749
|
+
dance: (t) => ({
|
|
750
|
+
armL: { z: -1.6 + sin(t, 2) * 0.7 },
|
|
751
|
+
armR: { z: 1.6 + sin(t, 2) * 0.7 },
|
|
752
|
+
legL: { x: Math.max(0, sin(t, 2)) * 0.5 },
|
|
753
|
+
legR: { x: Math.max(0, -sin(t, 2)) * 0.5 },
|
|
754
|
+
torso: { z: sin(t, 1) * 0.12 },
|
|
755
|
+
lift: Math.abs(sin(t, 2)) * 0.25
|
|
756
|
+
}),
|
|
757
|
+
recoil: authored("recoil"),
|
|
758
|
+
flail: authored("flail"),
|
|
759
|
+
topple: authored("topple"),
|
|
760
|
+
collapse: authored("collapse"),
|
|
761
|
+
sneak: authored("sneak"),
|
|
762
|
+
cheer: authored("cheer"),
|
|
763
|
+
laugh: authored("laugh"),
|
|
764
|
+
pose: authored("pose"),
|
|
765
|
+
rage: authored("rage"),
|
|
766
|
+
sob: authored("sob"),
|
|
767
|
+
nod: authored("nod")
|
|
768
|
+
};
|
|
769
|
+
var isCustomClip = (clip) => typeof clip !== "string";
|
|
770
|
+
var customDuration = (clip) => clip.frames.length / clip.fps;
|
|
771
|
+
function customFrame(clip, seconds) {
|
|
772
|
+
const count = clip.frames.length;
|
|
773
|
+
const position = Math.max(0, seconds) * clip.fps;
|
|
774
|
+
const wrapped = clip.loop ? position % count : Math.min(position, count - 1);
|
|
775
|
+
const index = Math.floor(wrapped);
|
|
776
|
+
const here = clip.frames[index] ?? clip.frames[count - 1] ?? [];
|
|
777
|
+
const next = clip.frames[clip.loop ? (index + 1) % count : Math.min(index + 1, count - 1)] ?? here;
|
|
778
|
+
const blend = wrapped - index;
|
|
779
|
+
return here.map((value, slot) => value + ((next[slot] ?? value) - value) * blend);
|
|
780
|
+
}
|
|
781
|
+
function sampleCustom(clip, seconds) {
|
|
782
|
+
const frame = customFrame(clip, seconds);
|
|
783
|
+
const out = {};
|
|
784
|
+
clip.bones.forEach((bone, index) => {
|
|
785
|
+
out[bone] = {
|
|
786
|
+
x: frame[index * 3] ?? 0,
|
|
787
|
+
y: frame[index * 3 + 1] ?? 0,
|
|
788
|
+
z: frame[index * 3 + 2] ?? 0
|
|
789
|
+
};
|
|
790
|
+
});
|
|
791
|
+
out.lift = frame[clip.bones.length * 3] ?? 0;
|
|
792
|
+
return out;
|
|
793
|
+
}
|
|
794
|
+
function evaluate(clip, seconds) {
|
|
795
|
+
return isCustomClip(clip) ? sampleCustom(clip, seconds) : CLIPS[clip](seconds);
|
|
796
|
+
}
|
|
797
|
+
function sampleClip(clip, seconds) {
|
|
798
|
+
const { lift: _lift, ...pose } = evaluate(clip, seconds);
|
|
799
|
+
return pose;
|
|
800
|
+
}
|
|
801
|
+
function clipLift(clip, seconds) {
|
|
802
|
+
return evaluate(clip, seconds).lift ?? 0;
|
|
803
|
+
}
|
|
804
|
+
function mergePoses(...poses) {
|
|
805
|
+
const merged = {};
|
|
806
|
+
for (const pose of poses) {
|
|
807
|
+
for (const [name, rotation] of Object.entries(pose)) {
|
|
808
|
+
merged[name] = { ...merged[name], ...rotation };
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return merged;
|
|
812
|
+
}
|
|
813
|
+
function resolvePose(rigId, pose) {
|
|
814
|
+
const rig = RIGS[rigId];
|
|
815
|
+
const resolved = new Map;
|
|
816
|
+
for (const [name, rotation] of Object.entries(pose)) {
|
|
817
|
+
const bone = rig.aliases[name] ?? name;
|
|
818
|
+
if (rig.bones.some((candidate) => candidate.name === bone)) {
|
|
819
|
+
resolved.set(bone, { ...resolved.get(bone), ...rotation });
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return resolved;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export { AUTHORED_BONES, AUTHORED_CLIP_NAMES, AUTHORED_CLIPS, RIGS, boneOf, CLIPS, isCustomClip, customDuration, sampleClip, clipLift, mergePoses, resolvePose };
|