@plupin/character 0.0.0-stage → 0.2.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/canvas.d.ts +79 -0
- package/dist/canvas.js +315 -0
- package/dist/chunk-aa5nstet.js +39 -0
- package/dist/chunk-ae7gp5cc.js +101 -0
- package/dist/chunk-k5gwaq6t.js +315 -0
- package/dist/chunk-wpbgtn0y.js +179 -0
- package/dist/clip-bake.d.ts +48 -0
- package/dist/clip-bake.js +132 -0
- package/dist/emote.d.ts +23 -0
- package/dist/faces.d.ts +10 -0
- package/dist/faces.js +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +102 -0
- package/dist/listing.d.ts +195 -0
- package/dist/listing.js +753 -0
- package/dist/named-faces.d.ts +22 -0
- package/dist/plup2d.d.ts +29 -0
- package/dist/plup3d.d.ts +73 -0
- package/dist/png.d.ts +61 -0
- package/dist/pose.d.ts +43 -0
- package/dist/pose.js +18 -0
- package/dist/rig.d.ts +29 -0
- package/dist/skin-native.d.ts +252 -0
- package/dist/skin.d.ts +35 -0
- package/dist/three.d.ts +22 -0
- package/dist/three.js +581 -0
- package/package.json +58 -4
- package/README.md +0 -3
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RIGS
|
|
3
|
+
} from "./chunk-wpbgtn0y.js";
|
|
4
|
+
|
|
5
|
+
// src/skin.ts
|
|
6
|
+
var rect = (x, y, w, h) => ({ x, y, w, h });
|
|
7
|
+
var CLASSIC_WIDTH = 585;
|
|
8
|
+
var CLASSIC_HEIGHT = 559;
|
|
9
|
+
var CLASSIC_TORSO = {
|
|
10
|
+
up: rect(231, 8, 128, 64),
|
|
11
|
+
front: rect(231, 74, 128, 128),
|
|
12
|
+
down: rect(231, 204, 128, 64),
|
|
13
|
+
left: rect(361, 74, 64, 128),
|
|
14
|
+
right: rect(165, 74, 64, 128),
|
|
15
|
+
back: rect(427, 74, 128, 128)
|
|
16
|
+
};
|
|
17
|
+
var CLASSIC_RIGHT_LIMB = {
|
|
18
|
+
left: rect(19, 355, 64, 128),
|
|
19
|
+
back: rect(85, 355, 64, 128),
|
|
20
|
+
right: rect(151, 355, 64, 128),
|
|
21
|
+
front: rect(217, 355, 64, 128),
|
|
22
|
+
up: rect(217, 289, 64, 64),
|
|
23
|
+
down: rect(217, 485, 64, 64)
|
|
24
|
+
};
|
|
25
|
+
var CLASSIC_LEFT_LIMB = {
|
|
26
|
+
front: rect(308, 355, 64, 128),
|
|
27
|
+
left: rect(374, 355, 64, 128),
|
|
28
|
+
back: rect(440, 355, 64, 128),
|
|
29
|
+
right: rect(506, 355, 64, 128),
|
|
30
|
+
up: rect(308, 289, 64, 64),
|
|
31
|
+
down: rect(308, 485, 64, 64)
|
|
32
|
+
};
|
|
33
|
+
var CLASSIC_BONES = {
|
|
34
|
+
Torso: { sheet: "shirt", faces: CLASSIC_TORSO },
|
|
35
|
+
LeftArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB },
|
|
36
|
+
RightArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB },
|
|
37
|
+
LeftLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB },
|
|
38
|
+
RightLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB },
|
|
39
|
+
UpperTorso: { sheet: "shirt", faces: CLASSIC_TORSO, slice: [0, 0.8] },
|
|
40
|
+
LowerTorso: { sheet: "pants", faces: CLASSIC_TORSO, slice: [0.8, 1] },
|
|
41
|
+
LeftUpperArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0, 0.5] },
|
|
42
|
+
LeftLowerArm: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0.5, 0.9] },
|
|
43
|
+
LeftHand: { sheet: "shirt", faces: CLASSIC_LEFT_LIMB, slice: [0.9, 1] },
|
|
44
|
+
RightUpperArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0, 0.5] },
|
|
45
|
+
RightLowerArm: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0.5, 0.9] },
|
|
46
|
+
RightHand: { sheet: "shirt", faces: CLASSIC_RIGHT_LIMB, slice: [0.9, 1] },
|
|
47
|
+
LeftUpperLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0, 0.45] },
|
|
48
|
+
LeftLowerLeg: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0.45, 0.9] },
|
|
49
|
+
LeftFoot: { sheet: "pants", faces: CLASSIC_LEFT_LIMB, slice: [0.9, 1] },
|
|
50
|
+
RightUpperLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0, 0.45] },
|
|
51
|
+
RightLowerLeg: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0.45, 0.9] },
|
|
52
|
+
RightFoot: { sheet: "pants", faces: CLASSIC_RIGHT_LIMB, slice: [0.9, 1] }
|
|
53
|
+
};
|
|
54
|
+
function classicFaceRect(bone, face) {
|
|
55
|
+
const mapping = CLASSIC_BONES[bone];
|
|
56
|
+
if (!mapping)
|
|
57
|
+
return null;
|
|
58
|
+
const base = mapping.faces[face];
|
|
59
|
+
const slice = mapping.slice;
|
|
60
|
+
if (!slice)
|
|
61
|
+
return base;
|
|
62
|
+
const [from, to] = slice;
|
|
63
|
+
if (face === "up")
|
|
64
|
+
return from === 0 ? base : null;
|
|
65
|
+
if (face === "down")
|
|
66
|
+
return to === 1 ? base : null;
|
|
67
|
+
return rect(base.x, base.y + base.h * from, base.w, base.h * (to - from));
|
|
68
|
+
}
|
|
69
|
+
function validateClassicTemplate(width, height) {
|
|
70
|
+
return width === CLASSIC_WIDTH && height === CLASSIC_HEIGHT ? { ok: true } : { ok: false, reason: "wrong_size" };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/skin-native.ts
|
|
74
|
+
var NATIVE_PX_PER_STUD = 32;
|
|
75
|
+
var NATIVE_WIDTH = 512;
|
|
76
|
+
var NATIVE_HEIGHT = 256;
|
|
77
|
+
var rect2 = (x, y, w, h) => ({ x, y, w, h });
|
|
78
|
+
var NATIVE_TORSO = {
|
|
79
|
+
up: rect2(32, 0, 64, 32),
|
|
80
|
+
left: rect2(0, 32, 32, 64),
|
|
81
|
+
front: rect2(32, 32, 64, 64),
|
|
82
|
+
right: rect2(96, 32, 32, 64),
|
|
83
|
+
back: rect2(128, 32, 64, 64),
|
|
84
|
+
down: rect2(32, 96, 64, 32)
|
|
85
|
+
};
|
|
86
|
+
var NATIVE_HEAD = {
|
|
87
|
+
up: rect2(224, 0, 64, 32),
|
|
88
|
+
left: rect2(192, 32, 32, 32),
|
|
89
|
+
front: rect2(224, 32, 64, 32),
|
|
90
|
+
right: rect2(288, 32, 32, 32),
|
|
91
|
+
back: rect2(320, 32, 64, 32),
|
|
92
|
+
down: rect2(224, 64, 64, 32)
|
|
93
|
+
};
|
|
94
|
+
var NATIVE_ARM_LEFT = {
|
|
95
|
+
up: rect2(32, 128, 32, 32),
|
|
96
|
+
left: rect2(0, 160, 32, 64),
|
|
97
|
+
front: rect2(32, 160, 32, 64),
|
|
98
|
+
right: rect2(64, 160, 32, 64),
|
|
99
|
+
back: rect2(96, 160, 32, 64),
|
|
100
|
+
down: rect2(32, 224, 32, 32)
|
|
101
|
+
};
|
|
102
|
+
var NATIVE_ARM_RIGHT = {
|
|
103
|
+
up: rect2(160, 128, 32, 32),
|
|
104
|
+
left: rect2(128, 160, 32, 64),
|
|
105
|
+
front: rect2(160, 160, 32, 64),
|
|
106
|
+
right: rect2(192, 160, 32, 64),
|
|
107
|
+
back: rect2(224, 160, 32, 64),
|
|
108
|
+
down: rect2(160, 224, 32, 32)
|
|
109
|
+
};
|
|
110
|
+
var NATIVE_LEG_LEFT = {
|
|
111
|
+
up: rect2(288, 128, 32, 32),
|
|
112
|
+
left: rect2(256, 160, 32, 64),
|
|
113
|
+
front: rect2(288, 160, 32, 64),
|
|
114
|
+
right: rect2(320, 160, 32, 64),
|
|
115
|
+
back: rect2(352, 160, 32, 64),
|
|
116
|
+
down: rect2(288, 224, 32, 32)
|
|
117
|
+
};
|
|
118
|
+
var NATIVE_LEG_RIGHT = {
|
|
119
|
+
up: rect2(416, 128, 32, 32),
|
|
120
|
+
left: rect2(384, 160, 32, 64),
|
|
121
|
+
front: rect2(416, 160, 32, 64),
|
|
122
|
+
right: rect2(448, 160, 32, 64),
|
|
123
|
+
back: rect2(480, 160, 32, 64),
|
|
124
|
+
down: rect2(416, 224, 32, 32)
|
|
125
|
+
};
|
|
126
|
+
var NATIVE_PARTS = {
|
|
127
|
+
torso: { block: rect2(0, 0, 192, 128), studs: [2, 2, 1], faces: NATIVE_TORSO },
|
|
128
|
+
head: { block: rect2(192, 0, 192, 96), studs: [2, 1, 1], faces: NATIVE_HEAD },
|
|
129
|
+
armL: { block: rect2(0, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_ARM_LEFT },
|
|
130
|
+
armR: { block: rect2(128, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_ARM_RIGHT },
|
|
131
|
+
legL: { block: rect2(256, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_LEG_LEFT },
|
|
132
|
+
legR: { block: rect2(384, 128, 128, 128), studs: [1, 2, 1], faces: NATIVE_LEG_RIGHT }
|
|
133
|
+
};
|
|
134
|
+
var NATIVE_BONES = {
|
|
135
|
+
Torso: { part: "torso" },
|
|
136
|
+
Head: { part: "head" },
|
|
137
|
+
Body: { part: "torso" },
|
|
138
|
+
LeftArm: { part: "armL" },
|
|
139
|
+
RightArm: { part: "armR" },
|
|
140
|
+
LeftLeg: { part: "legL" },
|
|
141
|
+
RightLeg: { part: "legR" },
|
|
142
|
+
UpperTorso: { part: "torso", slice: [0, 0.8] },
|
|
143
|
+
LowerTorso: { part: "torso", slice: [0.8, 1] },
|
|
144
|
+
LeftUpperArm: { part: "armL", slice: [0, 0.5] },
|
|
145
|
+
LeftLowerArm: { part: "armL", slice: [0.5, 0.9] },
|
|
146
|
+
LeftHand: { part: "armL", slice: [0.9, 1] },
|
|
147
|
+
RightUpperArm: { part: "armR", slice: [0, 0.5] },
|
|
148
|
+
RightLowerArm: { part: "armR", slice: [0.5, 0.9] },
|
|
149
|
+
RightHand: { part: "armR", slice: [0.9, 1] },
|
|
150
|
+
LeftUpperLeg: { part: "legL", slice: [0, 0.45] },
|
|
151
|
+
LeftLowerLeg: { part: "legL", slice: [0.45, 0.9] },
|
|
152
|
+
LeftFoot: { part: "legL", slice: [0.9, 1] },
|
|
153
|
+
RightUpperLeg: { part: "legR", slice: [0, 0.45] },
|
|
154
|
+
RightLowerLeg: { part: "legR", slice: [0.45, 0.9] },
|
|
155
|
+
RightFoot: { part: "legR", slice: [0.9, 1] }
|
|
156
|
+
};
|
|
157
|
+
function nativePartOf(bone) {
|
|
158
|
+
return NATIVE_BONES[bone]?.part ?? null;
|
|
159
|
+
}
|
|
160
|
+
function nativeFaceRect(bone, face) {
|
|
161
|
+
const mapping = NATIVE_BONES[bone];
|
|
162
|
+
if (!mapping)
|
|
163
|
+
return null;
|
|
164
|
+
const base = NATIVE_PARTS[mapping.part].faces[face];
|
|
165
|
+
const slice = mapping.slice;
|
|
166
|
+
if (!slice)
|
|
167
|
+
return base;
|
|
168
|
+
const [from, to] = slice;
|
|
169
|
+
if (face === "up")
|
|
170
|
+
return from === 0 ? base : null;
|
|
171
|
+
if (face === "down")
|
|
172
|
+
return to === 1 ? base : null;
|
|
173
|
+
const top = Math.round(base.y + base.h * from);
|
|
174
|
+
const bottom = Math.round(base.y + base.h * to);
|
|
175
|
+
return rect2(base.x, top, base.w, bottom - top);
|
|
176
|
+
}
|
|
177
|
+
var BODY_SCALE_LIMITS = {
|
|
178
|
+
stature: { min: 0.5, max: 1.15 },
|
|
179
|
+
width: { min: 0.9, max: 1.3 },
|
|
180
|
+
head: { min: 0.9, max: 1.25 }
|
|
181
|
+
};
|
|
182
|
+
var CANONICAL_BODY_SCALE = { stature: 1, width: {}, head: 1 };
|
|
183
|
+
var WIDTH_PARTS = ["torso", "armL", "armR", "legL", "legR"];
|
|
184
|
+
var clamp = (value, limit) => typeof value === "number" && Number.isFinite(value) ? Math.min(limit.max, Math.max(limit.min, value)) : 1;
|
|
185
|
+
function clampBodyScale(scale) {
|
|
186
|
+
const width = {};
|
|
187
|
+
for (const part of WIDTH_PARTS) {
|
|
188
|
+
const value = scale?.width?.[part];
|
|
189
|
+
if (typeof value === "number")
|
|
190
|
+
width[part] = clamp(value, BODY_SCALE_LIMITS.width);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
stature: clamp(scale?.stature, BODY_SCALE_LIMITS.stature),
|
|
194
|
+
width,
|
|
195
|
+
head: clamp(scale?.head, BODY_SCALE_LIMITS.head)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
var widthOf = (scale, part) => part && part !== "head" ? scale.width[part] ?? 1 : 1;
|
|
199
|
+
function scaleBone(bone, part, parentPart, scale) {
|
|
200
|
+
const { stature } = scale;
|
|
201
|
+
const across = widthOf(scale, part);
|
|
202
|
+
const acrossParent = widthOf(scale, parentPart);
|
|
203
|
+
const head = part === "head" ? scale.head : 1;
|
|
204
|
+
return {
|
|
205
|
+
joint: [
|
|
206
|
+
bone.joint[0] * stature * acrossParent,
|
|
207
|
+
bone.joint[1] * stature,
|
|
208
|
+
bone.joint[2] * stature * acrossParent
|
|
209
|
+
],
|
|
210
|
+
size: [
|
|
211
|
+
bone.size[0] * stature * across * head,
|
|
212
|
+
bone.size[1] * stature * head,
|
|
213
|
+
bone.size[2] * stature * across * head
|
|
214
|
+
],
|
|
215
|
+
center: [
|
|
216
|
+
bone.center[0] * stature * across * head,
|
|
217
|
+
bone.center[1] * stature * head,
|
|
218
|
+
bone.center[2] * stature * across * head
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function canonicalFootprint(rigId) {
|
|
223
|
+
const rig = RIGS[rigId];
|
|
224
|
+
const joints = new Map;
|
|
225
|
+
const bones = {};
|
|
226
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
227
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
228
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
229
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
230
|
+
let minZ = Number.POSITIVE_INFINITY;
|
|
231
|
+
let maxZ = Number.NEGATIVE_INFINITY;
|
|
232
|
+
for (const bone of rig.bones) {
|
|
233
|
+
const parent = bone.parent ? joints.get(bone.parent) ?? [0, 0, 0] : [0, 0, 0];
|
|
234
|
+
const joint = [
|
|
235
|
+
parent[0] + bone.joint[0],
|
|
236
|
+
parent[1] + bone.joint[1],
|
|
237
|
+
parent[2] + bone.joint[2]
|
|
238
|
+
];
|
|
239
|
+
joints.set(bone.name, joint);
|
|
240
|
+
const center = [
|
|
241
|
+
joint[0] + bone.center[0],
|
|
242
|
+
joint[1] + bone.center[1],
|
|
243
|
+
joint[2] + bone.center[2]
|
|
244
|
+
];
|
|
245
|
+
bones[bone.name] = { size: bone.size, center };
|
|
246
|
+
minX = Math.min(minX, center[0] - bone.size[0] / 2);
|
|
247
|
+
maxX = Math.max(maxX, center[0] + bone.size[0] / 2);
|
|
248
|
+
minY = Math.min(minY, center[1] - bone.size[1] / 2);
|
|
249
|
+
maxY = Math.max(maxY, center[1] + bone.size[1] / 2);
|
|
250
|
+
minZ = Math.min(minZ, center[2] - bone.size[2] / 2);
|
|
251
|
+
maxZ = Math.max(maxZ, center[2] + bone.size[2] / 2);
|
|
252
|
+
}
|
|
253
|
+
return { width: maxX - minX, height: maxY - minY, depth: maxZ - minZ, bones };
|
|
254
|
+
}
|
|
255
|
+
function visualEnvelope(rigId) {
|
|
256
|
+
const footprint = canonicalFootprint(rigId);
|
|
257
|
+
const stature = BODY_SCALE_LIMITS.stature.max;
|
|
258
|
+
return {
|
|
259
|
+
width: footprint.width * stature * BODY_SCALE_LIMITS.width.max,
|
|
260
|
+
height: footprint.height * stature * BODY_SCALE_LIMITS.head.max,
|
|
261
|
+
depth: footprint.depth * stature * BODY_SCALE_LIMITS.width.max
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
var NATIVE_SHEET_CAPS = {
|
|
265
|
+
format: "png-24",
|
|
266
|
+
width: NATIVE_WIDTH,
|
|
267
|
+
height: NATIVE_HEIGHT,
|
|
268
|
+
maxBytes: 64 * 1024
|
|
269
|
+
};
|
|
270
|
+
function validateVariantSheet(facts) {
|
|
271
|
+
if (facts.width !== NATIVE_SHEET_CAPS.width || facts.height !== NATIVE_SHEET_CAPS.height)
|
|
272
|
+
return { ok: false, reason: "wrong_size" };
|
|
273
|
+
if (facts.bytes > NATIVE_SHEET_CAPS.maxBytes)
|
|
274
|
+
return { ok: false, reason: "over_byte_cap" };
|
|
275
|
+
return { ok: true };
|
|
276
|
+
}
|
|
277
|
+
var PANTS_BONE = /Leg|Foot/;
|
|
278
|
+
function boneSkin(bone, face, look) {
|
|
279
|
+
const part = nativePartOf(bone);
|
|
280
|
+
const variant = part ? look.variant?.parts[part] : undefined;
|
|
281
|
+
if (variant) {
|
|
282
|
+
const source2 = nativeFaceRect(bone, face);
|
|
283
|
+
return source2 ? { image: variant.image, source: source2, redraw: true } : null;
|
|
284
|
+
}
|
|
285
|
+
if (look.native) {
|
|
286
|
+
const source2 = nativeFaceRect(bone, face);
|
|
287
|
+
if (source2)
|
|
288
|
+
return { image: look.native, source: source2, redraw: false };
|
|
289
|
+
}
|
|
290
|
+
const sheet = PANTS_BONE.test(bone) || bone === "LowerTorso" ? look.pants : look.shirt;
|
|
291
|
+
const source = sheet ? classicFaceRect(bone, face) : null;
|
|
292
|
+
return sheet && source ? { image: sheet, source, redraw: false } : null;
|
|
293
|
+
}
|
|
294
|
+
var CONVERSION_FACES = ["front", "back", "left", "right", "up", "down"];
|
|
295
|
+
var CLASSIC_SOURCES = [
|
|
296
|
+
{ part: "torso", bone: "Torso" },
|
|
297
|
+
{ part: "armL", bone: "LeftArm" },
|
|
298
|
+
{ part: "armR", bone: "RightArm" },
|
|
299
|
+
{ part: "legL", bone: "LeftLeg" },
|
|
300
|
+
{ part: "legR", bone: "RightLeg" }
|
|
301
|
+
];
|
|
302
|
+
var CLASSIC_TO_NATIVE = CLASSIC_SOURCES.flatMap(({ part, bone }) => {
|
|
303
|
+
const mapping = CLASSIC_BONES[bone];
|
|
304
|
+
if (!mapping)
|
|
305
|
+
return [];
|
|
306
|
+
return CONVERSION_FACES.map((face) => ({
|
|
307
|
+
part,
|
|
308
|
+
face,
|
|
309
|
+
sheet: mapping.sheet,
|
|
310
|
+
source: mapping.faces[face],
|
|
311
|
+
dest: NATIVE_PARTS[part].faces[face]
|
|
312
|
+
}));
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
export { CLASSIC_WIDTH, CLASSIC_HEIGHT, CLASSIC_TORSO, CLASSIC_RIGHT_LIMB, CLASSIC_LEFT_LIMB, CLASSIC_BONES, classicFaceRect, validateClassicTemplate, NATIVE_PX_PER_STUD, NATIVE_WIDTH, NATIVE_HEIGHT, NATIVE_TORSO, NATIVE_HEAD, NATIVE_ARM_LEFT, NATIVE_ARM_RIGHT, NATIVE_LEG_LEFT, NATIVE_LEG_RIGHT, NATIVE_PARTS, NATIVE_BONES, nativePartOf, nativeFaceRect, BODY_SCALE_LIMITS, CANONICAL_BODY_SCALE, clampBodyScale, scaleBone, canonicalFootprint, visualEnvelope, NATIVE_SHEET_CAPS, validateVariantSheet, boneSkin, CLASSIC_TO_NATIVE };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// src/rig.ts
|
|
2
|
+
var box = (name, parent, joint, size, center = [0, 0, 0]) => ({ name, parent, joint, size, center });
|
|
3
|
+
var R6 = {
|
|
4
|
+
id: "r6",
|
|
5
|
+
height: 5,
|
|
6
|
+
bones: [
|
|
7
|
+
box("Torso", null, [0, 3, 0], [2, 2, 1]),
|
|
8
|
+
box("Head", "Torso", [0, 1, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
9
|
+
box("LeftArm", "Torso", [-1, 1, 0], [1, 2, 1], [-0.5, -1, 0]),
|
|
10
|
+
box("RightArm", "Torso", [1, 1, 0], [1, 2, 1], [0.5, -1, 0]),
|
|
11
|
+
box("LeftLeg", "Torso", [-0.5, -1, 0], [1, 2, 1], [0, -1, 0]),
|
|
12
|
+
box("RightLeg", "Torso", [0.5, -1, 0], [1, 2, 1], [0, -1, 0])
|
|
13
|
+
],
|
|
14
|
+
aliases: {
|
|
15
|
+
head: "Head",
|
|
16
|
+
torso: "Torso",
|
|
17
|
+
armL: "LeftArm",
|
|
18
|
+
armR: "RightArm",
|
|
19
|
+
legL: "LeftLeg",
|
|
20
|
+
legR: "RightLeg"
|
|
21
|
+
},
|
|
22
|
+
lower: {}
|
|
23
|
+
};
|
|
24
|
+
var R15 = {
|
|
25
|
+
id: "r15",
|
|
26
|
+
height: 5,
|
|
27
|
+
bones: [
|
|
28
|
+
box("LowerTorso", null, [0, 2.4, 0], [2, 0.4, 1], [0, -0.2, 0]),
|
|
29
|
+
box("UpperTorso", "LowerTorso", [0, -0, 0], [2, 1.6, 1], [0, 0.8, 0]),
|
|
30
|
+
box("Head", "UpperTorso", [0, 1.6, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
31
|
+
box("LeftUpperArm", "UpperTorso", [-1, 1.6, 0], [1, 1, 1], [-0.5, -0.5, 0]),
|
|
32
|
+
box("LeftLowerArm", "LeftUpperArm", [-0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
33
|
+
box("LeftHand", "LeftLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
34
|
+
box("RightUpperArm", "UpperTorso", [1, 1.6, 0], [1, 1, 1], [0.5, -0.5, 0]),
|
|
35
|
+
box("RightLowerArm", "RightUpperArm", [0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
36
|
+
box("RightHand", "RightLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
37
|
+
box("LeftUpperLeg", "LowerTorso", [-0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
38
|
+
box("LeftLowerLeg", "LeftUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
39
|
+
box("LeftFoot", "LeftLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
40
|
+
box("RightUpperLeg", "LowerTorso", [0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
41
|
+
box("RightLowerLeg", "RightUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
42
|
+
box("RightFoot", "RightLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0])
|
|
43
|
+
],
|
|
44
|
+
aliases: {
|
|
45
|
+
head: "Head",
|
|
46
|
+
torso: "UpperTorso",
|
|
47
|
+
armL: "LeftUpperArm",
|
|
48
|
+
armR: "RightUpperArm",
|
|
49
|
+
legL: "LeftUpperLeg",
|
|
50
|
+
legR: "RightUpperLeg"
|
|
51
|
+
},
|
|
52
|
+
lower: {
|
|
53
|
+
armL: "LeftLowerArm",
|
|
54
|
+
armR: "RightLowerArm",
|
|
55
|
+
legL: "LeftLowerLeg",
|
|
56
|
+
legR: "RightLowerLeg"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var PLUP = {
|
|
60
|
+
id: "plup",
|
|
61
|
+
height: 3.4,
|
|
62
|
+
bones: [
|
|
63
|
+
box("Body", null, [0, 1.1, 0], [2.6, 2.3, 2], [0, 1, 0]),
|
|
64
|
+
box("LeftArm", "Body", [-1.3, 1, 0], [0.5, 0.9, 0.5], [-0.2, -0.45, 0]),
|
|
65
|
+
box("RightArm", "Body", [1.3, 1, 0], [0.5, 0.9, 0.5], [0.2, -0.45, 0]),
|
|
66
|
+
box("LeftLeg", "Body", [-0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0]),
|
|
67
|
+
box("RightLeg", "Body", [0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0])
|
|
68
|
+
],
|
|
69
|
+
aliases: {
|
|
70
|
+
head: "Body",
|
|
71
|
+
torso: "Body",
|
|
72
|
+
armL: "LeftArm",
|
|
73
|
+
armR: "RightArm",
|
|
74
|
+
legL: "LeftLeg",
|
|
75
|
+
legR: "RightLeg"
|
|
76
|
+
},
|
|
77
|
+
lower: {}
|
|
78
|
+
};
|
|
79
|
+
var RIGS = { plup: PLUP, r6: R6, r15: R15 };
|
|
80
|
+
function boneOf(rig, name) {
|
|
81
|
+
const resolved = rig.aliases[name] ?? name;
|
|
82
|
+
return rig.bones.find((bone) => bone.name === resolved);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/pose.ts
|
|
86
|
+
var sin = (t, rate, phase = 0) => Math.sin(t * rate * Math.PI * 2 + phase);
|
|
87
|
+
var stride = (t, rate, swing) => ({
|
|
88
|
+
armL: { x: sin(t, rate) * swing * 0.9 },
|
|
89
|
+
armR: { x: -sin(t, rate) * swing * 0.9 },
|
|
90
|
+
legL: { x: -sin(t, rate) * swing },
|
|
91
|
+
legR: { x: sin(t, rate) * swing },
|
|
92
|
+
lift: Math.abs(sin(t, rate)) * 0.08
|
|
93
|
+
});
|
|
94
|
+
var CLIPS = {
|
|
95
|
+
idle: (t) => ({
|
|
96
|
+
armL: { z: -0.06 + sin(t, 0.4) * 0.03 },
|
|
97
|
+
armR: { z: 0.06 - sin(t, 0.4) * 0.03 },
|
|
98
|
+
head: { y: sin(t, 0.15) * 0.12 },
|
|
99
|
+
lift: sin(t, 0.4) * 0.02
|
|
100
|
+
}),
|
|
101
|
+
walk: (t) => stride(t, 1.4, 0.65),
|
|
102
|
+
run: (t) => ({ ...stride(t, 2.4, 1.05), torso: { x: 0.12 } }),
|
|
103
|
+
jump: (t) => {
|
|
104
|
+
const air = Math.max(0, Math.sin(Math.min(t, 1) * Math.PI));
|
|
105
|
+
return {
|
|
106
|
+
armL: { z: -0.5 - air * 1.8 },
|
|
107
|
+
armR: { z: 0.5 + air * 1.8 },
|
|
108
|
+
legL: { x: air * 0.5 },
|
|
109
|
+
legR: { x: -air * 0.3 },
|
|
110
|
+
lift: air * 1.6
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
wave: (t) => ({ armR: { z: 2.6 + sin(t, 2) * 0.35 }, head: { y: 0.15 } }),
|
|
114
|
+
dance: (t) => ({
|
|
115
|
+
armL: { z: -1.6 + sin(t, 2) * 0.7 },
|
|
116
|
+
armR: { z: 1.6 + sin(t, 2) * 0.7 },
|
|
117
|
+
legL: { x: Math.max(0, sin(t, 2)) * 0.5 },
|
|
118
|
+
legR: { x: Math.max(0, -sin(t, 2)) * 0.5 },
|
|
119
|
+
torso: { z: sin(t, 1) * 0.12 },
|
|
120
|
+
lift: Math.abs(sin(t, 2)) * 0.25
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
var isCustomClip = (clip) => typeof clip !== "string";
|
|
124
|
+
var customDuration = (clip) => clip.frames.length / clip.fps;
|
|
125
|
+
function customFrame(clip, seconds) {
|
|
126
|
+
const count = clip.frames.length;
|
|
127
|
+
const position = Math.max(0, seconds) * clip.fps;
|
|
128
|
+
const wrapped = clip.loop ? position % count : Math.min(position, count - 1);
|
|
129
|
+
const index = Math.floor(wrapped);
|
|
130
|
+
const here = clip.frames[index] ?? clip.frames[count - 1] ?? [];
|
|
131
|
+
const next = clip.frames[clip.loop ? (index + 1) % count : Math.min(index + 1, count - 1)] ?? here;
|
|
132
|
+
const blend = wrapped - index;
|
|
133
|
+
return here.map((value, slot) => value + ((next[slot] ?? value) - value) * blend);
|
|
134
|
+
}
|
|
135
|
+
function sampleCustom(clip, seconds) {
|
|
136
|
+
const frame = customFrame(clip, seconds);
|
|
137
|
+
const out = {};
|
|
138
|
+
clip.bones.forEach((bone, index) => {
|
|
139
|
+
out[bone] = {
|
|
140
|
+
x: frame[index * 3] ?? 0,
|
|
141
|
+
y: frame[index * 3 + 1] ?? 0,
|
|
142
|
+
z: frame[index * 3 + 2] ?? 0
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
out.lift = frame[clip.bones.length * 3] ?? 0;
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
function evaluate(clip, seconds) {
|
|
149
|
+
return isCustomClip(clip) ? sampleCustom(clip, seconds) : CLIPS[clip](seconds);
|
|
150
|
+
}
|
|
151
|
+
function sampleClip(clip, seconds) {
|
|
152
|
+
const { lift: _lift, ...pose } = evaluate(clip, seconds);
|
|
153
|
+
return pose;
|
|
154
|
+
}
|
|
155
|
+
function clipLift(clip, seconds) {
|
|
156
|
+
return evaluate(clip, seconds).lift ?? 0;
|
|
157
|
+
}
|
|
158
|
+
function mergePoses(...poses) {
|
|
159
|
+
const merged = {};
|
|
160
|
+
for (const pose of poses) {
|
|
161
|
+
for (const [name, rotation] of Object.entries(pose)) {
|
|
162
|
+
merged[name] = { ...merged[name], ...rotation };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return merged;
|
|
166
|
+
}
|
|
167
|
+
function resolvePose(rigId, pose) {
|
|
168
|
+
const rig = RIGS[rigId];
|
|
169
|
+
const resolved = new Map;
|
|
170
|
+
for (const [name, rotation] of Object.entries(pose)) {
|
|
171
|
+
const bone = rig.aliases[name] ?? name;
|
|
172
|
+
if (rig.bones.some((candidate) => candidate.name === bone)) {
|
|
173
|
+
resolved.set(bone, { ...resolved.get(bone), ...rotation });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return resolved;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { RIGS, boneOf, CLIPS, isCustomClip, customDuration, sampleClip, clipLift, mergePoses, resolvePose };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CustomClip } from "./pose";
|
|
2
|
+
import type { CanonicalBone } from "./rig";
|
|
3
|
+
/**
|
|
4
|
+
* Turns a baked motion clip (the CC0 library: Quaternius UAL, CMU, or a hand-keyed one) into the
|
|
5
|
+
* keyframes an emote ships. The source stores where 18 joints are, frame by frame; the rig wants a
|
|
6
|
+
* rotation per canonical bone. Each limb's direction is solved for the euler order the renderer uses
|
|
7
|
+
* (three's default XYZ: z swings a limb out, x swings it forward or back), and the solution is
|
|
8
|
+
* checked in the tests by applying the euler back to the rest vector and comparing directions.
|
|
9
|
+
*/
|
|
10
|
+
/** The 18-joint skeleton a baked clip carries, in file order. */
|
|
11
|
+
export declare const BAKED_JOINTS: readonly ["pelvis", "spine", "neck", "head", "shoulder_l", "elbow_l", "wrist_l", "shoulder_r", "elbow_r", "wrist_r", "hip_l", "knee_l", "ankle_l", "toe_l", "hip_r", "knee_r", "ankle_r", "toe_r"];
|
|
12
|
+
/** The clip file as the content pipeline writes it; only what the bake reads is typed. */
|
|
13
|
+
export interface BakedClip {
|
|
14
|
+
fps: number;
|
|
15
|
+
/** Seconds. */
|
|
16
|
+
durasi: number;
|
|
17
|
+
loop?: boolean;
|
|
18
|
+
sendi: readonly string[];
|
|
19
|
+
/** Frame-major: joint x, y, z for every joint in `sendi`, in metres, facing +z. */
|
|
20
|
+
data: readonly number[];
|
|
21
|
+
}
|
|
22
|
+
/** Which bones a bake drives, in the order a frame lists them. */
|
|
23
|
+
export declare const BAKE_BONES: readonly CanonicalBone[];
|
|
24
|
+
type Vec = readonly [number, number, number];
|
|
25
|
+
type Euler = {
|
|
26
|
+
x: number;
|
|
27
|
+
z: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The euler (x then z, XYZ order) that turns a limb hanging straight down onto `d`. Two solutions
|
|
31
|
+
* exist for every direction; the one closest to the previous frame keeps the limb from flipping
|
|
32
|
+
* when it sweeps through the horizontal.
|
|
33
|
+
*/
|
|
34
|
+
export declare function limbEuler(d: Vec, previous?: Euler): Euler;
|
|
35
|
+
/** What `limbEuler` must reproduce: where a hanging limb points after the euler. */
|
|
36
|
+
export declare function limbDirection(e: Euler): Vec;
|
|
37
|
+
/** The euler that tips an upright segment (the spine, the neck) onto `d`. */
|
|
38
|
+
export declare function uprightEuler(d: Vec): Euler;
|
|
39
|
+
export interface BakeOptions {
|
|
40
|
+
/** Output frames per second; never more than the source has. Default 20. */
|
|
41
|
+
fps?: number;
|
|
42
|
+
/** Longest clip kept, in seconds. Default 8. */
|
|
43
|
+
maxSeconds?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare class BakeError extends Error {
|
|
46
|
+
}
|
|
47
|
+
export declare function bakeToCustomClip(source: BakedClip, options?: BakeOptions): CustomClip;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/clip-bake.ts
|
|
2
|
+
var BAKED_JOINTS = [
|
|
3
|
+
"pelvis",
|
|
4
|
+
"spine",
|
|
5
|
+
"neck",
|
|
6
|
+
"head",
|
|
7
|
+
"shoulder_l",
|
|
8
|
+
"elbow_l",
|
|
9
|
+
"wrist_l",
|
|
10
|
+
"shoulder_r",
|
|
11
|
+
"elbow_r",
|
|
12
|
+
"wrist_r",
|
|
13
|
+
"hip_l",
|
|
14
|
+
"knee_l",
|
|
15
|
+
"ankle_l",
|
|
16
|
+
"toe_l",
|
|
17
|
+
"hip_r",
|
|
18
|
+
"knee_r",
|
|
19
|
+
"ankle_r",
|
|
20
|
+
"toe_r"
|
|
21
|
+
];
|
|
22
|
+
var BAKE_BONES = [
|
|
23
|
+
"armL",
|
|
24
|
+
"armR",
|
|
25
|
+
"legL",
|
|
26
|
+
"legR",
|
|
27
|
+
"torso",
|
|
28
|
+
"head"
|
|
29
|
+
];
|
|
30
|
+
var STUDS_PER_METRE = 5 / 1.75;
|
|
31
|
+
var sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
32
|
+
var unit = (v) => {
|
|
33
|
+
const length = Math.hypot(v[0], v[1], v[2]) || 1;
|
|
34
|
+
return [v[0] / length, v[1] / length, v[2] / length];
|
|
35
|
+
};
|
|
36
|
+
var wrap = (angle) => Math.atan2(Math.sin(angle), Math.cos(angle));
|
|
37
|
+
var unwrap = (angle, near) => near + wrap(angle - near);
|
|
38
|
+
var MAX_TURN = 3.15;
|
|
39
|
+
function limbEuler(d, previous) {
|
|
40
|
+
const r = Math.hypot(d[1], d[2]);
|
|
41
|
+
if (r < 0.0001)
|
|
42
|
+
return { x: previous?.x ?? 0, z: Math.sign(d[0]) * (Math.PI / 2) };
|
|
43
|
+
const below = { x: Math.atan2(-d[2], -d[1]), z: Math.atan2(d[0], r) };
|
|
44
|
+
const above = { x: Math.atan2(d[2], d[1]), z: Math.atan2(d[0], -r) };
|
|
45
|
+
if (!previous)
|
|
46
|
+
return d[1] <= 0 ? below : above;
|
|
47
|
+
const cost = (e) => Math.abs(wrap(e.x - previous.x)) + Math.abs(wrap(e.z - previous.z));
|
|
48
|
+
const near = (e) => ({ x: unwrap(e.x, previous.x), z: unwrap(e.z, previous.z) });
|
|
49
|
+
const inRange = (e) => Math.abs(e.x) <= MAX_TURN && Math.abs(e.z) <= MAX_TURN;
|
|
50
|
+
const ranked = [below, above].sort((a, b) => cost(a) - cost(b)).map(near);
|
|
51
|
+
return ranked.find(inRange) ?? { x: wrap(ranked[0].x), z: wrap(ranked[0].z) };
|
|
52
|
+
}
|
|
53
|
+
function limbDirection(e) {
|
|
54
|
+
return [Math.sin(e.z), -Math.cos(e.z) * Math.cos(e.x), -Math.cos(e.z) * Math.sin(e.x)];
|
|
55
|
+
}
|
|
56
|
+
function uprightEuler(d) {
|
|
57
|
+
return { z: -Math.asin(Math.max(-1, Math.min(1, d[0]))), x: Math.atan2(d[2], d[1]) };
|
|
58
|
+
}
|
|
59
|
+
var round = (value) => Math.round(value * 100) / 100;
|
|
60
|
+
|
|
61
|
+
class BakeError extends Error {
|
|
62
|
+
}
|
|
63
|
+
function bakeToCustomClip(source, options = {}) {
|
|
64
|
+
const joints = source.sendi;
|
|
65
|
+
const index = (name) => {
|
|
66
|
+
const found = joints.indexOf(name);
|
|
67
|
+
if (found < 0)
|
|
68
|
+
throw new BakeError(`The clip has no joint "${name}"; a baked clip carries ${BAKED_JOINTS.join(", ")}.`);
|
|
69
|
+
return found;
|
|
70
|
+
};
|
|
71
|
+
const stride = joints.length * 3;
|
|
72
|
+
if (!source.fps || source.data.length === 0 || source.data.length % stride !== 0)
|
|
73
|
+
throw new BakeError("The clip is empty or its data does not divide into whole frames.");
|
|
74
|
+
const sourceFrames = source.data.length / stride;
|
|
75
|
+
const at = (frame, name) => {
|
|
76
|
+
const base = frame * stride + index(name) * 3;
|
|
77
|
+
return [source.data[base] ?? 0, source.data[base + 1] ?? 0, source.data[base + 2] ?? 0];
|
|
78
|
+
};
|
|
79
|
+
const lerp = (a, b, t) => [
|
|
80
|
+
a[0] + (b[0] - a[0]) * t,
|
|
81
|
+
a[1] + (b[1] - a[1]) * t,
|
|
82
|
+
a[2] + (b[2] - a[2]) * t
|
|
83
|
+
];
|
|
84
|
+
const joint = (time, name) => {
|
|
85
|
+
const position = Math.min(time * source.fps, sourceFrames - 1);
|
|
86
|
+
const lo = Math.floor(position);
|
|
87
|
+
return lerp(at(lo, name), at(Math.min(lo + 1, sourceFrames - 1), name), position - lo);
|
|
88
|
+
};
|
|
89
|
+
const fps = Math.min(Math.round(options.fps ?? 20), Math.round(source.fps));
|
|
90
|
+
const seconds = Math.min(source.durasi || sourceFrames / source.fps, options.maxSeconds ?? 8);
|
|
91
|
+
const count = Math.max(1, Math.floor(seconds * fps));
|
|
92
|
+
const sideOf = (a, b) => at(0, a)[0] >= at(0, b)[0] ? [a, b] : [b, a];
|
|
93
|
+
const [shoulderPlus, shoulderMinus] = sideOf("shoulder_l", "shoulder_r");
|
|
94
|
+
const wristOf = (shoulder) => shoulder.replace("shoulder", "wrist");
|
|
95
|
+
const hipOf = (hip) => hip.replace("hip", "ankle");
|
|
96
|
+
const [hipPlus, hipMinus] = sideOf("hip_l", "hip_r");
|
|
97
|
+
const limbs = [
|
|
98
|
+
[shoulderMinus, wristOf(shoulderMinus)],
|
|
99
|
+
[shoulderPlus, wristOf(shoulderPlus)],
|
|
100
|
+
[hipMinus, hipOf(hipMinus)],
|
|
101
|
+
[hipPlus, hipOf(hipPlus)]
|
|
102
|
+
];
|
|
103
|
+
const restPelvis = at(0, "pelvis")[1];
|
|
104
|
+
const previous = [];
|
|
105
|
+
const frames = [];
|
|
106
|
+
for (let step = 0;step < count; step += 1) {
|
|
107
|
+
const time = step / fps;
|
|
108
|
+
const row = [];
|
|
109
|
+
limbs.forEach(([from, to], slot) => {
|
|
110
|
+
const d = unit(sub(joint(time, to), joint(time, from)));
|
|
111
|
+
const e = limbEuler(d, previous[slot]);
|
|
112
|
+
previous[slot] = e;
|
|
113
|
+
row.push(round(e.x), 0, round(e.z));
|
|
114
|
+
});
|
|
115
|
+
const spine = uprightEuler(unit(sub(joint(time, "neck"), joint(time, "pelvis"))));
|
|
116
|
+
row.push(round(spine.x), 0, round(spine.z));
|
|
117
|
+
const head = uprightEuler(unit(sub(joint(time, "head"), joint(time, "neck"))));
|
|
118
|
+
row.push(round(head.x - spine.x), 0, round(head.z - spine.z));
|
|
119
|
+
row.push(round(Math.max(0, (joint(time, "pelvis")[1] - restPelvis) * STUDS_PER_METRE)));
|
|
120
|
+
frames.push(row);
|
|
121
|
+
}
|
|
122
|
+
return { fps, loop: source.loop === true, bones: [...BAKE_BONES], frames };
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
uprightEuler,
|
|
126
|
+
limbEuler,
|
|
127
|
+
limbDirection,
|
|
128
|
+
bakeToCustomClip,
|
|
129
|
+
BakeError,
|
|
130
|
+
BAKE_BONES,
|
|
131
|
+
BAKED_JOINTS
|
|
132
|
+
};
|
package/dist/emote.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NamedFace } from "./faces";
|
|
2
|
+
import type { ClipName, CustomClip } from "./pose";
|
|
3
|
+
/**
|
|
4
|
+
* An emote is a name, a face and a clip the rig already has: nothing new to animate. `sigmaPrice` 0
|
|
5
|
+
* is free for everyone; anything else is bought in the shop (wardrobe), and the catalogue row has the
|
|
6
|
+
* same id. A game plays the face and the clip; whether a player may is the platform's to say.
|
|
7
|
+
*/
|
|
8
|
+
export interface Emote {
|
|
9
|
+
/** The catalogue id, also what a game passes: `emote-ngakak`. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** What a screen reader says, and the name in the shop. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** The kaomoji that rises over the character. Pixel-font safe. */
|
|
14
|
+
glyph: string;
|
|
15
|
+
face: NamedFace;
|
|
16
|
+
clip: ClipName;
|
|
17
|
+
/** Keyframes that replace `clip` when the emote ships its own animation; `clip` stays as the fallback. */
|
|
18
|
+
anim?: CustomClip;
|
|
19
|
+
sigmaPrice: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const EMOTES: readonly Emote[];
|
|
22
|
+
/** One emote by id (`emote-ngakak`) or by the short name (`ngakak`); undefined for an unknown name. */
|
|
23
|
+
export declare function emoteOf(name: string): Emote | undefined;
|