@plupin/character 0.4.0 → 0.6.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/blob.d.ts +15 -2
- package/dist/blob.js +3 -1
- package/dist/body-presets.d.ts +9 -8
- package/dist/canvas.js +2 -2
- package/dist/{chunk-ew73g2v7.js → chunk-phwn2cn7.js} +6 -4
- package/dist/{chunk-rqenm9tn.js → chunk-s083mv4f.js} +9 -8
- package/dist/{chunk-7ry0n8cw.js → chunk-wryfx2sg.js} +377 -233
- package/dist/{chunk-vy9w8as2.js → chunk-x8f5p1qg.js} +42 -12
- package/dist/dance-clips.d.ts +27 -0
- package/dist/ik-skeleton.d.ts +98 -0
- package/dist/index.js +3 -3
- package/dist/listing.js +2 -2
- package/dist/plup3d.d.ts +9 -1
- package/dist/pose.js +1 -1
- package/dist/skin-native.d.ts +11 -5
- package/dist/three.d.ts +3 -0
- package/dist/three.js +1674 -319
- package/dist/wear3d.d.ts +7 -1
- package/package.json +1 -1
package/dist/three.js
CHANGED
|
@@ -2,10 +2,6 @@ import {
|
|
|
2
2
|
BLOB_HEIGHT,
|
|
3
3
|
BLOB_RADIUS,
|
|
4
4
|
BLOB_SEAT,
|
|
5
|
-
FIGURE_HIP_Y,
|
|
6
|
-
FIGURE_SHOULDER_Y,
|
|
7
|
-
FIGURE_TORSO_MAX_Y,
|
|
8
|
-
FIGURE_TORSO_MIN_Y,
|
|
9
5
|
blobRadiusAt,
|
|
10
6
|
buildBlobGeometry,
|
|
11
7
|
buildFigureHeadGeometry,
|
|
@@ -13,8 +9,9 @@ import {
|
|
|
13
9
|
figureHeadMetrics,
|
|
14
10
|
figureHeadRadiusAt,
|
|
15
11
|
figureTorsoPoint,
|
|
16
|
-
figureTorsoRadiusAt
|
|
17
|
-
|
|
12
|
+
figureTorsoRadiusAt,
|
|
13
|
+
figureTorsoSpan
|
|
14
|
+
} from "./chunk-x8f5p1qg.js";
|
|
18
15
|
import {
|
|
19
16
|
ANIME_FACE_SIZE,
|
|
20
17
|
ANIME_FACE_UV,
|
|
@@ -26,7 +23,7 @@ import {
|
|
|
26
23
|
RAGDOLL_JOINTS,
|
|
27
24
|
createRagdoll,
|
|
28
25
|
emoteOf
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-s083mv4f.js";
|
|
30
27
|
import {
|
|
31
28
|
WEARABLES,
|
|
32
29
|
hairVolume,
|
|
@@ -40,7 +37,7 @@ import {
|
|
|
40
37
|
clampPlupBody,
|
|
41
38
|
nativePartOf,
|
|
42
39
|
scaleBone
|
|
43
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-phwn2cn7.js";
|
|
44
41
|
import {
|
|
45
42
|
AUTHORED_CLIPS,
|
|
46
43
|
RIGS,
|
|
@@ -48,7 +45,7 @@ import {
|
|
|
48
45
|
mergePoses,
|
|
49
46
|
resolvePose,
|
|
50
47
|
sampleClip
|
|
51
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-wryfx2sg.js";
|
|
52
49
|
import {
|
|
53
50
|
BODY_HEIGHT,
|
|
54
51
|
BODY_SHAPES,
|
|
@@ -79,20 +76,722 @@ import {
|
|
|
79
76
|
CanvasTexture as CanvasTexture2,
|
|
80
77
|
CapsuleGeometry,
|
|
81
78
|
Color as Color2,
|
|
79
|
+
CylinderGeometry as CylinderGeometry2,
|
|
82
80
|
DoubleSide,
|
|
83
81
|
Group as Group2,
|
|
84
82
|
Mesh as Mesh2,
|
|
85
83
|
MeshBasicMaterial as MeshBasicMaterial2,
|
|
86
84
|
QuadraticBezierCurve3,
|
|
87
|
-
Quaternion,
|
|
85
|
+
Quaternion as Quaternion2,
|
|
88
86
|
RepeatWrapping as RepeatWrapping2,
|
|
89
87
|
ShaderMaterial,
|
|
90
88
|
SphereGeometry as SphereGeometry3,
|
|
91
89
|
SRGBColorSpace as SRGBColorSpace2,
|
|
92
90
|
TubeGeometry,
|
|
93
|
-
|
|
91
|
+
Vector2 as Vector22,
|
|
92
|
+
Vector3 as Vector34
|
|
94
93
|
} from "three";
|
|
95
94
|
|
|
95
|
+
// src/dance-clips.ts
|
|
96
|
+
import { Vector3 } from "three";
|
|
97
|
+
var IK_DANCE_SET = new Set([
|
|
98
|
+
"brazil-funk",
|
|
99
|
+
"pacu-jalur",
|
|
100
|
+
"velocity",
|
|
101
|
+
"griddy",
|
|
102
|
+
"floss",
|
|
103
|
+
"caramel"
|
|
104
|
+
]);
|
|
105
|
+
function isIkDanceName(name) {
|
|
106
|
+
return typeof name === "string" && IK_DANCE_SET.has(name);
|
|
107
|
+
}
|
|
108
|
+
var HIPX = 0.1;
|
|
109
|
+
var SHX = 0.19;
|
|
110
|
+
var UA = 0.29;
|
|
111
|
+
var LA = 0.26;
|
|
112
|
+
var TH = 0.47;
|
|
113
|
+
var SH = 0.45;
|
|
114
|
+
var lerp = (a, b, k) => a + (b - a) * k;
|
|
115
|
+
var norm = (v) => {
|
|
116
|
+
const l = Math.hypot(v[0], v[1], v[2]) || 1;
|
|
117
|
+
return [v[0] / l, v[1] / l, v[2] / l];
|
|
118
|
+
};
|
|
119
|
+
var add = (a, b, k = 1) => [
|
|
120
|
+
a[0] + b[0] * k,
|
|
121
|
+
a[1] + b[1] * k,
|
|
122
|
+
a[2] + b[2] * k
|
|
123
|
+
];
|
|
124
|
+
function rot([x, y, z], yaw, lean, roll) {
|
|
125
|
+
let c = Math.cos(roll);
|
|
126
|
+
let s = Math.sin(roll);
|
|
127
|
+
[x, y] = [x * c - y * s, x * s + y * c];
|
|
128
|
+
c = Math.cos(lean);
|
|
129
|
+
s = Math.sin(lean);
|
|
130
|
+
[y, z] = [y * c - z * s, y * s + z * c];
|
|
131
|
+
c = Math.cos(yaw);
|
|
132
|
+
s = Math.sin(yaw);
|
|
133
|
+
[x, z] = [x * c + z * s, -x * s + z * c];
|
|
134
|
+
return [x, y, z];
|
|
135
|
+
}
|
|
136
|
+
var DOWN_ARM = { u: [0.18, -1, 0], l: [0.08, -1, 0.15] };
|
|
137
|
+
var BASE = {
|
|
138
|
+
drop: 0,
|
|
139
|
+
px: 0,
|
|
140
|
+
pz: 0,
|
|
141
|
+
yaw: 0,
|
|
142
|
+
lean: 0,
|
|
143
|
+
roll: 0,
|
|
144
|
+
headYaw: 0,
|
|
145
|
+
headPitch: 0,
|
|
146
|
+
headRoll: 0,
|
|
147
|
+
l: DOWN_ARM,
|
|
148
|
+
r: DOWN_ARM,
|
|
149
|
+
fl: [0.06, 0, 0, 0.1, 0],
|
|
150
|
+
fr: [0.06, 0, 0, -0.1, 0]
|
|
151
|
+
};
|
|
152
|
+
var full = (p) => ({
|
|
153
|
+
...BASE,
|
|
154
|
+
...p,
|
|
155
|
+
l: p.l ?? BASE.l,
|
|
156
|
+
r: p.r ?? BASE.r,
|
|
157
|
+
fl: p.fl ?? BASE.fl,
|
|
158
|
+
fr: p.fr ?? BASE.fr
|
|
159
|
+
});
|
|
160
|
+
function mixArm(a, b, k) {
|
|
161
|
+
return {
|
|
162
|
+
u: [lerp(a.u[0], b.u[0], k), lerp(a.u[1], b.u[1], k), lerp(a.u[2], b.u[2], k)],
|
|
163
|
+
l: [lerp(a.l[0], b.l[0], k), lerp(a.l[1], b.l[1], k), lerp(a.l[2], b.l[2], k)]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function mixPose(a, b, k) {
|
|
167
|
+
const m5 = (x, y) => [
|
|
168
|
+
lerp(x[0], y[0], k),
|
|
169
|
+
lerp(x[1], y[1], k),
|
|
170
|
+
lerp(x[2], y[2], k),
|
|
171
|
+
lerp(x[3], y[3], k),
|
|
172
|
+
lerp(x[4], y[4], k)
|
|
173
|
+
];
|
|
174
|
+
return {
|
|
175
|
+
drop: lerp(a.drop, b.drop, k),
|
|
176
|
+
px: lerp(a.px, b.px, k),
|
|
177
|
+
pz: lerp(a.pz, b.pz, k),
|
|
178
|
+
yaw: lerp(a.yaw, b.yaw, k),
|
|
179
|
+
lean: lerp(a.lean, b.lean, k),
|
|
180
|
+
roll: lerp(a.roll, b.roll, k),
|
|
181
|
+
headYaw: lerp(a.headYaw, b.headYaw, k),
|
|
182
|
+
headPitch: lerp(a.headPitch, b.headPitch, k),
|
|
183
|
+
headRoll: lerp(a.headRoll, b.headRoll, k),
|
|
184
|
+
l: mixArm(a.l, b.l, k),
|
|
185
|
+
r: mixArm(a.r, b.r, k),
|
|
186
|
+
fl: m5(a.fl, b.fl),
|
|
187
|
+
fr: m5(a.fr, b.fr)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
var smootherstep = (k) => k * k * k * (k * (k * 6 - 15) + 10);
|
|
191
|
+
function sampleTimeline(keys, t, extra) {
|
|
192
|
+
let i = keys.findIndex((k2) => k2[0] > t);
|
|
193
|
+
if (i < 0)
|
|
194
|
+
i = keys.length;
|
|
195
|
+
const a = keys[Math.max(0, i - 1)];
|
|
196
|
+
const b = keys[Math.min(keys.length - 1, i)];
|
|
197
|
+
let k = b === a ? 1 : (t - a[0]) / (b[0] - a[0]);
|
|
198
|
+
k = Math.min(1, Math.max(0, k / (b[2] ?? 1)));
|
|
199
|
+
const p = mixPose(full(a[1]), full(b[1]), smootherstep(k));
|
|
200
|
+
return extra ? extra(p, t) : p;
|
|
201
|
+
}
|
|
202
|
+
function sampleLayered(keys, dur, seconds, leadArm, lagHead, extra) {
|
|
203
|
+
const wrap = (v) => (v % dur + dur) % dur;
|
|
204
|
+
const t = wrap(seconds);
|
|
205
|
+
const body = sampleTimeline(keys, t, extra);
|
|
206
|
+
const arms = sampleTimeline(keys, wrap(t + leadArm), extra);
|
|
207
|
+
const head = sampleTimeline(keys, wrap(t - lagHead), extra);
|
|
208
|
+
return {
|
|
209
|
+
...body,
|
|
210
|
+
l: arms.l,
|
|
211
|
+
r: arms.r,
|
|
212
|
+
headYaw: head.headYaw,
|
|
213
|
+
headPitch: head.headPitch,
|
|
214
|
+
headRoll: head.headRoll
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function build18Joints(p) {
|
|
218
|
+
const P = [p.px, 1 - p.drop, p.pz];
|
|
219
|
+
const R = (v) => rot(v, p.yaw, p.lean, p.roll);
|
|
220
|
+
const Rh = (v) => rot(v, p.yaw + p.headYaw, p.lean + p.headPitch, p.roll + p.headRoll);
|
|
221
|
+
const spine = add(P, R([0, 0.25, 0]));
|
|
222
|
+
const neck = add(P, R([0, 0.5, 0]));
|
|
223
|
+
const head = add(neck, Rh([0, 0.16, 0]));
|
|
224
|
+
const J = { pelvis: P, spine, neck, head };
|
|
225
|
+
for (const [sd, sg] of [
|
|
226
|
+
["l", 1],
|
|
227
|
+
["r", -1]
|
|
228
|
+
]) {
|
|
229
|
+
const a = p[sd];
|
|
230
|
+
const side = (v) => [v[0] * sg, v[1], v[2]];
|
|
231
|
+
const sh = add(P, R([sg * SHX, 0.45, 0]));
|
|
232
|
+
const el = add(sh, R(norm(side(a.u))), UA);
|
|
233
|
+
const wr = add(el, R(norm(side(a.l))), LA);
|
|
234
|
+
J[`shoulder_${sd}`] = sh;
|
|
235
|
+
J[`elbow_${sd}`] = el;
|
|
236
|
+
J[`wrist_${sd}`] = wr;
|
|
237
|
+
const hip = add(P, R([sg * HIPX, 0, 0]));
|
|
238
|
+
const f = p[`f${sd}`];
|
|
239
|
+
const an = [sg * (HIPX + f[0]), 0.08 + f[2], f[1]];
|
|
240
|
+
const d = add(an, hip, -1);
|
|
241
|
+
const dl = Math.min(Math.hypot(d[0], d[1], d[2]), TH + SH - 0.001);
|
|
242
|
+
const u = norm(d);
|
|
243
|
+
const x = (TH * TH - SH * SH + dl * dl) / (2 * Math.max(0.0001, dl));
|
|
244
|
+
const h = Math.sqrt(Math.max(0, TH * TH - x * x));
|
|
245
|
+
let pole = norm(add(R([0, 0, 0.35]), [Math.sin(f[3]), 0, Math.cos(f[3])]));
|
|
246
|
+
const dot = pole[0] * u[0] + pole[1] * u[1] + pole[2] * u[2];
|
|
247
|
+
pole = norm(add(pole, u, -dot));
|
|
248
|
+
const kn = add(add(hip, u, x), pole, h);
|
|
249
|
+
const toeY = -0.06 + Math.sin(f[4]) * 0.12;
|
|
250
|
+
const toeFwd = Math.cos(f[4]) * 0.13;
|
|
251
|
+
const toe = add(an, [Math.sin(f[3]) * toeFwd, toeY, Math.cos(f[3]) * toeFwd]);
|
|
252
|
+
J[`hip_${sd}`] = hip;
|
|
253
|
+
J[`knee_${sd}`] = kn;
|
|
254
|
+
J[`ankle_${sd}`] = an;
|
|
255
|
+
J[`toe_${sd}`] = toe;
|
|
256
|
+
}
|
|
257
|
+
const frame = {};
|
|
258
|
+
for (const key of Object.keys(J)) {
|
|
259
|
+
const v = J[key];
|
|
260
|
+
frame[key] = new Vector3(v[0], v[1], v[2]);
|
|
261
|
+
}
|
|
262
|
+
return frame;
|
|
263
|
+
}
|
|
264
|
+
var B_BR = 0.43;
|
|
265
|
+
var ST_BR = 0.22;
|
|
266
|
+
var brCrossR = {
|
|
267
|
+
r: { u: [0.35, -0.3, 0.9], l: [-0.95, 0.32, 0.12] },
|
|
268
|
+
l: { u: [0.3, -0.95, -0.1], l: [0.15, -0.75, 0.6] },
|
|
269
|
+
yaw: 0.26,
|
|
270
|
+
px: 0.06,
|
|
271
|
+
drop: 0.18,
|
|
272
|
+
headYaw: -0.14,
|
|
273
|
+
headRoll: 0.08,
|
|
274
|
+
fl: [ST_BR, 0.02, 0, 0.45, 0],
|
|
275
|
+
fr: [ST_BR - 0.08, 0.14, 0.08, 0.6, -0.25]
|
|
276
|
+
};
|
|
277
|
+
var brCrossL = {
|
|
278
|
+
...brCrossR,
|
|
279
|
+
l: brCrossR.r,
|
|
280
|
+
r: brCrossR.l,
|
|
281
|
+
yaw: -0.26,
|
|
282
|
+
px: -0.06,
|
|
283
|
+
headYaw: 0.14,
|
|
284
|
+
headRoll: -0.08,
|
|
285
|
+
fr: [ST_BR, 0.02, 0, -0.45, 0],
|
|
286
|
+
fl: [ST_BR - 0.08, 0.14, 0.08, -0.6, -0.25]
|
|
287
|
+
};
|
|
288
|
+
var brSpread = {
|
|
289
|
+
l: { u: [0.95, 0.15, 0.1], l: [0.3, -0.95, 0.2] },
|
|
290
|
+
r: { u: [0.95, 0.15, 0.1], l: [0.3, -0.95, 0.2] },
|
|
291
|
+
lean: -0.08,
|
|
292
|
+
drop: 0.12,
|
|
293
|
+
headPitch: -0.08,
|
|
294
|
+
fl: [ST_BR + 0.12, 0, 0, 0.6, 0],
|
|
295
|
+
fr: [ST_BR + 0.12, 0, 0, -0.6, 0]
|
|
296
|
+
};
|
|
297
|
+
var brFists = {
|
|
298
|
+
l: { u: [0.4, -0.6, 0.7], l: [-0.85, -0.2, 0.45] },
|
|
299
|
+
r: { u: [0.4, -0.6, 0.7], l: [-0.85, -0.2, 0.45] },
|
|
300
|
+
lean: 0.28,
|
|
301
|
+
drop: 0.36,
|
|
302
|
+
headPitch: -0.14,
|
|
303
|
+
fl: [ST_BR + 0.12, 0.04, 0, 0.8, 0],
|
|
304
|
+
fr: [ST_BR + 0.12, 0.04, 0, -0.8, 0]
|
|
305
|
+
};
|
|
306
|
+
var brMouth = {
|
|
307
|
+
r: { u: [0.25, -0.15, 0.95], l: [-0.35, 0.92, 0.25] },
|
|
308
|
+
l: { u: [0.3, -0.95, -0.05], l: [0.1, -0.9, 0.4] },
|
|
309
|
+
lean: -0.12,
|
|
310
|
+
roll: -0.06,
|
|
311
|
+
drop: 0.16,
|
|
312
|
+
headYaw: 0.14,
|
|
313
|
+
headPitch: -0.1,
|
|
314
|
+
fl: [ST_BR - 0.05, 0.1, 0.06, -0.4, -0.2],
|
|
315
|
+
fr: [ST_BR, 0, 0, -0.45, 0]
|
|
316
|
+
};
|
|
317
|
+
var BR_SEQ = [
|
|
318
|
+
brCrossR,
|
|
319
|
+
brCrossL,
|
|
320
|
+
brCrossR,
|
|
321
|
+
brCrossL,
|
|
322
|
+
brSpread,
|
|
323
|
+
brFists,
|
|
324
|
+
{ ...brFists, drop: 0.3, lean: 0.24 },
|
|
325
|
+
brMouth
|
|
326
|
+
];
|
|
327
|
+
var BRAZIL_KEYS = [
|
|
328
|
+
[0, BR_SEQ[0], 1],
|
|
329
|
+
...BR_SEQ.slice(1).map((p, i) => [(i + 1) * B_BR, p, 0.3]),
|
|
330
|
+
[8 * B_BR, BR_SEQ[0], 0.3]
|
|
331
|
+
];
|
|
332
|
+
function brazilExtra(p, t) {
|
|
333
|
+
const beat = t / B_BR;
|
|
334
|
+
const ph = beat % 1;
|
|
335
|
+
const n = Math.floor(beat) % 8;
|
|
336
|
+
const out = { ...p, fl: [...p.fl], fr: [...p.fr] };
|
|
337
|
+
out.drop += 0.07 * Math.exp(-ph * 4) * Math.min(1, ph * 12) - 0.02 * Math.sin(ph * Math.PI);
|
|
338
|
+
out.px += 0.025 * Math.sin(beat * Math.PI);
|
|
339
|
+
if (n === 4) {
|
|
340
|
+
const h = Math.sin(Math.min(1, ph / 0.55) * Math.PI);
|
|
341
|
+
out.drop -= 0.22 * h;
|
|
342
|
+
out.fl[2] += 0.14 * h;
|
|
343
|
+
out.fr[2] += 0.14 * h;
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
var B_PJ = 0.45;
|
|
348
|
+
var ST_PJ = 0.2;
|
|
349
|
+
var pjRoll1 = {
|
|
350
|
+
drop: 0.16,
|
|
351
|
+
px: -0.05,
|
|
352
|
+
yaw: 0.14,
|
|
353
|
+
lean: 0.08,
|
|
354
|
+
roll: -0.05,
|
|
355
|
+
headYaw: -0.1,
|
|
356
|
+
headPitch: 0.04,
|
|
357
|
+
r: { u: [0.32, -0.38, 0.86], l: [-0.85, 0.42, 0.3] },
|
|
358
|
+
l: { u: [0.32, -0.62, 0.7], l: [-0.85, -0.25, 0.45] },
|
|
359
|
+
fl: [ST_PJ, 0.08, 0, 0.25, 0],
|
|
360
|
+
fr: [ST_PJ, -0.06, 0, -0.25, 0]
|
|
361
|
+
};
|
|
362
|
+
var pjRoll2 = {
|
|
363
|
+
...pjRoll1,
|
|
364
|
+
px: 0.05,
|
|
365
|
+
yaw: -0.14,
|
|
366
|
+
roll: 0.05,
|
|
367
|
+
headYaw: 0.1,
|
|
368
|
+
r: { u: [0.32, -0.62, 0.7], l: [-0.85, -0.25, 0.45] },
|
|
369
|
+
l: { u: [0.32, -0.38, 0.86], l: [-0.85, 0.42, 0.3] }
|
|
370
|
+
};
|
|
371
|
+
var pjSweepRIn = {
|
|
372
|
+
drop: 0.22,
|
|
373
|
+
px: 0.08,
|
|
374
|
+
yaw: 0.34,
|
|
375
|
+
lean: 0.1,
|
|
376
|
+
roll: -0.08,
|
|
377
|
+
headYaw: -0.26,
|
|
378
|
+
r: { u: [0.22, -0.22, 0.94], l: [-0.96, 0.24, 0.16] },
|
|
379
|
+
l: { u: [0.62, -0.68, -0.18], l: [-0.45, -0.2, 0.85] },
|
|
380
|
+
fl: [ST_PJ + 0.04, 0.1, 0, 0.32, 0],
|
|
381
|
+
fr: [ST_PJ, -0.06, 0, -0.3, 0]
|
|
382
|
+
};
|
|
383
|
+
var pjSweepROut = {
|
|
384
|
+
drop: 0.14,
|
|
385
|
+
px: -0.06,
|
|
386
|
+
yaw: -0.24,
|
|
387
|
+
lean: 0.04,
|
|
388
|
+
roll: 0.06,
|
|
389
|
+
headYaw: 0.18,
|
|
390
|
+
headPitch: -0.06,
|
|
391
|
+
r: { u: [0.92, 0.12, 0.36], l: [0.82, 0.06, 0.56] },
|
|
392
|
+
l: { u: [0.45, -0.55, 0.55], l: [-0.85, 0.12, 0.5] },
|
|
393
|
+
fl: [ST_PJ, 0.06, 0, 0.28, 0],
|
|
394
|
+
fr: [ST_PJ + 0.05, -0.04, 0, -0.32, 0]
|
|
395
|
+
};
|
|
396
|
+
var pjSweepLIn = {
|
|
397
|
+
...pjSweepRIn,
|
|
398
|
+
px: -0.08,
|
|
399
|
+
yaw: -0.34,
|
|
400
|
+
roll: 0.08,
|
|
401
|
+
headYaw: 0.26,
|
|
402
|
+
l: pjSweepRIn.r,
|
|
403
|
+
r: pjSweepRIn.l,
|
|
404
|
+
fr: [ST_PJ + 0.04, 0.1, 0, -0.32, 0],
|
|
405
|
+
fl: [ST_PJ, -0.06, 0, 0.3, 0]
|
|
406
|
+
};
|
|
407
|
+
var pjSweepLOut = {
|
|
408
|
+
...pjSweepROut,
|
|
409
|
+
px: 0.06,
|
|
410
|
+
yaw: 0.24,
|
|
411
|
+
roll: -0.06,
|
|
412
|
+
headYaw: -0.18,
|
|
413
|
+
l: pjSweepROut.r,
|
|
414
|
+
r: pjSweepROut.l,
|
|
415
|
+
fr: [ST_PJ, 0.06, 0, -0.28, 0],
|
|
416
|
+
fl: [ST_PJ + 0.05, -0.04, 0, 0.32, 0]
|
|
417
|
+
};
|
|
418
|
+
var pjPushR = {
|
|
419
|
+
drop: 0.2,
|
|
420
|
+
px: -0.06,
|
|
421
|
+
yaw: 0.28,
|
|
422
|
+
lean: 0.12,
|
|
423
|
+
roll: -0.06,
|
|
424
|
+
headYaw: -0.2,
|
|
425
|
+
r: { u: [0.42, 0.08, 0.9], l: [0.12, 0.15, 0.98] },
|
|
426
|
+
l: { u: [0.75, -0.25, -0.45], l: [-0.45, 0.35, 0.82] },
|
|
427
|
+
fl: [ST_PJ + 0.04, 0.12, 0, 0.3, 0],
|
|
428
|
+
fr: [ST_PJ + 0.02, -0.08, 0, -0.3, 0]
|
|
429
|
+
};
|
|
430
|
+
var pjPushL = {
|
|
431
|
+
...pjPushR,
|
|
432
|
+
px: 0.06,
|
|
433
|
+
yaw: -0.28,
|
|
434
|
+
roll: 0.06,
|
|
435
|
+
headYaw: 0.2,
|
|
436
|
+
l: pjPushR.r,
|
|
437
|
+
r: pjPushR.l,
|
|
438
|
+
fr: [ST_PJ + 0.04, 0.12, 0, -0.3, 0],
|
|
439
|
+
fl: [ST_PJ + 0.02, -0.08, 0, 0.3, 0]
|
|
440
|
+
};
|
|
441
|
+
var PJ_SEQ = [
|
|
442
|
+
pjRoll1,
|
|
443
|
+
pjRoll2,
|
|
444
|
+
pjSweepRIn,
|
|
445
|
+
pjSweepROut,
|
|
446
|
+
pjSweepLIn,
|
|
447
|
+
pjSweepLOut,
|
|
448
|
+
pjPushR,
|
|
449
|
+
pjPushL
|
|
450
|
+
];
|
|
451
|
+
var PACU_KEYS = [
|
|
452
|
+
[0, PJ_SEQ[0], 1],
|
|
453
|
+
...PJ_SEQ.slice(1).map((p, i) => [(i + 1) * B_PJ, p, 0.72]),
|
|
454
|
+
[8 * B_PJ, PJ_SEQ[0], 0.72]
|
|
455
|
+
];
|
|
456
|
+
function pacuExtra(p, t) {
|
|
457
|
+
const out = { ...p };
|
|
458
|
+
const wave = Math.sin(t / B_PJ * Math.PI);
|
|
459
|
+
out.drop += 0.045 * (0.5 + 0.5 * wave);
|
|
460
|
+
out.roll += 0.035 * Math.sin(t / (B_PJ * 2) * Math.PI);
|
|
461
|
+
if (t < 2 * B_PJ) {
|
|
462
|
+
const a = t / B_PJ * Math.PI * 2 * 2;
|
|
463
|
+
out.r = { u: [0.32, -0.4 + 0.18 * Math.sin(a), 0.85], l: [-0.85, 0.22 * Math.cos(a), 0.45] };
|
|
464
|
+
out.l = { u: [0.32, -0.4 - 0.18 * Math.sin(a), 0.85], l: [-0.85, -0.22 * Math.cos(a), 0.45] };
|
|
465
|
+
}
|
|
466
|
+
return out;
|
|
467
|
+
}
|
|
468
|
+
var B_VL = 0.4;
|
|
469
|
+
var vlGlide1 = {
|
|
470
|
+
drop: 0.08,
|
|
471
|
+
px: -0.07,
|
|
472
|
+
yaw: 0.2,
|
|
473
|
+
lean: -0.04,
|
|
474
|
+
roll: -0.06,
|
|
475
|
+
headYaw: -0.14,
|
|
476
|
+
r: { u: [0.55, -0.5, 0.65], l: [-0.5, 0.3, 0.8] },
|
|
477
|
+
l: { u: [0.65, -0.65, 0.3], l: [0.2, -0.8, 0.55] },
|
|
478
|
+
fl: [0.16, 0.08, 0, 0.22, 0],
|
|
479
|
+
fr: [0.16, -0.06, 0, -0.2, 0]
|
|
480
|
+
};
|
|
481
|
+
var vlHit1 = {
|
|
482
|
+
drop: 0.28,
|
|
483
|
+
px: 0.09,
|
|
484
|
+
yaw: -0.28,
|
|
485
|
+
lean: 0.18,
|
|
486
|
+
roll: 0.12,
|
|
487
|
+
headYaw: 0.26,
|
|
488
|
+
headPitch: 0.14,
|
|
489
|
+
headRoll: -0.14,
|
|
490
|
+
r: { u: [0.22, -0.25, 0.94], l: [-0.92, 0.35, 0.18] },
|
|
491
|
+
l: { u: [0.22, -0.25, 0.94], l: [-0.92, 0.35, 0.18] },
|
|
492
|
+
fl: [0.22, 0.12, 0, 0.4, 0],
|
|
493
|
+
fr: [0.2, -0.04, 0, -0.35, 0]
|
|
494
|
+
};
|
|
495
|
+
var vlHit1Hold = {
|
|
496
|
+
...vlHit1,
|
|
497
|
+
drop: 0.24,
|
|
498
|
+
px: 0.11,
|
|
499
|
+
yaw: -0.32,
|
|
500
|
+
headYaw: 0.29
|
|
501
|
+
};
|
|
502
|
+
var vlGlide2 = {
|
|
503
|
+
drop: 0.06,
|
|
504
|
+
px: 0,
|
|
505
|
+
yaw: 0.06,
|
|
506
|
+
lean: 0,
|
|
507
|
+
roll: 0,
|
|
508
|
+
headYaw: -0.04,
|
|
509
|
+
r: { u: [0.4, -0.6, 0.65], l: [-0.4, -0.2, 0.88] },
|
|
510
|
+
l: { u: [0.4, -0.6, 0.65], l: [-0.4, -0.2, 0.88] },
|
|
511
|
+
fl: [0.15, 0, 0, 0.2, 0],
|
|
512
|
+
fr: [0.18, 0.1, 0.06, -0.2, -0.2]
|
|
513
|
+
};
|
|
514
|
+
var vlHit2 = {
|
|
515
|
+
drop: 0.14,
|
|
516
|
+
px: -0.1,
|
|
517
|
+
yaw: 0.34,
|
|
518
|
+
lean: -0.14,
|
|
519
|
+
roll: -0.14,
|
|
520
|
+
headYaw: -0.28,
|
|
521
|
+
headPitch: -0.12,
|
|
522
|
+
headRoll: 0.16,
|
|
523
|
+
l: { u: [0.72, 0.68, 0.18], l: [0.58, 0.8, 0.15] },
|
|
524
|
+
r: { u: [0.35, -0.25, 0.88], l: [-0.9, 0.45, 0.18] },
|
|
525
|
+
fl: [0.22, -0.08, 0, 0.35, 0],
|
|
526
|
+
fr: [0.22, 0.18, 0.04, -0.3, 0.35]
|
|
527
|
+
};
|
|
528
|
+
var vlHit2Hold = {
|
|
529
|
+
...vlHit2,
|
|
530
|
+
drop: 0.11,
|
|
531
|
+
px: -0.12,
|
|
532
|
+
yaw: 0.38
|
|
533
|
+
};
|
|
534
|
+
var vlHit3 = {
|
|
535
|
+
drop: 0.32,
|
|
536
|
+
px: 0.06,
|
|
537
|
+
yaw: -0.18,
|
|
538
|
+
lean: 0.22,
|
|
539
|
+
roll: 0.08,
|
|
540
|
+
headYaw: 0.18,
|
|
541
|
+
headPitch: 0.12,
|
|
542
|
+
r: { u: [0.82, -0.2, 0.5], l: [0.45, -0.82, 0.35] },
|
|
543
|
+
l: { u: [0.82, -0.2, 0.5], l: [0.45, -0.82, 0.35] },
|
|
544
|
+
fl: [0.24, 0.06, 0, 0.45, 0],
|
|
545
|
+
fr: [0.24, 0.06, 0, -0.45, 0]
|
|
546
|
+
};
|
|
547
|
+
var VELOCITY_KEYS = [
|
|
548
|
+
[0, vlGlide1, 1],
|
|
549
|
+
[1 * B_VL, vlHit1, 0.22],
|
|
550
|
+
[2 * B_VL, vlHit1Hold, 1],
|
|
551
|
+
[3 * B_VL, vlGlide2, 0.9],
|
|
552
|
+
[4 * B_VL, vlHit2, 0.22],
|
|
553
|
+
[5 * B_VL, vlHit2Hold, 1],
|
|
554
|
+
[6 * B_VL, vlHit3, 0.24],
|
|
555
|
+
[7 * B_VL, { ...vlHit3, drop: 0.26, lean: 0.16 }, 1],
|
|
556
|
+
[8 * B_VL, vlGlide1, 0.75]
|
|
557
|
+
];
|
|
558
|
+
var B_GR = 0.36;
|
|
559
|
+
var grSwingL = {
|
|
560
|
+
drop: 0.14,
|
|
561
|
+
px: -0.05,
|
|
562
|
+
yaw: 0.12,
|
|
563
|
+
lean: 0.22,
|
|
564
|
+
roll: -0.06,
|
|
565
|
+
headPitch: -0.12,
|
|
566
|
+
headYaw: -0.1,
|
|
567
|
+
l: { u: [0.24, -0.78, -0.58], l: [0.12, -0.52, -0.84] },
|
|
568
|
+
r: { u: [0.24, -0.78, -0.58], l: [0.12, -0.52, -0.84] },
|
|
569
|
+
fl: [0.12, 0.26, 0.03, 0.1, 0.58],
|
|
570
|
+
fr: [0.12, -0.12, 0, -0.12, 0]
|
|
571
|
+
};
|
|
572
|
+
var grSwingR = {
|
|
573
|
+
...grSwingL,
|
|
574
|
+
px: 0.05,
|
|
575
|
+
yaw: -0.12,
|
|
576
|
+
roll: 0.06,
|
|
577
|
+
headYaw: 0.1,
|
|
578
|
+
fr: [0.12, 0.26, 0.03, -0.1, 0.58],
|
|
579
|
+
fl: [0.12, -0.12, 0, 0.12, 0]
|
|
580
|
+
};
|
|
581
|
+
var grGogglesL = {
|
|
582
|
+
drop: 0.2,
|
|
583
|
+
px: -0.06,
|
|
584
|
+
yaw: 0.16,
|
|
585
|
+
lean: 0.16,
|
|
586
|
+
roll: -0.08,
|
|
587
|
+
headPitch: -0.04,
|
|
588
|
+
headYaw: -0.16,
|
|
589
|
+
l: { u: [0.46, -0.12, 0.88], l: [-0.36, 0.9, 0.22] },
|
|
590
|
+
r: { u: [0.46, -0.12, 0.88], l: [-0.36, 0.9, 0.22] },
|
|
591
|
+
fl: [0.14, 0.28, 0.04, 0.14, 0.62],
|
|
592
|
+
fr: [0.12, -0.1, 0, -0.14, 0]
|
|
593
|
+
};
|
|
594
|
+
var grGogglesR = {
|
|
595
|
+
...grGogglesL,
|
|
596
|
+
px: 0.06,
|
|
597
|
+
yaw: -0.16,
|
|
598
|
+
roll: 0.08,
|
|
599
|
+
headYaw: 0.16,
|
|
600
|
+
fr: [0.14, 0.28, 0.04, -0.14, 0.62],
|
|
601
|
+
fl: [0.12, -0.1, 0, 0.14, 0]
|
|
602
|
+
};
|
|
603
|
+
var GR_SEQ = [
|
|
604
|
+
grSwingL,
|
|
605
|
+
grSwingR,
|
|
606
|
+
grGogglesL,
|
|
607
|
+
grGogglesR,
|
|
608
|
+
grSwingL,
|
|
609
|
+
grSwingR,
|
|
610
|
+
grGogglesL,
|
|
611
|
+
grGogglesR
|
|
612
|
+
];
|
|
613
|
+
var GRIDDY_KEYS = [
|
|
614
|
+
[0, GR_SEQ[0], 1],
|
|
615
|
+
...GR_SEQ.slice(1).map((p, i) => [(i + 1) * B_GR, p, 0.58]),
|
|
616
|
+
[8 * B_GR, GR_SEQ[0], 0.58]
|
|
617
|
+
];
|
|
618
|
+
function griddyExtra(p, t) {
|
|
619
|
+
const ph = t / B_GR % 1;
|
|
620
|
+
const out = { ...p };
|
|
621
|
+
out.drop += 0.055 * Math.cos(ph * Math.PI * 2);
|
|
622
|
+
return out;
|
|
623
|
+
}
|
|
624
|
+
var B_FL = 0.3;
|
|
625
|
+
var ST_FL = 0.22;
|
|
626
|
+
var flFrontR = {
|
|
627
|
+
drop: 0.1,
|
|
628
|
+
px: 0.15,
|
|
629
|
+
yaw: -0.14,
|
|
630
|
+
lean: 0.05,
|
|
631
|
+
roll: -0.16,
|
|
632
|
+
headYaw: 0.12,
|
|
633
|
+
headRoll: 0.14,
|
|
634
|
+
l: { u: [-0.55, -0.78, 0.32], l: [-0.55, -0.78, 0.32] },
|
|
635
|
+
r: { u: [0.76, -0.62, 0.18], l: [0.76, -0.62, 0.18] },
|
|
636
|
+
fl: [ST_FL, 0, 0, 0.22, 0],
|
|
637
|
+
fr: [ST_FL, 0, 0, -0.22, 0]
|
|
638
|
+
};
|
|
639
|
+
var flBackL = {
|
|
640
|
+
drop: 0.08,
|
|
641
|
+
px: -0.15,
|
|
642
|
+
yaw: 0.14,
|
|
643
|
+
lean: 0.06,
|
|
644
|
+
roll: 0.16,
|
|
645
|
+
headYaw: -0.12,
|
|
646
|
+
headRoll: -0.14,
|
|
647
|
+
l: { u: [0.76, -0.62, -0.28], l: [0.76, -0.62, -0.28] },
|
|
648
|
+
r: { u: [-0.55, -0.78, -0.34], l: [-0.55, -0.78, -0.34] },
|
|
649
|
+
fl: [ST_FL, 0, 0, 0.22, 0],
|
|
650
|
+
fr: [ST_FL, 0, 0, -0.22, 0]
|
|
651
|
+
};
|
|
652
|
+
var flBackR = {
|
|
653
|
+
drop: 0.1,
|
|
654
|
+
px: 0.15,
|
|
655
|
+
yaw: -0.14,
|
|
656
|
+
lean: 0.06,
|
|
657
|
+
roll: -0.16,
|
|
658
|
+
headYaw: 0.12,
|
|
659
|
+
headRoll: 0.14,
|
|
660
|
+
l: { u: [-0.55, -0.78, -0.34], l: [-0.55, -0.78, -0.34] },
|
|
661
|
+
r: { u: [0.76, -0.62, -0.28], l: [0.76, -0.62, -0.28] },
|
|
662
|
+
fl: [ST_FL, 0, 0, 0.22, 0],
|
|
663
|
+
fr: [ST_FL, 0, 0, -0.22, 0]
|
|
664
|
+
};
|
|
665
|
+
var flFrontL = {
|
|
666
|
+
drop: 0.08,
|
|
667
|
+
px: -0.15,
|
|
668
|
+
yaw: 0.14,
|
|
669
|
+
lean: 0.05,
|
|
670
|
+
roll: 0.16,
|
|
671
|
+
headYaw: -0.12,
|
|
672
|
+
headRoll: -0.14,
|
|
673
|
+
l: { u: [0.76, -0.62, 0.18], l: [0.76, -0.62, 0.18] },
|
|
674
|
+
r: { u: [-0.55, -0.78, 0.32], l: [-0.55, -0.78, 0.32] },
|
|
675
|
+
fl: [ST_FL, 0, 0, 0.22, 0],
|
|
676
|
+
fr: [ST_FL, 0, 0, -0.22, 0]
|
|
677
|
+
};
|
|
678
|
+
var FL_SEQ = [flFrontR, flBackL, flBackR, flFrontL, flFrontR, flBackL, flBackR, flFrontL];
|
|
679
|
+
var FLOSS_KEYS = [
|
|
680
|
+
[0, FL_SEQ[0], 1],
|
|
681
|
+
...FL_SEQ.slice(1).map((p, i) => [(i + 1) * B_FL, p, 0.65]),
|
|
682
|
+
[8 * B_FL, FL_SEQ[0], 0.65]
|
|
683
|
+
];
|
|
684
|
+
var B_CM = 0.36;
|
|
685
|
+
var ST_CM = 0.16;
|
|
686
|
+
var cmLeft = {
|
|
687
|
+
drop: 0.16,
|
|
688
|
+
px: 0.14,
|
|
689
|
+
yaw: -0.14,
|
|
690
|
+
lean: 0.06,
|
|
691
|
+
roll: -0.18,
|
|
692
|
+
headYaw: 0.16,
|
|
693
|
+
headRoll: 0.22,
|
|
694
|
+
l: { u: [0.72, 0.66, 0.2], l: [-0.72, 0.66, 0.2] },
|
|
695
|
+
r: { u: [0.72, 0.66, 0.2], l: [-0.72, 0.66, 0.2] },
|
|
696
|
+
fl: [ST_CM, 0.02, 0, 0.2, 0],
|
|
697
|
+
fr: [ST_CM - 0.04, 0.1, 0.07, -0.3, -0.35]
|
|
698
|
+
};
|
|
699
|
+
var cmUp = {
|
|
700
|
+
drop: 0.02,
|
|
701
|
+
px: 0,
|
|
702
|
+
yaw: 0,
|
|
703
|
+
lean: -0.04,
|
|
704
|
+
roll: 0,
|
|
705
|
+
headPitch: -0.08,
|
|
706
|
+
l: { u: [0.66, 0.72, 0.2], l: [-0.45, 0.86, 0.22] },
|
|
707
|
+
r: { u: [0.66, 0.72, 0.2], l: [-0.45, 0.86, 0.22] },
|
|
708
|
+
fl: [ST_CM, 0, 0.04, 0.16, 0],
|
|
709
|
+
fr: [ST_CM, 0, 0.04, -0.16, 0]
|
|
710
|
+
};
|
|
711
|
+
var cmRight = {
|
|
712
|
+
...cmLeft,
|
|
713
|
+
px: -0.14,
|
|
714
|
+
yaw: 0.14,
|
|
715
|
+
roll: 0.18,
|
|
716
|
+
headYaw: -0.16,
|
|
717
|
+
headRoll: -0.22,
|
|
718
|
+
fr: [ST_CM, 0.02, 0, -0.2, 0],
|
|
719
|
+
fl: [ST_CM - 0.04, 0.1, 0.07, 0.3, -0.35]
|
|
720
|
+
};
|
|
721
|
+
var cmHop = {
|
|
722
|
+
drop: -0.14,
|
|
723
|
+
px: 0,
|
|
724
|
+
yaw: 0,
|
|
725
|
+
lean: -0.06,
|
|
726
|
+
roll: 0,
|
|
727
|
+
headPitch: -0.12,
|
|
728
|
+
l: { u: [0.55, 0.82, 0.18], l: [-0.3, 0.94, 0.18] },
|
|
729
|
+
r: { u: [0.55, 0.82, 0.18], l: [-0.3, 0.94, 0.18] },
|
|
730
|
+
fl: [ST_CM + 0.06, 0.06, 0.14, 0.25, -0.3],
|
|
731
|
+
fr: [ST_CM + 0.06, 0.06, 0.14, -0.25, -0.3]
|
|
732
|
+
};
|
|
733
|
+
var CM_SEQ = [cmLeft, cmUp, cmRight, cmUp, cmLeft, cmUp, cmRight, cmHop];
|
|
734
|
+
var CARAMEL_KEYS = [
|
|
735
|
+
[0, CM_SEQ[0], 1],
|
|
736
|
+
...CM_SEQ.slice(1).map((p, i) => [(i + 1) * B_CM, p, 0.68]),
|
|
737
|
+
[8 * B_CM, CM_SEQ[0], 0.68]
|
|
738
|
+
];
|
|
739
|
+
function caramelExtra(p, t) {
|
|
740
|
+
const flap = Math.sin(t / B_CM * Math.PI * 2) * 0.28;
|
|
741
|
+
return {
|
|
742
|
+
...p,
|
|
743
|
+
l: { u: p.l.u, l: [p.l.l[0] - flap * 0.6, p.l.l[1] + flap * 0.4, p.l.l[2]] },
|
|
744
|
+
r: { u: p.r.u, l: [p.r.l[0] - flap * 0.6, p.r.l[1] + flap * 0.4, p.r.l[2]] }
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
var DANCE_SPECS = {
|
|
748
|
+
"brazil-funk": {
|
|
749
|
+
keys: BRAZIL_KEYS,
|
|
750
|
+
dur: 8 * B_BR,
|
|
751
|
+
leadArm: 0.04,
|
|
752
|
+
lagHead: 0.05,
|
|
753
|
+
extra: brazilExtra
|
|
754
|
+
},
|
|
755
|
+
"pacu-jalur": {
|
|
756
|
+
keys: PACU_KEYS,
|
|
757
|
+
dur: 8 * B_PJ,
|
|
758
|
+
leadArm: 0.05,
|
|
759
|
+
lagHead: 0.07,
|
|
760
|
+
extra: pacuExtra
|
|
761
|
+
},
|
|
762
|
+
velocity: {
|
|
763
|
+
keys: VELOCITY_KEYS,
|
|
764
|
+
dur: 8 * B_VL,
|
|
765
|
+
leadArm: 0.025,
|
|
766
|
+
lagHead: 0.04
|
|
767
|
+
},
|
|
768
|
+
griddy: {
|
|
769
|
+
keys: GRIDDY_KEYS,
|
|
770
|
+
dur: 8 * B_GR,
|
|
771
|
+
leadArm: 0.035,
|
|
772
|
+
lagHead: 0.05,
|
|
773
|
+
extra: griddyExtra
|
|
774
|
+
},
|
|
775
|
+
floss: {
|
|
776
|
+
keys: FLOSS_KEYS,
|
|
777
|
+
dur: 8 * B_FL,
|
|
778
|
+
leadArm: 0.02,
|
|
779
|
+
lagHead: 0.04
|
|
780
|
+
},
|
|
781
|
+
caramel: {
|
|
782
|
+
keys: CARAMEL_KEYS,
|
|
783
|
+
dur: 8 * B_CM,
|
|
784
|
+
leadArm: 0.04,
|
|
785
|
+
lagHead: 0.06,
|
|
786
|
+
extra: caramelExtra
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
function sampleIkDance(name, seconds) {
|
|
790
|
+
const spec = DANCE_SPECS[name];
|
|
791
|
+
const pose = sampleLayered(spec.keys, spec.dur, seconds, spec.leadArm, spec.lagHead, spec.extra);
|
|
792
|
+
return build18Joints(pose);
|
|
793
|
+
}
|
|
794
|
+
|
|
96
795
|
// src/hair3d.ts
|
|
97
796
|
import {
|
|
98
797
|
BoxGeometry,
|
|
@@ -101,7 +800,7 @@ import {
|
|
|
101
800
|
CatmullRomCurve3,
|
|
102
801
|
SphereGeometry as SphereGeometry2,
|
|
103
802
|
TorusGeometry as TorusGeometry2,
|
|
104
|
-
Vector3
|
|
803
|
+
Vector3 as Vector32
|
|
105
804
|
} from "three";
|
|
106
805
|
|
|
107
806
|
// src/wear3d.ts
|
|
@@ -180,8 +879,10 @@ class Spring {
|
|
|
180
879
|
}
|
|
181
880
|
}
|
|
182
881
|
var calm = (motion) => ({
|
|
183
|
-
lift: clamp(motion.lift, -
|
|
184
|
-
yaw: clamp(motion.yaw, -
|
|
882
|
+
lift: clamp(motion.lift, -6, 6),
|
|
883
|
+
yaw: clamp(motion.yaw, -10, 10),
|
|
884
|
+
swayX: clamp(motion.swayX ?? 0, -6, 6),
|
|
885
|
+
swayZ: clamp(motion.swayZ ?? 0, -6, 6)
|
|
185
886
|
});
|
|
186
887
|
function canvasTexture(size, draw) {
|
|
187
888
|
const canvas = document.createElement("canvas");
|
|
@@ -465,7 +1166,7 @@ function piece(kit, build) {
|
|
|
465
1166
|
};
|
|
466
1167
|
}
|
|
467
1168
|
function bunnyEars(kit) {
|
|
468
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1169
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
469
1170
|
const length = 0.46;
|
|
470
1171
|
const leaf = [
|
|
471
1172
|
[0, 0],
|
|
@@ -499,15 +1200,15 @@ function bunnyEars(kit) {
|
|
|
499
1200
|
for (let i = 0;i < innerPosition.count; i += 1)
|
|
500
1201
|
innerPosition.setZ(i, innerPosition.getZ(i) * 0.14 + 0.012);
|
|
501
1202
|
inner.computeVertexNormals();
|
|
502
|
-
|
|
503
|
-
|
|
1203
|
+
add2(outer, "#fbf8ff", { parent: root });
|
|
1204
|
+
add2(inner, "#ffffff", { parent: root }, { map: skin, outline: false });
|
|
504
1205
|
const tuft = new SphereGeometry(0.05, 14, 10);
|
|
505
1206
|
for (const [x, y, z] of [
|
|
506
1207
|
[-0.03, 0.01, 0.01],
|
|
507
1208
|
[0.03, 0, 0],
|
|
508
1209
|
[0, 0.03, 0.02]
|
|
509
1210
|
])
|
|
510
|
-
|
|
1211
|
+
add2(tuft, "#fbf8ff", { at: [x, y, z], parent: root }, { outline: false });
|
|
511
1212
|
const rest = side === 1 ? 0.95 : 0.16;
|
|
512
1213
|
return {
|
|
513
1214
|
side,
|
|
@@ -524,8 +1225,8 @@ function bunnyEars(kit) {
|
|
|
524
1225
|
for (const ear of ears) {
|
|
525
1226
|
if (twitch < 0 && ear.side === -1)
|
|
526
1227
|
ear.pitch.kick(-5);
|
|
527
|
-
const pitch = ear.pitch.step(ear.rest - motion.lift * 0.
|
|
528
|
-
const roll = ear.roll.step(motion.yaw * 0.
|
|
1228
|
+
const pitch = ear.pitch.step(ear.rest - motion.lift * 0.42 - motion.swayZ * 0.25, delta);
|
|
1229
|
+
const roll = ear.roll.step(motion.yaw * 0.08 * ear.side - motion.swayX * 0.35 + Math.sin(clock * 1.7 + ear.side) * 0.04, delta);
|
|
529
1230
|
for (const bend of ear.bends)
|
|
530
1231
|
bend(pitch, roll, ear.side === 1 ? 0.42 : 0);
|
|
531
1232
|
}
|
|
@@ -535,7 +1236,7 @@ function bunnyEars(kit) {
|
|
|
535
1236
|
});
|
|
536
1237
|
}
|
|
537
1238
|
function catEars(kit) {
|
|
538
|
-
return piece(kit, ({ add, node }) => {
|
|
1239
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
539
1240
|
const ear = new Shape;
|
|
540
1241
|
ear.moveTo(-0.12, 0);
|
|
541
1242
|
ear.quadraticCurveTo(-0.1, 0.12, -0.02, 0.22);
|
|
@@ -556,14 +1257,14 @@ function catEars(kit) {
|
|
|
556
1257
|
at: [side * 0.19, TOP - 0.1, 0],
|
|
557
1258
|
rotate: [-0.15, side * -0.25, side * -0.32]
|
|
558
1259
|
});
|
|
559
|
-
|
|
560
|
-
|
|
1260
|
+
add2(outerGeometry, "#2a2440", { at: [0, 0.1, 0], parent: root });
|
|
1261
|
+
add2(innerGeometry, "#ff9cc2", { at: [0, 0.085, 0.03], parent: root }, { outline: false });
|
|
561
1262
|
for (const [x, r] of [
|
|
562
1263
|
[-0.02, 0.3],
|
|
563
1264
|
[0, 0],
|
|
564
1265
|
[0.02, -0.3]
|
|
565
1266
|
])
|
|
566
|
-
|
|
1267
|
+
add2(tuft, "#fbf8ff", { at: [x, 0.05, 0.04], rotate: [0.2, 0, r], parent: root }, { outline: false });
|
|
567
1268
|
return { root, side, spring: new Spring(160, 10) };
|
|
568
1269
|
});
|
|
569
1270
|
let next = 2;
|
|
@@ -573,9 +1274,9 @@ function catEars(kit) {
|
|
|
573
1274
|
for (const ear2 of ears) {
|
|
574
1275
|
if (next < 0 && (ear2.side === 1 || Math.random() < 0.4))
|
|
575
1276
|
ear2.spring.kick(9);
|
|
576
|
-
const flick = ear2.spring.step(-motion.lift * 0.08, delta);
|
|
577
|
-
ear2.root.rotation.z = ear2.side * -0.32 + ear2.side * flick * 0.
|
|
578
|
-
ear2.root.rotation.x = -0.15 - Math.abs(flick) * 0.
|
|
1277
|
+
const flick = ear2.spring.step(-motion.lift * 0.12 - motion.swayX * 0.08 * ear2.side, delta);
|
|
1278
|
+
ear2.root.rotation.z = ear2.side * -0.32 + ear2.side * flick * 0.65;
|
|
1279
|
+
ear2.root.rotation.x = -0.15 - Math.abs(flick) * 0.45;
|
|
579
1280
|
}
|
|
580
1281
|
if (next < 0)
|
|
581
1282
|
next = 2 + Math.random() * 4;
|
|
@@ -583,7 +1284,7 @@ function catEars(kit) {
|
|
|
583
1284
|
});
|
|
584
1285
|
}
|
|
585
1286
|
function topHat(kit) {
|
|
586
|
-
return piece(kit, ({ add, node }) => {
|
|
1287
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
587
1288
|
const hat = node({ at: [0.04, TOP - 0.04, -0.01], rotate: [-0.08, 0.2, -0.16] });
|
|
588
1289
|
const brim = lathe([
|
|
589
1290
|
[0.18, 0.012],
|
|
@@ -604,8 +1305,8 @@ function topHat(kit) {
|
|
|
604
1305
|
position.setY(i, position.getY(i) + lift);
|
|
605
1306
|
}
|
|
606
1307
|
brim.computeVertexNormals();
|
|
607
|
-
|
|
608
|
-
|
|
1308
|
+
add2(brim, "#1b1830", { parent: hat }, { sheen: 0.25, double: true });
|
|
1309
|
+
add2(lathe([
|
|
609
1310
|
[0, 0.4],
|
|
610
1311
|
[0.2, 0.4],
|
|
611
1312
|
[0.215, 0.385],
|
|
@@ -614,7 +1315,7 @@ function topHat(kit) {
|
|
|
614
1315
|
[0.195, 0.03],
|
|
615
1316
|
[0, 0.03]
|
|
616
1317
|
]), "#1b1830", { parent: hat }, { sheen: 0.25, double: true });
|
|
617
|
-
|
|
1318
|
+
add2(lathe([
|
|
618
1319
|
[0.2, 0.05],
|
|
619
1320
|
[0.206, 0.05],
|
|
620
1321
|
[0.208, 0.12],
|
|
@@ -622,12 +1323,12 @@ function topHat(kit) {
|
|
|
622
1323
|
]), "#c8323c", { parent: hat }, { sheen: 0.5, outline: false, double: true });
|
|
623
1324
|
const buckle = rounded(0.07, 0.06, 0.012);
|
|
624
1325
|
buckle.holes.push(rounded(0.04, 0.032, 0.006));
|
|
625
|
-
|
|
1326
|
+
add2(slab(buckle, 0.008, 0.004), "#f2c94c", { at: [0, 0.085, 0.21], parent: hat }, { sheen: 0.8, outline: false });
|
|
626
1327
|
return;
|
|
627
1328
|
});
|
|
628
1329
|
}
|
|
629
1330
|
function crown(kit) {
|
|
630
|
-
return piece(kit, ({ add, node }) => {
|
|
1331
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
631
1332
|
const root = node({ at: [0, TOP - 0.07, 0], rotate: [-0.08, 0, 0.08] });
|
|
632
1333
|
const radius = 0.225;
|
|
633
1334
|
const width = Math.PI * 2 * radius;
|
|
@@ -659,8 +1360,8 @@ function crown(kit) {
|
|
|
659
1360
|
position.setXYZ(i, Math.sin(angle) * r, position.getY(i), Math.cos(angle) * r);
|
|
660
1361
|
}
|
|
661
1362
|
band.computeVertexNormals();
|
|
662
|
-
|
|
663
|
-
|
|
1363
|
+
add2(band, "#f2c94c", { parent: root }, { sheen: 0.85, double: true });
|
|
1364
|
+
add2(new SphereGeometry(radius - 0.01, 24, 12, 0, Math.PI * 2, 0, Math.PI / 2), "#a3173a", {
|
|
664
1365
|
at: [0, 0.02, 0],
|
|
665
1366
|
scale: [1, 0.55, 1],
|
|
666
1367
|
parent: root
|
|
@@ -670,29 +1371,29 @@ function crown(kit) {
|
|
|
670
1371
|
const colors = ["#e2574c", "#4cc9e2", "#3d8b5a"];
|
|
671
1372
|
for (let i = 0;i < points; i += 1) {
|
|
672
1373
|
const tip = (i + 0.5) / points * Math.PI * 2;
|
|
673
|
-
|
|
1374
|
+
add2(pearl, "#fff8e8", {
|
|
674
1375
|
at: [Math.sin(tip) * (radius + 0.01), 0.215, Math.cos(tip) * (radius + 0.01)],
|
|
675
1376
|
parent: root
|
|
676
1377
|
}, { sheen: 0.7, outline: false });
|
|
677
|
-
|
|
1378
|
+
add2(stone, colors[i % colors.length] ?? "#e2574c", {
|
|
678
1379
|
at: [Math.sin(tip) * (radius + 0.026), 0.045, Math.cos(tip) * (radius + 0.026)],
|
|
679
1380
|
rotate: [0, tip, 0],
|
|
680
1381
|
scale: [1, 1, 0.55],
|
|
681
1382
|
parent: root
|
|
682
1383
|
}, { sheen: 0.9, outline: false });
|
|
683
1384
|
}
|
|
684
|
-
|
|
1385
|
+
add2(new SphereGeometry(0.035, 12, 10), "#f2c94c", { at: [0, 0.14, 0], parent: root }, {
|
|
685
1386
|
sheen: 0.85
|
|
686
1387
|
});
|
|
687
|
-
|
|
1388
|
+
add2(new OctahedronGeometry(0.03), "#f2c94c", { at: [0, 0.19, 0], scale: [0.6, 1, 0.6], parent: root }, { sheen: 0.85 });
|
|
688
1389
|
return;
|
|
689
1390
|
});
|
|
690
1391
|
}
|
|
691
1392
|
function partyHat(kit) {
|
|
692
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1393
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
693
1394
|
const hat = node({ at: [-0.08, TOP - 0.05, 0.03], rotate: [0.05, 0, 0.24] });
|
|
694
|
-
|
|
695
|
-
|
|
1395
|
+
add2(new ConeGeometry(0.17, 0.42, 40, 1, true), "#ffffff", { at: [0, 0.21, 0], parent: hat }, { map: keep(candy("#ff5fa2", "#ffd84d")), repeat: [3, 1], double: true });
|
|
1396
|
+
add2(new TorusGeometry(0.168, 0.022, 10, 40), "#4cc9e2", { at: [0, 0.012, 0], rotate: [Math.PI / 2, 0, 0], parent: hat }, { outline: false });
|
|
696
1397
|
const puff = new SphereGeometry(0.038, 12, 10);
|
|
697
1398
|
const top = node({ at: [0, 0.43, 0], parent: hat });
|
|
698
1399
|
for (const [x, y, z, color] of [
|
|
@@ -703,7 +1404,7 @@ function partyHat(kit) {
|
|
|
703
1404
|
[0.01, 0.02, 0.03, "#fbf8ff"],
|
|
704
1405
|
[-0.02, -0.01, 0.025, "#ffd84d"]
|
|
705
1406
|
])
|
|
706
|
-
|
|
1407
|
+
add2(puff, color, { at: [x, y, z], parent: top }, { outline: false });
|
|
707
1408
|
const sway = new Spring(80, 6);
|
|
708
1409
|
return (clock, delta, raw) => {
|
|
709
1410
|
const motion = calm(raw);
|
|
@@ -714,13 +1415,13 @@ function partyHat(kit) {
|
|
|
714
1415
|
});
|
|
715
1416
|
}
|
|
716
1417
|
function halo(kit) {
|
|
717
|
-
return piece(kit, ({ add, glow, node }) => {
|
|
1418
|
+
return piece(kit, ({ add: add2, glow, node }) => {
|
|
718
1419
|
const ring = node({ at: [0, TOP + 0.17, -0.02], rotate: [Math.PI / 2 - 0.2, 0, 0] });
|
|
719
|
-
|
|
1420
|
+
add2(new TorusGeometry(0.22, 0.03, 14, 56), "#ffe680", { parent: ring }, { sheen: 0.8 });
|
|
720
1421
|
glow(new TorusGeometry(0.22, 0.075, 12, 56), "#fff2a8", 0.28, { parent: ring });
|
|
721
1422
|
glow(new TorusGeometry(0.22, 0.13, 10, 56), "#ffe680", 0.1, { parent: ring });
|
|
722
1423
|
const spark = new OctahedronGeometry(0.022);
|
|
723
|
-
const sparks = [0, 1, 2, 3].map(() =>
|
|
1424
|
+
const sparks = [0, 1, 2, 3].map(() => add2(spark, "#fffbe0", { parent: ring }, { outline: false, sheen: 1 }));
|
|
724
1425
|
return (clock) => {
|
|
725
1426
|
ring.position.y = TOP + 0.17 + Math.sin(clock * 2) * 0.022;
|
|
726
1427
|
ring.rotation.z = clock * 0.5;
|
|
@@ -734,7 +1435,7 @@ function halo(kit) {
|
|
|
734
1435
|
});
|
|
735
1436
|
}
|
|
736
1437
|
function bow(kit) {
|
|
737
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1438
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
738
1439
|
const root = node({ at: [0.19, TOP - 0.06, 0.06], rotate: [0.25, 0.35, -0.42] });
|
|
739
1440
|
const ribbon = keep(dots("#ff5fa2", "#ffffff"));
|
|
740
1441
|
const loop = new Shape;
|
|
@@ -743,12 +1444,12 @@ function bow(kit) {
|
|
|
743
1444
|
loop.bezierCurveTo(0.17, -0.08, 0.05, -0.08, 0, 0);
|
|
744
1445
|
const loopGeometry = slab(loop, 0.04, 0.02);
|
|
745
1446
|
for (const side of [-1, 1])
|
|
746
|
-
|
|
1447
|
+
add2(loopGeometry, "#ffffff", {
|
|
747
1448
|
at: [side * 0.085, 0.01, 0],
|
|
748
1449
|
rotate: [0, side === 1 ? 0 : Math.PI, side * 0.05],
|
|
749
1450
|
parent: root
|
|
750
1451
|
}, { map: ribbon, repeat: [9, 9], sheen: 0.35 });
|
|
751
|
-
|
|
1452
|
+
add2(new SphereGeometry(0.045, 16, 12), "#ff4f95", { at: [0, 0.01, 0.015], scale: [1, 1.15, 0.8], parent: root }, { sheen: 0.4 });
|
|
752
1453
|
const tail = new Shape;
|
|
753
1454
|
tail.moveTo(-0.025, 0);
|
|
754
1455
|
tail.lineTo(0.025, 0);
|
|
@@ -759,14 +1460,14 @@ function bow(kit) {
|
|
|
759
1460
|
const tailGeometry = slab(tail, 0.012, 0.006);
|
|
760
1461
|
const tails = [-1, 1].map((side) => {
|
|
761
1462
|
const hang = node({ at: [side * 0.02, -0.02, 0.01], parent: root });
|
|
762
|
-
|
|
1463
|
+
add2(tailGeometry, "#ffffff", { at: [0, -0.07, 0], parent: hang }, { map: ribbon, repeat: [9, 9], sheen: 0.35 });
|
|
763
1464
|
return { hang, side, spring: new Spring(60, 5) };
|
|
764
1465
|
});
|
|
765
1466
|
return (clock, delta, raw) => {
|
|
766
1467
|
const motion = calm(raw);
|
|
767
1468
|
for (const t of tails) {
|
|
768
|
-
t.hang.rotation.z = t.spring.step(t.side * 0.35 - motion.yaw * 0.
|
|
769
|
-
t.hang.rotation.x = clamp(motion.lift * 0.
|
|
1469
|
+
t.hang.rotation.z = t.spring.step(t.side * 0.35 - motion.yaw * 0.06 - motion.swayX * 0.25 + Math.sin(clock * 1.6 + t.side) * 0.05, delta);
|
|
1470
|
+
t.hang.rotation.x = clamp(motion.lift * 0.12 - motion.swayZ * 0.15, -0.45, 0.45);
|
|
770
1471
|
}
|
|
771
1472
|
};
|
|
772
1473
|
});
|
|
@@ -846,57 +1547,69 @@ function aLineSkirtPatch(kit, bottom, top, flareOut, pleatCount, pleatAmp, rows
|
|
|
846
1547
|
function pleatedSkirt(kit) {
|
|
847
1548
|
const z = zonesOf(kit);
|
|
848
1549
|
const surf = surfaceOf(kit);
|
|
849
|
-
return piece(kit, ({ add, keep }) => {
|
|
1550
|
+
return piece(kit, ({ add: add2, keep }) => {
|
|
850
1551
|
const top = kit.isFigure ? z.waistY + 0.02 : 0.25;
|
|
851
1552
|
const bottom = kit.isFigure ? z.bottomY - 0.14 : 0.02;
|
|
852
|
-
const geometry = aLineSkirtPatch(kit, bottom, top, kit.isFigure ? 0.
|
|
1553
|
+
const geometry = aLineSkirtPatch(kit, bottom, top, kit.isFigure ? 0.15 : 0.09, 22, 0.026, 10, 88);
|
|
853
1554
|
const position = geometry.attributes.position;
|
|
854
1555
|
const rest = Float32Array.from(position.array);
|
|
855
|
-
|
|
1556
|
+
add2(geometry, "#ffffff", {}, {
|
|
856
1557
|
map: keep(tartan("#c8323c", "#1b1f5e", "#f2d24b")),
|
|
857
1558
|
repeat: [6, 1.4],
|
|
858
1559
|
double: true,
|
|
859
1560
|
back: "#7d1d2a"
|
|
860
1561
|
});
|
|
861
|
-
|
|
862
|
-
|
|
1562
|
+
add2(fittedPatch(kit, top - 0.032, top + 0.014, 0.028, (_y, t) => t * Math.PI * 2, 3, 48), "#1b1f5e", {}, { double: true, outline: false });
|
|
1563
|
+
const hemGeo = aLineSkirtPatch(kit, bottom, bottom + 0.028, kit.isFigure ? 0.154 : 0.094, 22, 0.026, 2, 88);
|
|
1564
|
+
const hemPos = hemGeo.attributes.position;
|
|
1565
|
+
const hemRest = Float32Array.from(hemPos.array);
|
|
1566
|
+
add2(hemGeo, "#fbf8ff", {}, { double: true, outline: false });
|
|
863
1567
|
const frontBtn = surf(top - 0.008, 0.18, 0.034);
|
|
864
|
-
|
|
865
|
-
const flare = new Spring(
|
|
866
|
-
const sway = new Spring(
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
const
|
|
874
|
-
const z0 = rest[i * 3 + 2] ?? 0;
|
|
1568
|
+
add2(new SphereGeometry(0.016, 10, 8), "#f2c94c", { at: [frontBtn.x, top - 0.008, frontBtn.z] }, { sheen: 0.8, outline: false });
|
|
1569
|
+
const flare = new Spring(75, 3.4);
|
|
1570
|
+
const sway = new Spring(60, 3.2);
|
|
1571
|
+
const shiftX = new Spring(65, 3.2);
|
|
1572
|
+
const shiftZ = new Spring(65, 3.4);
|
|
1573
|
+
const deform = (pAttr, base, geo, out, turn, lagX, lagZ, clock) => {
|
|
1574
|
+
for (let i = 0;i < pAttr.count; i += 1) {
|
|
1575
|
+
const x = base[i * 3] ?? 0;
|
|
1576
|
+
const y = base[i * 3 + 1] ?? 0;
|
|
1577
|
+
const z0 = base[i * 3 + 2] ?? 0;
|
|
875
1578
|
const low = clamp((top - y) / Math.max(0.05, top - bottom), 0, 1);
|
|
1579
|
+
const low2 = low * low;
|
|
876
1580
|
const angle = Math.atan2(x, z0);
|
|
877
|
-
const spread = 1 + out *
|
|
878
|
-
const lag = turn * low + Math.sin(clock * 2 + angle * 2) * 0.
|
|
1581
|
+
const spread = 1 + out * low2;
|
|
1582
|
+
const lag = turn * low + Math.sin(clock * 2.4 + angle * 2) * 0.008 * low;
|
|
879
1583
|
const r = Math.hypot(x, z0) * spread;
|
|
880
|
-
|
|
1584
|
+
pAttr.setXYZ(i, Math.sin(angle + lag) * r + lagX * low2, y + Math.abs(out) * 0.022 * low2, Math.cos(angle + lag) * r + lagZ * low2);
|
|
881
1585
|
}
|
|
882
|
-
|
|
883
|
-
|
|
1586
|
+
pAttr.needsUpdate = true;
|
|
1587
|
+
geo.computeVertexNormals();
|
|
1588
|
+
};
|
|
1589
|
+
return (clock, delta, raw) => {
|
|
1590
|
+
const motion = calm(raw);
|
|
1591
|
+
const out = flare.step(clamp(-motion.lift * 0.12 + Math.abs(motion.swayX) * 0.08, -0.05, 0.28), delta);
|
|
1592
|
+
const turn = sway.step(-motion.yaw * 0.08, delta);
|
|
1593
|
+
const lagX = shiftX.step(-motion.swayX * 0.08, delta);
|
|
1594
|
+
const lagZ = shiftZ.step(-motion.swayZ * 0.06, delta);
|
|
1595
|
+
deform(position, rest, geometry, out, turn, lagX, lagZ, clock);
|
|
1596
|
+
deform(hemPos, hemRest, hemGeo, out, turn, lagX, lagZ, clock);
|
|
884
1597
|
};
|
|
885
1598
|
});
|
|
886
1599
|
}
|
|
887
1600
|
function tuxedo(kit) {
|
|
888
1601
|
const z = zonesOf(kit);
|
|
889
1602
|
const surf = surfaceOf(kit);
|
|
890
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1603
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
891
1604
|
const bottom = kit.isFigure ? z.hipY - 0.04 : 0.03;
|
|
892
1605
|
const button = kit.isFigure ? z.waistY + 0.02 : 0.15;
|
|
893
1606
|
const collar = kit.isFigure ? z.shoulderY + 0.04 : 0.34;
|
|
894
1607
|
const bowY = kit.isFigure ? collar - 0.04 : COLLAR_Y;
|
|
895
1608
|
const open = (y) => y > button ? 0.14 + (y - button) / Math.max(0.05, collar - button) * 0.52 : 0.14 + (button - y) / Math.max(0.05, button - bottom) * 0.42;
|
|
896
|
-
|
|
897
|
-
|
|
1609
|
+
add2(fittedPatch(kit, bottom, collar, 0.026, (y, t) => open(y) + t * (Math.PI * 2 - 2 * open(y))), "#1b1830", {}, { double: true, back: "#3b2a6b", sheen: 0.15 });
|
|
1610
|
+
add2(fittedPatch(kit, bottom + 0.02, collar - 0.01, 0.014, (y, t) => (t * 2 - 1) * (open(y) + 0.04), 16, 16), "#ffffff", {}, { map: keep(pleats()), repeat: [3, 1], outline: false });
|
|
898
1611
|
for (const side of [-1, 1])
|
|
899
|
-
|
|
1612
|
+
add2(fittedPatch(kit, button + 0.005, collar, 0.032, (y, t) => side * (open(y) + t * (0.05 + (y - button) / Math.max(0.05, collar - button) * 0.16)), 10, 4), "#3b3560", {}, { sheen: 0.6, double: true });
|
|
900
1613
|
const frontZ = (y) => surf(y, 0, 0.028).z;
|
|
901
1614
|
const wing = new Shape;
|
|
902
1615
|
wing.moveTo(0, 0.01);
|
|
@@ -906,12 +1619,12 @@ function tuxedo(kit) {
|
|
|
906
1619
|
wing.closePath();
|
|
907
1620
|
const wingGeometry = slab(wing, 0.018, 0.007);
|
|
908
1621
|
for (const side of [-1, 1])
|
|
909
|
-
|
|
1622
|
+
add2(wingGeometry, "#14102e", {
|
|
910
1623
|
at: [side * 0.042, bowY, frontZ(bowY) + 0.008],
|
|
911
1624
|
rotate: [0, side === 1 ? 0 : Math.PI, side * -0.06]
|
|
912
1625
|
}, { sheen: 0.55 });
|
|
913
|
-
|
|
914
|
-
|
|
1626
|
+
add2(new SphereGeometry(0.02, 12, 10), "#2e2a4a", { at: [0, bowY, frontZ(bowY) + 0.016], scale: [1, 1.2, 0.8] }, { sheen: 0.55 });
|
|
1627
|
+
add2(new CylinderGeometry(0.018, 0.018, 0.01, 16), "#14102e", { at: [0, button, frontZ(button) + 0.002], rotate: [Math.PI / 2, 0, 0] }, { sheen: 0.8 });
|
|
915
1628
|
const tail = new Shape;
|
|
916
1629
|
tail.moveTo(-0.055, 0);
|
|
917
1630
|
tail.lineTo(0.055, 0);
|
|
@@ -926,13 +1639,13 @@ function tuxedo(kit) {
|
|
|
926
1639
|
at: [side * 0.07, bottom + 0.06, backPt.z],
|
|
927
1640
|
rotate: [0, Math.PI + side * -0.18, 0]
|
|
928
1641
|
});
|
|
929
|
-
|
|
1642
|
+
add2(tailGeometry, "#1b1830", { at: [0, -0.09, 0], parent: hang }, { sheen: 0.15 });
|
|
930
1643
|
return { hang, spring: new Spring(60, 5), side };
|
|
931
1644
|
});
|
|
932
1645
|
return (clock, delta, raw) => {
|
|
933
1646
|
const motion = calm(raw);
|
|
934
1647
|
for (const t of tails) {
|
|
935
|
-
const kick = t.spring.step(-0.14 + clamp(-motion.lift * 0.12, -0.
|
|
1648
|
+
const kick = t.spring.step(-0.14 + clamp(-motion.lift * 0.14 - motion.swayZ * 0.12, -0.35, 0.55) + Math.abs(motion.yaw) * 0.05 + Math.abs(motion.swayX) * 0.12, delta);
|
|
936
1649
|
t.hang.rotation.x = kick + Math.sin(clock * 1.5 + t.side) * 0.02;
|
|
937
1650
|
}
|
|
938
1651
|
};
|
|
@@ -941,7 +1654,7 @@ function tuxedo(kit) {
|
|
|
941
1654
|
function heroCape(kit) {
|
|
942
1655
|
const z = zonesOf(kit);
|
|
943
1656
|
const surf = surfaceOf(kit);
|
|
944
|
-
return piece(kit, ({ add }) => {
|
|
1657
|
+
return piece(kit, ({ add: add2 }) => {
|
|
945
1658
|
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.6;
|
|
946
1659
|
const bottom = kit.isFigure ? -0.1 : 0;
|
|
947
1660
|
const across = Math.PI * 0.95;
|
|
@@ -983,8 +1696,8 @@ function heroCape(kit) {
|
|
|
983
1696
|
geometry.computeVertexNormals();
|
|
984
1697
|
};
|
|
985
1698
|
drape(0, 0, 0);
|
|
986
|
-
|
|
987
|
-
|
|
1699
|
+
add2(geometry, "#c8323c", {}, { double: true, back: "#f2c94c", sheen: 0.2 });
|
|
1700
|
+
add2(fittedPatch(kit, top - 0.04, top + 0.06, 0.045, (_y, t) => Math.PI * 0.42 + t * (Math.PI * 2 - Math.PI * 0.84), 3, 24), "#9e1f2c", {}, { double: true, back: "#f2c94c" });
|
|
988
1701
|
const clasp = new Shape;
|
|
989
1702
|
for (let i = 0;i < 10; i += 1) {
|
|
990
1703
|
const a = i / 10 * Math.PI * 2;
|
|
@@ -999,29 +1712,29 @@ function heroCape(kit) {
|
|
|
999
1712
|
for (const side of [-1, 1]) {
|
|
1000
1713
|
const angle = side * (Math.PI / 2 - 0.22);
|
|
1001
1714
|
const pt = surf(top - 0.02, angle, 0.04);
|
|
1002
|
-
|
|
1715
|
+
add2(star, "#f2c94c", { at: [pt.x, top - 0.02, pt.z], rotate: [0, angle, 0] }, { sheen: 0.85 });
|
|
1003
1716
|
}
|
|
1004
|
-
const flare = new Spring(
|
|
1005
|
-
const trail = new Spring(
|
|
1717
|
+
const flare = new Spring(48, 3.2);
|
|
1718
|
+
const trail = new Spring(42, 3.2);
|
|
1006
1719
|
return (clock, delta, raw) => {
|
|
1007
1720
|
const motion = calm(raw);
|
|
1008
|
-
const out = flare.step(clamp(Math.abs(motion.yaw) * 0.
|
|
1009
|
-
drape(clock, out, trail.step(-motion.yaw * 0.
|
|
1721
|
+
const out = flare.step(clamp(Math.abs(motion.yaw) * 0.04 + Math.max(0, -motion.lift) * 0.08 + Math.abs(motion.swayX) * 0.08 - motion.swayZ * 0.06, 0, 0.32), delta);
|
|
1722
|
+
drape(clock, out, trail.step(-motion.yaw * 0.07 - motion.swayX * 0.18, delta));
|
|
1010
1723
|
};
|
|
1011
1724
|
});
|
|
1012
1725
|
}
|
|
1013
1726
|
function scarf(kit) {
|
|
1014
1727
|
const z = zonesOf(kit);
|
|
1015
1728
|
const surf = surfaceOf(kit);
|
|
1016
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1729
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
1017
1730
|
const wool = keep(knit("#e2574c", "#fbf8ff"));
|
|
1018
1731
|
const y = kit.isFigure ? z.neckY - 0.03 : COLLAR_Y;
|
|
1019
1732
|
const r = Math.max(0.11, kit.radiusAt(y)) + 0.025;
|
|
1020
|
-
|
|
1733
|
+
add2(new TorusGeometry(r, kit.isFigure ? 0.048 : 0.058, 14, 64), "#ffffff", { at: [0, y, 0], rotate: [Math.PI / 2, 0, 0], scale: [1, DEPTH, 1.05] }, { map: wool, repeat: [14, 1] });
|
|
1021
1734
|
const knotAngle = 0.52;
|
|
1022
1735
|
const knotPt = surf(y, knotAngle, 0.045);
|
|
1023
1736
|
const knotAt = [knotPt.x, y - 0.01, knotPt.z];
|
|
1024
|
-
|
|
1737
|
+
add2(new SphereGeometry(0.05, 16, 12), "#ffffff", { at: knotAt, scale: [1, 0.85, 0.75] }, { map: wool, repeat: [3, 1] });
|
|
1025
1738
|
const strip = new CylinderGeometry(0.046, 0.05, 0.26, 12, 6);
|
|
1026
1739
|
strip.scale(1, 1, 0.35);
|
|
1027
1740
|
const fringeGeo = new CylinderGeometry(0.006, 0.004, 0.04, 5);
|
|
@@ -1033,16 +1746,16 @@ function scarf(kit) {
|
|
|
1033
1746
|
at: [knotAt[0] + x, knotAt[1] - 0.02, knotAt[2] + 0.02],
|
|
1034
1747
|
rotate: [0.12, knotAngle * 0.6, tilt]
|
|
1035
1748
|
});
|
|
1036
|
-
|
|
1749
|
+
add2(strip, "#ffffff", { at: [0, -0.13 * length, 0], scale: [1, length, 1], parent: hang }, { map: wool, repeat: [2, 2] });
|
|
1037
1750
|
for (let i = 0;i < 5; i += 1)
|
|
1038
|
-
|
|
1751
|
+
add2(fringeGeo, "#e2574c", { at: [-0.036 + i * 0.018, -0.26 * length - 0.02, 0], parent: hang }, { outline: false });
|
|
1039
1752
|
return { hang, tilt, spring: new Spring(55, 5, tilt) };
|
|
1040
1753
|
});
|
|
1041
1754
|
return (clock, delta, raw) => {
|
|
1042
1755
|
const motion = calm(raw);
|
|
1043
1756
|
tails.forEach((t, i) => {
|
|
1044
|
-
t.hang.rotation.z = t.spring.step(t.tilt - motion.yaw * 0.
|
|
1045
|
-
t.hang.rotation.x = 0.12 + clamp(motion.lift * 0.
|
|
1757
|
+
t.hang.rotation.z = t.spring.step(t.tilt - motion.yaw * 0.06 - motion.swayX * 0.24 + Math.sin(clock * 1.8 + i) * 0.03, delta);
|
|
1758
|
+
t.hang.rotation.x = 0.12 + clamp(motion.lift * 0.12 - motion.swayZ * 0.14, -0.35, 0.55);
|
|
1046
1759
|
});
|
|
1047
1760
|
};
|
|
1048
1761
|
});
|
|
@@ -1050,85 +1763,97 @@ function scarf(kit) {
|
|
|
1050
1763
|
function ribbonDress(kit) {
|
|
1051
1764
|
const z = zonesOf(kit);
|
|
1052
1765
|
const surf = surfaceOf(kit);
|
|
1053
|
-
return piece(kit, ({ add, keep, node }) => {
|
|
1766
|
+
return piece(kit, ({ add: add2, keep, node }) => {
|
|
1054
1767
|
const bodiceTop = kit.isFigure ? z.bustY + 0.09 : 0.36;
|
|
1055
1768
|
const waist = kit.isFigure ? z.waistY : 0.24;
|
|
1056
1769
|
const hem = kit.isFigure ? z.bottomY - 0.16 : 0.02;
|
|
1057
|
-
|
|
1058
|
-
|
|
1770
|
+
add2(fittedPatch(kit, waist, bodiceTop, 0.028, (_y, t) => t * Math.PI * 2, 20, 56), "#ff6fa8", {}, { double: true, back: "#c43f76", sheen: 0.32 });
|
|
1771
|
+
add2(fittedPatch(kit, bodiceTop - 0.022, bodiceTop + 0.008, 0.033, (_y, t) => t * Math.PI * 2, 2, 56), "#fff7fb", {}, { double: true, outline: false });
|
|
1059
1772
|
if (kit.isFigure) {
|
|
1060
1773
|
for (const side of [-1, 1]) {
|
|
1061
1774
|
const shPt = surf(z.shoulderY, side * 1.15, 0.015);
|
|
1062
|
-
|
|
1775
|
+
add2(new SphereGeometry(0.055, 14, 12), "#fff7fb", { at: [shPt.x, z.shoulderY - 0.02, shPt.z], scale: [1.1, 0.85, 1] }, { sheen: 0.25 });
|
|
1063
1776
|
}
|
|
1064
1777
|
}
|
|
1065
|
-
|
|
1778
|
+
add2(fittedPatch(kit, waist - 0.026, waist + 0.024, 0.032, (_y, t) => t * Math.PI * 2, 3, 56), "#fff7fb", {}, { double: true, sheen: 0.45 });
|
|
1066
1779
|
const frontW = surf(waist, 0, 0.04);
|
|
1067
1780
|
const bowNode = node({ at: [frontW.x, waist, frontW.z] });
|
|
1068
1781
|
const loopGeo = new TorusGeometry(0.038, 0.013, 10, 20);
|
|
1069
1782
|
for (const side of [-1, 1])
|
|
1070
|
-
|
|
1783
|
+
add2(loopGeo, "#ff3d8b", {
|
|
1071
1784
|
at: [side * 0.04, 0, 0],
|
|
1072
1785
|
rotate: [0, 0, side * 0.3],
|
|
1073
1786
|
scale: [1.15, 0.72, 0.55],
|
|
1074
1787
|
parent: bowNode
|
|
1075
1788
|
}, { sheen: 0.5 });
|
|
1076
|
-
|
|
1077
|
-
const skirtGeo = aLineSkirtPatch(kit, hem, waist, kit.isFigure ? 0.
|
|
1789
|
+
add2(new SphereGeometry(0.018, 10, 8), "#ff3d8b", { parent: bowNode }, { sheen: 0.5 });
|
|
1790
|
+
const skirtGeo = aLineSkirtPatch(kit, hem, waist, kit.isFigure ? 0.185 : 0.1, 16, 0.02, 10, 72);
|
|
1078
1791
|
const pos = skirtGeo.attributes.position;
|
|
1079
1792
|
const rest = Float32Array.from(pos.array);
|
|
1080
|
-
|
|
1793
|
+
add2(skirtGeo, "#ff6fa8", {}, {
|
|
1081
1794
|
map: keep(dots("#ff7eb6", "#ffe3f0")),
|
|
1082
1795
|
repeat: [8, 3],
|
|
1083
1796
|
double: true,
|
|
1084
1797
|
back: "#ffe8f3",
|
|
1085
1798
|
sheen: 0.22
|
|
1086
1799
|
});
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1800
|
+
const pettiGeo = aLineSkirtPatch(kit, hem - 0.032, hem + 0.025, kit.isFigure ? 0.19 : 0.105, 22, 0.016, 3, 72);
|
|
1801
|
+
const pettiPos = pettiGeo.attributes.position;
|
|
1802
|
+
const pettiRest = Float32Array.from(pettiPos.array);
|
|
1803
|
+
add2(pettiGeo, "#fffaff", {}, { double: true, outline: false });
|
|
1804
|
+
const flare = new Spring(75, 3.2);
|
|
1805
|
+
const swayX = new Spring(65, 3);
|
|
1806
|
+
const swayZ = new Spring(65, 3.3);
|
|
1807
|
+
const deform = (pAttr, base, geo, out, lagX, lagZ, clock) => {
|
|
1808
|
+
for (let i = 0;i < pAttr.count; i += 1) {
|
|
1809
|
+
const x = base[i * 3] ?? 0;
|
|
1810
|
+
const y = base[i * 3 + 1] ?? 0;
|
|
1811
|
+
const z0 = base[i * 3 + 2] ?? 0;
|
|
1812
|
+
const low = clamp((waist - y) / Math.max(0.05, waist - hem), 0, 1.12);
|
|
1813
|
+
const low2 = low * low;
|
|
1097
1814
|
const a = Math.atan2(x, z0);
|
|
1098
|
-
const r = Math.hypot(x, z0) * (1 + out *
|
|
1099
|
-
|
|
1815
|
+
const r = Math.hypot(x, z0) * (1 + out * low2 + Math.sin(clock * 2.5 + a * 3) * 0.01 * low);
|
|
1816
|
+
pAttr.setXYZ(i, Math.sin(a) * r + lagX * low2, y + Math.abs(out) * 0.025 * low2, Math.cos(a) * r + lagZ * low2);
|
|
1100
1817
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1818
|
+
pAttr.needsUpdate = true;
|
|
1819
|
+
geo.computeVertexNormals();
|
|
1820
|
+
};
|
|
1821
|
+
return (clock, delta, raw) => {
|
|
1822
|
+
const motion = calm(raw);
|
|
1823
|
+
const out = flare.step(clamp(-motion.lift * 0.12 + Math.abs(motion.swayX) * 0.08, -0.05, 0.28), delta);
|
|
1824
|
+
const lagX = swayX.step(-motion.swayX * 0.085 - motion.yaw * 0.018, delta);
|
|
1825
|
+
const lagZ = swayZ.step(-motion.swayZ * 0.06, delta);
|
|
1826
|
+
deform(pos, rest, skirtGeo, out, lagX, lagZ, clock);
|
|
1827
|
+
deform(pettiPos, pettiRest, pettiGeo, out, lagX, lagZ, clock);
|
|
1103
1828
|
};
|
|
1104
1829
|
});
|
|
1105
1830
|
}
|
|
1106
1831
|
function cropHoodie(kit) {
|
|
1107
1832
|
const z = zonesOf(kit);
|
|
1108
1833
|
const surf = surfaceOf(kit);
|
|
1109
|
-
return piece(kit, ({ add, node }) => {
|
|
1834
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
1110
1835
|
const bottom = kit.isFigure ? z.waistY + 0.06 : 0.2;
|
|
1111
1836
|
const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
|
|
1112
|
-
|
|
1113
|
-
|
|
1837
|
+
add2(fittedPatch(kit, bottom, top, (v) => 0.03 + (1 - v) * 0.012, (_y, t) => t * Math.PI * 2, 18, 56), "#d8b8ff", {}, { double: true, back: "#8f6ec4", sheen: 0.1 });
|
|
1838
|
+
add2(fittedPatch(kit, bottom - 0.022, bottom + 0.012, 0.036, (_y, t) => t * Math.PI * 2, 3, 56), "#fffaff", {}, { double: true, outline: false });
|
|
1114
1839
|
const neckY = kit.isFigure ? z.neckY - 0.02 : top;
|
|
1115
1840
|
const backPt = surf(neckY, Math.PI, 0.05);
|
|
1116
|
-
|
|
1841
|
+
add2(new SphereGeometry(kit.isFigure ? 0.12 : 0.16, 16, 12), "#c69eff", { at: [0, neckY - 0.01, backPt.z - 0.05], scale: [1.35, 0.72, 0.95] }, { sheen: 0.1 });
|
|
1117
1842
|
if (kit.isFigure) {
|
|
1118
|
-
|
|
1843
|
+
add2(fittedPatch(kit, z.bottomY - 0.02, z.hipY + 0.09, 0.024, (_y, t) => t * Math.PI * 2, 12, 56), "#2c2448", {}, { double: true });
|
|
1119
1844
|
}
|
|
1120
1845
|
const frontNeck = surf(top - 0.02, 0, 0.04);
|
|
1121
1846
|
const strings = [-1, 1].map((side) => {
|
|
1122
1847
|
const hang = node({ at: [side * 0.042, top - 0.02, frontNeck.z] });
|
|
1123
|
-
|
|
1124
|
-
|
|
1848
|
+
add2(new CylinderGeometry(0.008, 0.008, 0.14, 8), "#fffaff", { at: [0, -0.07, 0], parent: hang }, { outline: false });
|
|
1849
|
+
add2(new SphereGeometry(0.013, 8, 8), "#ff7eb8", { at: [0, -0.14, 0], parent: hang }, { outline: false });
|
|
1125
1850
|
return { hang, side, spring: new Spring(60, 4.5) };
|
|
1126
1851
|
});
|
|
1127
1852
|
return (clock, delta, raw) => {
|
|
1128
1853
|
const motion = calm(raw);
|
|
1129
1854
|
for (const s of strings) {
|
|
1130
|
-
s.hang.rotation.z = s.spring.step(-motion.yaw * 0.
|
|
1131
|
-
s.hang.rotation.x = clamp(motion.lift * 0.
|
|
1855
|
+
s.hang.rotation.z = s.spring.step(-motion.yaw * 0.05 - motion.swayX * 0.24 + Math.sin(clock * 2.1 + s.side) * 0.05, delta);
|
|
1856
|
+
s.hang.rotation.x = clamp(motion.lift * 0.1 - motion.swayZ * 0.12, -0.3, 0.4);
|
|
1132
1857
|
}
|
|
1133
1858
|
};
|
|
1134
1859
|
});
|
|
@@ -1136,54 +1861,84 @@ function cropHoodie(kit) {
|
|
|
1136
1861
|
function idolSet(kit) {
|
|
1137
1862
|
const z = zonesOf(kit);
|
|
1138
1863
|
const surf = surfaceOf(kit);
|
|
1139
|
-
return piece(kit, ({ add, node }) => {
|
|
1864
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
1140
1865
|
const topBottom = kit.isFigure ? z.waistY + 0.05 : 0.24;
|
|
1141
1866
|
const topHigh = kit.isFigure ? z.shoulderY + 0.05 : 0.38;
|
|
1142
1867
|
const skirtTop = kit.isFigure ? z.waistY - 0.01 : 0.22;
|
|
1143
1868
|
const skirtBot = kit.isFigure ? z.bottomY - 0.12 : 0.02;
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1869
|
+
add2(fittedPatch(kit, topBottom, topHigh, 0.028, (_y, t) => t * Math.PI * 2, 16, 56), "#ffffff", {}, { double: true, sheen: 0.2 });
|
|
1870
|
+
add2(fittedPatch(kit, topHigh - 0.1, topHigh + 0.01, 0.034, (_y, t) => t * Math.PI * 2, 6, 56), "#1f2b6c", {}, { double: true });
|
|
1871
|
+
add2(fittedPatch(kit, topHigh - 0.09, topHigh - 0.075, 0.038, (_y, t) => t * Math.PI * 2, 2, 56), "#ffd84d", {}, { double: true, outline: false, sheen: 0.7 });
|
|
1147
1872
|
const chest = surf(topHigh - 0.09, 0, 0.045);
|
|
1148
1873
|
const bow2 = node({ at: [0, topHigh - 0.09, chest.z] });
|
|
1149
1874
|
const loop = new TorusGeometry(0.038, 0.013, 10, 20);
|
|
1150
1875
|
for (const side of [-1, 1]) {
|
|
1151
|
-
|
|
1152
|
-
|
|
1876
|
+
add2(loop, "#ff3b6b", { at: [side * 0.038, 0, 0], scale: [1.15, 0.75, 0.5], parent: bow2 }, { sheen: 0.45 });
|
|
1877
|
+
add2(new CylinderGeometry(0.015, 0.022, 0.095, 8), "#ff3b6b", {
|
|
1153
1878
|
at: [side * 0.024, -0.055, 0],
|
|
1154
1879
|
rotate: [0, 0, side * 0.24],
|
|
1155
1880
|
scale: [1, 1, 0.3],
|
|
1156
1881
|
parent: bow2
|
|
1157
1882
|
}, { outline: false });
|
|
1158
1883
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1884
|
+
const idolSkirtGeo = aLineSkirtPatch(kit, skirtBot, skirtTop, kit.isFigure ? 0.155 : 0.085, 22, 0.02, 8, 72);
|
|
1885
|
+
const idolRest = new Float32Array(idolSkirtGeo.attributes.position.array);
|
|
1886
|
+
const idolPos = idolSkirtGeo.attributes.position;
|
|
1887
|
+
add2(idolSkirtGeo, "#1f2b6c", {}, { double: true, back: "#ff6fa8" });
|
|
1888
|
+
const trimGeo = aLineSkirtPatch(kit, skirtBot + 0.016, skirtBot + 0.038, kit.isFigure ? 0.15 : 0.08, 22, 0.018, 2, 72);
|
|
1889
|
+
const trimRest = new Float32Array(trimGeo.attributes.position.array);
|
|
1890
|
+
const trimPos = trimGeo.attributes.position;
|
|
1891
|
+
add2(trimGeo, "#ffd84d", {}, { double: true, outline: false, sheen: 0.75 });
|
|
1892
|
+
const flare = new Spring(80, 3.4);
|
|
1893
|
+
const swayX = new Spring(65, 3.2);
|
|
1894
|
+
const swayZ = new Spring(65, 3.5);
|
|
1895
|
+
const deform = (pAttr, base, geo, out, lx, lz, clock) => {
|
|
1896
|
+
for (let i = 0;i < pAttr.count; i += 1) {
|
|
1897
|
+
const x = base[i * 3] ?? 0;
|
|
1898
|
+
const y = base[i * 3 + 1] ?? 0;
|
|
1899
|
+
const z0 = base[i * 3 + 2] ?? 0;
|
|
1900
|
+
const low = clamp((skirtTop - y) / Math.max(0.05, skirtTop - skirtBot), 0, 1);
|
|
1901
|
+
const low2 = low * low;
|
|
1902
|
+
const a = Math.atan2(x, z0);
|
|
1903
|
+
const r = Math.hypot(x, z0) * (1 + out * low2 + Math.sin(clock * 2.6 + a * 3) * 0.008 * low);
|
|
1904
|
+
pAttr.setXYZ(i, Math.sin(a) * r + lx * low2, y + Math.abs(out) * 0.02 * low2, Math.cos(a) * r + lz * low2);
|
|
1905
|
+
}
|
|
1906
|
+
pAttr.needsUpdate = true;
|
|
1907
|
+
geo.computeVertexNormals();
|
|
1908
|
+
};
|
|
1909
|
+
return (clock, delta, raw) => {
|
|
1910
|
+
const motion = calm(raw);
|
|
1911
|
+
const out = flare.step(clamp(-motion.lift * 0.1 + Math.abs(motion.swayX) * 0.06, -0.05, 0.25), delta);
|
|
1912
|
+
const lx = swayX.step(-motion.swayX * 0.075 - motion.yaw * 0.015, delta);
|
|
1913
|
+
const lz = swayZ.step(-motion.swayZ * 0.055, delta);
|
|
1914
|
+
deform(idolPos, idolRest, idolSkirtGeo, out, lx, lz, clock);
|
|
1915
|
+
deform(trimPos, trimRest, trimGeo, out, lx, lz, clock);
|
|
1916
|
+
};
|
|
1162
1917
|
});
|
|
1163
1918
|
}
|
|
1164
1919
|
function streetJacket(kit) {
|
|
1165
1920
|
const z = zonesOf(kit);
|
|
1166
1921
|
const surf = surfaceOf(kit);
|
|
1167
|
-
return piece(kit, ({ add }) => {
|
|
1922
|
+
return piece(kit, ({ add: add2 }) => {
|
|
1168
1923
|
const bottom = kit.isFigure ? z.hipY - 0.04 : 0.04;
|
|
1169
1924
|
const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
|
|
1170
1925
|
if (kit.isFigure) {
|
|
1171
|
-
|
|
1926
|
+
add2(fittedPatch(kit, z.bottomY - 0.03, z.waistY + 0.02, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#161622", {}, { double: true });
|
|
1172
1927
|
}
|
|
1173
|
-
|
|
1928
|
+
add2(fittedPatch(kit, bottom + 0.02, top - 0.01, 0.026, (_y, t) => t * Math.PI * 2, 16, 48), "#181726", {}, { double: true });
|
|
1174
1929
|
const gap = 0.34;
|
|
1175
|
-
|
|
1930
|
+
add2(fittedPatch(kit, bottom, top, (v) => 0.04 + (1 - v) * 0.008, (_y, t) => gap + t * (Math.PI * 2 - gap * 2), 18, 48), "#2c2f48", {}, { double: true, back: "#ff4f7a", sheen: 0.25 });
|
|
1176
1931
|
for (const side of [-1, 1]) {
|
|
1177
|
-
|
|
1932
|
+
add2(fittedPatch(kit, bottom, top, 0.045, (_y, t) => side * (gap + t * 0.08), 12, 3), "#ff4f7a", {}, { double: true, outline: false });
|
|
1178
1933
|
}
|
|
1179
|
-
|
|
1934
|
+
add2(fittedPatch(kit, top - 0.02, top + 0.065, 0.042, (_y, t) => gap * 1.1 + t * (Math.PI * 2 - gap * 2.2), 4, 32), "#1b1d2e", {}, { double: true, back: "#ff4f7a" });
|
|
1180
1935
|
const chainY = kit.isFigure ? z.bustY + 0.04 : top - 0.08;
|
|
1181
1936
|
const bead = new SphereGeometry(0.011, 8, 8);
|
|
1182
1937
|
for (let i = -5;i <= 5; i += 1) {
|
|
1183
1938
|
const phi = i * 0.08;
|
|
1184
1939
|
const drop = Math.cos(i / 5 * Math.PI * 0.5) * 0.065;
|
|
1185
1940
|
const pt = surf(chainY - drop, phi, 0.036);
|
|
1186
|
-
|
|
1941
|
+
add2(bead, "#e4ebff", { at: [pt.x, chainY - drop, pt.z] }, { sheen: 0.9, outline: false });
|
|
1187
1942
|
}
|
|
1188
1943
|
return;
|
|
1189
1944
|
});
|
|
@@ -1191,27 +1946,27 @@ function streetJacket(kit) {
|
|
|
1191
1946
|
function blazerCoat(kit) {
|
|
1192
1947
|
const z = zonesOf(kit);
|
|
1193
1948
|
const surf = surfaceOf(kit);
|
|
1194
|
-
return piece(kit, ({ add }) => {
|
|
1949
|
+
return piece(kit, ({ add: add2 }) => {
|
|
1195
1950
|
const bottom = kit.isFigure ? z.hipY - 0.05 : 0.03;
|
|
1196
1951
|
const waist = kit.isFigure ? z.waistY + 0.02 : 0.18;
|
|
1197
1952
|
const top = kit.isFigure ? z.shoulderY + 0.05 : 0.37;
|
|
1198
1953
|
const vOpen = (y) => y > waist ? 0.1 + (y - waist) / Math.max(0.05, top - waist) * 0.45 : 0.06;
|
|
1199
1954
|
if (kit.isFigure) {
|
|
1200
|
-
|
|
1955
|
+
add2(fittedPatch(kit, z.bottomY - 0.03, z.waistY, 0.022, (_y, t) => t * Math.PI * 2, 10, 48), "#1c223c", {}, { double: true });
|
|
1201
1956
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1957
|
+
add2(fittedPatch(kit, bottom + 0.02, top, 0.024, (_y, t) => t * Math.PI * 2, 16, 48), "#f8f9ff", {}, { double: true, outline: false });
|
|
1958
|
+
add2(fittedPatch(kit, bottom, top, 0.036, (y, t) => vOpen(y) + t * (Math.PI * 2 - 2 * vOpen(y)), 18, 48), "#232b4f", {}, { double: true, back: "#3c4a7d", sheen: 0.18 });
|
|
1204
1959
|
for (const side of [-1, 1]) {
|
|
1205
|
-
|
|
1960
|
+
add2(fittedPatch(kit, waist, top, 0.041, (y, t) => side * (vOpen(y) + t * 0.09), 10, 3), "#f2c94c", {}, { double: true, outline: false, sheen: 0.75 });
|
|
1206
1961
|
}
|
|
1207
|
-
|
|
1962
|
+
add2(fittedPatch(kit, waist - 0.02, top - 0.02, 0.034, (y, t) => {
|
|
1208
1963
|
const w = y > top - 0.07 ? 0.08 : 0.12 - (y - waist) / Math.max(0.05, top - waist) * 0.05;
|
|
1209
1964
|
return (t * 2 - 1) * w;
|
|
1210
1965
|
}, 10, 6), "#d6354a", {}, { double: true });
|
|
1211
1966
|
const btn = new SphereGeometry(0.014, 8, 8);
|
|
1212
1967
|
for (const by of [waist, waist - 0.065]) {
|
|
1213
1968
|
const pt = surf(by, 0.16, 0.042);
|
|
1214
|
-
|
|
1969
|
+
add2(btn, "#f2c94c", { at: [pt.x, by, pt.z] }, { sheen: 0.85, outline: false });
|
|
1215
1970
|
}
|
|
1216
1971
|
return;
|
|
1217
1972
|
});
|
|
@@ -1219,36 +1974,36 @@ function blazerCoat(kit) {
|
|
|
1219
1974
|
function brawlerVest(kit) {
|
|
1220
1975
|
const z = zonesOf(kit);
|
|
1221
1976
|
const surf = surfaceOf(kit);
|
|
1222
|
-
return piece(kit, ({ add }) => {
|
|
1977
|
+
return piece(kit, ({ add: add2 }) => {
|
|
1223
1978
|
const bottom = kit.isFigure ? z.waistY - 0.08 : 0.05;
|
|
1224
1979
|
const top = kit.isFigure ? z.shoulderY + 0.03 : 0.36;
|
|
1225
1980
|
if (kit.isFigure) {
|
|
1226
|
-
|
|
1981
|
+
add2(fittedPatch(kit, z.bottomY - 0.04, z.waistY - 0.02, 0.026, (_y, t) => t * Math.PI * 2, 12, 48), "#2b2538", {}, { double: true });
|
|
1227
1982
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1983
|
+
add2(fittedPatch(kit, bottom, top, (v) => 0.028 + (v > 0.7 ? 0.008 : 0), (_y, t) => t * Math.PI * 2, 20, 56), "#232030", {}, { double: true, sheen: 0.12 });
|
|
1984
|
+
add2(fittedPatch(kit, (top + bottom) * 0.54, (top + bottom) * 0.65, 0.036, (_y, t) => t * Math.PI * 2, 4, 56), "#ff5733", {}, { double: true, outline: false });
|
|
1230
1985
|
const beltY = kit.isFigure ? z.waistY - 0.04 : 0.14;
|
|
1231
|
-
|
|
1986
|
+
add2(fittedPatch(kit, beltY - 0.028, beltY + 0.028, 0.036, (_y, t) => t * Math.PI * 2, 3, 48), "#4a2b1d", {}, { double: true });
|
|
1232
1987
|
const bucklePt = surf(beltY, 0, 0.045);
|
|
1233
|
-
|
|
1988
|
+
add2(new CylinderGeometry(0.032, 0.032, 0.016, 6), "#ffd24a", { at: [bucklePt.x, beltY, bucklePt.z], rotate: [Math.PI / 2, 0, 0] }, { sheen: 0.85 });
|
|
1234
1989
|
return;
|
|
1235
1990
|
});
|
|
1236
1991
|
}
|
|
1237
1992
|
function martialGi(kit) {
|
|
1238
1993
|
const z = zonesOf(kit);
|
|
1239
1994
|
const surf = surfaceOf(kit);
|
|
1240
|
-
return piece(kit, ({ add, node }) => {
|
|
1995
|
+
return piece(kit, ({ add: add2, node }) => {
|
|
1241
1996
|
const bottom = kit.isFigure ? z.bottomY - 0.03 : 0.03;
|
|
1242
1997
|
const waist = kit.isFigure ? z.waistY - 0.02 : 0.16;
|
|
1243
1998
|
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.37;
|
|
1244
1999
|
const vOpen = (y) => y > waist ? 0.08 + (y - waist) / Math.max(0.05, top - waist) * 0.44 : 0;
|
|
1245
|
-
|
|
2000
|
+
add2(fittedPatch(kit, bottom, top, (v) => 0.032 + (1 - v) * 0.014, (y, t) => vOpen(y) + t * (Math.PI * 2 - 2 * vOpen(y)), 20, 56), "#f4f1ea", {}, { double: true, back: "#d8d1c5" });
|
|
1246
2001
|
for (const side of [-1, 1]) {
|
|
1247
|
-
|
|
2002
|
+
add2(fittedPatch(kit, waist, top, 0.038, (y, t) => side * (vOpen(y) + t * 0.1), 10, 3), "#1b2042", {}, { double: true, outline: false });
|
|
1248
2003
|
}
|
|
1249
|
-
|
|
2004
|
+
add2(fittedPatch(kit, waist - 0.032, waist + 0.032, 0.042, (_y, t) => t * Math.PI * 2, 4, 48), "#181624", {}, { double: true });
|
|
1250
2005
|
const knotPt = surf(waist, 0, 0.052);
|
|
1251
|
-
|
|
2006
|
+
add2(new SphereGeometry(0.038, 12, 10), "#181624", { at: [knotPt.x, waist, knotPt.z] });
|
|
1252
2007
|
const tailGeo = new CylinderGeometry(0.022, 0.028, 0.22, 8);
|
|
1253
2008
|
tailGeo.scale(1, 1, 0.3);
|
|
1254
2009
|
const tails = [-1, 1].map((side) => {
|
|
@@ -1256,13 +2011,13 @@ function martialGi(kit) {
|
|
|
1256
2011
|
at: [knotPt.x + side * 0.028, waist - 0.02, knotPt.z + 0.008],
|
|
1257
2012
|
rotate: [0.08, 0, side * 0.24]
|
|
1258
2013
|
});
|
|
1259
|
-
|
|
2014
|
+
add2(tailGeo, "#181624", { at: [0, -0.1, 0], parent: hang });
|
|
1260
2015
|
return { hang, side, spring: new Spring(55, 5) };
|
|
1261
2016
|
});
|
|
1262
2017
|
return (clock, delta, raw) => {
|
|
1263
2018
|
const motion = calm(raw);
|
|
1264
2019
|
for (const t of tails) {
|
|
1265
|
-
t.hang.rotation.z = t.spring.step(t.side * 0.24 - motion.yaw * 0.
|
|
2020
|
+
t.hang.rotation.z = t.spring.step(t.side * 0.24 - motion.yaw * 0.05 - motion.swayX * 0.22 + Math.sin(clock * 2 + t.side) * 0.04, delta);
|
|
1266
2021
|
}
|
|
1267
2022
|
};
|
|
1268
2023
|
});
|
|
@@ -1270,20 +2025,20 @@ function martialGi(kit) {
|
|
|
1270
2025
|
function chibiOveralls(kit) {
|
|
1271
2026
|
const z = zonesOf(kit);
|
|
1272
2027
|
const surf = surfaceOf(kit);
|
|
1273
|
-
return piece(kit, ({ add }) => {
|
|
2028
|
+
return piece(kit, ({ add: add2 }) => {
|
|
1274
2029
|
const bottom = kit.isFigure ? z.bottomY - 0.02 : 0.03;
|
|
1275
2030
|
const waist = kit.isFigure ? z.waistY + 0.02 : 0.22;
|
|
1276
2031
|
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.36;
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
2032
|
+
add2(fittedPatch(kit, waist - 0.02, top, 0.014, (_y, t) => t * Math.PI * 2, 12, 48), "#fff3d9", {}, { double: true, outline: false });
|
|
2033
|
+
add2(fittedPatch(kit, bottom, waist + 0.03, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#5b8ff9", {}, { double: true, back: "#3d66bf" });
|
|
2034
|
+
add2(fittedPatch(kit, waist, top - 0.05, 0.026, (_y, t) => (t * 2 - 1) * 0.55, 8, 12), "#5b8ff9", {}, { double: true });
|
|
1280
2035
|
for (const side of [-1, 1]) {
|
|
1281
|
-
|
|
2036
|
+
add2(fittedPatch(kit, top - 0.07, top + 0.02, 0.028, (_y, t) => side * (0.36 + t * 0.2), 6, 4), "#5b8ff9", {}, { double: true, outline: false });
|
|
1282
2037
|
const btnPt = surf(top - 0.07, side * 0.44, 0.034);
|
|
1283
|
-
|
|
2038
|
+
add2(new SphereGeometry(0.018, 10, 8), "#ffd84d", { at: [btnPt.x, top - 0.07, btnPt.z] }, { sheen: 0.85 });
|
|
1284
2039
|
}
|
|
1285
2040
|
const pockPt = surf(waist + 0.06, 0, 0.033);
|
|
1286
|
-
|
|
2041
|
+
add2(new CylinderGeometry(0.045, 0.045, 0.012, 12), "#ffd84d", {
|
|
1287
2042
|
at: [pockPt.x, waist + 0.06, pockPt.z],
|
|
1288
2043
|
rotate: [Math.PI / 2, 0, 0],
|
|
1289
2044
|
scale: [1.1, 1, 0.85]
|
|
@@ -1293,7 +2048,7 @@ function chibiOveralls(kit) {
|
|
|
1293
2048
|
}
|
|
1294
2049
|
function sunglasses(kit) {
|
|
1295
2050
|
const R = kit.radiusAt;
|
|
1296
|
-
return piece(kit, ({ add, keep }) => {
|
|
2051
|
+
return piece(kit, ({ add: add2, keep }) => {
|
|
1297
2052
|
const glass = keep(lensGlass());
|
|
1298
2053
|
const lens = new Shape;
|
|
1299
2054
|
lens.moveTo(-0.085, 0.04);
|
|
@@ -1318,11 +2073,11 @@ function sunglasses(kit) {
|
|
|
1318
2073
|
for (const side of [-1, 1]) {
|
|
1319
2074
|
const x = side * 0.13;
|
|
1320
2075
|
const at = [x, EYES_Y, z + 0.035 - Math.abs(x) * 0.18];
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
2076
|
+
add2(lensGeometry, "#ffffff", { at, rotate: [0, side * turn, 0], scale: [side, 1, 1] }, { map: glass, sheen: 0.7, outline: false, double: true });
|
|
2077
|
+
add2(frameGeometry, "#1b1830", { at: [at[0], at[1], at[2] + 0.002], rotate: [0, side * turn, 0], scale: [side, 1, 1] }, { sheen: 0.6, double: true });
|
|
2078
|
+
add2(bodyPatch(R, EYES_Y + 0.022, EYES_Y + 0.038, 0.012, (_y, t) => side * (0.42 + t * 0.95), 1, 10), "#1b1830", {}, { double: true, outline: false, sheen: 0.5 });
|
|
1324
2079
|
}
|
|
1325
|
-
|
|
2080
|
+
add2(new TorusGeometry(0.03, 0.007, 6, 12, Math.PI), "#1b1830", { at: [0, EYES_Y + 0.025, z + 0.045] }, { sheen: 0.6, outline: false });
|
|
1326
2081
|
return;
|
|
1327
2082
|
});
|
|
1328
2083
|
}
|
|
@@ -1353,7 +2108,7 @@ function buildGarment(key, kit) {
|
|
|
1353
2108
|
}
|
|
1354
2109
|
|
|
1355
2110
|
// src/hair3d.ts
|
|
1356
|
-
var SKULL = new
|
|
2111
|
+
var SKULL = new Vector32(0, BLOB_SEAT + 0.08, 0);
|
|
1357
2112
|
var hexCh = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
|
|
1358
2113
|
var tintHex = (a, b, t) => `#${[0, 1, 2].map((i) => Math.max(0, Math.min(255, Math.round(hexCh(a, i) + (hexCh(b, i) - hexCh(a, i)) * t))).toString(16).padStart(2, "0")).join("")}`;
|
|
1359
2114
|
function resolvePalette(base, override) {
|
|
@@ -1371,10 +2126,10 @@ var anime = (p, ring = p.ring ?? 1) => ({
|
|
|
1371
2126
|
});
|
|
1372
2127
|
function onHead(radius, phi, y, out) {
|
|
1373
2128
|
const r = Math.max(0.02, radius(Math.min(y, TOP - 0.005))) + out;
|
|
1374
|
-
return new
|
|
2129
|
+
return new Vector32(Math.sin(phi) * r, y, Math.cos(phi) * r * DEPTH);
|
|
1375
2130
|
}
|
|
1376
|
-
var UP = new
|
|
1377
|
-
var FORWARD = new
|
|
2131
|
+
var UP = new Vector32(0, 1, 0);
|
|
2132
|
+
var FORWARD = new Vector32(0, 0, 1);
|
|
1378
2133
|
function clump(points, width, thickness, tip = 1, twist = 0) {
|
|
1379
2134
|
const curve = new CatmullRomCurve3(points, false, "centripetal");
|
|
1380
2135
|
const segments = 22;
|
|
@@ -1382,10 +2137,10 @@ function clump(points, width, thickness, tip = 1, twist = 0) {
|
|
|
1382
2137
|
const positions = [];
|
|
1383
2138
|
const along = [];
|
|
1384
2139
|
const indices = [];
|
|
1385
|
-
const tangent = new
|
|
1386
|
-
const out = new
|
|
1387
|
-
const across = new
|
|
1388
|
-
const depth = new
|
|
2140
|
+
const tangent = new Vector32;
|
|
2141
|
+
const out = new Vector32;
|
|
2142
|
+
const across = new Vector32;
|
|
2143
|
+
const depth = new Vector32;
|
|
1389
2144
|
for (let k = 0;k <= segments; k += 1) {
|
|
1390
2145
|
const t = k / segments;
|
|
1391
2146
|
const p = curve.getPointAt(t);
|
|
@@ -1437,7 +2192,7 @@ function clump(points, width, thickness, tip = 1, twist = 0) {
|
|
|
1437
2192
|
geometry.setAttribute("along", new BufferAttribute2(new Float32Array(along), 1));
|
|
1438
2193
|
geometry.setIndex(indices);
|
|
1439
2194
|
geometry.computeVertexNormals();
|
|
1440
|
-
return { geometry, along: Float32Array.from(along), root: points[0] ?? new
|
|
2195
|
+
return { geometry, along: Float32Array.from(along), root: points[0] ?? new Vector32 };
|
|
1441
2196
|
}
|
|
1442
2197
|
function swinger(made) {
|
|
1443
2198
|
const position = made.geometry.attributes.position;
|
|
@@ -1475,8 +2230,9 @@ function cap(radius, front, back, grow, part = 0, partLift = 0.03) {
|
|
|
1475
2230
|
const y = TOP + 0.015 - s * (TOP + 0.015 - line);
|
|
1476
2231
|
const dPart = Math.sin(phi - part);
|
|
1477
2232
|
const lobe = Math.abs(dPart) * (1 - s * 0.65) * partLift;
|
|
2233
|
+
const apexClose = Math.min(1, s * 6);
|
|
1478
2234
|
const p = onHead(radius, phi, y, grow * (0.78 + 0.32 * Math.sin(s * Math.PI * 0.72 + 0.25)) + lobe);
|
|
1479
|
-
positions.push(p.x, p.y + grow * 0.
|
|
2235
|
+
positions.push(p.x * apexClose, p.y + grow * 0.62 * (1 - s) + lobe * 0.65, p.z * apexClose);
|
|
1480
2236
|
along.push(s * 0.45);
|
|
1481
2237
|
}
|
|
1482
2238
|
}
|
|
@@ -1493,7 +2249,7 @@ function cap(radius, front, back, grow, part = 0, partLift = 0.03) {
|
|
|
1493
2249
|
geometry.computeVertexNormals();
|
|
1494
2250
|
return geometry;
|
|
1495
2251
|
}
|
|
1496
|
-
function
|
|
2252
|
+
function add2(b, p, made) {
|
|
1497
2253
|
b.add(made.geometry, p.color, {}, anime(p));
|
|
1498
2254
|
return made;
|
|
1499
2255
|
}
|
|
@@ -1514,7 +2270,7 @@ function fringe(b, radius, p, bangs, part = 0) {
|
|
|
1514
2270
|
const fall = onHead(radius, bang.at + mid, 0.7 + yShift * 0.5, 0.115 + lift * 0.85);
|
|
1515
2271
|
const end = onHead(radius, bang.at + sweep, bang.length + yShift, 0.075 + lift * 0.45 + flick);
|
|
1516
2272
|
const made = clump([root, crest, fall, end], bang.width * wBoost, bang.width * wBoost * 0.38, bang.blunt ? 0.56 : 1, bang.twist ?? sweep * 0.55);
|
|
1517
|
-
|
|
2273
|
+
add2(b, p, made);
|
|
1518
2274
|
}
|
|
1519
2275
|
}
|
|
1520
2276
|
function sidelocks(b, radius, p, end, width = 0.09, {
|
|
@@ -1539,7 +2295,7 @@ function sidelocks(b, radius, p, end, width = 0.09, {
|
|
|
1539
2295
|
onHead(radius, side * (phi - (blunt ? 0.03 : curlIn * 0.5)), y + 0.12, out * 0.88 + flick * 0.35),
|
|
1540
2296
|
onHead(radius, side * (phi - (blunt ? 0.04 : curlIn)), y, endOut)
|
|
1541
2297
|
];
|
|
1542
|
-
|
|
2298
|
+
add2(b, p, clump(path, w, w * 0.4, blunt ? 0.58 : 1, side * (blunt ? 0.2 : 0.55)));
|
|
1543
2299
|
}
|
|
1544
2300
|
}
|
|
1545
2301
|
}
|
|
@@ -1547,9 +2303,9 @@ function crownTufts(b, radius, p, tufts) {
|
|
|
1547
2303
|
for (const [phi, y, len, liftOut, w] of tufts) {
|
|
1548
2304
|
const root = onHead(radius, phi, y, 0.05);
|
|
1549
2305
|
const out = onHead(radius, phi, y, 1).sub(root).normalize();
|
|
1550
|
-
const mid = root.clone().addScaledVector(out, liftOut).add(new
|
|
1551
|
-
const tip = mid.clone().addScaledVector(out, liftOut * 0.85).add(new
|
|
1552
|
-
|
|
2306
|
+
const mid = root.clone().addScaledVector(out, liftOut).add(new Vector32(Math.sin(phi + 0.6) * 0.05, len * 0.35, Math.cos(phi + 0.6) * 0.03));
|
|
2307
|
+
const tip = mid.clone().addScaledVector(out, liftOut * 0.85).add(new Vector32(Math.sin(phi + 1.1) * 0.08, -len * 0.45, Math.cos(phi + 1.1) * 0.05));
|
|
2308
|
+
add2(b, p, clump([root, mid, tip], w, w * 0.42, 1, Math.sin(phi) * 0.5));
|
|
1553
2309
|
}
|
|
1554
2310
|
}
|
|
1555
2311
|
function strays(b, radius, p, at) {
|
|
@@ -1558,26 +2314,29 @@ function strays(b, radius, p, at) {
|
|
|
1558
2314
|
const out = onHead(radius, phi, y, 1).sub(root).normalize();
|
|
1559
2315
|
const path = [
|
|
1560
2316
|
root,
|
|
1561
|
-
root.clone().addScaledVector(out, 0.065).add(new
|
|
1562
|
-
root.clone().addScaledVector(out, 0.1).add(new
|
|
2317
|
+
root.clone().addScaledVector(out, 0.065).add(new Vector32(Math.cos(phi) * 0.025, -length * 0.35, 0)),
|
|
2318
|
+
root.clone().addScaledVector(out, 0.1).add(new Vector32(Math.sin(phi * 3.1) * 0.055, -length, Math.cos(phi * 2.3) * 0.03))
|
|
1563
2319
|
];
|
|
1564
|
-
|
|
2320
|
+
add2(b, p, clump(path, 0.028, 0.012, 1, 0.4));
|
|
1565
2321
|
}
|
|
1566
2322
|
}
|
|
1567
2323
|
function ahoge(b, p, lean = 1, size = 1) {
|
|
1568
|
-
const crown2 = new
|
|
2324
|
+
const crown2 = new Vector32(0.02 * lean, TOP + 0.035, -0.02);
|
|
1569
2325
|
const made = clump([
|
|
1570
2326
|
crown2,
|
|
1571
|
-
crown2.clone().add(new
|
|
1572
|
-
crown2.clone().add(new
|
|
1573
|
-
crown2.clone().add(new
|
|
2327
|
+
crown2.clone().add(new Vector32(0.03 * lean * size, 0.13 * size, 0.03)),
|
|
2328
|
+
crown2.clone().add(new Vector32(0.09 * lean * size, 0.19 * size, 0.08)),
|
|
2329
|
+
crown2.clone().add(new Vector32(0.15 * lean * size, 0.14 * size, 0.11))
|
|
1574
2330
|
], 0.038 * size, 0.016 * size);
|
|
1575
|
-
|
|
2331
|
+
add2(b, p, made);
|
|
1576
2332
|
const swing = swinger(made);
|
|
1577
|
-
const spring = new Spring(
|
|
2333
|
+
const spring = new Spring(75, 2.4);
|
|
2334
|
+
const sideSpring = new Spring(65, 2.6);
|
|
1578
2335
|
return (_clock, delta, raw) => {
|
|
1579
2336
|
const motion = calm(raw);
|
|
1580
|
-
|
|
2337
|
+
const p2 = spring.step(clamp(motion.lift * 0.65 - motion.swayZ * 0.35, -1, 1), delta);
|
|
2338
|
+
const r = sideSpring.step(clamp(-motion.yaw * 0.08 - motion.swayX * 0.45, -0.9, 0.9), delta);
|
|
2339
|
+
swing(p2, r);
|
|
1581
2340
|
};
|
|
1582
2341
|
}
|
|
1583
2342
|
function back(b, radius, p, {
|
|
@@ -1614,21 +2373,21 @@ function back(b, radius, p, {
|
|
|
1614
2373
|
path.push(onHead(radius, phi + s + turn, y, gap));
|
|
1615
2374
|
}
|
|
1616
2375
|
const twist = (i % 3 === 0 ? 0.85 : i % 3 === 1 ? -0.55 : 0.25) * (blunt ? 0.25 : 1);
|
|
1617
|
-
made.push(
|
|
2376
|
+
made.push(add2(b, p, clump(path, width * (0.86 + vary * 0.34) * (under ? 1.08 : 0.92), width * 0.38, blunt ? 0.56 : 1, twist)));
|
|
1618
2377
|
}
|
|
1619
2378
|
}
|
|
1620
2379
|
return made;
|
|
1621
2380
|
}
|
|
1622
2381
|
function hangs(made) {
|
|
1623
2382
|
const swings = made.map(swinger);
|
|
1624
|
-
const pitch = new Spring(
|
|
1625
|
-
const roll = new Spring(
|
|
2383
|
+
const pitch = new Spring(58, 2.7);
|
|
2384
|
+
const roll = new Spring(52, 2.5);
|
|
1626
2385
|
return (clock, delta, raw) => {
|
|
1627
2386
|
const motion = calm(raw);
|
|
1628
|
-
const p = pitch.step(clamp(motion.lift * 0.
|
|
1629
|
-
const r = roll.step(-motion.yaw * 0.
|
|
2387
|
+
const p = pitch.step(clamp(motion.lift * 0.32 - motion.swayZ * 0.25, -0.85, 0.85), delta);
|
|
2388
|
+
const r = roll.step(clamp(-motion.yaw * 0.1 - motion.swayX * 0.38 + Math.sin(clock * 1.4) * 0.035, -0.85, 0.85), delta);
|
|
1630
2389
|
swings.forEach((swing, i) => {
|
|
1631
|
-
swing(p * (1 + i % 3 * 0.
|
|
2390
|
+
swing(p * (1 + i % 3 * 0.14), r * (1 + i % 2 * 0.18));
|
|
1632
2391
|
});
|
|
1633
2392
|
};
|
|
1634
2393
|
}
|
|
@@ -1662,7 +2421,7 @@ function ringlet(origin, length, spiralR, turns, dir) {
|
|
|
1662
2421
|
const t = k / steps;
|
|
1663
2422
|
const a = t * turns * Math.PI * 2 * dir;
|
|
1664
2423
|
const r = spiralR * (0.35 + 0.75 * Math.sin(t * Math.PI * 0.85));
|
|
1665
|
-
pts.push(new
|
|
2424
|
+
pts.push(new Vector32(origin.x + Math.cos(a) * r + dir * t * 0.08, origin.y - t * length, origin.z + Math.sin(a) * r + t * 0.04));
|
|
1666
2425
|
}
|
|
1667
2426
|
return pts;
|
|
1668
2427
|
}
|
|
@@ -1677,9 +2436,9 @@ function ribbon(b, at, facing, color, size = 1) {
|
|
|
1677
2436
|
parent: node
|
|
1678
2437
|
});
|
|
1679
2438
|
const end = clump([
|
|
1680
|
-
new
|
|
1681
|
-
new
|
|
1682
|
-
new
|
|
2439
|
+
new Vector32(side * 0.01, -0.01, 0.01),
|
|
2440
|
+
new Vector32(side * 0.038, -0.065, 0.014),
|
|
2441
|
+
new Vector32(side * 0.034, -0.13, 0.008)
|
|
1683
2442
|
], 0.024, 0.006, 0.5);
|
|
1684
2443
|
b.add(end.geometry, color, { parent: node });
|
|
1685
2444
|
}
|
|
@@ -1925,8 +2684,8 @@ var HAIR = {
|
|
|
1925
2684
|
const curls = [];
|
|
1926
2685
|
for (const side of [-1, 1]) {
|
|
1927
2686
|
const origin = onHead(radius, side * 1.18, 0.58, 0.12);
|
|
1928
|
-
curls.push(
|
|
1929
|
-
curls.push(
|
|
2687
|
+
curls.push(add2(b, p, clump(ringlet(origin, 0.92, 0.095, 2.3, side), 0.1, 0.062, 1, side * 1.2)));
|
|
2688
|
+
curls.push(add2(b, p, clump(ringlet(origin.clone().add(new Vector32(side * 0.04, -0.04, -0.06)), 0.78, 0.08, 2, -side), 0.075, 0.045, 1, -side * 0.9)));
|
|
1930
2689
|
}
|
|
1931
2690
|
ribbon(b, onHead(radius, Math.PI, 0.84, 0.12), Math.PI, "#ffffff", 1.55);
|
|
1932
2691
|
return together(ahoge(b, p, 1, 0.85), hangs([...backLocks, ...curls]));
|
|
@@ -1976,10 +2735,10 @@ var HAIR = {
|
|
|
1976
2735
|
const tiePos = onHead(radius, 0.82, 0.08, 0.2);
|
|
1977
2736
|
tiePos.y = -0.34;
|
|
1978
2737
|
ribbon(b, tiePos, 0.6, "#ff789e", 1.15);
|
|
1979
|
-
const braidTip =
|
|
2738
|
+
const braidTip = add2(b, p, clump([
|
|
1980
2739
|
tiePos.clone(),
|
|
1981
|
-
tiePos.clone().add(new
|
|
1982
|
-
tiePos.clone().add(new
|
|
2740
|
+
tiePos.clone().add(new Vector32(0.02, -0.16, 0.04)),
|
|
2741
|
+
tiePos.clone().add(new Vector32(-0.02, -0.3, 0.06))
|
|
1983
2742
|
], 0.085, 0.045, 1, 0.4));
|
|
1984
2743
|
return together(ahoge(b, p, -1, 0.85), hangs([...backLocks, braidTip]));
|
|
1985
2744
|
}
|
|
@@ -2036,8 +2795,8 @@ var HAIR = {
|
|
|
2036
2795
|
const tieY = TOP - 0.1;
|
|
2037
2796
|
const tie = onHead(radius, side * 1.28, tieY, 0.085);
|
|
2038
2797
|
for (const path of tail(radius, side * 1.28, tieY, 1.15, 0.38, 6))
|
|
2039
|
-
tails.push(
|
|
2040
|
-
ribbon(b, tie.add(new
|
|
2798
|
+
tails.push(add2(b, p, clump(path, 0.135, 0.058, 1, side * 0.75)));
|
|
2799
|
+
ribbon(b, tie.add(new Vector32(0, 0.02, 0.02)), side * 1.28, "#5bc8ff", 1.75);
|
|
2041
2800
|
}
|
|
2042
2801
|
strays(b, radius, p, [
|
|
2043
2802
|
[0.75, 0.82, 0.13],
|
|
@@ -2068,9 +2827,9 @@ var HAIR = {
|
|
|
2068
2827
|
const length = reach * 1.48;
|
|
2069
2828
|
const root = onHead(radius, phi, y, 0.03);
|
|
2070
2829
|
const out = onHead(radius, phi, y, 1).sub(root).normalize();
|
|
2071
|
-
const tip = root.clone().addScaledVector(out, length * (1 - up)).addScaledVector(UP, length * up).add(new
|
|
2830
|
+
const tip = root.clone().addScaledVector(out, length * (1 - up)).addScaledVector(UP, length * up).add(new Vector32(0, 0, -length * 0.2));
|
|
2072
2831
|
const mid = root.clone().lerp(tip, 0.45).addScaledVector(out, 0.035);
|
|
2073
|
-
|
|
2832
|
+
add2(b, p, clump([root, mid, tip], 0.15, 0.075));
|
|
2074
2833
|
}
|
|
2075
2834
|
fringe(b, radius, p, [
|
|
2076
2835
|
{ at: -0.52, length: 0.56, width: 0.125, sweep: -0.14 },
|
|
@@ -2172,7 +2931,7 @@ var HAIR = {
|
|
|
2172
2931
|
], 0.18);
|
|
2173
2932
|
sidelocks(b, radius, p, 0.24, 0.075, { curlIn: 0.24 });
|
|
2174
2933
|
const tieY = TOP + 0.01;
|
|
2175
|
-
const locks = tail(radius, Math.PI, tieY, 1.05, 0.44, 6).map((path, i) =>
|
|
2934
|
+
const locks = tail(radius, Math.PI, tieY, 1.05, 0.44, 6).map((path, i) => add2(b, p, clump(path, 0.135, 0.055, 1, (i % 2 ? 1 : -1) * 0.7)));
|
|
2176
2935
|
ribbon(b, onHead(radius, Math.PI, tieY, 0.095), Math.PI, "#e2574c", 1.25);
|
|
2177
2936
|
return together(ahoge(b, p), hangs(locks));
|
|
2178
2937
|
}
|
|
@@ -2187,9 +2946,9 @@ var HAIR = {
|
|
|
2187
2946
|
const y = s < 0.45 ? 0.82 + s * 0.3 : TOP - (s - 0.45) * 0.5;
|
|
2188
2947
|
const root = onHead(radius, phi, Math.min(y, TOP - 0.01), 0);
|
|
2189
2948
|
root.x = 0;
|
|
2190
|
-
const tip = root.clone().add(new
|
|
2191
|
-
const mid = root.clone().lerp(tip, 0.5).add(new
|
|
2192
|
-
|
|
2949
|
+
const tip = root.clone().add(new Vector32(0, 0.22 - Math.abs(s - 0.4) * 0.14, 0)).add(new Vector32(0, 0, -0.08 - s * 0.05));
|
|
2950
|
+
const mid = root.clone().lerp(tip, 0.5).add(new Vector32(0, 0.02, 0.02));
|
|
2951
|
+
add2(b, p, clump([root, mid, tip], 0.032, 0.095));
|
|
2193
2952
|
}
|
|
2194
2953
|
return;
|
|
2195
2954
|
}
|
|
@@ -2209,18 +2968,18 @@ var HAIR = {
|
|
|
2209
2968
|
sidelocks(b, radius, p, 0.22, 0.072, { curlIn: 0.24 });
|
|
2210
2969
|
const tufts = [];
|
|
2211
2970
|
for (const side of [-1, 1]) {
|
|
2212
|
-
const at = onHead(radius, side * 0.9, TOP - 0.08, 0.11).add(new
|
|
2971
|
+
const at = onHead(radius, side * 0.9, TOP - 0.08, 0.11).add(new Vector32(0, 0.05, 0));
|
|
2213
2972
|
const coil = [];
|
|
2214
2973
|
for (let k = 0;k <= 14; k += 1) {
|
|
2215
2974
|
const a = k * 0.9;
|
|
2216
2975
|
const r = 0.115 - k * 0.004;
|
|
2217
|
-
coil.push(new
|
|
2976
|
+
coil.push(new Vector32(at.x + Math.cos(a) * r, at.y + (k / 14 - 0.5) * 0.12, at.z + Math.sin(a) * r));
|
|
2218
2977
|
}
|
|
2219
2978
|
b.add(new SphereGeometry2(0.105, 20, 16), p.color, { at: [at.x, at.y, at.z] }, { anime: { center: [at.x, at.y, at.z], ring: 0.8, tip: p.tip, inner: p.inner } });
|
|
2220
|
-
|
|
2221
|
-
ribbon(b, at.clone().add(new
|
|
2979
|
+
add2(b, p, clump(coil, 0.065, 0.038, 0.7));
|
|
2980
|
+
ribbon(b, at.clone().add(new Vector32(0, -0.07, 0.06)), side * 0.9, "#ffd84d", 0.88);
|
|
2222
2981
|
for (const path of tail(radius, side * 1.05, TOP - 0.16, 0.48, 0.24, 3))
|
|
2223
|
-
tufts.push(
|
|
2982
|
+
tufts.push(add2(b, p, clump(path, 0.085, 0.034)));
|
|
2224
2983
|
}
|
|
2225
2984
|
return hangs(tufts);
|
|
2226
2985
|
}
|
|
@@ -2267,6 +3026,241 @@ function buildWear(key, kit) {
|
|
|
2267
3026
|
return isHairKey(key) ? buildHair(key, kit) : buildGarment(key, kit);
|
|
2268
3027
|
}
|
|
2269
3028
|
|
|
3029
|
+
// src/ik-skeleton.ts
|
|
3030
|
+
import { Euler, Matrix4, Quaternion, Vector3 as Vector33 } from "three";
|
|
3031
|
+
var SKELETON_JOINTS = [
|
|
3032
|
+
"pelvis",
|
|
3033
|
+
"spine",
|
|
3034
|
+
"neck",
|
|
3035
|
+
"head",
|
|
3036
|
+
"shoulder_l",
|
|
3037
|
+
"elbow_l",
|
|
3038
|
+
"wrist_l",
|
|
3039
|
+
"shoulder_r",
|
|
3040
|
+
"elbow_r",
|
|
3041
|
+
"wrist_r",
|
|
3042
|
+
"hip_l",
|
|
3043
|
+
"knee_l",
|
|
3044
|
+
"ankle_l",
|
|
3045
|
+
"toe_l",
|
|
3046
|
+
"hip_r",
|
|
3047
|
+
"knee_r",
|
|
3048
|
+
"ankle_r",
|
|
3049
|
+
"toe_r"
|
|
3050
|
+
];
|
|
3051
|
+
var UP2 = new Vector33(0, 1, 0);
|
|
3052
|
+
var FWD = new Vector33(0, 0, 1);
|
|
3053
|
+
var DOWN = new Vector33(0, -1, 0);
|
|
3054
|
+
var QI = new Quaternion;
|
|
3055
|
+
var clamp2 = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
3056
|
+
function solveTwoBoneIK(a, target, len1, len2, poleDir) {
|
|
3057
|
+
const dir = target.clone().sub(a);
|
|
3058
|
+
const rawDist = dir.length();
|
|
3059
|
+
const minReach = Math.abs(len1 - len2) + 0.001;
|
|
3060
|
+
const maxReach = (len1 + len2) * 0.996;
|
|
3061
|
+
const d = clamp2(rawDist, minReach, maxReach);
|
|
3062
|
+
const u = rawDist > 0.00001 ? dir.divideScalar(rawDist) : DOWN.clone();
|
|
3063
|
+
const end = a.clone().addScaledVector(u, d);
|
|
3064
|
+
const along = (len1 * len1 - len2 * len2 + d * d) / (2 * d);
|
|
3065
|
+
const perpSq = Math.max(0, len1 * len1 - along * along);
|
|
3066
|
+
const perp = Math.sqrt(perpSq);
|
|
3067
|
+
const p = poleDir.clone().addScaledVector(u, -poleDir.dot(u));
|
|
3068
|
+
if (p.lengthSq() < 0.000001) {
|
|
3069
|
+
p.set(0, 0, 1).addScaledVector(u, -u.z);
|
|
3070
|
+
if (p.lengthSq() < 0.000001)
|
|
3071
|
+
p.set(1, 0, 0);
|
|
3072
|
+
}
|
|
3073
|
+
p.normalize();
|
|
3074
|
+
const mid = a.clone().addScaledVector(u, along).addScaledVector(p, perp);
|
|
3075
|
+
return { mid, end };
|
|
3076
|
+
}
|
|
3077
|
+
function basisQuat(leftVec, upVec) {
|
|
3078
|
+
const x = leftVec.clone().normalize();
|
|
3079
|
+
const y = upVec.clone().addScaledVector(x, -x.dot(upVec));
|
|
3080
|
+
if (y.lengthSq() < 0.000001)
|
|
3081
|
+
y.copy(UP2);
|
|
3082
|
+
y.normalize();
|
|
3083
|
+
const z = new Vector33().crossVectors(x, y).normalize();
|
|
3084
|
+
x.crossVectors(y, z).normalize();
|
|
3085
|
+
const m = new Matrix4().makeBasis(x, y, z);
|
|
3086
|
+
return new Quaternion().setFromRotationMatrix(m);
|
|
3087
|
+
}
|
|
3088
|
+
function calmTilt(q, keepTilt) {
|
|
3089
|
+
const f = FWD.clone().applyQuaternion(q);
|
|
3090
|
+
const yaw = new Quaternion().setFromAxisAngle(UP2, Math.atan2(f.x, f.z));
|
|
3091
|
+
const local = yaw.clone().invert().multiply(q);
|
|
3092
|
+
return yaw.multiply(QI.clone().slerp(local, keepTilt));
|
|
3093
|
+
}
|
|
3094
|
+
function pushOutOfTorso(pt, metrics) {
|
|
3095
|
+
const dy = pt.y - metrics.torsoCenterY;
|
|
3096
|
+
const halfH = metrics.isClassic ? 0.56 : 0.42;
|
|
3097
|
+
if (Math.abs(dy) > halfH * 1.05)
|
|
3098
|
+
return pt;
|
|
3099
|
+
const yn = clamp2(dy / halfH, -0.99, 0.99);
|
|
3100
|
+
const profile = Math.sqrt(Math.max(0.05, 1 - yn * yn));
|
|
3101
|
+
const rx = metrics.torsoRadiusX * profile + 0.045;
|
|
3102
|
+
const rz = metrics.torsoRadiusZ * profile + 0.045;
|
|
3103
|
+
const e = Math.hypot(pt.x / rx, pt.z / rz);
|
|
3104
|
+
if (e >= 1)
|
|
3105
|
+
return pt;
|
|
3106
|
+
const out = pt.clone();
|
|
3107
|
+
if (e < 0.0001) {
|
|
3108
|
+
out.z = rz;
|
|
3109
|
+
} else {
|
|
3110
|
+
out.x /= e;
|
|
3111
|
+
out.z /= e;
|
|
3112
|
+
}
|
|
3113
|
+
return out;
|
|
3114
|
+
}
|
|
3115
|
+
function sampleBakedJoints(clip2, seconds) {
|
|
3116
|
+
const stride = clip2.sendi.length * 3;
|
|
3117
|
+
const frameCount = Math.max(1, Math.floor(clip2.data.length / stride));
|
|
3118
|
+
const dur = clip2.durasi > 0 ? clip2.durasi : (frameCount - 1) / Math.max(1, clip2.fps);
|
|
3119
|
+
const tSec = clip2.loop ? (seconds % dur + dur) % dur : clamp2(seconds, 0, Math.max(0, dur - 0.0001));
|
|
3120
|
+
const fPos = tSec / Math.max(0.0001, dur) * (frameCount - 1);
|
|
3121
|
+
const i1 = Math.floor(fPos);
|
|
3122
|
+
const u = fPos - i1;
|
|
3123
|
+
const wrapIdx = (i) => clip2.loop ? (i % (frameCount - 1 || 1) + (frameCount - 1 || 1)) % (frameCount - 1 || 1) : clamp2(i, 0, frameCount - 1);
|
|
3124
|
+
const i0 = wrapIdx(i1 - 1);
|
|
3125
|
+
const i2 = wrapIdx(i1 + 1);
|
|
3126
|
+
const i3 = wrapIdx(i1 + 2);
|
|
3127
|
+
const u2 = u * u;
|
|
3128
|
+
const u3 = u2 * u;
|
|
3129
|
+
const idxOf = new Map;
|
|
3130
|
+
clip2.sendi.forEach((name, idx) => idxOf.set(name, idx));
|
|
3131
|
+
const out = {};
|
|
3132
|
+
for (const name of SKELETON_JOINTS) {
|
|
3133
|
+
const j = idxOf.get(name);
|
|
3134
|
+
if (j === undefined) {
|
|
3135
|
+
out[name] = new Vector33;
|
|
3136
|
+
continue;
|
|
3137
|
+
}
|
|
3138
|
+
const read = (fi, c) => clip2.data[fi * stride + j * 3 + c] ?? 0;
|
|
3139
|
+
const cr = (c) => {
|
|
3140
|
+
const v0 = read(i0, c);
|
|
3141
|
+
const v1 = read(i1, c);
|
|
3142
|
+
const v2 = read(i2, c);
|
|
3143
|
+
const v3 = read(i3, c);
|
|
3144
|
+
return 0.5 * (2 * v1 + (-v0 + v2) * u + (2 * v0 - 5 * v1 + 4 * v2 - v3) * u2 + (-v0 + 3 * v1 - 3 * v2 + v3) * u3);
|
|
3145
|
+
};
|
|
3146
|
+
out[name] = new Vector33(cr(0), cr(1), cr(2));
|
|
3147
|
+
}
|
|
3148
|
+
return out;
|
|
3149
|
+
}
|
|
3150
|
+
function retarget18JointPose(F, m) {
|
|
3151
|
+
const srcLegL = F.hip_l.distanceTo(F.knee_l) + F.knee_l.distanceTo(F.ankle_l);
|
|
3152
|
+
const srcLegR = F.hip_r.distanceTo(F.knee_r) + F.knee_r.distanceTo(F.ankle_r);
|
|
3153
|
+
const srcLegLen = Math.max(0.7, (srcLegL + srcLegR) * 0.5);
|
|
3154
|
+
const legScale = m.legLength / srcLegLen;
|
|
3155
|
+
const hipMid = F.hip_l.clone().add(F.hip_r).multiplyScalar(0.5);
|
|
3156
|
+
const pelvisUp = F.spine.clone().sub(hipMid);
|
|
3157
|
+
const pelvisLeft = F.hip_l.clone().sub(F.hip_r);
|
|
3158
|
+
const rawHipsQ = basisQuat(pelvisLeft, pelvisUp);
|
|
3159
|
+
const chestUp = F.neck.clone().sub(F.spine);
|
|
3160
|
+
const chestLeft = F.shoulder_l.clone().sub(F.shoulder_r);
|
|
3161
|
+
const rawChestQ = basisQuat(chestLeft, chestUp);
|
|
3162
|
+
const torsoQ = calmTilt(rawHipsQ.clone().slerp(rawChestQ, 0.55), m.isClassic ? 0.42 : 0.56);
|
|
3163
|
+
const invTorsoQ = torsoQ.clone().invert();
|
|
3164
|
+
const headUp = F.head.clone().sub(F.neck);
|
|
3165
|
+
const headWorldQ = calmTilt(basisQuat(chestLeft, headUp), 0.55);
|
|
3166
|
+
const headQ = calmTilt(invTorsoQ.clone().multiply(headWorldQ), 0.72);
|
|
3167
|
+
const soleH = m.isClassic ? 0.055 : 0.045;
|
|
3168
|
+
const minSrcAnkleY = Math.min(F.ankle_l.y, F.ankle_r.y);
|
|
3169
|
+
const airLift = Math.max(0, minSrcAnkleY - 0.095) * legScale;
|
|
3170
|
+
const hipAboveStance = Math.max(0.24, hipMid.y - minSrcAnkleY) * legScale;
|
|
3171
|
+
const pelvisWorldY = soleH + airLift + hipAboveStance;
|
|
3172
|
+
const rootPos = new Vector33(hipMid.x * legScale * (m.isClassic ? 0.75 : 0.92), Math.max(0.01, pelvisWorldY - m.hipLocalY), hipMid.z * legScale * 0.65);
|
|
3173
|
+
const worldToLocal = (w) => w.clone().sub(rootPos).applyQuaternion(invTorsoQ);
|
|
3174
|
+
const solveLeg = (srcSide, anchorX) => {
|
|
3175
|
+
const hipLocal = new Vector33(anchorX, m.hipLocalY, 0);
|
|
3176
|
+
const hipWorld = hipLocal.clone().applyQuaternion(torsoQ).add(rootPos);
|
|
3177
|
+
const srcHip = F[`hip_${srcSide}`];
|
|
3178
|
+
const srcKnee = F[`knee_${srcSide}`];
|
|
3179
|
+
const srcAnkle = F[`ankle_${srcSide}`];
|
|
3180
|
+
const srcToe = F[`toe_${srcSide}`];
|
|
3181
|
+
const ankleOffset = srcAnkle.clone().sub(srcHip).multiplyScalar(legScale);
|
|
3182
|
+
const ankleWorld = hipWorld.clone().add(ankleOffset);
|
|
3183
|
+
const floorY = soleH + Math.max(0, srcAnkle.y - 0.095) * legScale;
|
|
3184
|
+
ankleWorld.y = Math.max(soleH, floorY);
|
|
3185
|
+
const srcMid = srcHip.clone().add(srcAnkle).multiplyScalar(0.5);
|
|
3186
|
+
const poleWorld = srcKnee.clone().sub(srcMid);
|
|
3187
|
+
if (poleWorld.lengthSq() < 0.00001) {
|
|
3188
|
+
poleWorld.copy(FWD).applyQuaternion(torsoQ);
|
|
3189
|
+
}
|
|
3190
|
+
poleWorld.normalize();
|
|
3191
|
+
const thighLen = m.legLength * 0.52;
|
|
3192
|
+
const shinLen = m.legLength * 0.48;
|
|
3193
|
+
const { mid: kneeWorld, end: endWorld } = solveTwoBoneIK(hipWorld, ankleWorld, thighLen, shinLen, poleWorld);
|
|
3194
|
+
const toeDir = srcToe.clone().sub(srcAnkle);
|
|
3195
|
+
const toeLen = toeDir.length() || 1;
|
|
3196
|
+
toeDir.divideScalar(toeLen);
|
|
3197
|
+
const footPitch = clamp2(-Math.asin(clamp2(toeDir.y, -0.95, 0.95)) - 0.43, -0.7, 0.75);
|
|
3198
|
+
const footYaw = clamp2(Math.atan2(toeDir.x, Math.max(0.05, toeDir.z)), -0.8, 0.8);
|
|
3199
|
+
return {
|
|
3200
|
+
pts: [hipLocal, worldToLocal(kneeWorld), worldToLocal(endWorld)],
|
|
3201
|
+
footPitch,
|
|
3202
|
+
footYaw
|
|
3203
|
+
};
|
|
3204
|
+
};
|
|
3205
|
+
const legL = solveLeg("r", -m.hipHalfWidth);
|
|
3206
|
+
const legR = solveLeg("l", m.hipHalfWidth);
|
|
3207
|
+
const solveArm = (srcSide, anchorX) => {
|
|
3208
|
+
const shLocal = new Vector33(anchorX, m.shoulderLocalY, 0.01);
|
|
3209
|
+
const shWorld = shLocal.clone().applyQuaternion(torsoQ).add(rootPos);
|
|
3210
|
+
const srcSh = F[`shoulder_${srcSide}`];
|
|
3211
|
+
const srcEl = F[`elbow_${srcSide}`];
|
|
3212
|
+
const srcWr = F[`wrist_${srcSide}`];
|
|
3213
|
+
const uDir = srcEl.clone().sub(srcSh);
|
|
3214
|
+
const lDir = srcWr.clone().sub(srcEl);
|
|
3215
|
+
const uLen = uDir.length() || 0.29;
|
|
3216
|
+
const lLen = lDir.length() || 0.26;
|
|
3217
|
+
uDir.divideScalar(uLen);
|
|
3218
|
+
lDir.divideScalar(lLen);
|
|
3219
|
+
const upperLen = m.armLength * 0.5;
|
|
3220
|
+
const lowerLen = m.armLength * 0.5;
|
|
3221
|
+
const rawElWorld = shWorld.clone().addScaledVector(uDir, upperLen);
|
|
3222
|
+
const rawWrWorld = rawElWorld.clone().addScaledVector(lDir, lowerLen);
|
|
3223
|
+
let wrLocal = pushOutOfTorso(worldToLocal(rawWrWorld), m);
|
|
3224
|
+
const elHintLocal = pushOutOfTorso(worldToLocal(rawElWorld), m);
|
|
3225
|
+
const poleLocal = elHintLocal.clone().sub(shLocal.clone().add(wrLocal).multiplyScalar(0.5));
|
|
3226
|
+
if (poleLocal.lengthSq() < 0.00001) {
|
|
3227
|
+
poleLocal.set(Math.sign(anchorX) * 0.6, -0.4, -0.7);
|
|
3228
|
+
}
|
|
3229
|
+
poleLocal.normalize();
|
|
3230
|
+
const { mid: elLocal, end: finalWr } = solveTwoBoneIK(shLocal, wrLocal, upperLen, lowerLen, poleLocal);
|
|
3231
|
+
const clearedEl = pushOutOfTorso(elLocal, m);
|
|
3232
|
+
const elDir = clearedEl.sub(shLocal);
|
|
3233
|
+
const elFixed = elDir.lengthSq() > 0.000001 ? shLocal.clone().addScaledVector(elDir.normalize(), upperLen) : elLocal;
|
|
3234
|
+
const wrDir = finalWr.clone().sub(elFixed);
|
|
3235
|
+
wrLocal = wrDir.lengthSq() > 0.000001 ? elFixed.clone().addScaledVector(wrDir.normalize(), lowerLen) : finalWr;
|
|
3236
|
+
return [shLocal, elFixed, wrLocal];
|
|
3237
|
+
};
|
|
3238
|
+
const armL = solveArm("r", -m.shoulderHalfWidth);
|
|
3239
|
+
const armR = solveArm("l", m.shoulderHalfWidth);
|
|
3240
|
+
const dip = clamp2(1 - F.pelvis.y, -0.25, 0.45);
|
|
3241
|
+
const squash = clamp2(-dip * 0.14, -0.06, 0.05);
|
|
3242
|
+
return { rootPos, torsoQ, headQ, armL, armR, legL, legR, squash };
|
|
3243
|
+
}
|
|
3244
|
+
function aimTwoBoneLimb(upperPivot, lowerPivot, a, b, c) {
|
|
3245
|
+
upperPivot.position.copy(a);
|
|
3246
|
+
const d1 = b.clone().sub(a);
|
|
3247
|
+
const len1 = d1.length();
|
|
3248
|
+
if (len1 > 0.00001) {
|
|
3249
|
+
d1.divideScalar(len1);
|
|
3250
|
+
upperPivot.quaternion.setFromUnitVectors(DOWN, d1);
|
|
3251
|
+
}
|
|
3252
|
+
const invUpper = upperPivot.quaternion.clone().invert();
|
|
3253
|
+
const d2World = c.clone().sub(b);
|
|
3254
|
+
const len2 = d2World.length();
|
|
3255
|
+
if (len2 > 0.00001) {
|
|
3256
|
+
const d2Local = d2World.divideScalar(len2).applyQuaternion(invUpper).normalize();
|
|
3257
|
+
lowerPivot.quaternion.setFromUnitVectors(DOWN, d2Local);
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
function orientFoot(foot, pitch, yaw) {
|
|
3261
|
+
foot.quaternion.setFromEuler(new Euler(pitch, yaw, 0, "YXZ"));
|
|
3262
|
+
}
|
|
3263
|
+
|
|
2270
3264
|
// src/proportions.ts
|
|
2271
3265
|
var ARM_LENGTH = 0.3;
|
|
2272
3266
|
var BELLY_HALF_WIDTH = 0.6;
|
|
@@ -2300,15 +3294,36 @@ function pixelArtFiltering(texture) {
|
|
|
2300
3294
|
function stampFor(face, type) {
|
|
2301
3295
|
return faceStamp(type, face);
|
|
2302
3296
|
}
|
|
3297
|
+
var JIGGLE_DEFORM_GLSL = `
|
|
3298
|
+
vec3 applyJiggle(vec3 p, vec3 jiggle, vec2 band) {
|
|
3299
|
+
if (dot(jiggle, jiggle) < 1e-8) return p;
|
|
3300
|
+
float hN = clamp((p.y - band.x) / max(0.05, band.y - band.x), 0.0, 1.0);
|
|
3301
|
+
float softBell = sin(hN * 3.14159265);
|
|
3302
|
+
float topLag = hN * hN;
|
|
3303
|
+
float bustBoost = 1.0 + smoothstep(0.09, 0.28, p.z) * 0.65;
|
|
3304
|
+
vec3 q = p;
|
|
3305
|
+
q.y += jiggle.y * (0.45 * topLag + 0.55 * softBell * bustBoost);
|
|
3306
|
+
float bulge = clamp(1.0 - jiggle.y * 0.45 * softBell, 0.90, 1.12);
|
|
3307
|
+
q.x *= bulge;
|
|
3308
|
+
q.z *= bulge;
|
|
3309
|
+
q.x += jiggle.x * (0.38 * topLag + 0.62 * softBell * bustBoost);
|
|
3310
|
+
q.z += jiggle.z * (0.38 * topLag + 0.62 * softBell * bustBoost);
|
|
3311
|
+
return q;
|
|
3312
|
+
}
|
|
3313
|
+
`;
|
|
2303
3314
|
var TOON_VERTEX = `
|
|
2304
3315
|
varying vec3 vNormal;
|
|
2305
3316
|
varying vec2 vUv;
|
|
2306
3317
|
uniform vec2 uvOffset;
|
|
2307
3318
|
uniform vec2 uvRepeat;
|
|
3319
|
+
uniform vec3 uJiggle;
|
|
3320
|
+
uniform vec2 uJiggleBand;
|
|
3321
|
+
${JIGGLE_DEFORM_GLSL}
|
|
2308
3322
|
void main() {
|
|
2309
3323
|
vNormal = normalize(normalMatrix * (length(normal) > 0.001 ? normal : vec3(0.0, 0.0, 1.0)));
|
|
2310
3324
|
vUv = uv * uvRepeat + uvOffset;
|
|
2311
|
-
|
|
3325
|
+
vec3 pos = applyJiggle(position, uJiggle, uJiggleBand);
|
|
3326
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
2312
3327
|
}`;
|
|
2313
3328
|
var TOON_FRAGMENT = `
|
|
2314
3329
|
varying vec3 vNormal;
|
|
@@ -2397,7 +3412,7 @@ function taperedHose(curve, muscle, baseRadius = 0.046) {
|
|
|
2397
3412
|
const radial = 14;
|
|
2398
3413
|
const tube = new TubeGeometry(curve, segments, baseRadius, radial);
|
|
2399
3414
|
const position = tube.attributes.position;
|
|
2400
|
-
const centre = new
|
|
3415
|
+
const centre = new Vector34;
|
|
2401
3416
|
const strength = Math.max(0, muscle - 1);
|
|
2402
3417
|
const slim = muscle < 1 ? 0.72 + 0.28 * muscle : 1;
|
|
2403
3418
|
for (let i = 0;i <= segments; i += 1) {
|
|
@@ -2420,7 +3435,7 @@ function sculptedLeg(curve, hips, muscle) {
|
|
|
2420
3435
|
const radial = 14;
|
|
2421
3436
|
const tube = new TubeGeometry(curve, segments, 0.095, radial);
|
|
2422
3437
|
const position = tube.attributes.position;
|
|
2423
|
-
const centre = new
|
|
3438
|
+
const centre = new Vector34;
|
|
2424
3439
|
const thighScale = 0.88 + Math.max(0, hips - 0.85) * 0.52 + Math.max(0, muscle - 1) * 0.36;
|
|
2425
3440
|
const calfScale = 0.78 + Math.max(0, muscle - 1) * 0.34 + Math.max(0, hips - 1) * 0.14;
|
|
2426
3441
|
for (let i = 0;i <= segments; i += 1) {
|
|
@@ -2438,6 +3453,8 @@ function sculptedLeg(curve, hips, muscle) {
|
|
|
2438
3453
|
tube.computeVertexNormals();
|
|
2439
3454
|
return tube;
|
|
2440
3455
|
}
|
|
3456
|
+
var ZERO_JIGGLE = new Vector34(0, 0, 0);
|
|
3457
|
+
var DEFAULT_JIGGLE_BAND = new Vector22(0, 1);
|
|
2441
3458
|
function toon(options) {
|
|
2442
3459
|
if (options.anime)
|
|
2443
3460
|
return new ShaderMaterial({
|
|
@@ -2447,7 +3464,7 @@ function toon(options) {
|
|
|
2447
3464
|
toneMapped: false,
|
|
2448
3465
|
uniforms: {
|
|
2449
3466
|
color: { value: new Color2(options.color ?? "#ffffff") },
|
|
2450
|
-
center: { value: new
|
|
3467
|
+
center: { value: new Vector34(...options.anime.center) },
|
|
2451
3468
|
ring: { value: options.anime.ring ?? 1 },
|
|
2452
3469
|
tip: { value: new Color2(options.anime.tip ?? options.color ?? "#ffffff") },
|
|
2453
3470
|
inner: { value: new Color2(options.anime.inner ?? options.color ?? "#ffffff") }
|
|
@@ -2465,19 +3482,30 @@ function toon(options) {
|
|
|
2465
3482
|
backColor: { value: new Color2(options.back ?? options.color ?? "#ffffff") },
|
|
2466
3483
|
sheen: { value: options.sheen ?? 0 },
|
|
2467
3484
|
uvOffset: { value: [options.map?.offset.x ?? 0, 0] },
|
|
2468
|
-
uvRepeat: { value: options.repeat ?? [1, 1] }
|
|
3485
|
+
uvRepeat: { value: options.repeat ?? [1, 1] },
|
|
3486
|
+
uJiggle: { value: options.jiggle?.value ?? ZERO_JIGGLE },
|
|
3487
|
+
uJiggleBand: { value: options.jiggle?.band ?? DEFAULT_JIGGLE_BAND }
|
|
2469
3488
|
}
|
|
2470
3489
|
});
|
|
2471
3490
|
}
|
|
2472
|
-
function hull(color, width) {
|
|
3491
|
+
function hull(color, width, jiggle) {
|
|
2473
3492
|
return new ShaderMaterial({
|
|
2474
3493
|
side: BackSide,
|
|
2475
3494
|
toneMapped: false,
|
|
2476
|
-
uniforms: {
|
|
3495
|
+
uniforms: {
|
|
3496
|
+
color: { value: new Color2(color) },
|
|
3497
|
+
width: { value: width },
|
|
3498
|
+
uJiggle: { value: jiggle?.value ?? ZERO_JIGGLE },
|
|
3499
|
+
uJiggleBand: { value: jiggle?.band ?? DEFAULT_JIGGLE_BAND }
|
|
3500
|
+
},
|
|
2477
3501
|
vertexShader: `
|
|
2478
3502
|
uniform float width;
|
|
3503
|
+
uniform vec3 uJiggle;
|
|
3504
|
+
uniform vec2 uJiggleBand;
|
|
3505
|
+
${JIGGLE_DEFORM_GLSL}
|
|
2479
3506
|
void main() {
|
|
2480
|
-
|
|
3507
|
+
vec3 pos = applyJiggle(position, uJiggle, uJiggleBand);
|
|
3508
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos + normal * width, 1.0);
|
|
2481
3509
|
}`,
|
|
2482
3510
|
fragmentShader: `
|
|
2483
3511
|
uniform vec3 color;
|
|
@@ -2489,13 +3517,13 @@ void main() {
|
|
|
2489
3517
|
}
|
|
2490
3518
|
function hexChannels(hex) {
|
|
2491
3519
|
const bare = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
2492
|
-
const
|
|
2493
|
-
if (!/^[0-9a-f]{6}$/i.test(
|
|
3520
|
+
const full2 = bare.length === 3 || bare.length === 4 ? `${bare[0]}${bare[0]}${bare[1]}${bare[1]}${bare[2]}${bare[2]}` : bare.length === 6 || bare.length === 8 ? bare.slice(0, 6) : "";
|
|
3521
|
+
if (!/^[0-9a-f]{6}$/i.test(full2))
|
|
2494
3522
|
return [0, 0, 0];
|
|
2495
3523
|
return [
|
|
2496
|
-
Number.parseInt(
|
|
2497
|
-
Number.parseInt(
|
|
2498
|
-
Number.parseInt(
|
|
3524
|
+
Number.parseInt(full2.slice(0, 2), 16),
|
|
3525
|
+
Number.parseInt(full2.slice(2, 4), 16),
|
|
3526
|
+
Number.parseInt(full2.slice(4, 6), 16)
|
|
2499
3527
|
];
|
|
2500
3528
|
}
|
|
2501
3529
|
var shade = (hex, toward, amount) => `#${hexChannels(hex).map((value) => Math.max(0, Math.min(255, Math.round(value + (toward - value) * amount))).toString(16).padStart(2, "0")).join("")}`;
|
|
@@ -2603,19 +3631,16 @@ var OUTFIT_LEG_COLOR = {
|
|
|
2603
3631
|
"chibi-overalls": "#5b8ff9"
|
|
2604
3632
|
};
|
|
2605
3633
|
var inkHull = null;
|
|
2606
|
-
var neonHull = null;
|
|
2607
3634
|
var fineHull = null;
|
|
2608
3635
|
var hairHull = null;
|
|
2609
3636
|
var figureHull = null;
|
|
2610
3637
|
function createPlup(options = {}) {
|
|
2611
3638
|
inkHull ??= hull("#14102e", 0.022);
|
|
2612
3639
|
figureHull ??= hull("#1b1438", 0.013);
|
|
2613
|
-
neonHull ??= hull("#b9a6ff", 0.04);
|
|
2614
3640
|
fineHull ??= hull("#191233", 0.007);
|
|
2615
3641
|
hairHull ??= hull("#1c1433", 0.0045);
|
|
2616
3642
|
const fine = fineHull;
|
|
2617
3643
|
const ink = inkHull;
|
|
2618
|
-
const neon = neonHull;
|
|
2619
3644
|
const figureInk = figureHull;
|
|
2620
3645
|
const hairInk = hairHull;
|
|
2621
3646
|
let color = options.color ?? "#3d7bff";
|
|
@@ -2631,9 +3656,11 @@ function createPlup(options = {}) {
|
|
|
2631
3656
|
hips: build.hips,
|
|
2632
3657
|
bust: build.bust,
|
|
2633
3658
|
muscle: build.muscle,
|
|
3659
|
+
torsoHeight: build.torsoHeight,
|
|
2634
3660
|
figure: build.figure
|
|
2635
3661
|
};
|
|
2636
|
-
const
|
|
3662
|
+
const span = figureTorsoSpan(build.torsoHeight);
|
|
3663
|
+
const legRaise = isFigure ? Math.max(0.14, 0.28 + 0.16 * (build.legLength - 1)) : Math.max(0, 0.16 * (build.legLength - 1));
|
|
2637
3664
|
const canvas = document.createElement("canvas");
|
|
2638
3665
|
canvas.width = BODY_WIDTH * 4;
|
|
2639
3666
|
canvas.height = BODY_HEIGHT * 4;
|
|
@@ -2644,8 +3671,16 @@ function createPlup(options = {}) {
|
|
|
2644
3671
|
texture.wrapS = RepeatWrapping2;
|
|
2645
3672
|
texture.offset.x = (FACE_COLUMN + 4) / BODY_WIDTH - 0.25;
|
|
2646
3673
|
const anime2 = animeDecal(skin?.faceType ?? options.faceType, face, options.eyeColor, isFigure);
|
|
2647
|
-
const
|
|
2648
|
-
|
|
3674
|
+
const jiggleUniform = {
|
|
3675
|
+
value: new Vector34(0, 0, 0),
|
|
3676
|
+
band: new Vector22(isFigure ? span.minY : 0, isFigure ? span.maxY : BLOB_HEIGHT)
|
|
3677
|
+
};
|
|
3678
|
+
const torsoInkMat = hull("#1b1438", 0.013, jiggleUniform);
|
|
3679
|
+
const blobInkMat = hull("#14102e", 0.022, jiggleUniform);
|
|
3680
|
+
const blobNeonMat = hull("#b9a6ff", 0.04, jiggleUniform);
|
|
3681
|
+
const garmentInkMat = hull("#191233", 0.007, jiggleUniform);
|
|
3682
|
+
const bodyMaterial = toon({ map: texture, ...isFigure ? {} : { jiggle: jiggleUniform } });
|
|
3683
|
+
const torsoMaterial = toon({ color, jiggle: jiggleUniform });
|
|
2649
3684
|
const limbMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
|
|
2650
3685
|
const legMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
|
|
2651
3686
|
const tipMaterial = toon({ color: isFigure ? shade(color, 0, 0.12) : shade(color, 0, 0.3) });
|
|
@@ -2653,14 +3688,14 @@ function createPlup(options = {}) {
|
|
|
2653
3688
|
const root = new Group2;
|
|
2654
3689
|
const lifted = new Group2;
|
|
2655
3690
|
root.add(lifted);
|
|
2656
|
-
const headMetrics = figureHeadMetrics(build.headSize);
|
|
3691
|
+
const headMetrics = figureHeadMetrics(build.headSize, build.torsoHeight);
|
|
2657
3692
|
const geometry = isFigure ? buildFigureHeadGeometry() : buildBlobGeometry(silhouette);
|
|
2658
3693
|
const torsoGeometry = isFigure ? buildFigureTorsoGeometry(silhouette) : null;
|
|
2659
3694
|
const headGroup = new Group2;
|
|
2660
3695
|
if (!options.model) {
|
|
2661
3696
|
if (isFigure && torsoGeometry) {
|
|
2662
3697
|
const torsoMesh = new Mesh2(torsoGeometry, torsoMaterial);
|
|
2663
|
-
const torsoInk = new Mesh2(torsoGeometry,
|
|
3698
|
+
const torsoInk = new Mesh2(torsoGeometry, torsoInkMat);
|
|
2664
3699
|
lifted.add(torsoMesh, torsoInk);
|
|
2665
3700
|
headGroup.position.set(0, headMetrics.originY, 0);
|
|
2666
3701
|
headGroup.scale.setScalar(headMetrics.scale);
|
|
@@ -2676,7 +3711,7 @@ function createPlup(options = {}) {
|
|
|
2676
3711
|
lifted.add(headGroup);
|
|
2677
3712
|
} else {
|
|
2678
3713
|
const bodyMesh = new Mesh2(geometry, bodyMaterial);
|
|
2679
|
-
const blobMeshes = [bodyMesh, new Mesh2(geometry,
|
|
3714
|
+
const blobMeshes = [bodyMesh, new Mesh2(geometry, blobInkMat), new Mesh2(geometry, blobNeonMat)];
|
|
2680
3715
|
for (const mesh of blobMeshes)
|
|
2681
3716
|
mesh.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
|
|
2682
3717
|
lifted.add(...blobMeshes);
|
|
@@ -2693,13 +3728,13 @@ function createPlup(options = {}) {
|
|
|
2693
3728
|
const headWearRoot = new Group2;
|
|
2694
3729
|
const bodyWearRoot = new Group2;
|
|
2695
3730
|
if (isFigure) {
|
|
2696
|
-
|
|
2697
|
-
|
|
3731
|
+
headGroup.add(headWearRoot);
|
|
3732
|
+
lifted.add(bodyWearRoot);
|
|
2698
3733
|
} else {
|
|
2699
3734
|
headWearRoot.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
|
|
2700
3735
|
bodyWearRoot.scale.copy(headWearRoot.scale);
|
|
3736
|
+
lifted.add(headWearRoot, bodyWearRoot);
|
|
2701
3737
|
}
|
|
2702
|
-
lifted.add(headWearRoot, bodyWearRoot);
|
|
2703
3738
|
const worn = new Map;
|
|
2704
3739
|
const headKit = {
|
|
2705
3740
|
radiusAt: (y) => isFigure ? figureHeadRadiusAt(y) : blobRadiusAt(y, silhouette),
|
|
@@ -2720,17 +3755,17 @@ function createPlup(options = {}) {
|
|
|
2720
3755
|
const r = blobRadiusAt(y, silhouette) + grow;
|
|
2721
3756
|
return { x: Math.sin(phi) * r, z: Math.cos(phi) * r * (BLOB_RADIUS.z / BLOB_RADIUS.x) };
|
|
2722
3757
|
},
|
|
2723
|
-
paint: (paint, more = {}) => toon({ ...more, color: paint }),
|
|
2724
|
-
ink:
|
|
3758
|
+
paint: (paint, more = {}) => toon({ ...more, color: paint, jiggle: jiggleUniform }),
|
|
3759
|
+
ink: garmentInkMat,
|
|
2725
3760
|
hairColor: options.hairColor,
|
|
2726
3761
|
isFigure,
|
|
2727
3762
|
zones: isFigure ? {
|
|
2728
|
-
bottomY:
|
|
2729
|
-
hipY: 0.
|
|
2730
|
-
waistY:
|
|
2731
|
-
bustY:
|
|
2732
|
-
shoulderY:
|
|
2733
|
-
neckY:
|
|
3763
|
+
bottomY: span.minY,
|
|
3764
|
+
hipY: span.hipY + 0.05 * build.torsoHeight,
|
|
3765
|
+
waistY: span.waistY,
|
|
3766
|
+
bustY: span.bustY,
|
|
3767
|
+
shoulderY: span.shoulderY,
|
|
3768
|
+
neckY: span.maxY - 0.08 * build.torsoHeight
|
|
2734
3769
|
} : {
|
|
2735
3770
|
bottomY: 0.04,
|
|
2736
3771
|
hipY: 0.14,
|
|
@@ -2784,7 +3819,7 @@ function createPlup(options = {}) {
|
|
|
2784
3819
|
const limb = (name, x, y, length, tip, flat, bow2 = 0, legStyle = false) => {
|
|
2785
3820
|
const pivot = pivots[name];
|
|
2786
3821
|
pivot.position.set(x, y, 0);
|
|
2787
|
-
const curve = bow2 ? new QuadraticBezierCurve3(new
|
|
3822
|
+
const curve = bow2 ? new QuadraticBezierCurve3(new Vector34(0, 0.02, 0), new Vector34(bow2 * (legStyle ? 0.025 : 0.07), -length * 0.5, legStyle ? 0.02 : 0.03), new Vector34(bow2 * (legStyle ? 0.01 : 0.03), -length, legStyle ? 0.01 : 0.04)) : null;
|
|
2788
3823
|
const shaft = curve ? legStyle ? sculptedLeg(curve, build.hips, build.muscle) : taperedHose(curve, build.muscle, isFigure ? 0.042 : 0.046) : limbGeometry;
|
|
2789
3824
|
if (curve)
|
|
2790
3825
|
armGeometries.push(shaft);
|
|
@@ -2814,6 +3849,105 @@ function createPlup(options = {}) {
|
|
|
2814
3849
|
mesh.raycast = () => {};
|
|
2815
3850
|
lifted.add(pivot);
|
|
2816
3851
|
};
|
|
3852
|
+
const subPivots = { elbowL: null, elbowR: null, kneeL: null, kneeR: null };
|
|
3853
|
+
const shoePivots = { legL: null, legR: null };
|
|
3854
|
+
const restAnchors = {
|
|
3855
|
+
armL: new Vector34,
|
|
3856
|
+
armR: new Vector34,
|
|
3857
|
+
legL: new Vector34,
|
|
3858
|
+
legR: new Vector34
|
|
3859
|
+
};
|
|
3860
|
+
let figureLegLen = 0.44;
|
|
3861
|
+
let ikMetrics = {
|
|
3862
|
+
hipHeight: 0.56,
|
|
3863
|
+
hipHalfWidth: 0.1,
|
|
3864
|
+
hipLocalY: 0.14,
|
|
3865
|
+
shoulderHalfWidth: 0.18,
|
|
3866
|
+
shoulderLocalY: 0.5,
|
|
3867
|
+
armLength: 0.34,
|
|
3868
|
+
legLength: 0.44,
|
|
3869
|
+
torsoRadiusX: 0.18,
|
|
3870
|
+
torsoRadiusZ: 0.15,
|
|
3871
|
+
torsoCenterY: 0.35,
|
|
3872
|
+
isClassic: !isFigure
|
|
3873
|
+
};
|
|
3874
|
+
const articulatedArm = (name, elbowKey, x, y, length) => {
|
|
3875
|
+
const pivot = pivots[name];
|
|
3876
|
+
pivot.position.set(x, y, 0);
|
|
3877
|
+
const upperLen = length * 0.5;
|
|
3878
|
+
const lowerLen = length * 0.5;
|
|
3879
|
+
const mScale = build.muscle > 1 ? 1 + (build.muscle - 1) * 0.42 : 0.84 + build.muscle * 0.16;
|
|
3880
|
+
const rTop = 0.046 * mScale;
|
|
3881
|
+
const rMid = 0.04 * mScale;
|
|
3882
|
+
const rWrist = 0.03 * mScale;
|
|
3883
|
+
const upperGeo = new CylinderGeometry2(rTop, rMid, upperLen, 12, 1);
|
|
3884
|
+
upperGeo.translate(0, -upperLen / 2, 0);
|
|
3885
|
+
const jointGeo = new SphereGeometry3(rMid * 1.04, 10, 8);
|
|
3886
|
+
const lowerGeo = new CylinderGeometry2(rMid, rWrist, lowerLen, 12, 1);
|
|
3887
|
+
lowerGeo.translate(0, -lowerLen / 2, 0);
|
|
3888
|
+
armGeometries.push(upperGeo, jointGeo, lowerGeo);
|
|
3889
|
+
const upperMesh = new Mesh2(upperGeo, limbMaterial);
|
|
3890
|
+
const upperInk = new Mesh2(upperGeo, figureInk);
|
|
3891
|
+
const jointMesh = new Mesh2(jointGeo, limbMaterial);
|
|
3892
|
+
jointMesh.position.y = -upperLen;
|
|
3893
|
+
const elbow = new Group2;
|
|
3894
|
+
elbow.position.set(0, -upperLen, 0);
|
|
3895
|
+
const lowerMesh = new Mesh2(lowerGeo, limbMaterial);
|
|
3896
|
+
const lowerInk = new Mesh2(lowerGeo, figureInk);
|
|
3897
|
+
const hand = new Mesh2(handGeometry, tipMaterial);
|
|
3898
|
+
hand.position.y = -lowerLen;
|
|
3899
|
+
hand.scale.setScalar(0.92 + Math.max(0, build.muscle - 1) * 0.22);
|
|
3900
|
+
const handInk = new Mesh2(handGeometry, figureInk);
|
|
3901
|
+
handInk.position.copy(hand.position);
|
|
3902
|
+
handInk.scale.copy(hand.scale);
|
|
3903
|
+
elbow.add(lowerMesh, lowerInk, hand, handInk);
|
|
3904
|
+
pivot.add(upperMesh, upperInk, jointMesh, elbow);
|
|
3905
|
+
for (const m of [...pivot.children, ...elbow.children])
|
|
3906
|
+
m.raycast = () => {};
|
|
3907
|
+
subPivots[elbowKey] = elbow;
|
|
3908
|
+
lifted.add(pivot);
|
|
3909
|
+
};
|
|
3910
|
+
const articulatedLeg = (name, kneeKey, x, y, length) => {
|
|
3911
|
+
const pivot = pivots[name];
|
|
3912
|
+
pivot.position.set(x, y, 0);
|
|
3913
|
+
const upperLen = length * 0.52;
|
|
3914
|
+
const lowerLen = length * 0.48;
|
|
3915
|
+
const thighBoost = 1 + Math.max(0, build.hips - 1) * 0.36 + Math.max(0, build.muscle - 1) * 0.22;
|
|
3916
|
+
const compact = Math.min(1, 0.65 + 0.35 * build.torsoHeight);
|
|
3917
|
+
const rHip = 0.072 * thighBoost * compact;
|
|
3918
|
+
const rKnee = 0.048 * (0.85 + 0.15 * thighBoost) * compact;
|
|
3919
|
+
const rAnkle = 0.036 * compact;
|
|
3920
|
+
const thighGeo = new CylinderGeometry2(rHip, rKnee, upperLen, 12, 1);
|
|
3921
|
+
thighGeo.translate(0, -upperLen / 2, 0);
|
|
3922
|
+
const jointGeo = new SphereGeometry3(rKnee * 1.03, 10, 8);
|
|
3923
|
+
const shinGeo = new CylinderGeometry2(rKnee, rAnkle, lowerLen, 12, 1);
|
|
3924
|
+
shinGeo.translate(0, -lowerLen / 2, 0);
|
|
3925
|
+
armGeometries.push(thighGeo, jointGeo, shinGeo);
|
|
3926
|
+
const thighMesh = new Mesh2(thighGeo, legMaterial);
|
|
3927
|
+
const thighInk = new Mesh2(thighGeo, figureInk);
|
|
3928
|
+
const jointMesh = new Mesh2(jointGeo, legMaterial);
|
|
3929
|
+
jointMesh.position.y = -upperLen;
|
|
3930
|
+
const knee = new Group2;
|
|
3931
|
+
knee.position.set(0, -upperLen, 0);
|
|
3932
|
+
const shinMesh = new Mesh2(shinGeo, legMaterial);
|
|
3933
|
+
const shinInk = new Mesh2(shinGeo, figureInk);
|
|
3934
|
+
const shoePivot = new Group2;
|
|
3935
|
+
shoePivot.position.set(0, -lowerLen, 0);
|
|
3936
|
+
const shoe = new Mesh2(footGeometry, shoeMaterial);
|
|
3937
|
+
shoe.position.set(0, 0, 0.025 * compact);
|
|
3938
|
+
shoe.scale.set(1.02 * compact, 0.62 * compact, 1.58 * compact);
|
|
3939
|
+
const shoeInk = new Mesh2(footGeometry, figureInk);
|
|
3940
|
+
shoeInk.position.copy(shoe.position);
|
|
3941
|
+
shoeInk.scale.copy(shoe.scale);
|
|
3942
|
+
shoePivot.add(shoe, shoeInk);
|
|
3943
|
+
knee.add(shinMesh, shinInk, shoePivot);
|
|
3944
|
+
pivot.add(thighMesh, thighInk, jointMesh, knee);
|
|
3945
|
+
for (const m of [...pivot.children, ...knee.children, ...shoePivot.children])
|
|
3946
|
+
m.raycast = () => {};
|
|
3947
|
+
subPivots[kneeKey] = knee;
|
|
3948
|
+
shoePivots[name] = shoePivot;
|
|
3949
|
+
lifted.add(pivot);
|
|
3950
|
+
};
|
|
2817
3951
|
if (options.model) {
|
|
2818
3952
|
lifted.add(options.model);
|
|
2819
3953
|
for (const name of Object.keys(pivots)) {
|
|
@@ -2822,39 +3956,69 @@ function createPlup(options = {}) {
|
|
|
2822
3956
|
pivots[name] = found;
|
|
2823
3957
|
}
|
|
2824
3958
|
} else if (isFigure) {
|
|
2825
|
-
const shPt = figureTorsoPoint(
|
|
2826
|
-
const shoulderX = Math.max(0.
|
|
2827
|
-
const arm = 0.34 * build.armLength;
|
|
2828
|
-
const hipAnchorY =
|
|
3959
|
+
const shPt = figureTorsoPoint(span.shoulderY, Math.PI / 2, silhouette);
|
|
3960
|
+
const shoulderX = Math.max(0.11, shPt.x * 0.92);
|
|
3961
|
+
const arm = 0.34 * build.armLength * (0.72 + 0.28 * build.torsoHeight);
|
|
3962
|
+
const hipAnchorY = span.hipY + 0.05 * build.torsoHeight;
|
|
2829
3963
|
const hipPt = figureTorsoPoint(hipAnchorY, Math.PI / 2, silhouette);
|
|
2830
|
-
const hipX = Math.max(0.
|
|
2831
|
-
const leg = Math.max(0.
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
pivots.armL.scale.set(fit.armWidth[0]
|
|
2838
|
-
pivots.armR.scale.set(fit.armWidth[1]
|
|
3964
|
+
const hipX = Math.max(0.065, hipPt.x * 0.46);
|
|
3965
|
+
const leg = Math.max(0.24, legRaise + hipAnchorY - 0.02);
|
|
3966
|
+
figureLegLen = leg;
|
|
3967
|
+
articulatedArm("armL", "elbowL", -shoulderX, span.shoulderY, arm);
|
|
3968
|
+
articulatedArm("armR", "elbowR", shoulderX, span.shoulderY, arm);
|
|
3969
|
+
articulatedLeg("legL", "kneeL", -hipX, hipAnchorY, leg);
|
|
3970
|
+
articulatedLeg("legR", "kneeR", hipX, hipAnchorY, leg);
|
|
3971
|
+
pivots.armL.scale.set(fit.armWidth[0], 1, fit.armWidth[0]);
|
|
3972
|
+
pivots.armR.scale.set(fit.armWidth[1], 1, fit.armWidth[1]);
|
|
2839
3973
|
pivots.legL.scale.set(fit.legWidth[0], 1, fit.legWidth[0]);
|
|
2840
3974
|
pivots.legR.scale.set(fit.legWidth[1], 1, fit.legWidth[1]);
|
|
3975
|
+
ikMetrics = {
|
|
3976
|
+
hipHeight: legRaise + hipAnchorY,
|
|
3977
|
+
hipHalfWidth: hipX,
|
|
3978
|
+
hipLocalY: hipAnchorY,
|
|
3979
|
+
shoulderHalfWidth: shoulderX,
|
|
3980
|
+
shoulderLocalY: span.shoulderY,
|
|
3981
|
+
armLength: arm,
|
|
3982
|
+
legLength: leg,
|
|
3983
|
+
torsoRadiusX: Math.max(0.12, figureTorsoPoint(span.bustY, Math.PI / 2, silhouette).x),
|
|
3984
|
+
torsoRadiusZ: Math.max(0.11, figureTorsoPoint(span.bustY, 0, silhouette).z),
|
|
3985
|
+
torsoCenterY: (span.minY + span.maxY) * 0.5,
|
|
3986
|
+
isClassic: false
|
|
3987
|
+
};
|
|
2841
3988
|
} else {
|
|
2842
3989
|
const torso = fit.girth / shape.x;
|
|
2843
3990
|
const shoulderY = BLOB_HEIGHT * build.shoulderHeight;
|
|
2844
3991
|
const shoulder = blobRadiusAt(shoulderY, silhouette) * 0.92 * torso;
|
|
2845
3992
|
const arm = 0.27 * build.armLength;
|
|
2846
|
-
const
|
|
3993
|
+
const hipY = BLOB_HEIGHT * 0.18;
|
|
3994
|
+
const hip = blobRadiusAt(hipY, silhouette) * 0.42 * torso;
|
|
2847
3995
|
const leg = 0.16 * build.legLength;
|
|
2848
3996
|
limb("armL", -shoulder, shoulderY, arm, handGeometry, false, -1);
|
|
2849
3997
|
limb("armR", shoulder, shoulderY, arm, handGeometry, false, 1);
|
|
2850
3998
|
const knee = build.legLength > 1.2 ? 0.35 : 0;
|
|
2851
|
-
limb("legL", -hip,
|
|
2852
|
-
limb("legR", hip,
|
|
3999
|
+
limb("legL", -hip, hipY, leg, footGeometry, true, -knee);
|
|
4000
|
+
limb("legR", hip, hipY, leg, footGeometry, true, knee);
|
|
2853
4001
|
const bulk = build.muscle ** 0.6;
|
|
2854
4002
|
pivots.armL.scale.set(fit.armWidth[0] * bulk, 1, fit.armWidth[0] * bulk);
|
|
2855
4003
|
pivots.armR.scale.set(fit.armWidth[1] * bulk, 1, fit.armWidth[1] * bulk);
|
|
2856
4004
|
pivots.legL.scale.set(fit.legWidth[0] * bulk, 1, fit.legWidth[0] * bulk);
|
|
2857
4005
|
pivots.legR.scale.set(fit.legWidth[1] * bulk, 1, fit.legWidth[1] * bulk);
|
|
4006
|
+
ikMetrics = {
|
|
4007
|
+
hipHeight: legRaise + hipY,
|
|
4008
|
+
hipHalfWidth: hip,
|
|
4009
|
+
hipLocalY: hipY,
|
|
4010
|
+
shoulderHalfWidth: shoulder,
|
|
4011
|
+
shoulderLocalY: shoulderY,
|
|
4012
|
+
armLength: arm,
|
|
4013
|
+
legLength: leg,
|
|
4014
|
+
torsoRadiusX: blobRadiusAt(BLOB_HEIGHT * 0.45, silhouette) * torso,
|
|
4015
|
+
torsoRadiusZ: blobRadiusAt(BLOB_HEIGHT * 0.45, silhouette) * torso * (BLOB_RADIUS.z / BLOB_RADIUS.x),
|
|
4016
|
+
torsoCenterY: BLOB_HEIGHT * 0.48,
|
|
4017
|
+
isClassic: true
|
|
4018
|
+
};
|
|
4019
|
+
}
|
|
4020
|
+
for (const name of Object.keys(pivots)) {
|
|
4021
|
+
restAnchors[name].copy(pivots[name].position);
|
|
2858
4022
|
}
|
|
2859
4023
|
let shadow = null;
|
|
2860
4024
|
if (options.shadow !== false) {
|
|
@@ -2870,6 +4034,7 @@ function createPlup(options = {}) {
|
|
|
2870
4034
|
root.add(shadow);
|
|
2871
4035
|
}
|
|
2872
4036
|
let clip2 = "idle";
|
|
4037
|
+
let bakedClip = null;
|
|
2873
4038
|
let held = {};
|
|
2874
4039
|
let ragdoll = null;
|
|
2875
4040
|
let down = false;
|
|
@@ -2879,48 +4044,160 @@ function createPlup(options = {}) {
|
|
|
2879
4044
|
};
|
|
2880
4045
|
if (options.ragdoll && options.ragdoll !== "off")
|
|
2881
4046
|
ragdollOf().set(options.ragdoll);
|
|
2882
|
-
const here = new
|
|
2883
|
-
const last = new
|
|
2884
|
-
const turn = new
|
|
4047
|
+
const here = new Vector34;
|
|
4048
|
+
const last = new Vector34;
|
|
4049
|
+
const turn = new Quaternion2;
|
|
4050
|
+
const DOWN_AXIS = new Vector34(0, -1, 0);
|
|
4051
|
+
const IDENTITY_Q = new Quaternion2;
|
|
4052
|
+
const headBobQ = new Quaternion2;
|
|
4053
|
+
const clampNum = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
2885
4054
|
let tracked = false;
|
|
2886
4055
|
let seconds = 0;
|
|
2887
4056
|
let clock = 0;
|
|
2888
4057
|
let lastDelta = 0;
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
4058
|
+
let lastPosX = 0;
|
|
4059
|
+
let lastPosZ = 0;
|
|
4060
|
+
let lastRotX = 0;
|
|
4061
|
+
let lastRotZ = 0;
|
|
4062
|
+
let prevVelX = 0;
|
|
4063
|
+
let prevVelY = 0;
|
|
4064
|
+
let prevVelZ = 0;
|
|
4065
|
+
let resetKinematics = true;
|
|
4066
|
+
const jiggleX = new Spring(105, 3.4);
|
|
4067
|
+
const jiggleY = new Spring(135, 3.8);
|
|
4068
|
+
const jiggleZ = new Spring(105, 3.4);
|
|
4069
|
+
const headBobX = new Spring(85, 3.4);
|
|
4070
|
+
const headBobZ = new Spring(85, 3.2);
|
|
4071
|
+
const jiggleGain = isFigure ? 0.9 + Math.max(0, build.bust - 1) * 0.42 + Math.max(0, build.hips - 1) * 0.28 : 1.3;
|
|
4072
|
+
const danceKinematics = (active, t) => {
|
|
4073
|
+
const out = {
|
|
4074
|
+
elbowLx: -0.14,
|
|
4075
|
+
elbowLz: 0,
|
|
4076
|
+
elbowRx: -0.14,
|
|
4077
|
+
elbowRz: 0,
|
|
4078
|
+
kneeL: 0,
|
|
4079
|
+
kneeR: 0,
|
|
4080
|
+
hipX: 0,
|
|
4081
|
+
crouch: 0,
|
|
4082
|
+
squash: 0
|
|
2896
4083
|
};
|
|
4084
|
+
if (typeof active !== "string")
|
|
4085
|
+
return out;
|
|
4086
|
+
const TAU = Math.PI * 2;
|
|
4087
|
+
if (active === "walk" || active === "run") {
|
|
4088
|
+
const rate = active === "run" ? 2.4 : 1.4;
|
|
4089
|
+
const stride = Math.sin(t * rate * TAU);
|
|
4090
|
+
const bend = active === "run" ? 0.95 : 0.42;
|
|
4091
|
+
out.elbowLx = -0.25 - Math.max(0, -stride) * bend;
|
|
4092
|
+
out.elbowRx = -0.25 - Math.max(0, stride) * bend;
|
|
4093
|
+
out.kneeL = Math.max(0, stride) * (active === "run" ? 0.95 : 0.55);
|
|
4094
|
+
out.kneeR = Math.max(0, -stride) * (active === "run" ? 0.95 : 0.55);
|
|
4095
|
+
} else if (active === "dance") {
|
|
4096
|
+
const beat = 0.5 - 0.5 * Math.cos(t * 2 * TAU);
|
|
4097
|
+
out.elbowLx = -0.65 - 0.35 * beat;
|
|
4098
|
+
out.elbowRx = -0.65 - 0.35 * beat;
|
|
4099
|
+
out.kneeL = 0.38 * beat;
|
|
4100
|
+
out.kneeR = 0.38 * beat;
|
|
4101
|
+
out.hipX = Math.sin(t * TAU) * 0.08;
|
|
4102
|
+
out.crouch = 0.05 * beat;
|
|
4103
|
+
}
|
|
4104
|
+
return out;
|
|
4105
|
+
};
|
|
4106
|
+
const apply = () => {
|
|
4107
|
+
const useIk = !options.model && (bakedClip !== null || typeof clip2 === "string" && isIkDanceName(clip2));
|
|
4108
|
+
let baseSquash = 0;
|
|
4109
|
+
let clipLiftY = legRaise;
|
|
2897
4110
|
const targets = {};
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
const
|
|
2901
|
-
const
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
4111
|
+
let bodyTilt = { x: 0, z: 0 };
|
|
4112
|
+
if (useIk) {
|
|
4113
|
+
const frame = bakedClip ? sampleBakedJoints(bakedClip, seconds) : sampleIkDance(clip2, seconds);
|
|
4114
|
+
const ik = retarget18JointPose(frame, ikMetrics);
|
|
4115
|
+
lifted.quaternion.copy(ik.torsoQ);
|
|
4116
|
+
lifted.position.copy(ik.rootPos).multiplyScalar(fit.stature);
|
|
4117
|
+
clipLiftY = lifted.position.y;
|
|
4118
|
+
baseSquash = ik.squash;
|
|
4119
|
+
if (isFigure && subPivots.elbowL && subPivots.elbowR && subPivots.kneeL && subPivots.kneeR) {
|
|
4120
|
+
aimTwoBoneLimb(pivots.armL, subPivots.elbowL, ik.armL[0], ik.armL[1], ik.armL[2]);
|
|
4121
|
+
aimTwoBoneLimb(pivots.armR, subPivots.elbowR, ik.armR[0], ik.armR[1], ik.armR[2]);
|
|
4122
|
+
aimTwoBoneLimb(pivots.legL, subPivots.kneeL, ik.legL.pts[0], ik.legL.pts[1], ik.legL.pts[2]);
|
|
4123
|
+
aimTwoBoneLimb(pivots.legR, subPivots.kneeR, ik.legR.pts[0], ik.legR.pts[1], ik.legR.pts[2]);
|
|
4124
|
+
if (shoePivots.legL)
|
|
4125
|
+
orientFoot(shoePivots.legL, ik.legL.footPitch, ik.legL.footYaw);
|
|
4126
|
+
if (shoePivots.legR)
|
|
4127
|
+
orientFoot(shoePivots.legR, ik.legR.footPitch, ik.legR.footYaw);
|
|
4128
|
+
headGroup.quaternion.copy(ik.headQ);
|
|
4129
|
+
} else {
|
|
4130
|
+
const aimSingle = (pivot, from, to) => {
|
|
4131
|
+
pivot.position.copy(from);
|
|
4132
|
+
const dir = to.clone().sub(from);
|
|
4133
|
+
if (dir.lengthSq() > 0.000001)
|
|
4134
|
+
pivot.quaternion.setFromUnitVectors(DOWN_AXIS, dir.normalize());
|
|
4135
|
+
};
|
|
4136
|
+
aimSingle(pivots.armL, ik.armL[0], ik.armL[2]);
|
|
4137
|
+
aimSingle(pivots.armR, ik.armR[0], ik.armR[2]);
|
|
4138
|
+
aimSingle(pivots.legL, ik.legL.pts[0], ik.legL.pts[2]);
|
|
4139
|
+
aimSingle(pivots.legR, ik.legR.pts[0], ik.legR.pts[2]);
|
|
4140
|
+
}
|
|
4141
|
+
for (const name of Object.keys(pivots)) {
|
|
4142
|
+
targets[name] = { x: pivots[name].rotation.x, z: pivots[name].rotation.z };
|
|
4143
|
+
}
|
|
4144
|
+
bodyTilt = { x: lifted.rotation.x, z: lifted.rotation.z };
|
|
4145
|
+
} else {
|
|
4146
|
+
const pose = resolvePose("plup", mergePoses(sampleClip(clip2, seconds), held));
|
|
4147
|
+
const kin = danceKinematics(clip2, seconds);
|
|
4148
|
+
const byAlias = {
|
|
4149
|
+
armL: "LeftArm",
|
|
4150
|
+
armR: "RightArm",
|
|
4151
|
+
legL: "LeftLeg",
|
|
4152
|
+
legR: "RightLeg"
|
|
4153
|
+
};
|
|
4154
|
+
for (const name of Object.keys(pivots)) {
|
|
4155
|
+
pivots[name].position.copy(restAnchors[name]);
|
|
4156
|
+
const rotation = pose.get(byAlias[name]);
|
|
4157
|
+
const clearance = name === "armL" ? fit.armClear[0] : name === "armR" ? -fit.armClear[1] : 0;
|
|
4158
|
+
const z = rotation?.z ?? 0;
|
|
4159
|
+
const side = name === "armL" ? -1 : name === "armR" ? 1 : 0;
|
|
4160
|
+
const restAngle = isFigure ? 0.14 : 0.42;
|
|
4161
|
+
const rest = options.model ? 0 : side * restAngle * Math.max(0, 1 - Math.abs(z) / 1.4);
|
|
4162
|
+
const kneeComp = isFigure && name === "legL" ? -kin.kneeL * 0.45 : isFigure && name === "legR" ? -kin.kneeR * 0.45 : 0;
|
|
4163
|
+
const rx = (rotation?.x ?? 0) + kneeComp;
|
|
4164
|
+
pivots[name].rotation.set(rx, rotation?.y ?? 0, z + clearance + rest);
|
|
4165
|
+
targets[name] = { x: rx, z: z + clearance + rest };
|
|
4166
|
+
}
|
|
4167
|
+
if (subPivots.elbowL)
|
|
4168
|
+
subPivots.elbowL.rotation.set(kin.elbowLx, 0, kin.elbowLz);
|
|
4169
|
+
if (subPivots.elbowR)
|
|
4170
|
+
subPivots.elbowR.rotation.set(kin.elbowRx, 0, kin.elbowRz);
|
|
4171
|
+
if (subPivots.kneeL)
|
|
4172
|
+
subPivots.kneeL.rotation.set(kin.kneeL, 0, 0);
|
|
4173
|
+
if (subPivots.kneeR)
|
|
4174
|
+
subPivots.kneeR.rotation.set(kin.kneeR, 0, 0);
|
|
4175
|
+
if (shoePivots.legL)
|
|
4176
|
+
shoePivots.legL.quaternion.copy(IDENTITY_Q);
|
|
4177
|
+
if (shoePivots.legR)
|
|
4178
|
+
shoePivots.legR.quaternion.copy(IDENTITY_Q);
|
|
4179
|
+
const body = pose.get("Body");
|
|
4180
|
+
const head = pose.get("Head");
|
|
4181
|
+
lifted.rotation.set(body?.x ?? 0, body?.y ?? 0, body?.z ?? 0);
|
|
4182
|
+
if (isFigure) {
|
|
4183
|
+
headGroup.rotation.set(head?.x ?? 0, head?.y ?? 0, head?.z ?? 0);
|
|
4184
|
+
}
|
|
4185
|
+
const crouchDrop = isFigure ? kin.crouch * (figureLegLen / 0.44) : kin.crouch * 0.4;
|
|
4186
|
+
clipLiftY = Math.max(0, legRaise + clipLift(clip2, seconds) * 0.32 * fit.lift - crouchDrop);
|
|
4187
|
+
baseSquash = kin.squash;
|
|
4188
|
+
lifted.position.set(kin.hipX, clipLiftY, 0);
|
|
4189
|
+
bodyTilt = { x: body?.x ?? 0, z: body?.z ?? 0 };
|
|
4190
|
+
}
|
|
2914
4191
|
if (ragdoll) {
|
|
2915
4192
|
root.getWorldPosition(here);
|
|
2916
|
-
const
|
|
2917
|
-
const velocity = tracked ? here.clone().sub(last).divideScalar(
|
|
4193
|
+
const step = Math.max(0.001, lastDelta);
|
|
4194
|
+
const velocity = tracked ? here.clone().sub(last).divideScalar(step) : new Vector34;
|
|
2918
4195
|
last.copy(here);
|
|
2919
4196
|
tracked = true;
|
|
2920
4197
|
velocity.applyQuaternion(root.getWorldQuaternion(turn).invert());
|
|
2921
4198
|
const out = ragdoll.step(lastDelta, {
|
|
2922
4199
|
joints: targets,
|
|
2923
|
-
body:
|
|
4200
|
+
body: bodyTilt,
|
|
2924
4201
|
lift: clipLiftY,
|
|
2925
4202
|
velocity: { x: velocity.x, z: velocity.z }
|
|
2926
4203
|
});
|
|
@@ -2935,16 +4212,69 @@ function createPlup(options = {}) {
|
|
|
2935
4212
|
shadow?.position.set(out.offset.x, 0.005, out.offset.z);
|
|
2936
4213
|
down = out.down;
|
|
2937
4214
|
}
|
|
2938
|
-
const
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
4215
|
+
const yaw = root.rotation.y + (root.parent?.rotation.y ?? 0) + lifted.rotation.y;
|
|
4216
|
+
let velX = 0;
|
|
4217
|
+
let velY = 0;
|
|
4218
|
+
let velZ = 0;
|
|
4219
|
+
let yawRate = 0;
|
|
4220
|
+
if (resetKinematics || lastDelta <= 0) {
|
|
4221
|
+
lastPosX = lifted.position.x;
|
|
4222
|
+
lastLift = lifted.position.y;
|
|
4223
|
+
lastPosZ = lifted.position.z;
|
|
4224
|
+
lastYaw = yaw;
|
|
4225
|
+
lastRotX = lifted.rotation.x;
|
|
4226
|
+
lastRotZ = lifted.rotation.z;
|
|
4227
|
+
prevVelX = 0;
|
|
4228
|
+
prevVelY = 0;
|
|
4229
|
+
prevVelZ = 0;
|
|
4230
|
+
resetKinematics = false;
|
|
4231
|
+
} else {
|
|
4232
|
+
const step = Math.max(0.001, lastDelta);
|
|
4233
|
+
velX = clampNum((lifted.position.x - lastPosX) / step, -6, 6);
|
|
4234
|
+
velY = clampNum((lifted.position.y - lastLift) / step, -6, 6);
|
|
4235
|
+
velZ = clampNum((lifted.position.z - lastPosZ) / step, -6, 6);
|
|
4236
|
+
yawRate = clampNum((yaw - lastYaw) / step, -12, 12);
|
|
4237
|
+
const rotVelX = clampNum((lifted.rotation.x - lastRotX) / step, -10, 10);
|
|
4238
|
+
const rotVelZ = clampNum((lifted.rotation.z - lastRotZ) / step, -10, 10);
|
|
4239
|
+
const accX = clampNum((velX - prevVelX) / step, -32, 32);
|
|
4240
|
+
const accY = clampNum((velY - prevVelY) / step, -32, 32);
|
|
4241
|
+
const accZ = clampNum((velZ - prevVelZ) / step, -32, 32);
|
|
4242
|
+
jiggleX.kick((-accX * 0.02 + rotVelZ * 0.045) * jiggleGain);
|
|
4243
|
+
jiggleY.kick((-accY * 0.024 - Math.abs(accX) * 0.005) * jiggleGain);
|
|
4244
|
+
jiggleZ.kick((-accZ * 0.02 - rotVelX * 0.045) * jiggleGain);
|
|
4245
|
+
const jx = clampNum(jiggleX.step(-velX * 0.022 * jiggleGain, lastDelta), -0.065, 0.065);
|
|
4246
|
+
const jy = clampNum(jiggleY.step(-velY * 0.028 * jiggleGain, lastDelta), -0.075, 0.075);
|
|
4247
|
+
const jz = clampNum(jiggleZ.step(-velZ * 0.022 * jiggleGain, lastDelta), -0.065, 0.065);
|
|
4248
|
+
jiggleUniform.value.set(jx, jy, jz);
|
|
4249
|
+
if (isFigure) {
|
|
4250
|
+
headGroup.position.y = headMetrics.originY + jy * 0.35;
|
|
4251
|
+
const hPitch = clampNum(headBobX.step(-velY * 0.045 - velZ * 0.05, lastDelta), -0.16, 0.16);
|
|
4252
|
+
const hRoll = clampNum(headBobZ.step(velX * 0.065, lastDelta), -0.18, 0.18);
|
|
4253
|
+
headBobQ.set(hPitch * 0.5, 0, hRoll * 0.5, 1).normalize();
|
|
4254
|
+
headGroup.quaternion.multiply(headBobQ);
|
|
4255
|
+
}
|
|
4256
|
+
lastPosX = lifted.position.x;
|
|
4257
|
+
lastLift = lifted.position.y;
|
|
4258
|
+
lastPosZ = lifted.position.z;
|
|
4259
|
+
lastYaw = yaw;
|
|
4260
|
+
lastRotX = lifted.rotation.x;
|
|
4261
|
+
lastRotZ = lifted.rotation.z;
|
|
4262
|
+
prevVelX = velX;
|
|
4263
|
+
prevVelY = velY;
|
|
4264
|
+
prevVelZ = velZ;
|
|
4265
|
+
}
|
|
4266
|
+
const breath = Math.sin(clock * 3.2) * (isFigure ? 0.01 : 0.018) * fit.squash;
|
|
4267
|
+
const sy = clampNum(1 + breath + baseSquash + jiggleUniform.value.y * 0.55, 0.84, 1.16);
|
|
4268
|
+
const sxz = 1 / Math.sqrt(Math.max(0.75, sy));
|
|
4269
|
+
lifted.scale.set((isFigure ? 1 : shape.x) * fit.stature * sxz, (isFigure ? 1 : shape.y) * fit.stature * sy, (isFigure ? 1 : shape.x) * fit.stature * sxz);
|
|
4270
|
+
const motion = { lift: velY, yaw: yawRate, swayX: velX, swayZ: velZ };
|
|
2943
4271
|
for (const piece2 of worn.values())
|
|
2944
4272
|
piece2.tick?.(clock, lastDelta, motion);
|
|
2945
4273
|
if (shadow) {
|
|
2946
|
-
const air = Math.min(1, (lifted.position.y - legRaise) / 0.5);
|
|
4274
|
+
const air = Math.max(0, Math.min(1, (lifted.position.y - legRaise * fit.stature) / 0.5));
|
|
2947
4275
|
const shadowR = isFigure ? 0.72 : 1;
|
|
4276
|
+
shadow.position.x = lifted.position.x;
|
|
4277
|
+
shadow.position.z = lifted.position.z;
|
|
2948
4278
|
shadow.scale.set((1 - air * 0.3) * fit.stature * fit.girth * shadowR, 0.02, (0.9 - air * 0.3) * fit.stature * fit.girth * shadowR);
|
|
2949
4279
|
shadow.material.opacity = 0.4 - air * 0.18;
|
|
2950
4280
|
}
|
|
@@ -2958,17 +4288,30 @@ function createPlup(options = {}) {
|
|
|
2958
4288
|
return {
|
|
2959
4289
|
object: root,
|
|
2960
4290
|
play(next) {
|
|
2961
|
-
if (next !== clip2)
|
|
4291
|
+
if (next !== clip2 || bakedClip !== null) {
|
|
2962
4292
|
seconds = 0;
|
|
4293
|
+
resetKinematics = true;
|
|
4294
|
+
}
|
|
4295
|
+
bakedClip = null;
|
|
2963
4296
|
clip2 = next;
|
|
2964
4297
|
},
|
|
4298
|
+
playBaked(next) {
|
|
4299
|
+
if (next !== bakedClip) {
|
|
4300
|
+
seconds = 0;
|
|
4301
|
+
resetKinematics = true;
|
|
4302
|
+
}
|
|
4303
|
+
bakedClip = next;
|
|
4304
|
+
},
|
|
2965
4305
|
emote(name, custom) {
|
|
2966
4306
|
const found = custom ?? emoteOf(name);
|
|
2967
4307
|
if (!found)
|
|
2968
4308
|
return;
|
|
2969
4309
|
const next = found.anim ?? found.clip;
|
|
2970
|
-
if (next !== clip2)
|
|
4310
|
+
if (next !== clip2 || bakedClip !== null) {
|
|
2971
4311
|
seconds = 0;
|
|
4312
|
+
resetKinematics = true;
|
|
4313
|
+
}
|
|
4314
|
+
bakedClip = null;
|
|
2972
4315
|
clip2 = next;
|
|
2973
4316
|
if (found.face !== face) {
|
|
2974
4317
|
face = found.face;
|
|
@@ -2986,7 +4329,7 @@ function createPlup(options = {}) {
|
|
|
2986
4329
|
ragdollOf().set(mode);
|
|
2987
4330
|
},
|
|
2988
4331
|
push(x, y, z) {
|
|
2989
|
-
const local = new
|
|
4332
|
+
const local = new Vector34(x, y, z).applyQuaternion(root.getWorldQuaternion(turn).invert());
|
|
2990
4333
|
ragdollOf().push(local.x, local.y, local.z);
|
|
2991
4334
|
},
|
|
2992
4335
|
isDown: () => down,
|
|
@@ -3034,6 +4377,10 @@ function createPlup(options = {}) {
|
|
|
3034
4377
|
anime2?.material.dispose();
|
|
3035
4378
|
bodyMaterial.dispose();
|
|
3036
4379
|
torsoMaterial.dispose();
|
|
4380
|
+
torsoInkMat.dispose();
|
|
4381
|
+
blobInkMat.dispose();
|
|
4382
|
+
blobNeonMat.dispose();
|
|
4383
|
+
garmentInkMat.dispose();
|
|
3037
4384
|
limbMaterial.dispose();
|
|
3038
4385
|
legMaterial.dispose();
|
|
3039
4386
|
tipMaterial.dispose();
|
|
@@ -3174,7 +4521,13 @@ function createCharacter(rigId = "plup", look = { bodyColor: "#3d7bff" }, bodySc
|
|
|
3174
4521
|
export {
|
|
3175
4522
|
wearSlotOf,
|
|
3176
4523
|
toon,
|
|
4524
|
+
solveTwoBoneIK,
|
|
4525
|
+
sampleIkDance,
|
|
4526
|
+
sampleBakedJoints,
|
|
4527
|
+
retarget18JointPose,
|
|
4528
|
+
orientFoot,
|
|
3177
4529
|
isWearKey,
|
|
4530
|
+
isIkDanceName,
|
|
3178
4531
|
isHighResFace,
|
|
3179
4532
|
isHairKey,
|
|
3180
4533
|
hairVolume,
|
|
@@ -3187,7 +4540,9 @@ export {
|
|
|
3187
4540
|
buildFigureHeadGeometry,
|
|
3188
4541
|
buildBlobGeometry,
|
|
3189
4542
|
blobRadiusAt,
|
|
4543
|
+
aimTwoBoneLimb,
|
|
3190
4544
|
WEARABLES,
|
|
4545
|
+
SKELETON_JOINTS,
|
|
3191
4546
|
EMOTES,
|
|
3192
4547
|
BODY_PRESETS,
|
|
3193
4548
|
AUTHORED_CLIPS,
|