@plupin/character 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anime-face.d.ts +42 -0
- package/dist/anime-face.js +14 -0
- package/dist/blob.d.ts +70 -0
- package/dist/blob.js +46 -0
- package/dist/body-presets.d.ts +153 -0
- package/dist/canvas.js +27 -8
- package/dist/chunk-7ry0n8cw.js +1209 -0
- package/dist/{chunk-k5gwaq6t.js → chunk-ew73g2v7.js} +36 -3
- package/dist/chunk-ewkkvpte.js +448 -0
- package/dist/chunk-kf7f1tdx.js +207 -0
- package/dist/chunk-nx2wbkfn.js +421 -0
- package/dist/chunk-rqenm9tn.js +487 -0
- package/dist/chunk-vy9w8as2.js +196 -0
- package/dist/clips.d.ts +40 -0
- package/dist/dress.d.ts +4 -0
- package/dist/emote.d.ts +5 -3
- package/dist/gaze.d.ts +81 -0
- package/dist/gaze.js +113 -0
- package/dist/hair3d.d.ts +3 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +46 -10
- package/dist/listing.d.ts +1 -1
- package/dist/listing.js +52 -16
- package/dist/platform-body-data.d.ts +9 -0
- package/dist/platform-body.d.ts +91 -0
- package/dist/plup3d.d.ts +43 -44
- package/dist/png.d.ts +23 -5
- package/dist/pose.d.ts +7 -1
- package/dist/pose.js +1 -1
- package/dist/proportions.d.ts +31 -0
- package/dist/ragdoll.d.ts +51 -0
- package/dist/resolution.d.ts +21 -0
- package/dist/skin-map.d.ts +156 -0
- package/dist/skin-map.js +57 -0
- package/dist/skin-native.d.ts +73 -6
- package/dist/texture.d.ts +8 -0
- package/dist/three.d.ts +11 -1
- package/dist/three.js +2820 -205
- package/dist/wear3d.d.ts +118 -0
- package/dist/wearables.d.ts +307 -0
- package/dist/wearables.js +26 -0
- package/package.json +21 -1
- package/dist/chunk-ae7gp5cc.js +0 -101
- package/dist/chunk-wpbgtn0y.js +0 -179
package/dist/three.js
CHANGED
|
@@ -1,143 +1,2313 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BLOB_HEIGHT,
|
|
3
|
+
BLOB_RADIUS,
|
|
4
|
+
BLOB_SEAT,
|
|
5
|
+
FIGURE_HIP_Y,
|
|
6
|
+
FIGURE_SHOULDER_Y,
|
|
7
|
+
FIGURE_TORSO_MAX_Y,
|
|
8
|
+
FIGURE_TORSO_MIN_Y,
|
|
9
|
+
blobRadiusAt,
|
|
10
|
+
buildBlobGeometry,
|
|
11
|
+
buildFigureHeadGeometry,
|
|
12
|
+
buildFigureTorsoGeometry,
|
|
13
|
+
figureHeadMetrics,
|
|
14
|
+
figureHeadRadiusAt,
|
|
15
|
+
figureTorsoPoint,
|
|
16
|
+
figureTorsoRadiusAt
|
|
17
|
+
} from "./chunk-vy9w8as2.js";
|
|
18
|
+
import {
|
|
19
|
+
ANIME_FACE_SIZE,
|
|
20
|
+
ANIME_FACE_UV,
|
|
21
|
+
drawAnimeFace
|
|
22
|
+
} from "./chunk-ewkkvpte.js";
|
|
23
|
+
import {
|
|
24
|
+
BODY_PRESETS,
|
|
25
|
+
EMOTES,
|
|
26
|
+
RAGDOLL_JOINTS,
|
|
27
|
+
createRagdoll,
|
|
2
28
|
emoteOf
|
|
3
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-rqenm9tn.js";
|
|
30
|
+
import {
|
|
31
|
+
WEARABLES,
|
|
32
|
+
hairVolume,
|
|
33
|
+
isHairKey,
|
|
34
|
+
isWearKey,
|
|
35
|
+
wearSlotOf
|
|
36
|
+
} from "./chunk-kf7f1tdx.js";
|
|
4
37
|
import {
|
|
5
38
|
boneSkin,
|
|
6
39
|
clampBodyScale,
|
|
40
|
+
clampPlupBody,
|
|
7
41
|
nativePartOf,
|
|
8
42
|
scaleBone
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
FACE_STAMP_PALETTE,
|
|
12
|
-
NAMED_FACE_STAMPS
|
|
13
|
-
} from "./chunk-aa5nstet.js";
|
|
43
|
+
} from "./chunk-ew73g2v7.js";
|
|
14
44
|
import {
|
|
45
|
+
AUTHORED_CLIPS,
|
|
15
46
|
RIGS,
|
|
16
47
|
clipLift,
|
|
17
48
|
mergePoses,
|
|
18
49
|
resolvePose,
|
|
19
50
|
sampleClip
|
|
20
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-7ry0n8cw.js";
|
|
52
|
+
import {
|
|
53
|
+
BODY_HEIGHT,
|
|
54
|
+
BODY_SHAPES,
|
|
55
|
+
BODY_WIDTH,
|
|
56
|
+
FACE_COLUMN,
|
|
57
|
+
FACE_ROW,
|
|
58
|
+
SKIN_PALETTE,
|
|
59
|
+
faceStamp,
|
|
60
|
+
isHighResFace
|
|
61
|
+
} from "./chunk-nx2wbkfn.js";
|
|
62
|
+
import {
|
|
63
|
+
FACE_STAMP_PALETTE
|
|
64
|
+
} from "./chunk-aa5nstet.js";
|
|
21
65
|
|
|
22
66
|
// src/three.ts
|
|
23
67
|
import {
|
|
24
|
-
BoxGeometry,
|
|
25
|
-
CanvasTexture as
|
|
26
|
-
Group as
|
|
27
|
-
Mesh as
|
|
68
|
+
BoxGeometry as BoxGeometry2,
|
|
69
|
+
CanvasTexture as CanvasTexture3,
|
|
70
|
+
Group as Group3,
|
|
71
|
+
Mesh as Mesh3,
|
|
28
72
|
MeshStandardMaterial,
|
|
29
|
-
|
|
30
|
-
SRGBColorSpace as SRGBColorSpace2
|
|
73
|
+
SRGBColorSpace as SRGBColorSpace3
|
|
31
74
|
} from "three";
|
|
32
75
|
|
|
33
76
|
// src/plup3d.ts
|
|
34
77
|
import {
|
|
35
78
|
BackSide,
|
|
36
|
-
CanvasTexture,
|
|
79
|
+
CanvasTexture as CanvasTexture2,
|
|
37
80
|
CapsuleGeometry,
|
|
81
|
+
Color as Color2,
|
|
82
|
+
DoubleSide,
|
|
83
|
+
Group as Group2,
|
|
84
|
+
Mesh as Mesh2,
|
|
85
|
+
MeshBasicMaterial as MeshBasicMaterial2,
|
|
86
|
+
QuadraticBezierCurve3,
|
|
87
|
+
Quaternion,
|
|
88
|
+
RepeatWrapping as RepeatWrapping2,
|
|
89
|
+
ShaderMaterial,
|
|
90
|
+
SphereGeometry as SphereGeometry3,
|
|
91
|
+
SRGBColorSpace as SRGBColorSpace2,
|
|
92
|
+
TubeGeometry,
|
|
93
|
+
Vector3 as Vector32
|
|
94
|
+
} from "three";
|
|
95
|
+
|
|
96
|
+
// src/hair3d.ts
|
|
97
|
+
import {
|
|
98
|
+
BoxGeometry,
|
|
99
|
+
BufferAttribute as BufferAttribute2,
|
|
100
|
+
BufferGeometry as BufferGeometry2,
|
|
101
|
+
CatmullRomCurve3,
|
|
102
|
+
SphereGeometry as SphereGeometry2,
|
|
103
|
+
TorusGeometry as TorusGeometry2,
|
|
104
|
+
Vector3
|
|
105
|
+
} from "three";
|
|
106
|
+
|
|
107
|
+
// src/wear3d.ts
|
|
108
|
+
import {
|
|
109
|
+
AdditiveBlending,
|
|
110
|
+
BufferAttribute,
|
|
111
|
+
BufferGeometry,
|
|
112
|
+
CanvasTexture,
|
|
38
113
|
Color,
|
|
114
|
+
ConeGeometry,
|
|
115
|
+
CylinderGeometry,
|
|
116
|
+
ExtrudeGeometry,
|
|
39
117
|
Group,
|
|
118
|
+
IcosahedronGeometry,
|
|
119
|
+
LatheGeometry,
|
|
120
|
+
LinearFilter,
|
|
40
121
|
Mesh,
|
|
41
122
|
MeshBasicMaterial,
|
|
42
|
-
|
|
123
|
+
OctahedronGeometry,
|
|
43
124
|
RepeatWrapping,
|
|
44
|
-
|
|
125
|
+
Shape,
|
|
45
126
|
SphereGeometry,
|
|
46
|
-
SRGBColorSpace
|
|
127
|
+
SRGBColorSpace,
|
|
128
|
+
TorusGeometry,
|
|
129
|
+
Vector2
|
|
47
130
|
} from "three";
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
131
|
+
var DEFAULT_ZONES = {
|
|
132
|
+
bottomY: 0.04,
|
|
133
|
+
hipY: 0.14,
|
|
134
|
+
waistY: 0.26,
|
|
135
|
+
bustY: 0.36,
|
|
136
|
+
shoulderY: 0.42,
|
|
137
|
+
neckY: 0.28
|
|
138
|
+
};
|
|
139
|
+
function zonesOf(kit) {
|
|
140
|
+
return kit.zones ?? DEFAULT_ZONES;
|
|
141
|
+
}
|
|
142
|
+
function surfaceOf(kit) {
|
|
143
|
+
if (kit.surfaceAt)
|
|
144
|
+
return kit.surfaceAt;
|
|
145
|
+
const R = kit.radiusAt;
|
|
146
|
+
return (y, phi, grow = 0) => {
|
|
147
|
+
const r = R(y) + grow;
|
|
148
|
+
return { x: Math.sin(phi) * r, z: Math.cos(phi) * r * DEPTH };
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var DEPTH = BLOB_RADIUS.z / BLOB_RADIUS.x;
|
|
152
|
+
var TOP = BLOB_HEIGHT;
|
|
153
|
+
var EYES_Y = 0.53;
|
|
154
|
+
var COLLAR_Y = 0.27;
|
|
155
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
156
|
+
var smooth = (edge0, edge1, x) => {
|
|
157
|
+
const t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
|
|
158
|
+
return t * t * (3 - 2 * t);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
class Spring {
|
|
162
|
+
stiffness;
|
|
163
|
+
damping;
|
|
164
|
+
value = 0;
|
|
165
|
+
velocity = 0;
|
|
166
|
+
constructor(stiffness, damping, start = 0) {
|
|
167
|
+
this.stiffness = stiffness;
|
|
168
|
+
this.damping = damping;
|
|
169
|
+
this.value = start;
|
|
170
|
+
}
|
|
171
|
+
step(target, delta) {
|
|
172
|
+
const dt = Math.min(delta, 1 / 30);
|
|
173
|
+
const force = this.stiffness * (target - this.value) - this.damping * this.velocity;
|
|
174
|
+
this.velocity += force * dt;
|
|
175
|
+
this.value += this.velocity * dt;
|
|
176
|
+
return this.value;
|
|
177
|
+
}
|
|
178
|
+
kick(amount) {
|
|
179
|
+
this.velocity += amount;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var calm = (motion) => ({
|
|
183
|
+
lift: clamp(motion.lift, -4, 4),
|
|
184
|
+
yaw: clamp(motion.yaw, -8, 8)
|
|
185
|
+
});
|
|
186
|
+
function canvasTexture(size, draw) {
|
|
187
|
+
const canvas = document.createElement("canvas");
|
|
188
|
+
canvas.width = canvas.height = size;
|
|
189
|
+
const ctx = canvas.getContext("2d");
|
|
190
|
+
if (ctx)
|
|
191
|
+
draw(ctx, size);
|
|
192
|
+
const texture = new CanvasTexture(canvas);
|
|
193
|
+
texture.colorSpace = SRGBColorSpace;
|
|
194
|
+
texture.wrapS = texture.wrapT = RepeatWrapping;
|
|
195
|
+
texture.magFilter = LinearFilter;
|
|
196
|
+
return texture;
|
|
197
|
+
}
|
|
198
|
+
function tartan(ground, band, line) {
|
|
199
|
+
return canvasTexture(128, (ctx, size) => {
|
|
200
|
+
ctx.fillStyle = ground;
|
|
201
|
+
ctx.fillRect(0, 0, size, size);
|
|
202
|
+
ctx.globalAlpha = 0.55;
|
|
203
|
+
ctx.fillStyle = band;
|
|
204
|
+
for (const at of [0, 64]) {
|
|
205
|
+
ctx.fillRect(at + 8, 0, 26, size);
|
|
206
|
+
ctx.fillRect(0, at + 8, size, 26);
|
|
207
|
+
}
|
|
208
|
+
ctx.globalAlpha = 0.9;
|
|
209
|
+
ctx.fillStyle = line;
|
|
210
|
+
for (const at of [0, 64]) {
|
|
211
|
+
ctx.fillRect(at + 46, 0, 3, size);
|
|
212
|
+
ctx.fillRect(0, at + 46, size, 3);
|
|
213
|
+
}
|
|
214
|
+
ctx.globalAlpha = 1;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function dots(ground, dot) {
|
|
218
|
+
return canvasTexture(64, (ctx, size) => {
|
|
219
|
+
ctx.fillStyle = ground;
|
|
220
|
+
ctx.fillRect(0, 0, size, size);
|
|
221
|
+
ctx.fillStyle = dot;
|
|
222
|
+
for (const [x, y] of [
|
|
223
|
+
[16, 16],
|
|
224
|
+
[48, 48]
|
|
225
|
+
]) {
|
|
226
|
+
for (const ox of [-size, 0, size])
|
|
227
|
+
for (const oy of [-size, 0, size]) {
|
|
228
|
+
ctx.beginPath();
|
|
229
|
+
ctx.arc(x + ox, y + oy, 7, 0, Math.PI * 2);
|
|
230
|
+
ctx.fill();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function knit(ground, stripe) {
|
|
236
|
+
return canvasTexture(64, (ctx, size) => {
|
|
237
|
+
ctx.fillStyle = ground;
|
|
238
|
+
ctx.fillRect(0, 0, size, size);
|
|
239
|
+
ctx.fillStyle = stripe;
|
|
240
|
+
ctx.fillRect(0, 22, size, 7);
|
|
241
|
+
ctx.fillRect(0, 36, size, 7);
|
|
242
|
+
ctx.fillStyle = "rgba(0,0,0,0.16)";
|
|
243
|
+
for (let x = 0;x < size; x += 8)
|
|
244
|
+
ctx.fillRect(x, 0, 3, size);
|
|
245
|
+
ctx.fillStyle = "rgba(255,255,255,0.14)";
|
|
246
|
+
for (let y = 0;y < size; y += 4)
|
|
247
|
+
for (let x = 4;x < size; x += 8)
|
|
248
|
+
ctx.fillRect(x, y, 2, 2);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function candy(a, b) {
|
|
252
|
+
return canvasTexture(64, (ctx, size) => {
|
|
253
|
+
ctx.fillStyle = a;
|
|
254
|
+
ctx.fillRect(0, 0, size, size);
|
|
255
|
+
ctx.fillStyle = b;
|
|
256
|
+
for (let i = -2;i < 3; i += 1) {
|
|
257
|
+
ctx.beginPath();
|
|
258
|
+
ctx.moveTo(i * 32, size);
|
|
259
|
+
ctx.lineTo(i * 32 + 14, size);
|
|
260
|
+
ctx.lineTo(i * 32 + 14 + size, 0);
|
|
261
|
+
ctx.lineTo(i * 32 + size, 0);
|
|
262
|
+
ctx.closePath();
|
|
263
|
+
ctx.fill();
|
|
264
|
+
}
|
|
265
|
+
ctx.fillStyle = "#ffffff";
|
|
266
|
+
for (let i = 0;i < 6; i += 1) {
|
|
267
|
+
ctx.beginPath();
|
|
268
|
+
ctx.arc(8 + i * 11, 8 + i * 23 % 50, 2.5, 0, Math.PI * 2);
|
|
269
|
+
ctx.fill();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function earSkin() {
|
|
274
|
+
return canvasTexture(64, (ctx, size) => {
|
|
275
|
+
const fade = ctx.createLinearGradient(0, 0, size, 0);
|
|
276
|
+
fade.addColorStop(0, "#ffe1ec");
|
|
277
|
+
fade.addColorStop(0.3, "#ff9cc2");
|
|
278
|
+
fade.addColorStop(0.5, "#ff86b4");
|
|
279
|
+
fade.addColorStop(0.7, "#ff9cc2");
|
|
280
|
+
fade.addColorStop(1, "#ffe1ec");
|
|
281
|
+
ctx.fillStyle = fade;
|
|
282
|
+
ctx.fillRect(0, 0, size, size);
|
|
283
|
+
ctx.strokeStyle = "rgba(230,90,140,0.45)";
|
|
284
|
+
ctx.lineWidth = 1.5;
|
|
285
|
+
for (const bend of [-6, 0, 6]) {
|
|
286
|
+
ctx.beginPath();
|
|
287
|
+
ctx.moveTo(32, size);
|
|
288
|
+
ctx.quadraticCurveTo(32 + bend, 32, 32 + bend * 1.6, 4);
|
|
289
|
+
ctx.stroke();
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function pleats() {
|
|
294
|
+
return canvasTexture(64, (ctx, size) => {
|
|
295
|
+
ctx.fillStyle = "#fbfaff";
|
|
296
|
+
ctx.fillRect(0, 0, size, size);
|
|
297
|
+
ctx.fillStyle = "rgba(60,50,110,0.12)";
|
|
298
|
+
for (let x = 2;x < size; x += 8)
|
|
299
|
+
ctx.fillRect(x, 0, 2, size);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function lensGlass() {
|
|
303
|
+
return canvasTexture(64, (ctx, size) => {
|
|
304
|
+
const fade = ctx.createLinearGradient(0, 0, 0, size);
|
|
305
|
+
fade.addColorStop(0, "#0d0a1c");
|
|
306
|
+
fade.addColorStop(1, "#4a3380");
|
|
307
|
+
ctx.fillStyle = fade;
|
|
308
|
+
ctx.fillRect(0, 0, size, size);
|
|
309
|
+
for (const [x, w, alpha] of [
|
|
310
|
+
[10, 8, 0.75],
|
|
311
|
+
[24, 3, 0.4]
|
|
312
|
+
]) {
|
|
313
|
+
ctx.fillStyle = `rgba(255,255,255,${alpha})`;
|
|
314
|
+
ctx.beginPath();
|
|
315
|
+
ctx.moveTo(x, 44);
|
|
316
|
+
ctx.lineTo(x + w, 44);
|
|
317
|
+
ctx.lineTo(x + w + 24, 12);
|
|
318
|
+
ctx.lineTo(x + 24, 12);
|
|
319
|
+
ctx.closePath();
|
|
320
|
+
ctx.fill();
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function lathe(profile, segments = 32) {
|
|
325
|
+
return new LatheGeometry(profile.map(([r, y]) => new Vector2(Math.max(0.0005, r), y)), segments);
|
|
326
|
+
}
|
|
327
|
+
function slab(shape, depth, bevel) {
|
|
328
|
+
const geometry = new ExtrudeGeometry(shape, {
|
|
329
|
+
depth,
|
|
330
|
+
bevelEnabled: true,
|
|
331
|
+
bevelThickness: bevel,
|
|
332
|
+
bevelSize: bevel,
|
|
333
|
+
bevelSegments: 3,
|
|
334
|
+
curveSegments: 18
|
|
335
|
+
});
|
|
336
|
+
geometry.center();
|
|
337
|
+
geometry.computeVertexNormals();
|
|
338
|
+
return geometry;
|
|
339
|
+
}
|
|
340
|
+
function rounded(width, height, radius, shape = new Shape) {
|
|
341
|
+
const x = -width / 2;
|
|
342
|
+
const y = -height / 2;
|
|
343
|
+
shape.moveTo(x + radius, y);
|
|
344
|
+
shape.lineTo(x + width - radius, y);
|
|
345
|
+
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
|
|
346
|
+
shape.lineTo(x + width, y + height - radius);
|
|
347
|
+
shape.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
|
|
348
|
+
shape.lineTo(x + radius, y + height);
|
|
349
|
+
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
|
|
350
|
+
shape.lineTo(x, y + radius);
|
|
351
|
+
shape.quadraticCurveTo(x, y, x + radius, y);
|
|
352
|
+
return shape;
|
|
353
|
+
}
|
|
354
|
+
function bodyPatch(R, from, to, grow, angle, rows = 18, columns = 48) {
|
|
355
|
+
const positions = [];
|
|
356
|
+
const uvs = [];
|
|
357
|
+
const indices = [];
|
|
358
|
+
for (let i = 0;i <= rows; i += 1) {
|
|
359
|
+
const y = from + (to - from) * i / rows;
|
|
360
|
+
const r = R(y) + grow;
|
|
361
|
+
for (let j = 0;j <= columns; j += 1) {
|
|
362
|
+
const phi = angle(y, j / columns);
|
|
363
|
+
positions.push(Math.sin(phi) * r, y, Math.cos(phi) * r * DEPTH);
|
|
364
|
+
uvs.push(j / columns, i / rows);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (let i = 0;i < rows; i += 1)
|
|
368
|
+
for (let j = 0;j < columns; j += 1) {
|
|
369
|
+
const a = i * (columns + 1) + j;
|
|
370
|
+
const b = a + columns + 1;
|
|
371
|
+
indices.push(a, a + 1, b, a + 1, b + 1, b);
|
|
372
|
+
}
|
|
373
|
+
const geometry = new BufferGeometry;
|
|
374
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
375
|
+
geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
|
|
376
|
+
geometry.setIndex(indices);
|
|
377
|
+
geometry.computeVertexNormals();
|
|
378
|
+
return geometry;
|
|
379
|
+
}
|
|
380
|
+
function bendable(geometry, length) {
|
|
381
|
+
const position = geometry.attributes.position;
|
|
382
|
+
const rest = Float32Array.from(position.array);
|
|
383
|
+
return (pitch, roll, from = 0) => {
|
|
384
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
385
|
+
const x = rest[i * 3] ?? 0;
|
|
386
|
+
const y = rest[i * 3 + 1] ?? 0;
|
|
387
|
+
const z = rest[i * 3 + 2] ?? 0;
|
|
388
|
+
const along = clamp((y / length - from) / (1 - from), 0, 1);
|
|
389
|
+
const curl = along * along * (3 - 2 * along);
|
|
390
|
+
const a = pitch * curl;
|
|
391
|
+
const b = roll * curl;
|
|
392
|
+
const y1 = y * Math.cos(a) - z * Math.sin(a);
|
|
393
|
+
const z1 = y * Math.sin(a) + z * Math.cos(a);
|
|
394
|
+
position.setXYZ(i, x * Math.cos(b) - y1 * Math.sin(b), x * Math.sin(b) + y1 * Math.cos(b), z1);
|
|
395
|
+
}
|
|
396
|
+
position.needsUpdate = true;
|
|
397
|
+
geometry.computeVertexNormals();
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function piece(kit, build) {
|
|
401
|
+
const group = new Group;
|
|
402
|
+
const geometries = new Set;
|
|
403
|
+
const materials = new Set;
|
|
404
|
+
const textures = new Set;
|
|
405
|
+
const place = (object, where = {}) => {
|
|
406
|
+
const at = where.at ?? [0, 0, 0];
|
|
407
|
+
object.position.set(at[0], at[1], at[2]);
|
|
408
|
+
if (where.rotate)
|
|
409
|
+
object.rotation.set(where.rotate[0], where.rotate[1], where.rotate[2]);
|
|
410
|
+
if (where.scale)
|
|
411
|
+
object.scale.set(where.scale[0], where.scale[1], where.scale[2]);
|
|
412
|
+
(where.parent ?? group).add(object);
|
|
413
|
+
};
|
|
414
|
+
const tick = build({
|
|
415
|
+
add(geometry, color, where = {}, look = {}) {
|
|
416
|
+
geometries.add(geometry);
|
|
417
|
+
const { outline, ...paint } = look;
|
|
418
|
+
const material = kit.paint(color, paint);
|
|
419
|
+
materials.add(material);
|
|
420
|
+
const mesh = new Mesh(geometry, material);
|
|
421
|
+
place(mesh, where);
|
|
422
|
+
if (outline !== false)
|
|
423
|
+
mesh.add(new Mesh(geometry, kit.ink));
|
|
424
|
+
return mesh;
|
|
425
|
+
},
|
|
426
|
+
glow(geometry, color, opacity, where = {}) {
|
|
427
|
+
geometries.add(geometry);
|
|
428
|
+
const material = new MeshBasicMaterial({
|
|
429
|
+
color: new Color(color),
|
|
430
|
+
transparent: true,
|
|
431
|
+
opacity,
|
|
432
|
+
blending: AdditiveBlending,
|
|
433
|
+
depthWrite: false,
|
|
434
|
+
toneMapped: false
|
|
435
|
+
});
|
|
436
|
+
materials.add(material);
|
|
437
|
+
const mesh = new Mesh(geometry, material);
|
|
438
|
+
place(mesh, where);
|
|
439
|
+
return mesh;
|
|
440
|
+
},
|
|
441
|
+
keep(texture) {
|
|
442
|
+
textures.add(texture);
|
|
443
|
+
return texture;
|
|
444
|
+
},
|
|
445
|
+
node(where = {}) {
|
|
446
|
+
const node = new Group;
|
|
447
|
+
place(node, where);
|
|
448
|
+
return node;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
group.traverse((node) => {
|
|
452
|
+
node.raycast = () => {};
|
|
453
|
+
});
|
|
454
|
+
return {
|
|
455
|
+
object: group,
|
|
456
|
+
...tick ? { tick } : {},
|
|
457
|
+
dispose() {
|
|
458
|
+
for (const geometry of geometries)
|
|
459
|
+
geometry.dispose();
|
|
460
|
+
for (const material of materials)
|
|
461
|
+
material.dispose();
|
|
462
|
+
for (const texture of textures)
|
|
463
|
+
texture.dispose();
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function bunnyEars(kit) {
|
|
468
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
469
|
+
const length = 0.46;
|
|
470
|
+
const leaf = [
|
|
471
|
+
[0, 0],
|
|
472
|
+
[0.05, 0.012],
|
|
473
|
+
[0.072, 0.06],
|
|
474
|
+
[0.088, 0.15],
|
|
475
|
+
[0.092, 0.24],
|
|
476
|
+
[0.085, 0.32],
|
|
477
|
+
[0.066, 0.39],
|
|
478
|
+
[0.038, 0.44],
|
|
479
|
+
[0, length]
|
|
480
|
+
];
|
|
481
|
+
const skin = keep(earSkin());
|
|
482
|
+
const ears = [-1, 1].map((side) => {
|
|
483
|
+
const root = node({
|
|
484
|
+
at: [side * 0.13, TOP - 0.075, -0.03],
|
|
485
|
+
rotate: [-0.1, side * 0.18, side * -0.2]
|
|
486
|
+
});
|
|
487
|
+
const outer = lathe(leaf, 28);
|
|
488
|
+
const position = outer.attributes.position;
|
|
489
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
490
|
+
const z = position.getZ(i);
|
|
491
|
+
const x = position.getX(i);
|
|
492
|
+
const width = Math.max(0.001, Math.abs(x) + Math.abs(z));
|
|
493
|
+
const cup = z > 0 ? 0.35 + 0.65 * (Math.abs(x) / width) ** 2 : 1;
|
|
494
|
+
position.setZ(i, z * 0.42 * cup);
|
|
495
|
+
}
|
|
496
|
+
outer.computeVertexNormals();
|
|
497
|
+
const inner = lathe(leaf.slice(1, -1).map(([r, y]) => [r * 0.6, y * 0.9 + 0.025]), 20);
|
|
498
|
+
const innerPosition = inner.attributes.position;
|
|
499
|
+
for (let i = 0;i < innerPosition.count; i += 1)
|
|
500
|
+
innerPosition.setZ(i, innerPosition.getZ(i) * 0.14 + 0.012);
|
|
501
|
+
inner.computeVertexNormals();
|
|
502
|
+
add(outer, "#fbf8ff", { parent: root });
|
|
503
|
+
add(inner, "#ffffff", { parent: root }, { map: skin, outline: false });
|
|
504
|
+
const tuft = new SphereGeometry(0.05, 14, 10);
|
|
505
|
+
for (const [x, y, z] of [
|
|
506
|
+
[-0.03, 0.01, 0.01],
|
|
507
|
+
[0.03, 0, 0],
|
|
508
|
+
[0, 0.03, 0.02]
|
|
509
|
+
])
|
|
510
|
+
add(tuft, "#fbf8ff", { at: [x, y, z], parent: root }, { outline: false });
|
|
511
|
+
const rest = side === 1 ? 0.95 : 0.16;
|
|
512
|
+
return {
|
|
513
|
+
side,
|
|
514
|
+
bends: [bendable(outer, length), bendable(inner, length)],
|
|
515
|
+
pitch: new Spring(90, 7, rest),
|
|
516
|
+
roll: new Spring(70, 6),
|
|
517
|
+
rest
|
|
518
|
+
};
|
|
519
|
+
});
|
|
520
|
+
let twitch = 2.5;
|
|
521
|
+
return (clock, delta, raw) => {
|
|
522
|
+
const motion = calm(raw);
|
|
523
|
+
twitch -= delta;
|
|
524
|
+
for (const ear of ears) {
|
|
525
|
+
if (twitch < 0 && ear.side === -1)
|
|
526
|
+
ear.pitch.kick(-5);
|
|
527
|
+
const pitch = ear.pitch.step(ear.rest - motion.lift * 0.35, delta);
|
|
528
|
+
const roll = ear.roll.step(motion.yaw * 0.06 * ear.side + Math.sin(clock * 1.7 + ear.side) * 0.04, delta);
|
|
529
|
+
for (const bend of ear.bends)
|
|
530
|
+
bend(pitch, roll, ear.side === 1 ? 0.42 : 0);
|
|
531
|
+
}
|
|
532
|
+
if (twitch < 0)
|
|
533
|
+
twitch = 3 + Math.random() * 3;
|
|
534
|
+
};
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
function catEars(kit) {
|
|
538
|
+
return piece(kit, ({ add, node }) => {
|
|
539
|
+
const ear = new Shape;
|
|
540
|
+
ear.moveTo(-0.12, 0);
|
|
541
|
+
ear.quadraticCurveTo(-0.1, 0.12, -0.02, 0.22);
|
|
542
|
+
ear.quadraticCurveTo(0, 0.245, 0.02, 0.22);
|
|
543
|
+
ear.quadraticCurveTo(0.1, 0.12, 0.12, 0);
|
|
544
|
+
ear.quadraticCurveTo(0, -0.03, -0.12, 0);
|
|
545
|
+
const inner = new Shape;
|
|
546
|
+
inner.moveTo(-0.065, 0.02);
|
|
547
|
+
inner.quadraticCurveTo(-0.05, 0.1, -0.01, 0.165);
|
|
548
|
+
inner.quadraticCurveTo(0, 0.18, 0.01, 0.165);
|
|
549
|
+
inner.quadraticCurveTo(0.05, 0.1, 0.065, 0.02);
|
|
550
|
+
inner.quadraticCurveTo(0, 0, -0.065, 0.02);
|
|
551
|
+
const outerGeometry = slab(ear, 0.035, 0.02);
|
|
552
|
+
const innerGeometry = slab(inner, 0.01, 0.006);
|
|
553
|
+
const tuft = new ConeGeometry(0.012, 0.07, 6);
|
|
554
|
+
const ears = [-1, 1].map((side) => {
|
|
555
|
+
const root = node({
|
|
556
|
+
at: [side * 0.19, TOP - 0.1, 0],
|
|
557
|
+
rotate: [-0.15, side * -0.25, side * -0.32]
|
|
558
|
+
});
|
|
559
|
+
add(outerGeometry, "#2a2440", { at: [0, 0.1, 0], parent: root });
|
|
560
|
+
add(innerGeometry, "#ff9cc2", { at: [0, 0.085, 0.03], parent: root }, { outline: false });
|
|
561
|
+
for (const [x, r] of [
|
|
562
|
+
[-0.02, 0.3],
|
|
563
|
+
[0, 0],
|
|
564
|
+
[0.02, -0.3]
|
|
565
|
+
])
|
|
566
|
+
add(tuft, "#fbf8ff", { at: [x, 0.05, 0.04], rotate: [0.2, 0, r], parent: root }, { outline: false });
|
|
567
|
+
return { root, side, spring: new Spring(160, 10) };
|
|
568
|
+
});
|
|
569
|
+
let next = 2;
|
|
570
|
+
return (_clock, delta, raw) => {
|
|
571
|
+
const motion = calm(raw);
|
|
572
|
+
next -= delta;
|
|
573
|
+
for (const ear2 of ears) {
|
|
574
|
+
if (next < 0 && (ear2.side === 1 || Math.random() < 0.4))
|
|
575
|
+
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.6;
|
|
578
|
+
ear2.root.rotation.x = -0.15 - Math.abs(flick) * 0.4;
|
|
579
|
+
}
|
|
580
|
+
if (next < 0)
|
|
581
|
+
next = 2 + Math.random() * 4;
|
|
582
|
+
};
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function topHat(kit) {
|
|
586
|
+
return piece(kit, ({ add, node }) => {
|
|
587
|
+
const hat = node({ at: [0.04, TOP - 0.04, -0.01], rotate: [-0.08, 0.2, -0.16] });
|
|
588
|
+
const brim = lathe([
|
|
589
|
+
[0.18, 0.012],
|
|
590
|
+
[0.3, 0.008],
|
|
591
|
+
[0.355, 0.022],
|
|
592
|
+
[0.37, 0.042],
|
|
593
|
+
[0.36, 0.05],
|
|
594
|
+
[0.33, 0.034],
|
|
595
|
+
[0.26, 0.026],
|
|
596
|
+
[0.18, 0.03]
|
|
597
|
+
], 48);
|
|
598
|
+
const position = brim.attributes.position;
|
|
599
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
600
|
+
const x = position.getX(i);
|
|
601
|
+
const z = position.getZ(i);
|
|
602
|
+
const reach = Math.max(0.001, Math.hypot(x, z));
|
|
603
|
+
const lift = smooth(0.2, 0.37, reach) * (0.07 * (x / reach) ** 2 - 0.012 * (z / reach) ** 2);
|
|
604
|
+
position.setY(i, position.getY(i) + lift);
|
|
605
|
+
}
|
|
606
|
+
brim.computeVertexNormals();
|
|
607
|
+
add(brim, "#1b1830", { parent: hat }, { sheen: 0.25, double: true });
|
|
608
|
+
add(lathe([
|
|
609
|
+
[0, 0.4],
|
|
610
|
+
[0.2, 0.4],
|
|
611
|
+
[0.215, 0.385],
|
|
612
|
+
[0.212, 0.3],
|
|
613
|
+
[0.198, 0.15],
|
|
614
|
+
[0.195, 0.03],
|
|
615
|
+
[0, 0.03]
|
|
616
|
+
]), "#1b1830", { parent: hat }, { sheen: 0.25, double: true });
|
|
617
|
+
add(lathe([
|
|
618
|
+
[0.2, 0.05],
|
|
619
|
+
[0.206, 0.05],
|
|
620
|
+
[0.208, 0.12],
|
|
621
|
+
[0.203, 0.12]
|
|
622
|
+
]), "#c8323c", { parent: hat }, { sheen: 0.5, outline: false, double: true });
|
|
623
|
+
const buckle = rounded(0.07, 0.06, 0.012);
|
|
624
|
+
buckle.holes.push(rounded(0.04, 0.032, 0.006));
|
|
625
|
+
add(slab(buckle, 0.008, 0.004), "#f2c94c", { at: [0, 0.085, 0.21], parent: hat }, { sheen: 0.8, outline: false });
|
|
626
|
+
return;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function crown(kit) {
|
|
630
|
+
return piece(kit, ({ add, node }) => {
|
|
631
|
+
const root = node({ at: [0, TOP - 0.07, 0], rotate: [-0.08, 0, 0.08] });
|
|
632
|
+
const radius = 0.225;
|
|
633
|
+
const width = Math.PI * 2 * radius;
|
|
634
|
+
const points = 6;
|
|
635
|
+
const step = width / points;
|
|
636
|
+
const outline = new Shape;
|
|
637
|
+
outline.moveTo(0, 0);
|
|
638
|
+
outline.lineTo(width, 0);
|
|
639
|
+
outline.lineTo(width, 0.08);
|
|
640
|
+
for (let i = points;i > 0; i -= 1) {
|
|
641
|
+
const mid = (i - 0.5) * step;
|
|
642
|
+
outline.quadraticCurveTo(i * step - step / 6, 0.11, mid, 0.2);
|
|
643
|
+
outline.quadraticCurveTo(mid - step / 3, 0.11, (i - 1) * step, 0.08);
|
|
644
|
+
}
|
|
645
|
+
outline.lineTo(0, 0);
|
|
646
|
+
const band = new ExtrudeGeometry(outline, {
|
|
647
|
+
depth: 0.018,
|
|
648
|
+
bevelEnabled: true,
|
|
649
|
+
bevelThickness: 0.006,
|
|
650
|
+
bevelSize: 0.006,
|
|
651
|
+
bevelSegments: 2,
|
|
652
|
+
curveSegments: 10,
|
|
653
|
+
steps: 1
|
|
654
|
+
});
|
|
655
|
+
const position = band.attributes.position;
|
|
656
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
657
|
+
const angle = position.getX(i) / width * Math.PI * 2;
|
|
658
|
+
const r = radius + position.getZ(i);
|
|
659
|
+
position.setXYZ(i, Math.sin(angle) * r, position.getY(i), Math.cos(angle) * r);
|
|
660
|
+
}
|
|
661
|
+
band.computeVertexNormals();
|
|
662
|
+
add(band, "#f2c94c", { parent: root }, { sheen: 0.85, double: true });
|
|
663
|
+
add(new SphereGeometry(radius - 0.01, 24, 12, 0, Math.PI * 2, 0, Math.PI / 2), "#a3173a", {
|
|
664
|
+
at: [0, 0.02, 0],
|
|
665
|
+
scale: [1, 0.55, 1],
|
|
666
|
+
parent: root
|
|
667
|
+
});
|
|
668
|
+
const pearl = new SphereGeometry(0.022, 12, 10);
|
|
669
|
+
const stone = new IcosahedronGeometry(0.03, 0);
|
|
670
|
+
const colors = ["#e2574c", "#4cc9e2", "#3d8b5a"];
|
|
671
|
+
for (let i = 0;i < points; i += 1) {
|
|
672
|
+
const tip = (i + 0.5) / points * Math.PI * 2;
|
|
673
|
+
add(pearl, "#fff8e8", {
|
|
674
|
+
at: [Math.sin(tip) * (radius + 0.01), 0.215, Math.cos(tip) * (radius + 0.01)],
|
|
675
|
+
parent: root
|
|
676
|
+
}, { sheen: 0.7, outline: false });
|
|
677
|
+
add(stone, colors[i % colors.length] ?? "#e2574c", {
|
|
678
|
+
at: [Math.sin(tip) * (radius + 0.026), 0.045, Math.cos(tip) * (radius + 0.026)],
|
|
679
|
+
rotate: [0, tip, 0],
|
|
680
|
+
scale: [1, 1, 0.55],
|
|
681
|
+
parent: root
|
|
682
|
+
}, { sheen: 0.9, outline: false });
|
|
683
|
+
}
|
|
684
|
+
add(new SphereGeometry(0.035, 12, 10), "#f2c94c", { at: [0, 0.14, 0], parent: root }, {
|
|
685
|
+
sheen: 0.85
|
|
686
|
+
});
|
|
687
|
+
add(new OctahedronGeometry(0.03), "#f2c94c", { at: [0, 0.19, 0], scale: [0.6, 1, 0.6], parent: root }, { sheen: 0.85 });
|
|
688
|
+
return;
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
function partyHat(kit) {
|
|
692
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
693
|
+
const hat = node({ at: [-0.08, TOP - 0.05, 0.03], rotate: [0.05, 0, 0.24] });
|
|
694
|
+
add(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 });
|
|
695
|
+
add(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
|
+
const puff = new SphereGeometry(0.038, 12, 10);
|
|
697
|
+
const top = node({ at: [0, 0.43, 0], parent: hat });
|
|
698
|
+
for (const [x, y, z, color] of [
|
|
699
|
+
[0, 0, 0, "#fbf8ff"],
|
|
700
|
+
[0.03, 0.02, 0.01, "#ffd84d"],
|
|
701
|
+
[-0.03, 0.015, 0, "#fbf8ff"],
|
|
702
|
+
[0, 0.035, -0.02, "#4cc9e2"],
|
|
703
|
+
[0.01, 0.02, 0.03, "#fbf8ff"],
|
|
704
|
+
[-0.02, -0.01, 0.025, "#ffd84d"]
|
|
705
|
+
])
|
|
706
|
+
add(puff, color, { at: [x, y, z], parent: top }, { outline: false });
|
|
707
|
+
const sway = new Spring(80, 6);
|
|
708
|
+
return (clock, delta, raw) => {
|
|
709
|
+
const motion = calm(raw);
|
|
710
|
+
const lean = sway.step(-motion.yaw * 0.04 + motion.lift * 0.03, delta);
|
|
711
|
+
hat.rotation.z = 0.24 + lean + Math.sin(clock * 2.2) * 0.015;
|
|
712
|
+
top.scale.setScalar(1 + Math.max(0, -motion.lift) * 0.04);
|
|
713
|
+
};
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
function halo(kit) {
|
|
717
|
+
return piece(kit, ({ add, glow, node }) => {
|
|
718
|
+
const ring = node({ at: [0, TOP + 0.17, -0.02], rotate: [Math.PI / 2 - 0.2, 0, 0] });
|
|
719
|
+
add(new TorusGeometry(0.22, 0.03, 14, 56), "#ffe680", { parent: ring }, { sheen: 0.8 });
|
|
720
|
+
glow(new TorusGeometry(0.22, 0.075, 12, 56), "#fff2a8", 0.28, { parent: ring });
|
|
721
|
+
glow(new TorusGeometry(0.22, 0.13, 10, 56), "#ffe680", 0.1, { parent: ring });
|
|
722
|
+
const spark = new OctahedronGeometry(0.022);
|
|
723
|
+
const sparks = [0, 1, 2, 3].map(() => add(spark, "#fffbe0", { parent: ring }, { outline: false, sheen: 1 }));
|
|
724
|
+
return (clock) => {
|
|
725
|
+
ring.position.y = TOP + 0.17 + Math.sin(clock * 2) * 0.022;
|
|
726
|
+
ring.rotation.z = clock * 0.5;
|
|
727
|
+
sparks.forEach((s, i) => {
|
|
728
|
+
const a = clock * 0.9 + i * Math.PI / 2;
|
|
729
|
+
s.position.set(Math.cos(a) * 0.27, Math.sin(a) * 0.27, Math.sin(clock * 3 + i) * 0.03);
|
|
730
|
+
const twinkle = 0.5 + 0.5 * Math.abs(Math.sin(clock * 2.5 + i * 1.7));
|
|
731
|
+
s.scale.set(0.6 * twinkle, 1.6 * twinkle, 0.6 * twinkle);
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
function bow(kit) {
|
|
737
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
738
|
+
const root = node({ at: [0.19, TOP - 0.06, 0.06], rotate: [0.25, 0.35, -0.42] });
|
|
739
|
+
const ribbon = keep(dots("#ff5fa2", "#ffffff"));
|
|
740
|
+
const loop = new Shape;
|
|
741
|
+
loop.moveTo(0, 0);
|
|
742
|
+
loop.bezierCurveTo(0.05, 0.11, 0.17, 0.12, 0.17, 0.02);
|
|
743
|
+
loop.bezierCurveTo(0.17, -0.08, 0.05, -0.08, 0, 0);
|
|
744
|
+
const loopGeometry = slab(loop, 0.04, 0.02);
|
|
745
|
+
for (const side of [-1, 1])
|
|
746
|
+
add(loopGeometry, "#ffffff", {
|
|
747
|
+
at: [side * 0.085, 0.01, 0],
|
|
748
|
+
rotate: [0, side === 1 ? 0 : Math.PI, side * 0.05],
|
|
749
|
+
parent: root
|
|
750
|
+
}, { map: ribbon, repeat: [9, 9], sheen: 0.35 });
|
|
751
|
+
add(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
|
+
const tail = new Shape;
|
|
753
|
+
tail.moveTo(-0.025, 0);
|
|
754
|
+
tail.lineTo(0.025, 0);
|
|
755
|
+
tail.lineTo(0.035, -0.14);
|
|
756
|
+
tail.lineTo(0, -0.115);
|
|
757
|
+
tail.lineTo(-0.035, -0.14);
|
|
758
|
+
tail.closePath();
|
|
759
|
+
const tailGeometry = slab(tail, 0.012, 0.006);
|
|
760
|
+
const tails = [-1, 1].map((side) => {
|
|
761
|
+
const hang = node({ at: [side * 0.02, -0.02, 0.01], parent: root });
|
|
762
|
+
add(tailGeometry, "#ffffff", { at: [0, -0.07, 0], parent: hang }, { map: ribbon, repeat: [9, 9], sheen: 0.35 });
|
|
763
|
+
return { hang, side, spring: new Spring(60, 5) };
|
|
764
|
+
});
|
|
765
|
+
return (clock, delta, raw) => {
|
|
766
|
+
const motion = calm(raw);
|
|
767
|
+
for (const t of tails) {
|
|
768
|
+
t.hang.rotation.z = t.spring.step(t.side * 0.35 - motion.yaw * 0.05 + Math.sin(clock * 1.6 + t.side) * 0.05, delta);
|
|
769
|
+
t.hang.rotation.x = clamp(motion.lift * 0.08, -0.4, 0.4);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
function fittedPatch(kit, from, to, grow, angle = (_y, t) => t * Math.PI * 2, rows = 20, columns = 48) {
|
|
775
|
+
const surf = surfaceOf(kit);
|
|
776
|
+
const positions = [];
|
|
777
|
+
const uvs = [];
|
|
778
|
+
const indices = [];
|
|
779
|
+
for (let i = 0;i <= rows; i += 1) {
|
|
780
|
+
const v = i / rows;
|
|
781
|
+
const y = from + (to - from) * v;
|
|
782
|
+
for (let j = 0;j <= columns; j += 1) {
|
|
783
|
+
const u = j / columns;
|
|
784
|
+
const phi = angle(y, u);
|
|
785
|
+
const g = typeof grow === "function" ? grow(v, phi) : grow;
|
|
786
|
+
const pt = surf(y, phi, g);
|
|
787
|
+
positions.push(pt.x, y, pt.z);
|
|
788
|
+
uvs.push(u, v);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
for (let i = 0;i < rows; i += 1)
|
|
792
|
+
for (let j = 0;j < columns; j += 1) {
|
|
793
|
+
const a = i * (columns + 1) + j;
|
|
794
|
+
const b = a + columns + 1;
|
|
795
|
+
indices.push(a, a + 1, b, a + 1, b + 1, b);
|
|
796
|
+
}
|
|
797
|
+
const geometry = new BufferGeometry;
|
|
798
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
799
|
+
geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
|
|
800
|
+
geometry.setIndex(indices);
|
|
801
|
+
geometry.computeVertexNormals();
|
|
802
|
+
return geometry;
|
|
803
|
+
}
|
|
804
|
+
function aLineSkirtPatch(kit, bottom, top, flareOut, pleatCount, pleatAmp, rows = 10, columns = 64) {
|
|
805
|
+
const surf = surfaceOf(kit);
|
|
806
|
+
const z = zonesOf(kit);
|
|
807
|
+
const positions = [];
|
|
808
|
+
const uvs = [];
|
|
809
|
+
const indices = [];
|
|
810
|
+
for (let i = 0;i <= rows; i += 1) {
|
|
811
|
+
const v = i / rows;
|
|
812
|
+
const low = 1 - v;
|
|
813
|
+
const y = bottom + (top - bottom) * v;
|
|
814
|
+
for (let j = 0;j <= columns; j += 1) {
|
|
815
|
+
const u = j / columns;
|
|
816
|
+
const phi = u * Math.PI * 2;
|
|
817
|
+
const wPt = surf(top, phi, 0.022);
|
|
818
|
+
const hPt = surf(Math.max(z.hipY, bottom), phi, 0.028);
|
|
819
|
+
const bPt = surf(Math.max(y, z.bottomY), phi, 0.024);
|
|
820
|
+
const wR = Math.hypot(wPt.x, wPt.z);
|
|
821
|
+
const hR = Math.hypot(hPt.x, hPt.z);
|
|
822
|
+
const bR = Math.hypot(bPt.x, bPt.z);
|
|
823
|
+
const targetR = Math.max(bR, wR + (Math.max(hR - wR, 0.04) + flareOut) * low ** 0.85);
|
|
824
|
+
const phase = (phi / (Math.PI * 2) * pleatCount % 1 + 1) % 1;
|
|
825
|
+
const pleat = (Math.abs(phase * 2 - 1) - 0.5) * pleatAmp * low;
|
|
826
|
+
const r = targetR + pleat;
|
|
827
|
+
const baseR = bR || 1;
|
|
828
|
+
const scale = r / baseR;
|
|
829
|
+
positions.push(bPt.x * scale, y, bPt.z * scale);
|
|
830
|
+
uvs.push(u, v);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
for (let i = 0;i < rows; i += 1)
|
|
834
|
+
for (let j = 0;j < columns; j += 1) {
|
|
835
|
+
const a = i * (columns + 1) + j;
|
|
836
|
+
const b = a + columns + 1;
|
|
837
|
+
indices.push(a, a + 1, b, a + 1, b + 1, b);
|
|
838
|
+
}
|
|
839
|
+
const geometry = new BufferGeometry;
|
|
840
|
+
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
|
|
841
|
+
geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
|
|
842
|
+
geometry.setIndex(indices);
|
|
843
|
+
geometry.computeVertexNormals();
|
|
844
|
+
return geometry;
|
|
845
|
+
}
|
|
846
|
+
function pleatedSkirt(kit) {
|
|
847
|
+
const z = zonesOf(kit);
|
|
848
|
+
const surf = surfaceOf(kit);
|
|
849
|
+
return piece(kit, ({ add, keep }) => {
|
|
850
|
+
const top = kit.isFigure ? z.waistY + 0.02 : 0.25;
|
|
851
|
+
const bottom = kit.isFigure ? z.bottomY - 0.14 : 0.02;
|
|
852
|
+
const geometry = aLineSkirtPatch(kit, bottom, top, kit.isFigure ? 0.11 : 0.09, 22, 0.026, 10, 88);
|
|
853
|
+
const position = geometry.attributes.position;
|
|
854
|
+
const rest = Float32Array.from(position.array);
|
|
855
|
+
add(geometry, "#ffffff", {}, {
|
|
856
|
+
map: keep(tartan("#c8323c", "#1b1f5e", "#f2d24b")),
|
|
857
|
+
repeat: [6, 1.4],
|
|
858
|
+
double: true,
|
|
859
|
+
back: "#7d1d2a"
|
|
860
|
+
});
|
|
861
|
+
add(fittedPatch(kit, top - 0.032, top + 0.014, 0.028, (_y, t) => t * Math.PI * 2, 3, 48), "#1b1f5e", {}, { double: true, outline: false });
|
|
862
|
+
add(aLineSkirtPatch(kit, bottom, bottom + 0.028, kit.isFigure ? 0.114 : 0.094, 22, 0.026, 2, 88), "#fbf8ff", {}, { double: true, outline: false });
|
|
863
|
+
const frontBtn = surf(top - 0.008, 0.18, 0.034);
|
|
864
|
+
add(new SphereGeometry(0.016, 10, 8), "#f2c94c", { at: [frontBtn.x, top - 0.008, frontBtn.z] }, { sheen: 0.8, outline: false });
|
|
865
|
+
const flare = new Spring(70, 6);
|
|
866
|
+
const sway = new Spring(50, 5);
|
|
867
|
+
return (clock, delta, raw) => {
|
|
868
|
+
const motion = calm(raw);
|
|
869
|
+
const out = flare.step(clamp(-motion.lift * 0.05, -0.04, 0.14), delta);
|
|
870
|
+
const turn = sway.step(-motion.yaw * 0.05, delta);
|
|
871
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
872
|
+
const x = rest[i * 3] ?? 0;
|
|
873
|
+
const y = rest[i * 3 + 1] ?? 0;
|
|
874
|
+
const z0 = rest[i * 3 + 2] ?? 0;
|
|
875
|
+
const low = clamp((top - y) / Math.max(0.05, top - bottom), 0, 1);
|
|
876
|
+
const angle = Math.atan2(x, z0);
|
|
877
|
+
const spread = 1 + out * low * low;
|
|
878
|
+
const lag = turn * low + Math.sin(clock * 2 + angle * 2) * 0.006 * low;
|
|
879
|
+
const r = Math.hypot(x, z0) * spread;
|
|
880
|
+
position.setXYZ(i, Math.sin(angle + lag) * r, y, Math.cos(angle + lag) * r);
|
|
881
|
+
}
|
|
882
|
+
position.needsUpdate = true;
|
|
883
|
+
geometry.computeVertexNormals();
|
|
884
|
+
};
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
function tuxedo(kit) {
|
|
888
|
+
const z = zonesOf(kit);
|
|
889
|
+
const surf = surfaceOf(kit);
|
|
890
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
891
|
+
const bottom = kit.isFigure ? z.hipY - 0.04 : 0.03;
|
|
892
|
+
const button = kit.isFigure ? z.waistY + 0.02 : 0.15;
|
|
893
|
+
const collar = kit.isFigure ? z.shoulderY + 0.04 : 0.34;
|
|
894
|
+
const bowY = kit.isFigure ? collar - 0.04 : COLLAR_Y;
|
|
895
|
+
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
|
+
add(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 });
|
|
897
|
+
add(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
|
+
for (const side of [-1, 1])
|
|
899
|
+
add(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
|
+
const frontZ = (y) => surf(y, 0, 0.028).z;
|
|
901
|
+
const wing = new Shape;
|
|
902
|
+
wing.moveTo(0, 0.01);
|
|
903
|
+
wing.quadraticCurveTo(0.042, 0.042, 0.072, 0.034);
|
|
904
|
+
wing.quadraticCurveTo(0.08, 0, 0.072, -0.034);
|
|
905
|
+
wing.quadraticCurveTo(0.042, -0.042, 0, -0.01);
|
|
906
|
+
wing.closePath();
|
|
907
|
+
const wingGeometry = slab(wing, 0.018, 0.007);
|
|
908
|
+
for (const side of [-1, 1])
|
|
909
|
+
add(wingGeometry, "#14102e", {
|
|
910
|
+
at: [side * 0.042, bowY, frontZ(bowY) + 0.008],
|
|
911
|
+
rotate: [0, side === 1 ? 0 : Math.PI, side * -0.06]
|
|
912
|
+
}, { sheen: 0.55 });
|
|
913
|
+
add(new SphereGeometry(0.02, 12, 10), "#2e2a4a", { at: [0, bowY, frontZ(bowY) + 0.016], scale: [1, 1.2, 0.8] }, { sheen: 0.55 });
|
|
914
|
+
add(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
|
+
const tail = new Shape;
|
|
916
|
+
tail.moveTo(-0.055, 0);
|
|
917
|
+
tail.lineTo(0.055, 0);
|
|
918
|
+
tail.quadraticCurveTo(0.065, -0.13, 0.032, -0.22);
|
|
919
|
+
tail.lineTo(0, -0.18);
|
|
920
|
+
tail.lineTo(-0.032, -0.22);
|
|
921
|
+
tail.quadraticCurveTo(-0.065, -0.13, -0.055, 0);
|
|
922
|
+
const tailGeometry = slab(tail, 0.014, 0.006);
|
|
923
|
+
const backPt = surf(bottom + 0.06, Math.PI, 0.026);
|
|
924
|
+
const tails = [-1, 1].map((side) => {
|
|
925
|
+
const hang = node({
|
|
926
|
+
at: [side * 0.07, bottom + 0.06, backPt.z],
|
|
927
|
+
rotate: [0, Math.PI + side * -0.18, 0]
|
|
928
|
+
});
|
|
929
|
+
add(tailGeometry, "#1b1830", { at: [0, -0.09, 0], parent: hang }, { sheen: 0.15 });
|
|
930
|
+
return { hang, spring: new Spring(60, 5), side };
|
|
931
|
+
});
|
|
932
|
+
return (clock, delta, raw) => {
|
|
933
|
+
const motion = calm(raw);
|
|
934
|
+
for (const t of tails) {
|
|
935
|
+
const kick = t.spring.step(-0.14 + clamp(-motion.lift * 0.12, -0.3, 0.5) + Math.abs(motion.yaw) * 0.04, delta);
|
|
936
|
+
t.hang.rotation.x = kick + Math.sin(clock * 1.5 + t.side) * 0.02;
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
function heroCape(kit) {
|
|
942
|
+
const z = zonesOf(kit);
|
|
943
|
+
const surf = surfaceOf(kit);
|
|
944
|
+
return piece(kit, ({ add }) => {
|
|
945
|
+
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.6;
|
|
946
|
+
const bottom = kit.isFigure ? -0.1 : 0;
|
|
947
|
+
const across = Math.PI * 0.95;
|
|
948
|
+
const columns = 22;
|
|
949
|
+
const rows = 14;
|
|
950
|
+
const positions = new Float32Array((columns + 1) * (rows + 1) * 3);
|
|
951
|
+
const uvs = [];
|
|
952
|
+
const indices = [];
|
|
953
|
+
for (let i = 0;i <= rows; i += 1)
|
|
954
|
+
for (let j = 0;j <= columns; j += 1)
|
|
955
|
+
uvs.push(j / columns, 1 - i / rows);
|
|
956
|
+
for (let i = 0;i < rows; i += 1)
|
|
957
|
+
for (let j = 0;j < columns; j += 1) {
|
|
958
|
+
const a = i * (columns + 1) + j;
|
|
959
|
+
const b = a + columns + 1;
|
|
960
|
+
indices.push(a, b, a + 1, a + 1, b, b + 1);
|
|
961
|
+
}
|
|
962
|
+
const geometry = new BufferGeometry;
|
|
963
|
+
geometry.setAttribute("position", new BufferAttribute(positions, 3));
|
|
964
|
+
geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
|
|
965
|
+
geometry.setIndex(indices);
|
|
966
|
+
const drape = (clock, out, lag) => {
|
|
967
|
+
for (let i = 0;i <= rows; i += 1) {
|
|
968
|
+
const v = i / rows;
|
|
969
|
+
const y = top + (bottom - top) * v;
|
|
970
|
+
for (let j = 0;j <= columns; j += 1) {
|
|
971
|
+
const u = j / columns;
|
|
972
|
+
const angle = Math.PI - across / 2 + across * u + lag * v * v;
|
|
973
|
+
const ripple = Math.sin(u * 9 + clock * 2.4) * 0.025 * v * v;
|
|
974
|
+
const sampleY = Math.max(y, z.hipY);
|
|
975
|
+
const pt = surf(sampleY, angle, 0.045 + v * 0.16 + out * v * v + ripple);
|
|
976
|
+
const k = (i * (columns + 1) + j) * 3;
|
|
977
|
+
positions[k] = pt.x;
|
|
978
|
+
positions[k + 1] = y + out * v * v * 0.1;
|
|
979
|
+
positions[k + 2] = pt.z;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
geometry.attributes.position.needsUpdate = true;
|
|
983
|
+
geometry.computeVertexNormals();
|
|
984
|
+
};
|
|
985
|
+
drape(0, 0, 0);
|
|
986
|
+
add(geometry, "#c8323c", {}, { double: true, back: "#f2c94c", sheen: 0.2 });
|
|
987
|
+
add(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
|
+
const clasp = new Shape;
|
|
989
|
+
for (let i = 0;i < 10; i += 1) {
|
|
990
|
+
const a = i / 10 * Math.PI * 2;
|
|
991
|
+
const r = i % 2 ? 0.02 : 0.04;
|
|
992
|
+
if (i === 0)
|
|
993
|
+
clasp.moveTo(Math.sin(a) * r, Math.cos(a) * r);
|
|
994
|
+
else
|
|
995
|
+
clasp.lineTo(Math.sin(a) * r, Math.cos(a) * r);
|
|
996
|
+
}
|
|
997
|
+
clasp.closePath();
|
|
998
|
+
const star = slab(clasp, 0.012, 0.005);
|
|
999
|
+
for (const side of [-1, 1]) {
|
|
1000
|
+
const angle = side * (Math.PI / 2 - 0.22);
|
|
1001
|
+
const pt = surf(top - 0.02, angle, 0.04);
|
|
1002
|
+
add(star, "#f2c94c", { at: [pt.x, top - 0.02, pt.z], rotate: [0, angle, 0] }, { sheen: 0.85 });
|
|
1003
|
+
}
|
|
1004
|
+
const flare = new Spring(40, 4);
|
|
1005
|
+
const trail = new Spring(35, 4);
|
|
1006
|
+
return (clock, delta, raw) => {
|
|
1007
|
+
const motion = calm(raw);
|
|
1008
|
+
const out = flare.step(clamp(Math.abs(motion.yaw) * 0.03 + Math.max(0, -motion.lift) * 0.06, 0, 0.25), delta);
|
|
1009
|
+
drape(clock, out, trail.step(-motion.yaw * 0.06, delta));
|
|
1010
|
+
};
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function scarf(kit) {
|
|
1014
|
+
const z = zonesOf(kit);
|
|
1015
|
+
const surf = surfaceOf(kit);
|
|
1016
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
1017
|
+
const wool = keep(knit("#e2574c", "#fbf8ff"));
|
|
1018
|
+
const y = kit.isFigure ? z.neckY - 0.03 : COLLAR_Y;
|
|
1019
|
+
const r = Math.max(0.11, kit.radiusAt(y)) + 0.025;
|
|
1020
|
+
add(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
|
+
const knotAngle = 0.52;
|
|
1022
|
+
const knotPt = surf(y, knotAngle, 0.045);
|
|
1023
|
+
const knotAt = [knotPt.x, y - 0.01, knotPt.z];
|
|
1024
|
+
add(new SphereGeometry(0.05, 16, 12), "#ffffff", { at: knotAt, scale: [1, 0.85, 0.75] }, { map: wool, repeat: [3, 1] });
|
|
1025
|
+
const strip = new CylinderGeometry(0.046, 0.05, 0.26, 12, 6);
|
|
1026
|
+
strip.scale(1, 1, 0.35);
|
|
1027
|
+
const fringeGeo = new CylinderGeometry(0.006, 0.004, 0.04, 5);
|
|
1028
|
+
const tails = [
|
|
1029
|
+
{ x: -0.01, tilt: 0.12, length: 1 },
|
|
1030
|
+
{ x: 0.042, tilt: -0.05, length: 0.82 }
|
|
1031
|
+
].map(({ x, tilt, length }) => {
|
|
1032
|
+
const hang = node({
|
|
1033
|
+
at: [knotAt[0] + x, knotAt[1] - 0.02, knotAt[2] + 0.02],
|
|
1034
|
+
rotate: [0.12, knotAngle * 0.6, tilt]
|
|
1035
|
+
});
|
|
1036
|
+
add(strip, "#ffffff", { at: [0, -0.13 * length, 0], scale: [1, length, 1], parent: hang }, { map: wool, repeat: [2, 2] });
|
|
1037
|
+
for (let i = 0;i < 5; i += 1)
|
|
1038
|
+
add(fringeGeo, "#e2574c", { at: [-0.036 + i * 0.018, -0.26 * length - 0.02, 0], parent: hang }, { outline: false });
|
|
1039
|
+
return { hang, tilt, spring: new Spring(55, 5, tilt) };
|
|
1040
|
+
});
|
|
1041
|
+
return (clock, delta, raw) => {
|
|
1042
|
+
const motion = calm(raw);
|
|
1043
|
+
tails.forEach((t, i) => {
|
|
1044
|
+
t.hang.rotation.z = t.spring.step(t.tilt - motion.yaw * 0.05 + Math.sin(clock * 1.8 + i) * 0.03, delta);
|
|
1045
|
+
t.hang.rotation.x = 0.12 + clamp(motion.lift * 0.1, -0.3, 0.5);
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
function ribbonDress(kit) {
|
|
1051
|
+
const z = zonesOf(kit);
|
|
1052
|
+
const surf = surfaceOf(kit);
|
|
1053
|
+
return piece(kit, ({ add, keep, node }) => {
|
|
1054
|
+
const bodiceTop = kit.isFigure ? z.bustY + 0.09 : 0.36;
|
|
1055
|
+
const waist = kit.isFigure ? z.waistY : 0.24;
|
|
1056
|
+
const hem = kit.isFigure ? z.bottomY - 0.16 : 0.02;
|
|
1057
|
+
add(fittedPatch(kit, waist, bodiceTop, 0.028, (_y, t) => t * Math.PI * 2, 20, 56), "#ff6fa8", {}, { double: true, back: "#c43f76", sheen: 0.32 });
|
|
1058
|
+
add(fittedPatch(kit, bodiceTop - 0.022, bodiceTop + 0.008, 0.033, (_y, t) => t * Math.PI * 2, 2, 56), "#fff7fb", {}, { double: true, outline: false });
|
|
1059
|
+
if (kit.isFigure) {
|
|
1060
|
+
for (const side of [-1, 1]) {
|
|
1061
|
+
const shPt = surf(z.shoulderY, side * 1.15, 0.015);
|
|
1062
|
+
add(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
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
add(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
|
+
const frontW = surf(waist, 0, 0.04);
|
|
1067
|
+
const bowNode = node({ at: [frontW.x, waist, frontW.z] });
|
|
1068
|
+
const loopGeo = new TorusGeometry(0.038, 0.013, 10, 20);
|
|
1069
|
+
for (const side of [-1, 1])
|
|
1070
|
+
add(loopGeo, "#ff3d8b", {
|
|
1071
|
+
at: [side * 0.04, 0, 0],
|
|
1072
|
+
rotate: [0, 0, side * 0.3],
|
|
1073
|
+
scale: [1.15, 0.72, 0.55],
|
|
1074
|
+
parent: bowNode
|
|
1075
|
+
}, { sheen: 0.5 });
|
|
1076
|
+
add(new SphereGeometry(0.018, 10, 8), "#ff3d8b", { parent: bowNode }, { sheen: 0.5 });
|
|
1077
|
+
const skirtGeo = aLineSkirtPatch(kit, hem, waist, kit.isFigure ? 0.14 : 0.1, 16, 0.02, 10, 72);
|
|
1078
|
+
const pos = skirtGeo.attributes.position;
|
|
1079
|
+
const rest = Float32Array.from(pos.array);
|
|
1080
|
+
add(skirtGeo, "#ff6fa8", {}, {
|
|
1081
|
+
map: keep(dots("#ff7eb6", "#ffe3f0")),
|
|
1082
|
+
repeat: [8, 3],
|
|
1083
|
+
double: true,
|
|
1084
|
+
back: "#ffe8f3",
|
|
1085
|
+
sheen: 0.22
|
|
1086
|
+
});
|
|
1087
|
+
add(aLineSkirtPatch(kit, hem - 0.032, hem + 0.025, kit.isFigure ? 0.145 : 0.105, 22, 0.016, 3, 72), "#fffaff", {}, { double: true, outline: false });
|
|
1088
|
+
const flare = new Spring(65, 5.5);
|
|
1089
|
+
return (clock, delta, raw) => {
|
|
1090
|
+
const motion = calm(raw);
|
|
1091
|
+
const out = flare.step(clamp(-motion.lift * 0.06, -0.03, 0.15), delta);
|
|
1092
|
+
for (let i = 0;i < pos.count; i += 1) {
|
|
1093
|
+
const x = rest[i * 3] ?? 0;
|
|
1094
|
+
const y = rest[i * 3 + 1] ?? 0;
|
|
1095
|
+
const z0 = rest[i * 3 + 2] ?? 0;
|
|
1096
|
+
const low = clamp((waist - y) / Math.max(0.05, waist - hem), 0, 1);
|
|
1097
|
+
const a = Math.atan2(x, z0);
|
|
1098
|
+
const r = Math.hypot(x, z0) * (1 + out * low * low + Math.sin(clock * 2.2 + a * 3) * 0.008 * low);
|
|
1099
|
+
pos.setXYZ(i, Math.sin(a) * r, y, Math.cos(a) * r);
|
|
1100
|
+
}
|
|
1101
|
+
pos.needsUpdate = true;
|
|
1102
|
+
skirtGeo.computeVertexNormals();
|
|
1103
|
+
};
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
function cropHoodie(kit) {
|
|
1107
|
+
const z = zonesOf(kit);
|
|
1108
|
+
const surf = surfaceOf(kit);
|
|
1109
|
+
return piece(kit, ({ add, node }) => {
|
|
1110
|
+
const bottom = kit.isFigure ? z.waistY + 0.06 : 0.2;
|
|
1111
|
+
const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
|
|
1112
|
+
add(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 });
|
|
1113
|
+
add(fittedPatch(kit, bottom - 0.022, bottom + 0.012, 0.036, (_y, t) => t * Math.PI * 2, 3, 56), "#fffaff", {}, { double: true, outline: false });
|
|
1114
|
+
const neckY = kit.isFigure ? z.neckY - 0.02 : top;
|
|
1115
|
+
const backPt = surf(neckY, Math.PI, 0.05);
|
|
1116
|
+
add(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
|
+
if (kit.isFigure) {
|
|
1118
|
+
add(fittedPatch(kit, z.bottomY - 0.02, z.hipY + 0.09, 0.024, (_y, t) => t * Math.PI * 2, 12, 56), "#2c2448", {}, { double: true });
|
|
1119
|
+
}
|
|
1120
|
+
const frontNeck = surf(top - 0.02, 0, 0.04);
|
|
1121
|
+
const strings = [-1, 1].map((side) => {
|
|
1122
|
+
const hang = node({ at: [side * 0.042, top - 0.02, frontNeck.z] });
|
|
1123
|
+
add(new CylinderGeometry(0.008, 0.008, 0.14, 8), "#fffaff", { at: [0, -0.07, 0], parent: hang }, { outline: false });
|
|
1124
|
+
add(new SphereGeometry(0.013, 8, 8), "#ff7eb8", { at: [0, -0.14, 0], parent: hang }, { outline: false });
|
|
1125
|
+
return { hang, side, spring: new Spring(60, 4.5) };
|
|
1126
|
+
});
|
|
1127
|
+
return (clock, delta, raw) => {
|
|
1128
|
+
const motion = calm(raw);
|
|
1129
|
+
for (const s of strings) {
|
|
1130
|
+
s.hang.rotation.z = s.spring.step(-motion.yaw * 0.04 + Math.sin(clock * 2.1 + s.side) * 0.05, delta);
|
|
1131
|
+
s.hang.rotation.x = clamp(motion.lift * 0.08, -0.25, 0.35);
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
function idolSet(kit) {
|
|
1137
|
+
const z = zonesOf(kit);
|
|
1138
|
+
const surf = surfaceOf(kit);
|
|
1139
|
+
return piece(kit, ({ add, node }) => {
|
|
1140
|
+
const topBottom = kit.isFigure ? z.waistY + 0.05 : 0.24;
|
|
1141
|
+
const topHigh = kit.isFigure ? z.shoulderY + 0.05 : 0.38;
|
|
1142
|
+
const skirtTop = kit.isFigure ? z.waistY - 0.01 : 0.22;
|
|
1143
|
+
const skirtBot = kit.isFigure ? z.bottomY - 0.12 : 0.02;
|
|
1144
|
+
add(fittedPatch(kit, topBottom, topHigh, 0.028, (_y, t) => t * Math.PI * 2, 16, 56), "#ffffff", {}, { double: true, sheen: 0.2 });
|
|
1145
|
+
add(fittedPatch(kit, topHigh - 0.1, topHigh + 0.01, 0.034, (_y, t) => t * Math.PI * 2, 6, 56), "#1f2b6c", {}, { double: true });
|
|
1146
|
+
add(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
|
+
const chest = surf(topHigh - 0.09, 0, 0.045);
|
|
1148
|
+
const bow2 = node({ at: [0, topHigh - 0.09, chest.z] });
|
|
1149
|
+
const loop = new TorusGeometry(0.038, 0.013, 10, 20);
|
|
1150
|
+
for (const side of [-1, 1]) {
|
|
1151
|
+
add(loop, "#ff3b6b", { at: [side * 0.038, 0, 0], scale: [1.15, 0.75, 0.5], parent: bow2 }, { sheen: 0.45 });
|
|
1152
|
+
add(new CylinderGeometry(0.015, 0.022, 0.095, 8), "#ff3b6b", {
|
|
1153
|
+
at: [side * 0.024, -0.055, 0],
|
|
1154
|
+
rotate: [0, 0, side * 0.24],
|
|
1155
|
+
scale: [1, 1, 0.3],
|
|
1156
|
+
parent: bow2
|
|
1157
|
+
}, { outline: false });
|
|
1158
|
+
}
|
|
1159
|
+
add(aLineSkirtPatch(kit, skirtBot, skirtTop, kit.isFigure ? 0.11 : 0.085, 22, 0.02, 8, 72), "#1f2b6c", {}, { double: true, back: "#ff6fa8" });
|
|
1160
|
+
add(aLineSkirtPatch(kit, skirtBot + 0.016, skirtBot + 0.038, kit.isFigure ? 0.105 : 0.08, 22, 0.018, 2, 72), "#ffd84d", {}, { double: true, outline: false, sheen: 0.75 });
|
|
1161
|
+
return;
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
function streetJacket(kit) {
|
|
1165
|
+
const z = zonesOf(kit);
|
|
1166
|
+
const surf = surfaceOf(kit);
|
|
1167
|
+
return piece(kit, ({ add }) => {
|
|
1168
|
+
const bottom = kit.isFigure ? z.hipY - 0.04 : 0.04;
|
|
1169
|
+
const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
|
|
1170
|
+
if (kit.isFigure) {
|
|
1171
|
+
add(fittedPatch(kit, z.bottomY - 0.03, z.waistY + 0.02, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#161622", {}, { double: true });
|
|
1172
|
+
}
|
|
1173
|
+
add(fittedPatch(kit, bottom + 0.02, top - 0.01, 0.026, (_y, t) => t * Math.PI * 2, 16, 48), "#181726", {}, { double: true });
|
|
1174
|
+
const gap = 0.34;
|
|
1175
|
+
add(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
|
+
for (const side of [-1, 1]) {
|
|
1177
|
+
add(fittedPatch(kit, bottom, top, 0.045, (_y, t) => side * (gap + t * 0.08), 12, 3), "#ff4f7a", {}, { double: true, outline: false });
|
|
1178
|
+
}
|
|
1179
|
+
add(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
|
+
const chainY = kit.isFigure ? z.bustY + 0.04 : top - 0.08;
|
|
1181
|
+
const bead = new SphereGeometry(0.011, 8, 8);
|
|
1182
|
+
for (let i = -5;i <= 5; i += 1) {
|
|
1183
|
+
const phi = i * 0.08;
|
|
1184
|
+
const drop = Math.cos(i / 5 * Math.PI * 0.5) * 0.065;
|
|
1185
|
+
const pt = surf(chainY - drop, phi, 0.036);
|
|
1186
|
+
add(bead, "#e4ebff", { at: [pt.x, chainY - drop, pt.z] }, { sheen: 0.9, outline: false });
|
|
1187
|
+
}
|
|
1188
|
+
return;
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
function blazerCoat(kit) {
|
|
1192
|
+
const z = zonesOf(kit);
|
|
1193
|
+
const surf = surfaceOf(kit);
|
|
1194
|
+
return piece(kit, ({ add }) => {
|
|
1195
|
+
const bottom = kit.isFigure ? z.hipY - 0.05 : 0.03;
|
|
1196
|
+
const waist = kit.isFigure ? z.waistY + 0.02 : 0.18;
|
|
1197
|
+
const top = kit.isFigure ? z.shoulderY + 0.05 : 0.37;
|
|
1198
|
+
const vOpen = (y) => y > waist ? 0.1 + (y - waist) / Math.max(0.05, top - waist) * 0.45 : 0.06;
|
|
1199
|
+
if (kit.isFigure) {
|
|
1200
|
+
add(fittedPatch(kit, z.bottomY - 0.03, z.waistY, 0.022, (_y, t) => t * Math.PI * 2, 10, 48), "#1c223c", {}, { double: true });
|
|
1201
|
+
}
|
|
1202
|
+
add(fittedPatch(kit, bottom + 0.02, top, 0.024, (_y, t) => t * Math.PI * 2, 16, 48), "#f8f9ff", {}, { double: true, outline: false });
|
|
1203
|
+
add(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
|
+
for (const side of [-1, 1]) {
|
|
1205
|
+
add(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
|
+
}
|
|
1207
|
+
add(fittedPatch(kit, waist - 0.02, top - 0.02, 0.034, (y, t) => {
|
|
1208
|
+
const w = y > top - 0.07 ? 0.08 : 0.12 - (y - waist) / Math.max(0.05, top - waist) * 0.05;
|
|
1209
|
+
return (t * 2 - 1) * w;
|
|
1210
|
+
}, 10, 6), "#d6354a", {}, { double: true });
|
|
1211
|
+
const btn = new SphereGeometry(0.014, 8, 8);
|
|
1212
|
+
for (const by of [waist, waist - 0.065]) {
|
|
1213
|
+
const pt = surf(by, 0.16, 0.042);
|
|
1214
|
+
add(btn, "#f2c94c", { at: [pt.x, by, pt.z] }, { sheen: 0.85, outline: false });
|
|
1215
|
+
}
|
|
1216
|
+
return;
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
function brawlerVest(kit) {
|
|
1220
|
+
const z = zonesOf(kit);
|
|
1221
|
+
const surf = surfaceOf(kit);
|
|
1222
|
+
return piece(kit, ({ add }) => {
|
|
1223
|
+
const bottom = kit.isFigure ? z.waistY - 0.08 : 0.05;
|
|
1224
|
+
const top = kit.isFigure ? z.shoulderY + 0.03 : 0.36;
|
|
1225
|
+
if (kit.isFigure) {
|
|
1226
|
+
add(fittedPatch(kit, z.bottomY - 0.04, z.waistY - 0.02, 0.026, (_y, t) => t * Math.PI * 2, 12, 48), "#2b2538", {}, { double: true });
|
|
1227
|
+
}
|
|
1228
|
+
add(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 });
|
|
1229
|
+
add(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
|
+
const beltY = kit.isFigure ? z.waistY - 0.04 : 0.14;
|
|
1231
|
+
add(fittedPatch(kit, beltY - 0.028, beltY + 0.028, 0.036, (_y, t) => t * Math.PI * 2, 3, 48), "#4a2b1d", {}, { double: true });
|
|
1232
|
+
const bucklePt = surf(beltY, 0, 0.045);
|
|
1233
|
+
add(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
|
+
return;
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
function martialGi(kit) {
|
|
1238
|
+
const z = zonesOf(kit);
|
|
1239
|
+
const surf = surfaceOf(kit);
|
|
1240
|
+
return piece(kit, ({ add, node }) => {
|
|
1241
|
+
const bottom = kit.isFigure ? z.bottomY - 0.03 : 0.03;
|
|
1242
|
+
const waist = kit.isFigure ? z.waistY - 0.02 : 0.16;
|
|
1243
|
+
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.37;
|
|
1244
|
+
const vOpen = (y) => y > waist ? 0.08 + (y - waist) / Math.max(0.05, top - waist) * 0.44 : 0;
|
|
1245
|
+
add(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
|
+
for (const side of [-1, 1]) {
|
|
1247
|
+
add(fittedPatch(kit, waist, top, 0.038, (y, t) => side * (vOpen(y) + t * 0.1), 10, 3), "#1b2042", {}, { double: true, outline: false });
|
|
1248
|
+
}
|
|
1249
|
+
add(fittedPatch(kit, waist - 0.032, waist + 0.032, 0.042, (_y, t) => t * Math.PI * 2, 4, 48), "#181624", {}, { double: true });
|
|
1250
|
+
const knotPt = surf(waist, 0, 0.052);
|
|
1251
|
+
add(new SphereGeometry(0.038, 12, 10), "#181624", { at: [knotPt.x, waist, knotPt.z] });
|
|
1252
|
+
const tailGeo = new CylinderGeometry(0.022, 0.028, 0.22, 8);
|
|
1253
|
+
tailGeo.scale(1, 1, 0.3);
|
|
1254
|
+
const tails = [-1, 1].map((side) => {
|
|
1255
|
+
const hang = node({
|
|
1256
|
+
at: [knotPt.x + side * 0.028, waist - 0.02, knotPt.z + 0.008],
|
|
1257
|
+
rotate: [0.08, 0, side * 0.24]
|
|
1258
|
+
});
|
|
1259
|
+
add(tailGeo, "#181624", { at: [0, -0.1, 0], parent: hang });
|
|
1260
|
+
return { hang, side, spring: new Spring(55, 5) };
|
|
1261
|
+
});
|
|
1262
|
+
return (clock, delta, raw) => {
|
|
1263
|
+
const motion = calm(raw);
|
|
1264
|
+
for (const t of tails) {
|
|
1265
|
+
t.hang.rotation.z = t.spring.step(t.side * 0.24 - motion.yaw * 0.04 + Math.sin(clock * 2 + t.side) * 0.04, delta);
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
function chibiOveralls(kit) {
|
|
1271
|
+
const z = zonesOf(kit);
|
|
1272
|
+
const surf = surfaceOf(kit);
|
|
1273
|
+
return piece(kit, ({ add }) => {
|
|
1274
|
+
const bottom = kit.isFigure ? z.bottomY - 0.02 : 0.03;
|
|
1275
|
+
const waist = kit.isFigure ? z.waistY + 0.02 : 0.22;
|
|
1276
|
+
const top = kit.isFigure ? z.shoulderY + 0.04 : 0.36;
|
|
1277
|
+
add(fittedPatch(kit, waist - 0.02, top, 0.014, (_y, t) => t * Math.PI * 2, 12, 48), "#fff3d9", {}, { double: true, outline: false });
|
|
1278
|
+
add(fittedPatch(kit, bottom, waist + 0.03, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#5b8ff9", {}, { double: true, back: "#3d66bf" });
|
|
1279
|
+
add(fittedPatch(kit, waist, top - 0.05, 0.026, (_y, t) => (t * 2 - 1) * 0.55, 8, 12), "#5b8ff9", {}, { double: true });
|
|
1280
|
+
for (const side of [-1, 1]) {
|
|
1281
|
+
add(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
|
+
const btnPt = surf(top - 0.07, side * 0.44, 0.034);
|
|
1283
|
+
add(new SphereGeometry(0.018, 10, 8), "#ffd84d", { at: [btnPt.x, top - 0.07, btnPt.z] }, { sheen: 0.85 });
|
|
1284
|
+
}
|
|
1285
|
+
const pockPt = surf(waist + 0.06, 0, 0.033);
|
|
1286
|
+
add(new CylinderGeometry(0.045, 0.045, 0.012, 12), "#ffd84d", {
|
|
1287
|
+
at: [pockPt.x, waist + 0.06, pockPt.z],
|
|
1288
|
+
rotate: [Math.PI / 2, 0, 0],
|
|
1289
|
+
scale: [1.1, 1, 0.85]
|
|
1290
|
+
}, { sheen: 0.4, outline: false });
|
|
1291
|
+
return;
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
function sunglasses(kit) {
|
|
1295
|
+
const R = kit.radiusAt;
|
|
1296
|
+
return piece(kit, ({ add, keep }) => {
|
|
1297
|
+
const glass = keep(lensGlass());
|
|
1298
|
+
const lens = new Shape;
|
|
1299
|
+
lens.moveTo(-0.085, 0.04);
|
|
1300
|
+
lens.quadraticCurveTo(0, 0.06, 0.085, 0.04);
|
|
1301
|
+
lens.quadraticCurveTo(0.1, -0.02, 0.05, -0.06);
|
|
1302
|
+
lens.quadraticCurveTo(0, -0.08, -0.05, -0.06);
|
|
1303
|
+
lens.quadraticCurveTo(-0.1, -0.02, -0.085, 0.04);
|
|
1304
|
+
const frame = new Shape;
|
|
1305
|
+
frame.moveTo(-0.1, 0.05);
|
|
1306
|
+
frame.quadraticCurveTo(0, 0.075, 0.1, 0.05);
|
|
1307
|
+
frame.quadraticCurveTo(0.12, -0.025, 0.06, -0.075);
|
|
1308
|
+
frame.quadraticCurveTo(0, -0.095, -0.06, -0.075);
|
|
1309
|
+
frame.quadraticCurveTo(-0.12, -0.025, -0.1, 0.05);
|
|
1310
|
+
frame.holes.push(lens);
|
|
1311
|
+
const lensGeometry = slab(lens, 0.006, 0.003);
|
|
1312
|
+
const uv = lensGeometry.attributes.uv;
|
|
1313
|
+
for (let i = 0;i < uv.count; i += 1)
|
|
1314
|
+
uv.setXY(i, uv.getX(i) * 5 + 0.5, uv.getY(i) * 5 + 0.5);
|
|
1315
|
+
const frameGeometry = slab(frame, 0.014, 0.004);
|
|
1316
|
+
const turn = 0.32;
|
|
1317
|
+
const z = R(EYES_Y) * DEPTH;
|
|
1318
|
+
for (const side of [-1, 1]) {
|
|
1319
|
+
const x = side * 0.13;
|
|
1320
|
+
const at = [x, EYES_Y, z + 0.035 - Math.abs(x) * 0.18];
|
|
1321
|
+
add(lensGeometry, "#ffffff", { at, rotate: [0, side * turn, 0], scale: [side, 1, 1] }, { map: glass, sheen: 0.7, outline: false, double: true });
|
|
1322
|
+
add(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 });
|
|
1323
|
+
add(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
|
+
}
|
|
1325
|
+
add(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
|
+
return;
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
var BUILDERS = {
|
|
1330
|
+
"bunny-ears": bunnyEars,
|
|
1331
|
+
"cat-ears": catEars,
|
|
1332
|
+
"top-hat": topHat,
|
|
1333
|
+
crown,
|
|
1334
|
+
"party-hat": partyHat,
|
|
1335
|
+
halo,
|
|
1336
|
+
bow,
|
|
1337
|
+
"ribbon-dress": ribbonDress,
|
|
1338
|
+
"crop-hoodie": cropHoodie,
|
|
1339
|
+
"idol-set": idolSet,
|
|
1340
|
+
"street-jacket": streetJacket,
|
|
1341
|
+
"blazer-coat": blazerCoat,
|
|
1342
|
+
"brawler-vest": brawlerVest,
|
|
1343
|
+
"martial-gi": martialGi,
|
|
1344
|
+
"chibi-overalls": chibiOveralls,
|
|
1345
|
+
"pleated-skirt": pleatedSkirt,
|
|
1346
|
+
tuxedo,
|
|
1347
|
+
"hero-cape": heroCape,
|
|
1348
|
+
scarf,
|
|
1349
|
+
sunglasses
|
|
65
1350
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1351
|
+
function buildGarment(key, kit) {
|
|
1352
|
+
return BUILDERS[key](kit);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
// src/hair3d.ts
|
|
1356
|
+
var SKULL = new Vector3(0, BLOB_SEAT + 0.08, 0);
|
|
1357
|
+
var hexCh = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
|
|
1358
|
+
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
|
+
function resolvePalette(base, override) {
|
|
1360
|
+
if (!override || !/^#[0-9a-f]{6}$/i.test(override))
|
|
1361
|
+
return base;
|
|
1362
|
+
return {
|
|
1363
|
+
color: override,
|
|
1364
|
+
tip: tintHex(override, "#fff0f8", 0.34),
|
|
1365
|
+
inner: tintHex(override, "#1c1238", 0.42),
|
|
1366
|
+
ring: base.ring ?? 1
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
var anime = (p, ring = p.ring ?? 1) => ({
|
|
1370
|
+
anime: { center: [SKULL.x, SKULL.y, SKULL.z], ring, tip: p.tip, inner: p.inner }
|
|
1371
|
+
});
|
|
1372
|
+
function onHead(radius, phi, y, out) {
|
|
1373
|
+
const r = Math.max(0.02, radius(Math.min(y, TOP - 0.005))) + out;
|
|
1374
|
+
return new Vector3(Math.sin(phi) * r, y, Math.cos(phi) * r * DEPTH);
|
|
1375
|
+
}
|
|
1376
|
+
var UP = new Vector3(0, 1, 0);
|
|
1377
|
+
var FORWARD = new Vector3(0, 0, 1);
|
|
1378
|
+
function clump(points, width, thickness, tip = 1, twist = 0) {
|
|
1379
|
+
const curve = new CatmullRomCurve3(points, false, "centripetal");
|
|
1380
|
+
const segments = 22;
|
|
1381
|
+
const sides = 10;
|
|
1382
|
+
const positions = [];
|
|
1383
|
+
const along = [];
|
|
1384
|
+
const indices = [];
|
|
1385
|
+
const tangent = new Vector3;
|
|
1386
|
+
const out = new Vector3;
|
|
1387
|
+
const across = new Vector3;
|
|
1388
|
+
const depth = new Vector3;
|
|
1389
|
+
for (let k = 0;k <= segments; k += 1) {
|
|
1390
|
+
const t = k / segments;
|
|
1391
|
+
const p = curve.getPointAt(t);
|
|
1392
|
+
curve.getTangentAt(t, tangent);
|
|
1393
|
+
out.copy(p).sub(SKULL).normalize();
|
|
1394
|
+
across.crossVectors(tangent, out);
|
|
1395
|
+
if (across.lengthSq() < 0.04)
|
|
1396
|
+
across.crossVectors(tangent, FORWARD);
|
|
1397
|
+
if (across.lengthSq() < 0.04)
|
|
1398
|
+
across.crossVectors(tangent, UP);
|
|
1399
|
+
across.normalize();
|
|
1400
|
+
depth.crossVectors(across, tangent).normalize();
|
|
1401
|
+
if (twist) {
|
|
1402
|
+
const turn = twist * t * t;
|
|
1403
|
+
const a = across.clone().multiplyScalar(Math.cos(turn)).addScaledVector(depth, Math.sin(turn));
|
|
1404
|
+
depth.multiplyScalar(Math.cos(turn)).addScaledVector(across, -Math.sin(turn));
|
|
1405
|
+
across.copy(a);
|
|
1406
|
+
}
|
|
1407
|
+
const taper = Math.max(1 - tip, (1 - t) ** 0.72);
|
|
1408
|
+
const swell = 1 + 0.48 * Math.sin(Math.min(1, t * 1.45) * Math.PI);
|
|
1409
|
+
const s = taper * swell;
|
|
1410
|
+
for (let m = 0;m <= sides; m += 1) {
|
|
1411
|
+
const a = m / sides * Math.PI * 2;
|
|
1412
|
+
const c = Math.cos(a);
|
|
1413
|
+
const n = Math.sin(a);
|
|
1414
|
+
const w = c * width * s;
|
|
1415
|
+
const d = n * thickness * s * (0.38 + 0.62 * Math.abs(n));
|
|
1416
|
+
positions.push(p.x + across.x * w + depth.x * d, p.y + across.y * w + depth.y * d, p.z + across.z * w + depth.z * d);
|
|
1417
|
+
along.push(t);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
for (let k = 0;k < segments; k += 1)
|
|
1421
|
+
for (let m = 0;m < sides; m += 1) {
|
|
1422
|
+
const a = k * (sides + 1) + m;
|
|
1423
|
+
const c = a + sides + 1;
|
|
1424
|
+
indices.push(a, c, a + 1, a + 1, c, c + 1);
|
|
1425
|
+
}
|
|
1426
|
+
if (tip < 1) {
|
|
1427
|
+
const last = segments * (sides + 1);
|
|
1428
|
+
const end = curve.getPointAt(1);
|
|
1429
|
+
const centre = positions.length / 3;
|
|
1430
|
+
positions.push(end.x, end.y, end.z);
|
|
1431
|
+
along.push(1);
|
|
1432
|
+
for (let m = 0;m < sides; m += 1)
|
|
1433
|
+
indices.push(last + m, centre, last + m + 1);
|
|
1434
|
+
}
|
|
1435
|
+
const geometry = new BufferGeometry2;
|
|
1436
|
+
geometry.setAttribute("position", new BufferAttribute2(new Float32Array(positions), 3));
|
|
1437
|
+
geometry.setAttribute("along", new BufferAttribute2(new Float32Array(along), 1));
|
|
1438
|
+
geometry.setIndex(indices);
|
|
1439
|
+
geometry.computeVertexNormals();
|
|
1440
|
+
return { geometry, along: Float32Array.from(along), root: points[0] ?? new Vector3 };
|
|
1441
|
+
}
|
|
1442
|
+
function swinger(made) {
|
|
1443
|
+
const position = made.geometry.attributes.position;
|
|
1444
|
+
const rest = Float32Array.from(position.array);
|
|
1445
|
+
const { root, along } = made;
|
|
1446
|
+
return (pitch, roll) => {
|
|
1447
|
+
for (let i = 0;i < position.count; i += 1) {
|
|
1448
|
+
const t = along[i] ?? 0;
|
|
1449
|
+
const k = t * t;
|
|
1450
|
+
const x = (rest[i * 3] ?? 0) - root.x;
|
|
1451
|
+
const y = (rest[i * 3 + 1] ?? 0) - root.y;
|
|
1452
|
+
const z = (rest[i * 3 + 2] ?? 0) - root.z;
|
|
1453
|
+
const a = pitch * k;
|
|
1454
|
+
const b = roll * k;
|
|
1455
|
+
const y1 = y * Math.cos(a) - z * Math.sin(a);
|
|
1456
|
+
const z1 = y * Math.sin(a) + z * Math.cos(a);
|
|
1457
|
+
position.setXYZ(i, root.x + x * Math.cos(b) - y1 * Math.sin(b), root.y + x * Math.sin(b) + y1 * Math.cos(b), root.z + z1);
|
|
1458
|
+
}
|
|
1459
|
+
position.needsUpdate = true;
|
|
1460
|
+
made.geometry.computeVertexNormals();
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
function cap(radius, front, back, grow, part = 0, partLift = 0.03) {
|
|
1464
|
+
const rows = 18;
|
|
1465
|
+
const columns = 56;
|
|
1466
|
+
const positions = [];
|
|
1467
|
+
const along = [];
|
|
1468
|
+
const indices = [];
|
|
1469
|
+
for (let i = 0;i <= rows; i += 1) {
|
|
1470
|
+
const s = i / rows;
|
|
1471
|
+
for (let j = 0;j <= columns; j += 1) {
|
|
1472
|
+
const phi = j / columns * Math.PI * 2;
|
|
1473
|
+
const facing = (1 + Math.cos(phi - part)) / 2;
|
|
1474
|
+
const line = back + (front - back) * facing ** 1.45;
|
|
1475
|
+
const y = TOP + 0.015 - s * (TOP + 0.015 - line);
|
|
1476
|
+
const dPart = Math.sin(phi - part);
|
|
1477
|
+
const lobe = Math.abs(dPart) * (1 - s * 0.65) * partLift;
|
|
1478
|
+
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.55 * (1 - s) + lobe * 0.65, p.z);
|
|
1480
|
+
along.push(s * 0.45);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
for (let i = 0;i < rows; i += 1)
|
|
1484
|
+
for (let j = 0;j < columns; j += 1) {
|
|
1485
|
+
const a = i * (columns + 1) + j;
|
|
1486
|
+
const b = a + columns + 1;
|
|
1487
|
+
indices.push(a, b, a + 1, a + 1, b, b + 1);
|
|
1488
|
+
}
|
|
1489
|
+
const geometry = new BufferGeometry2;
|
|
1490
|
+
geometry.setAttribute("position", new BufferAttribute2(new Float32Array(positions), 3));
|
|
1491
|
+
geometry.setAttribute("along", new BufferAttribute2(new Float32Array(along), 1));
|
|
1492
|
+
geometry.setIndex(indices);
|
|
1493
|
+
geometry.computeVertexNormals();
|
|
1494
|
+
return geometry;
|
|
1495
|
+
}
|
|
1496
|
+
function add(b, p, made) {
|
|
1497
|
+
b.add(made.geometry, p.color, {}, anime(p));
|
|
1498
|
+
return made;
|
|
1499
|
+
}
|
|
1500
|
+
function base(b, radius, p, front, back, grow, part = 0, partLift = 0.036) {
|
|
1501
|
+
b.add(cap(radius, Math.min(front, 0.64), Math.min(back, 0.36), grow * 1.24, part, partLift), p.color, {}, { ...anime(p), double: true });
|
|
1502
|
+
}
|
|
1503
|
+
function fringe(b, radius, p, bangs, part = 0) {
|
|
1504
|
+
const wBoost = 1.2;
|
|
1505
|
+
const yShift = -0.04;
|
|
1506
|
+
for (const bang of bangs) {
|
|
1507
|
+
const sweep = bang.sweep ?? 0;
|
|
1508
|
+
const mid = bang.midSweep ?? sweep * 0.48;
|
|
1509
|
+
const lift = bang.lift ?? 0;
|
|
1510
|
+
const flick = bang.flick ?? 0;
|
|
1511
|
+
const rootPhi = part + (bang.at - part) * 0.34;
|
|
1512
|
+
const root = onHead(radius, rootPhi, TOP - 0.01, 0.065 + lift * 0.4);
|
|
1513
|
+
const crest = onHead(radius, part + (bang.at - part) * 0.7 + mid * 0.28, 0.87, 0.14 + lift);
|
|
1514
|
+
const fall = onHead(radius, bang.at + mid, 0.7 + yShift * 0.5, 0.115 + lift * 0.85);
|
|
1515
|
+
const end = onHead(radius, bang.at + sweep, bang.length + yShift, 0.075 + lift * 0.45 + flick);
|
|
1516
|
+
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
|
+
add(b, p, made);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
function sidelocks(b, radius, p, end, width = 0.09, {
|
|
1521
|
+
blunt = false,
|
|
1522
|
+
flick = 0,
|
|
1523
|
+
curlIn = 0.22
|
|
1524
|
+
} = {}) {
|
|
1525
|
+
for (const side of [-1, 1]) {
|
|
1526
|
+
const skew = side > 0 ? 0.045 : -0.02;
|
|
1527
|
+
const layers = [
|
|
1528
|
+
[0.82, 0, width, 0.095],
|
|
1529
|
+
[1.04, 0.09, width * 0.88, 0.105],
|
|
1530
|
+
[0.7, 0.14, width * 0.46, 0.088]
|
|
1531
|
+
];
|
|
1532
|
+
for (const [phi, drop, w, out] of layers) {
|
|
1533
|
+
const y = end + drop + skew;
|
|
1534
|
+
const endOut = blunt ? 0.075 : 0.078 + flick;
|
|
1535
|
+
const path = [
|
|
1536
|
+
onHead(radius, side * (phi - 0.28), TOP - 0.04, 0.055),
|
|
1537
|
+
onHead(radius, side * (phi + 0.04), 0.79, out + 0.02),
|
|
1538
|
+
onHead(radius, side * (phi + 0.06), 0.54, out),
|
|
1539
|
+
onHead(radius, side * (phi - (blunt ? 0.03 : curlIn * 0.5)), y + 0.12, out * 0.88 + flick * 0.35),
|
|
1540
|
+
onHead(radius, side * (phi - (blunt ? 0.04 : curlIn)), y, endOut)
|
|
1541
|
+
];
|
|
1542
|
+
add(b, p, clump(path, w, w * 0.4, blunt ? 0.58 : 1, side * (blunt ? 0.2 : 0.55)));
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
function crownTufts(b, radius, p, tufts) {
|
|
1547
|
+
for (const [phi, y, len, liftOut, w] of tufts) {
|
|
1548
|
+
const root = onHead(radius, phi, y, 0.05);
|
|
1549
|
+
const out = onHead(radius, phi, y, 1).sub(root).normalize();
|
|
1550
|
+
const mid = root.clone().addScaledVector(out, liftOut).add(new Vector3(Math.sin(phi + 0.6) * 0.05, len * 0.35, Math.cos(phi + 0.6) * 0.03));
|
|
1551
|
+
const tip = mid.clone().addScaledVector(out, liftOut * 0.85).add(new Vector3(Math.sin(phi + 1.1) * 0.08, -len * 0.45, Math.cos(phi + 1.1) * 0.05));
|
|
1552
|
+
add(b, p, clump([root, mid, tip], w, w * 0.42, 1, Math.sin(phi) * 0.5));
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function strays(b, radius, p, at) {
|
|
1556
|
+
for (const [phi, y, length] of at) {
|
|
1557
|
+
const root = onHead(radius, phi, y, 0.075);
|
|
1558
|
+
const out = onHead(radius, phi, y, 1).sub(root).normalize();
|
|
1559
|
+
const path = [
|
|
1560
|
+
root,
|
|
1561
|
+
root.clone().addScaledVector(out, 0.065).add(new Vector3(Math.cos(phi) * 0.025, -length * 0.35, 0)),
|
|
1562
|
+
root.clone().addScaledVector(out, 0.1).add(new Vector3(Math.sin(phi * 3.1) * 0.055, -length, Math.cos(phi * 2.3) * 0.03))
|
|
1563
|
+
];
|
|
1564
|
+
add(b, p, clump(path, 0.028, 0.012, 1, 0.4));
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
function ahoge(b, p, lean = 1, size = 1) {
|
|
1568
|
+
const crown2 = new Vector3(0.02 * lean, TOP + 0.035, -0.02);
|
|
1569
|
+
const made = clump([
|
|
1570
|
+
crown2,
|
|
1571
|
+
crown2.clone().add(new Vector3(0.03 * lean * size, 0.13 * size, 0.03)),
|
|
1572
|
+
crown2.clone().add(new Vector3(0.09 * lean * size, 0.19 * size, 0.08)),
|
|
1573
|
+
crown2.clone().add(new Vector3(0.15 * lean * size, 0.14 * size, 0.11))
|
|
1574
|
+
], 0.038 * size, 0.016 * size);
|
|
1575
|
+
add(b, p, made);
|
|
1576
|
+
const swing = swinger(made);
|
|
1577
|
+
const spring = new Spring(60, 3);
|
|
1578
|
+
return (_clock, delta, raw) => {
|
|
1579
|
+
const motion = calm(raw);
|
|
1580
|
+
swing(spring.step(clamp(motion.lift * 0.4, -0.8, 0.8), delta), -motion.yaw * 0.05);
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
function back(b, radius, p, {
|
|
1584
|
+
count,
|
|
1585
|
+
from,
|
|
1586
|
+
end,
|
|
1587
|
+
width,
|
|
1588
|
+
wave = 0.05,
|
|
1589
|
+
curl = 0.08,
|
|
1590
|
+
flick = 0,
|
|
1591
|
+
blunt = false,
|
|
1592
|
+
layers = 2,
|
|
1593
|
+
spread = 0.08
|
|
1594
|
+
}) {
|
|
1595
|
+
const made = [];
|
|
1596
|
+
const step = (Math.PI * 2 - from * 2) / Math.max(1, count - 1);
|
|
1597
|
+
for (let layer = 0;layer < layers; layer += 1) {
|
|
1598
|
+
const under = layer < layers - 1;
|
|
1599
|
+
const nLocks = under ? Math.max(1, count - 1) : count;
|
|
1600
|
+
for (let i = 0;i < nLocks; i += 1) {
|
|
1601
|
+
const jitter = ((i * 17 + layer * 13) % 7 / 7 - 0.5) * 0.07;
|
|
1602
|
+
const phi = from + i * step + (under ? step / 2 : 0) + jitter;
|
|
1603
|
+
const vary = (i * 7 + layer * 3) % 5 / 5;
|
|
1604
|
+
const reach = blunt ? end : end + (under ? -0.05 : 0.06) - vary * (0.09 + Math.abs(flick) * 0.35);
|
|
1605
|
+
const steps = 6;
|
|
1606
|
+
const path = [onHead(radius, phi * 0.85, TOP - 0.015, 0.045)];
|
|
1607
|
+
for (let k = 1;k <= steps; k += 1) {
|
|
1608
|
+
const t = k / steps;
|
|
1609
|
+
const y = TOP - 0.04 - (TOP - 0.04 - reach) * t;
|
|
1610
|
+
const s = Math.sin(t * Math.PI * 1.65 + i * 0.85 + layer) * wave;
|
|
1611
|
+
const outFlick = t > 0.65 ? flick * ((t - 0.65) / 0.35) ** 1.4 : 0;
|
|
1612
|
+
const gap = spread + 0.06 * Math.sin(Math.min(1, t * 1.9) * Math.PI * 0.5) + t * 0.035 + outFlick - (under ? 0.022 : 0);
|
|
1613
|
+
const turn = t > 0.72 ? (phi < Math.PI ? -curl : curl) * ((t - 0.72) / 0.28) : 0;
|
|
1614
|
+
path.push(onHead(radius, phi + s + turn, y, gap));
|
|
1615
|
+
}
|
|
1616
|
+
const twist = (i % 3 === 0 ? 0.85 : i % 3 === 1 ? -0.55 : 0.25) * (blunt ? 0.25 : 1);
|
|
1617
|
+
made.push(add(b, p, clump(path, width * (0.86 + vary * 0.34) * (under ? 1.08 : 0.92), width * 0.38, blunt ? 0.56 : 1, twist)));
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
return made;
|
|
1621
|
+
}
|
|
1622
|
+
function hangs(made) {
|
|
1623
|
+
const swings = made.map(swinger);
|
|
1624
|
+
const pitch = new Spring(45, 4.5);
|
|
1625
|
+
const roll = new Spring(40, 4);
|
|
1626
|
+
return (clock, delta, raw) => {
|
|
1627
|
+
const motion = calm(raw);
|
|
1628
|
+
const p = pitch.step(clamp(motion.lift * 0.18, -0.6, 0.6), delta);
|
|
1629
|
+
const r = roll.step(-motion.yaw * 0.07 + Math.sin(clock * 1.3) * 0.03, delta);
|
|
1630
|
+
swings.forEach((swing, i) => {
|
|
1631
|
+
swing(p * (1 + i % 3 * 0.1), r * (1 + i % 2 * 0.15));
|
|
1632
|
+
});
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
var together = (...ticks) => (clock, delta, motion) => {
|
|
1636
|
+
for (const tick of ticks)
|
|
1637
|
+
tick?.(clock, delta, motion);
|
|
72
1638
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1639
|
+
function tail(radius, phi, tieY, length, spread, count = 5) {
|
|
1640
|
+
const paths = [];
|
|
1641
|
+
for (let i = 0;i < count; i += 1) {
|
|
1642
|
+
const k = i / Math.max(1, count - 1) - 0.5;
|
|
1643
|
+
const fan = k * spread;
|
|
1644
|
+
const path = [onHead(radius, phi, tieY, 0.06)];
|
|
1645
|
+
const steps = 7;
|
|
1646
|
+
const reach = length * (1 - Math.abs(k) * 0.2 + i * 3 % 3 * 0.05);
|
|
1647
|
+
for (let n = 1;n <= steps; n += 1) {
|
|
1648
|
+
const t = n / steps;
|
|
1649
|
+
const y = tieY + 0.08 * Math.sin(t * Math.PI) - reach * t ** 1.18;
|
|
1650
|
+
const gap = 0.14 + 0.14 * Math.sin(Math.min(1, t * 1.8) * Math.PI * 0.5) + Math.abs(k) * 0.06 + t * 0.04;
|
|
1651
|
+
const s = Math.sin(t * Math.PI * 1.7 + i * 0.5) * 0.1;
|
|
1652
|
+
path.push(onHead(radius, phi + fan * (0.45 + t) + s * Math.sign(phi || 1), y, gap));
|
|
1653
|
+
}
|
|
1654
|
+
paths.push(path);
|
|
1655
|
+
}
|
|
1656
|
+
return paths;
|
|
1657
|
+
}
|
|
1658
|
+
function ringlet(origin, length, spiralR, turns, dir) {
|
|
1659
|
+
const pts = [];
|
|
1660
|
+
const steps = 16;
|
|
1661
|
+
for (let k = 0;k <= steps; k += 1) {
|
|
1662
|
+
const t = k / steps;
|
|
1663
|
+
const a = t * turns * Math.PI * 2 * dir;
|
|
1664
|
+
const r = spiralR * (0.35 + 0.75 * Math.sin(t * Math.PI * 0.85));
|
|
1665
|
+
pts.push(new Vector3(origin.x + Math.cos(a) * r + dir * t * 0.08, origin.y - t * length, origin.z + Math.sin(a) * r + t * 0.04));
|
|
1666
|
+
}
|
|
1667
|
+
return pts;
|
|
1668
|
+
}
|
|
1669
|
+
function ribbon(b, at, facing, color, size = 1) {
|
|
1670
|
+
const node = b.node({ at: [at.x, at.y, at.z], rotate: [0, facing, 0], scale: [size, size, size] });
|
|
1671
|
+
const loop = new TorusGeometry2(0.052, 0.018, 10, 24);
|
|
1672
|
+
for (const side of [-1, 1]) {
|
|
1673
|
+
b.add(loop, color, {
|
|
1674
|
+
at: [side * 0.056, 0.008, 0],
|
|
1675
|
+
rotate: [0, 0, side * 0.35],
|
|
1676
|
+
scale: [1.18, 0.74, 0.62],
|
|
1677
|
+
parent: node
|
|
1678
|
+
});
|
|
1679
|
+
const end = clump([
|
|
1680
|
+
new Vector3(side * 0.01, -0.01, 0.01),
|
|
1681
|
+
new Vector3(side * 0.038, -0.065, 0.014),
|
|
1682
|
+
new Vector3(side * 0.034, -0.13, 0.008)
|
|
1683
|
+
], 0.024, 0.006, 0.5);
|
|
1684
|
+
b.add(end.geometry, color, { parent: node });
|
|
1685
|
+
}
|
|
1686
|
+
b.add(new SphereGeometry2(0.026, 12, 10), color, { scale: [1, 1, 0.82], parent: node });
|
|
1687
|
+
}
|
|
1688
|
+
function clip(b, at, tilt, color) {
|
|
1689
|
+
const node = b.node({ at: [at.x, at.y, at.z], rotate: [0, Math.atan2(at.x, at.z), tilt] });
|
|
1690
|
+
const bar = new BoxGeometry(0.075, 0.016, 0.012);
|
|
1691
|
+
b.add(bar, color, { rotate: [0, 0, 0.45], parent: node }, { sheen: 0.5 });
|
|
1692
|
+
b.add(bar, color, { rotate: [0, 0, -0.45], parent: node }, { sheen: 0.5 });
|
|
1693
|
+
}
|
|
1694
|
+
var HAIR = {
|
|
1695
|
+
"wolf-cut": {
|
|
1696
|
+
palette: { color: "#1d1d2e", tip: "#565985", inner: "#11101d", ring: 0.95 },
|
|
1697
|
+
build(b, radius, p) {
|
|
1698
|
+
base(b, radius, p, 0.74, 0.42, 0.068, -0.18, 0.045);
|
|
1699
|
+
fringe(b, radius, p, [
|
|
1700
|
+
{
|
|
1701
|
+
at: -0.68,
|
|
1702
|
+
length: 0.46,
|
|
1703
|
+
width: 0.13,
|
|
1704
|
+
sweep: -0.22,
|
|
1705
|
+
midSweep: -0.06,
|
|
1706
|
+
lift: 0.01,
|
|
1707
|
+
flick: 0.02
|
|
1708
|
+
},
|
|
1709
|
+
{ at: -0.34, length: 0.54, width: 0.135, sweep: -0.18, midSweep: -0.05 },
|
|
1710
|
+
{ at: 0.08, length: 0.55, width: 0.14, sweep: 0.24, midSweep: 0.12 },
|
|
1711
|
+
{ at: 0.48, length: 0.52, width: 0.13, sweep: 0.28, midSweep: 0.12, lift: 0.01 },
|
|
1712
|
+
{ at: 0.74, length: 0.45, width: 0.12, sweep: 0.24, flick: 0.025 },
|
|
1713
|
+
{ at: -0.14, length: 0.5, width: 0.065, sweep: 0.22, midSweep: 0.08, lift: 0.028 },
|
|
1714
|
+
{ at: 0.24, length: 0.53, width: 0.058, sweep: -0.28, midSweep: -0.12, lift: 0.032 },
|
|
1715
|
+
{ at: -0.48, length: 0.58, width: 0.055, sweep: 0.16, lift: 0.024 }
|
|
1716
|
+
], -0.18);
|
|
1717
|
+
sidelocks(b, radius, p, 0.22, 0.095, { flick: 0.065, curlIn: 0.04 });
|
|
1718
|
+
const upper = back(b, radius, p, {
|
|
1719
|
+
count: 14,
|
|
1720
|
+
from: 1,
|
|
1721
|
+
end: 0.42,
|
|
1722
|
+
width: 0.15,
|
|
1723
|
+
wave: 0.06,
|
|
1724
|
+
flick: 0.11,
|
|
1725
|
+
layers: 1,
|
|
1726
|
+
spread: 0.1
|
|
1727
|
+
});
|
|
1728
|
+
const nape = back(b, radius, p, {
|
|
1729
|
+
count: 12,
|
|
1730
|
+
from: 1.22,
|
|
1731
|
+
end: 0.06,
|
|
1732
|
+
width: 0.125,
|
|
1733
|
+
wave: 0.08,
|
|
1734
|
+
flick: 0.16,
|
|
1735
|
+
layers: 2,
|
|
1736
|
+
spread: 0.08
|
|
1737
|
+
});
|
|
1738
|
+
crownTufts(b, radius, p, [
|
|
1739
|
+
[-0.45, TOP - 0.03, 0.22, 0.09, 0.075],
|
|
1740
|
+
[0.32, TOP - 0.02, 0.24, 0.1, 0.08],
|
|
1741
|
+
[1.35, TOP - 0.08, 0.26, 0.11, 0.085],
|
|
1742
|
+
[-1.55, TOP - 0.07, 0.25, 0.1, 0.08],
|
|
1743
|
+
[2.5, TOP - 0.06, 0.24, 0.11, 0.085],
|
|
1744
|
+
[-2.6, TOP - 0.05, 0.22, 0.09, 0.075]
|
|
1745
|
+
]);
|
|
1746
|
+
strays(b, radius, p, [
|
|
1747
|
+
[0.82, 0.72, 0.18],
|
|
1748
|
+
[-0.88, 0.74, 0.16],
|
|
1749
|
+
[1.75, 0.56, 0.2],
|
|
1750
|
+
[-1.9, 0.52, 0.18]
|
|
1751
|
+
]);
|
|
1752
|
+
return hangs([...upper, ...nape]);
|
|
1753
|
+
}
|
|
80
1754
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1755
|
+
"curtain-ikemen": {
|
|
1756
|
+
palette: { color: "#281e2c", tip: "#6e4e60", inner: "#17101c", ring: 1.05 },
|
|
1757
|
+
build(b, radius, p) {
|
|
1758
|
+
base(b, radius, p, 0.76, 0.44, 0.065, 0.04, 0.048);
|
|
1759
|
+
fringe(b, radius, p, [
|
|
1760
|
+
{
|
|
1761
|
+
at: -0.14,
|
|
1762
|
+
length: 0.5,
|
|
1763
|
+
width: 0.13,
|
|
1764
|
+
sweep: -0.34,
|
|
1765
|
+
midSweep: -0.22,
|
|
1766
|
+
lift: 0.025,
|
|
1767
|
+
twist: -0.4
|
|
1768
|
+
},
|
|
1769
|
+
{ at: -0.44, length: 0.48, width: 0.14, sweep: -0.2, midSweep: -0.14, lift: 0.015 },
|
|
1770
|
+
{ at: -0.74, length: 0.42, width: 0.12, sweep: -0.1, flick: 0.02 },
|
|
1771
|
+
{
|
|
1772
|
+
at: 0.18,
|
|
1773
|
+
length: 0.52,
|
|
1774
|
+
width: 0.135,
|
|
1775
|
+
sweep: 0.32,
|
|
1776
|
+
midSweep: 0.2,
|
|
1777
|
+
lift: 0.025,
|
|
1778
|
+
twist: 0.4
|
|
1779
|
+
},
|
|
1780
|
+
{ at: 0.48, length: 0.48, width: 0.14, sweep: 0.22, midSweep: 0.14, lift: 0.015 },
|
|
1781
|
+
{ at: 0.76, length: 0.43, width: 0.12, sweep: 0.12, flick: 0.02 },
|
|
1782
|
+
{ at: -0.02, length: 0.56, width: 0.055, sweep: -0.18, midSweep: -0.28, lift: 0.036 },
|
|
1783
|
+
{ at: 0.09, length: 0.58, width: 0.05, sweep: 0.14, midSweep: 0.22, lift: 0.034 }
|
|
1784
|
+
], 0.04);
|
|
1785
|
+
sidelocks(b, radius, p, 0.3, 0.085, { flick: 0.03, curlIn: 0.12 });
|
|
1786
|
+
const locks = back(b, radius, p, {
|
|
1787
|
+
count: 15,
|
|
1788
|
+
from: 1.08,
|
|
1789
|
+
end: 0.28,
|
|
1790
|
+
width: 0.14,
|
|
1791
|
+
wave: 0.04,
|
|
1792
|
+
flick: 0.06,
|
|
1793
|
+
layers: 2,
|
|
1794
|
+
spread: 0.09
|
|
1795
|
+
});
|
|
1796
|
+
crownTufts(b, radius, p, [
|
|
1797
|
+
[-0.3, TOP - 0.02, 0.18, 0.08, 0.075],
|
|
1798
|
+
[0.36, TOP - 0.02, 0.19, 0.085, 0.075],
|
|
1799
|
+
[2.2, TOP - 0.06, 0.2, 0.08, 0.07]
|
|
1800
|
+
]);
|
|
1801
|
+
return hangs(locks);
|
|
1802
|
+
}
|
|
1803
|
+
},
|
|
1804
|
+
"messy-fluff": {
|
|
1805
|
+
palette: { color: "#e0e7f8", tip: "#9fb4f0", inner: "#8c9ac4", ring: 1 },
|
|
1806
|
+
build(b, radius, p) {
|
|
1807
|
+
base(b, radius, p, 0.74, 0.44, 0.075, -0.22, 0.05);
|
|
1808
|
+
fringe(b, radius, p, [
|
|
1809
|
+
{ at: -0.64, length: 0.52, width: 0.13, sweep: -0.16, lift: 0.015 },
|
|
1810
|
+
{ at: -0.34, length: 0.5, width: 0.135, sweep: 0.12, midSweep: -0.06, lift: 0.01 },
|
|
1811
|
+
{ at: -0.04, length: 0.53, width: 0.13, sweep: -0.18, midSweep: 0.04, lift: 0.02 },
|
|
1812
|
+
{ at: 0.28, length: 0.49, width: 0.14, sweep: 0.18, midSweep: 0.06, lift: 0.015 },
|
|
1813
|
+
{ at: 0.62, length: 0.52, width: 0.125, sweep: 0.22, lift: 0.015 },
|
|
1814
|
+
{
|
|
1815
|
+
at: -0.2,
|
|
1816
|
+
length: 0.47,
|
|
1817
|
+
width: 0.062,
|
|
1818
|
+
sweep: 0.26,
|
|
1819
|
+
midSweep: 0.1,
|
|
1820
|
+
lift: 0.038,
|
|
1821
|
+
flick: 0.02
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
at: 0.18,
|
|
1825
|
+
length: 0.48,
|
|
1826
|
+
width: 0.06,
|
|
1827
|
+
sweep: -0.24,
|
|
1828
|
+
midSweep: -0.1,
|
|
1829
|
+
lift: 0.04,
|
|
1830
|
+
flick: 0.02
|
|
1831
|
+
},
|
|
1832
|
+
{ at: 0.52, length: 0.55, width: 0.055, sweep: -0.12, lift: 0.032 }
|
|
1833
|
+
], -0.22);
|
|
1834
|
+
sidelocks(b, radius, p, 0.34, 0.088, { flick: 0.07, curlIn: 0.02 });
|
|
1835
|
+
const locks = back(b, radius, p, {
|
|
1836
|
+
count: 15,
|
|
1837
|
+
from: 1,
|
|
1838
|
+
end: 0.3,
|
|
1839
|
+
width: 0.15,
|
|
1840
|
+
wave: 0.055,
|
|
1841
|
+
flick: 0.13,
|
|
1842
|
+
layers: 2,
|
|
1843
|
+
spread: 0.1
|
|
1844
|
+
});
|
|
1845
|
+
crownTufts(b, radius, p, [
|
|
1846
|
+
[-0.65, TOP - 0.03, 0.24, 0.11, 0.085],
|
|
1847
|
+
[-0.08, TOP - 0.01, 0.26, 0.12, 0.085],
|
|
1848
|
+
[0.52, TOP - 0.02, 0.25, 0.11, 0.085],
|
|
1849
|
+
[1.25, TOP - 0.06, 0.26, 0.12, 0.09],
|
|
1850
|
+
[-1.35, TOP - 0.06, 0.25, 0.11, 0.085],
|
|
1851
|
+
[2.3, TOP - 0.05, 0.26, 0.11, 0.085],
|
|
1852
|
+
[-2.4, TOP - 0.05, 0.24, 0.1, 0.08]
|
|
1853
|
+
]);
|
|
1854
|
+
return together(ahoge(b, p, 1, 1.1), hangs(locks));
|
|
1855
|
+
}
|
|
87
1856
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1857
|
+
"silky-layers": {
|
|
1858
|
+
palette: { color: "#f2cfb4", tip: "#ff9ec8", inner: "#b87a86", ring: 1.1 },
|
|
1859
|
+
build(b, radius, p) {
|
|
1860
|
+
base(b, radius, p, 0.72, 0.4, 0.065, 0.22, 0.042);
|
|
1861
|
+
fringe(b, radius, p, [
|
|
1862
|
+
{ at: -0.68, length: 0.44, width: 0.12, sweep: -0.14, lift: 0.01 },
|
|
1863
|
+
{ at: -0.36, length: 0.56, width: 0.1, sweep: -0.06, lift: 0.008 },
|
|
1864
|
+
{ at: -0.06, length: 0.57, width: 0.085, sweep: 0.08, lift: 0.015 },
|
|
1865
|
+
{ at: 0.22, length: 0.55, width: 0.095, sweep: 0.1, lift: 0.01 },
|
|
1866
|
+
{ at: 0.52, length: 0.52, width: 0.11, sweep: 0.16, lift: 0.012 },
|
|
1867
|
+
{ at: 0.74, length: 0.42, width: 0.115, sweep: 0.14, lift: 0.01 },
|
|
1868
|
+
{ at: -0.22, length: 0.53, width: 0.048, sweep: 0.12, lift: 0.028 },
|
|
1869
|
+
{ at: 0.1, length: 0.52, width: 0.046, sweep: -0.14, lift: 0.03 }
|
|
1870
|
+
], 0.22);
|
|
1871
|
+
sidelocks(b, radius, p, -0.08, 0.1, { curlIn: 0.24, flick: 0.02 });
|
|
1872
|
+
const midLayer = back(b, radius, p, {
|
|
1873
|
+
count: 14,
|
|
1874
|
+
from: 1.05,
|
|
1875
|
+
end: 0.18,
|
|
1876
|
+
width: 0.15,
|
|
1877
|
+
wave: 0.06,
|
|
1878
|
+
flick: 0.07,
|
|
1879
|
+
layers: 1,
|
|
1880
|
+
spread: 0.1
|
|
1881
|
+
});
|
|
1882
|
+
const longFlow = back(b, radius, p, {
|
|
1883
|
+
count: 16,
|
|
1884
|
+
from: 1.12,
|
|
1885
|
+
end: -0.95,
|
|
1886
|
+
width: 0.16,
|
|
1887
|
+
wave: 0.09,
|
|
1888
|
+
curl: 0.14,
|
|
1889
|
+
layers: 2,
|
|
1890
|
+
spread: 0.09
|
|
1891
|
+
});
|
|
1892
|
+
strays(b, radius, p, [
|
|
1893
|
+
[0.78, 0.68, 0.2],
|
|
1894
|
+
[-0.82, 0.65, 0.22],
|
|
1895
|
+
[1.6, 0.45, 0.22],
|
|
1896
|
+
[-1.7, 0.4, 0.2]
|
|
1897
|
+
]);
|
|
1898
|
+
clip(b, onHead(radius, 0.62, 0.82, 0.12), -0.35, "#ff7eb8");
|
|
1899
|
+
return together(ahoge(b, p, -1, 0.9), hangs([...midLayer, ...longFlow]));
|
|
1900
|
+
}
|
|
94
1901
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
1902
|
+
"ojou-curls": {
|
|
1903
|
+
palette: { color: "#eca8dc", tip: "#b596ff", inner: "#9e5c9c", ring: 1.15 },
|
|
1904
|
+
build(b, radius, p) {
|
|
1905
|
+
base(b, radius, p, 0.72, 0.4, 0.065, -0.2, 0.044);
|
|
1906
|
+
fringe(b, radius, p, [
|
|
1907
|
+
{ at: -0.64, length: 0.5, width: 0.125, sweep: -0.14, lift: 0.01 },
|
|
1908
|
+
{ at: -0.34, length: 0.55, width: 0.12, sweep: -0.08 },
|
|
1909
|
+
{ at: -0.02, length: 0.54, width: 0.115, sweep: 0.12, lift: 0.014 },
|
|
1910
|
+
{ at: 0.3, length: 0.55, width: 0.12, sweep: 0.16 },
|
|
1911
|
+
{ at: 0.62, length: 0.5, width: 0.12, sweep: 0.18, lift: 0.01 },
|
|
1912
|
+
{ at: 0.14, length: 0.51, width: 0.052, sweep: -0.16, lift: 0.028 }
|
|
1913
|
+
], -0.2);
|
|
1914
|
+
sidelocks(b, radius, p, 0.14, 0.09, { curlIn: 0.26 });
|
|
1915
|
+
const backLocks = back(b, radius, p, {
|
|
1916
|
+
count: 15,
|
|
1917
|
+
from: 1.15,
|
|
1918
|
+
end: -0.22,
|
|
1919
|
+
width: 0.15,
|
|
1920
|
+
wave: 0.08,
|
|
1921
|
+
curl: 0.16,
|
|
1922
|
+
layers: 2,
|
|
1923
|
+
spread: 0.09
|
|
1924
|
+
});
|
|
1925
|
+
const curls = [];
|
|
1926
|
+
for (const side of [-1, 1]) {
|
|
1927
|
+
const origin = onHead(radius, side * 1.18, 0.58, 0.12);
|
|
1928
|
+
curls.push(add(b, p, clump(ringlet(origin, 0.92, 0.095, 2.3, side), 0.1, 0.062, 1, side * 1.2)));
|
|
1929
|
+
curls.push(add(b, p, clump(ringlet(origin.clone().add(new Vector3(side * 0.04, -0.04, -0.06)), 0.78, 0.08, 2, -side), 0.075, 0.045, 1, -side * 0.9)));
|
|
1930
|
+
}
|
|
1931
|
+
ribbon(b, onHead(radius, Math.PI, 0.84, 0.12), Math.PI, "#ffffff", 1.55);
|
|
1932
|
+
return together(ahoge(b, p, 1, 0.85), hangs([...backLocks, ...curls]));
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
"side-braid": {
|
|
1936
|
+
palette: { color: "#a45e3d", tip: "#f4c27c", inner: "#663628", ring: 1.05 },
|
|
1937
|
+
build(b, radius, p) {
|
|
1938
|
+
base(b, radius, p, 0.72, 0.42, 0.064, 0.26, 0.042);
|
|
1939
|
+
fringe(b, radius, p, [
|
|
1940
|
+
{ at: -0.62, length: 0.48, width: 0.12, sweep: -0.14 },
|
|
1941
|
+
{ at: -0.32, length: 0.54, width: 0.125, sweep: -0.16, lift: 0.01 },
|
|
1942
|
+
{ at: 0, length: 0.55, width: 0.12, sweep: -0.18, lift: 0.016 },
|
|
1943
|
+
{ at: 0.34, length: 0.56, width: 0.115, sweep: 0.18 },
|
|
1944
|
+
{ at: 0.64, length: 0.5, width: 0.115, sweep: 0.22 },
|
|
1945
|
+
{ at: 0.15, length: 0.52, width: 0.052, sweep: -0.22, lift: 0.03 }
|
|
1946
|
+
], 0.26);
|
|
1947
|
+
sidelocks(b, radius, p, 0.16, 0.085, { curlIn: 0.24 });
|
|
1948
|
+
const backLocks = back(b, radius, p, {
|
|
1949
|
+
count: 13,
|
|
1950
|
+
from: 1.2,
|
|
1951
|
+
end: 0.32,
|
|
1952
|
+
width: 0.14,
|
|
1953
|
+
wave: 0.04,
|
|
1954
|
+
curl: 0.14,
|
|
1955
|
+
layers: 2,
|
|
1956
|
+
spread: 0.08
|
|
1957
|
+
});
|
|
1958
|
+
const braidGroup = b.node();
|
|
1959
|
+
const segments = 9;
|
|
1960
|
+
const plaitGeo = new SphereGeometry2(0.085, 14, 12);
|
|
1961
|
+
for (let k = 0;k < segments; k += 1) {
|
|
1962
|
+
const t = k / (segments - 1);
|
|
1963
|
+
const phi = 1.65 - t * 0.85;
|
|
1964
|
+
const y = 0.54 - t * 0.92;
|
|
1965
|
+
const out = 0.11 + t * 0.09;
|
|
1966
|
+
const pos = onHead(radius, phi, Math.max(0.05, y), out);
|
|
1967
|
+
const sideOff = (k % 2 ? 1 : -1) * 0.034;
|
|
1968
|
+
const scale = 1.05 - t * 0.42;
|
|
1969
|
+
b.add(plaitGeo, p.color, {
|
|
1970
|
+
at: [pos.x + sideOff * 0.7, y, pos.z + sideOff * 0.5],
|
|
1971
|
+
rotate: [0.3, phi, (k % 2 ? 1 : -1) * 0.45],
|
|
1972
|
+
scale: [scale * 1.1, scale * 0.78, scale * 0.85],
|
|
1973
|
+
parent: braidGroup
|
|
1974
|
+
}, anime(p, 0.7));
|
|
1975
|
+
}
|
|
1976
|
+
const tiePos = onHead(radius, 0.82, 0.08, 0.2);
|
|
1977
|
+
tiePos.y = -0.34;
|
|
1978
|
+
ribbon(b, tiePos, 0.6, "#ff789e", 1.15);
|
|
1979
|
+
const braidTip = add(b, p, clump([
|
|
1980
|
+
tiePos.clone(),
|
|
1981
|
+
tiePos.clone().add(new Vector3(0.02, -0.16, 0.04)),
|
|
1982
|
+
tiePos.clone().add(new Vector3(-0.02, -0.3, 0.06))
|
|
1983
|
+
], 0.085, 0.045, 1, 0.4));
|
|
1984
|
+
return together(ahoge(b, p, -1, 0.85), hangs([...backLocks, braidTip]));
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
"fluffy-bob": {
|
|
1988
|
+
palette: { color: "#8a5236", tip: "#eab07c", inner: "#5a323e" },
|
|
1989
|
+
build(b, radius, p) {
|
|
1990
|
+
base(b, radius, p, 0.71, 0.38, 0.066, -0.12, 0.04);
|
|
1991
|
+
const made = back(b, radius, p, {
|
|
1992
|
+
count: 16,
|
|
1993
|
+
from: 0.96,
|
|
1994
|
+
end: 0.28,
|
|
1995
|
+
width: 0.15,
|
|
1996
|
+
wave: 0.03,
|
|
1997
|
+
curl: 0.22,
|
|
1998
|
+
layers: 2,
|
|
1999
|
+
spread: 0.095
|
|
2000
|
+
});
|
|
2001
|
+
fringe(b, radius, p, [
|
|
2002
|
+
{ at: -0.64, length: 0.54, width: 0.12, sweep: -0.14, lift: 0.01 },
|
|
2003
|
+
{ at: -0.34, length: 0.54, width: 0.135, sweep: -0.05 },
|
|
2004
|
+
{ at: -0.04, length: 0.57, width: 0.125, sweep: 0.08, lift: 0.012 },
|
|
2005
|
+
{ at: 0.26, length: 0.53, width: 0.135, sweep: 0.1 },
|
|
2006
|
+
{ at: 0.58, length: 0.54, width: 0.12, sweep: 0.16, lift: 0.01 },
|
|
2007
|
+
{ at: -0.18, length: 0.52, width: 0.055, sweep: 0.16, lift: 0.028 },
|
|
2008
|
+
{ at: 0.14, length: 0.52, width: 0.05, sweep: -0.12, lift: 0.03 }
|
|
2009
|
+
], -0.12);
|
|
2010
|
+
sidelocks(b, radius, p, 0.2, 0.095, { curlIn: 0.26 });
|
|
2011
|
+
strays(b, radius, p, [
|
|
2012
|
+
[0.64, 0.84, 0.14],
|
|
2013
|
+
[-1.5, 0.78, 0.16],
|
|
2014
|
+
[2.3, 0.8, 0.14]
|
|
2015
|
+
]);
|
|
2016
|
+
clip(b, onHead(radius, 0.58, 0.78, 0.12), -0.4, "#ffd84d");
|
|
2017
|
+
return together(ahoge(b, p), hangs(made));
|
|
2018
|
+
}
|
|
2019
|
+
},
|
|
2020
|
+
"twin-tails": {
|
|
2021
|
+
palette: { color: "#ff86b8", tip: "#b38cff", inner: "#d65a98" },
|
|
2022
|
+
build(b, radius, p) {
|
|
2023
|
+
base(b, radius, p, 0.72, 0.44, 0.062, 0, 0.038);
|
|
2024
|
+
fringe(b, radius, p, [
|
|
2025
|
+
{ at: -0.6, length: 0.54, width: 0.12, sweep: -0.12, lift: 0.01 },
|
|
2026
|
+
{ at: -0.3, length: 0.55, width: 0.13, sweep: -0.04 },
|
|
2027
|
+
{ at: 0.02, length: 0.57, width: 0.12, sweep: 0.06, lift: 0.012 },
|
|
2028
|
+
{ at: 0.32, length: 0.54, width: 0.13, sweep: 0.09 },
|
|
2029
|
+
{ at: 0.62, length: 0.55, width: 0.115, sweep: 0.14, lift: 0.01 },
|
|
2030
|
+
{ at: -0.14, length: 0.52, width: 0.052, sweep: 0.14, lift: 0.028 }
|
|
2031
|
+
]);
|
|
2032
|
+
sidelocks(b, radius, p, 0.24, 0.082, { curlIn: 0.24 });
|
|
2033
|
+
back(b, radius, p, { count: 12, from: 1.4, end: 0.46, width: 0.14, wave: 0.02, layers: 2 });
|
|
2034
|
+
const tails = [];
|
|
2035
|
+
for (const side of [-1, 1]) {
|
|
2036
|
+
const tieY = TOP - 0.1;
|
|
2037
|
+
const tie = onHead(radius, side * 1.28, tieY, 0.085);
|
|
2038
|
+
for (const path of tail(radius, side * 1.28, tieY, 1.15, 0.38, 6))
|
|
2039
|
+
tails.push(add(b, p, clump(path, 0.135, 0.058, 1, side * 0.75)));
|
|
2040
|
+
ribbon(b, tie.add(new Vector3(0, 0.02, 0.02)), side * 1.28, "#5bc8ff", 1.75);
|
|
2041
|
+
}
|
|
2042
|
+
strays(b, radius, p, [
|
|
2043
|
+
[0.75, 0.82, 0.13],
|
|
2044
|
+
[-0.8, 0.81, 0.15]
|
|
2045
|
+
]);
|
|
2046
|
+
return together(ahoge(b, p, -1), hangs(tails));
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
"spiky-hero": {
|
|
2050
|
+
palette: { color: "#f6c945", tip: "#ff8a3d", inner: "#b07b1e" },
|
|
2051
|
+
build(b, radius, p) {
|
|
2052
|
+
base(b, radius, p, 0.74, 0.48, 0.06, 0, 0.035);
|
|
2053
|
+
const spikes = [
|
|
2054
|
+
[0, TOP - 0.03, 0.3, 0.62],
|
|
2055
|
+
[0.52, TOP - 0.05, 0.28, 0.52],
|
|
2056
|
+
[-0.52, TOP - 0.05, 0.28, 0.52],
|
|
2057
|
+
[1.15, 0.8, 0.27, 0.36],
|
|
2058
|
+
[-1.15, 0.8, 0.27, 0.36],
|
|
2059
|
+
[1.85, 0.78, 0.25, 0.26],
|
|
2060
|
+
[-1.85, 0.78, 0.25, 0.26],
|
|
2061
|
+
[2.45, 0.78, 0.26, 0.3],
|
|
2062
|
+
[-2.45, 0.78, 0.26, 0.3],
|
|
2063
|
+
[Math.PI, 0.8, 0.27, 0.36],
|
|
2064
|
+
[2.9, TOP - 0.05, 0.3, 0.55],
|
|
2065
|
+
[-2.9, TOP - 0.05, 0.3, 0.55]
|
|
2066
|
+
];
|
|
2067
|
+
for (const [phi, y, reach, up] of spikes) {
|
|
2068
|
+
const length = reach * 1.48;
|
|
2069
|
+
const root = onHead(radius, phi, y, 0.03);
|
|
2070
|
+
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 Vector3(0, 0, -length * 0.2));
|
|
2072
|
+
const mid = root.clone().lerp(tip, 0.45).addScaledVector(out, 0.035);
|
|
2073
|
+
add(b, p, clump([root, mid, tip], 0.15, 0.075));
|
|
2074
|
+
}
|
|
2075
|
+
fringe(b, radius, p, [
|
|
2076
|
+
{ at: -0.52, length: 0.56, width: 0.125, sweep: -0.14 },
|
|
2077
|
+
{ at: -0.16, length: 0.54, width: 0.135, sweep: -0.06, lift: 0.015 },
|
|
2078
|
+
{ at: 0.18, length: 0.53, width: 0.135, sweep: 0.08, lift: 0.015 },
|
|
2079
|
+
{ at: 0.52, length: 0.56, width: 0.12, sweep: 0.14 }
|
|
2080
|
+
]);
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
},
|
|
2084
|
+
afro: {
|
|
2085
|
+
palette: { color: "#3a271b", tip: "#8a5a38", inner: "#24170f", ring: 0.45 },
|
|
2086
|
+
build(b, radius, p) {
|
|
2087
|
+
base(b, radius, p, 0.74, 0.4, 0.055);
|
|
2088
|
+
const puff = new SphereGeometry2(1, 18, 14);
|
|
2089
|
+
for (let i = 0;i < 46; i += 1) {
|
|
2090
|
+
const phi = i * 2.399963;
|
|
2091
|
+
const lat = 1 - (i + 0.5) / 46;
|
|
2092
|
+
const y = 0.62 + lat * (TOP + 0.12 - 0.62);
|
|
2093
|
+
if (Math.cos(phi) > 0.55 && y < 0.82)
|
|
2094
|
+
continue;
|
|
2095
|
+
const at = onHead(radius, phi, Math.min(y, TOP - 0.02), 0.1 + lat * 0.08);
|
|
2096
|
+
const size = 0.1 + lat * 0.05 + i * 7 % 5 * 0.006;
|
|
2097
|
+
b.add(puff, p.color, { at: [at.x, at.y + lat * 0.08, at.z], scale: [size, size * 0.92, size] }, anime(p, 0.6));
|
|
2098
|
+
}
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
},
|
|
2102
|
+
"swoosh-quiff": {
|
|
2103
|
+
palette: { color: "#5b3a86", tip: "#b698f0", inner: "#372058" },
|
|
2104
|
+
build(b, radius, p) {
|
|
2105
|
+
base(b, radius, p, 0.73, 0.42, 0.065, -0.42, 0.045);
|
|
2106
|
+
const locks = back(b, radius, p, {
|
|
2107
|
+
count: 14,
|
|
2108
|
+
from: 1.1,
|
|
2109
|
+
end: 0.38,
|
|
2110
|
+
width: 0.135,
|
|
2111
|
+
wave: 0.03,
|
|
2112
|
+
flick: 0.06,
|
|
2113
|
+
layers: 2,
|
|
2114
|
+
spread: 0.085
|
|
2115
|
+
});
|
|
2116
|
+
fringe(b, radius, p, [
|
|
2117
|
+
{ at: -0.6, length: 0.56, width: 0.13, sweep: 0.42, midSweep: 0.2, lift: 0.015 },
|
|
2118
|
+
{ at: -0.32, length: 0.53, width: 0.145, sweep: 0.54, midSweep: 0.28, lift: 0.025 },
|
|
2119
|
+
{ at: -0.02, length: 0.52, width: 0.14, sweep: 0.56, midSweep: 0.3, lift: 0.02 },
|
|
2120
|
+
{ at: 0.28, length: 0.54, width: 0.125, sweep: 0.48, midSweep: 0.24, lift: 0.015 },
|
|
2121
|
+
{ at: -0.15, length: 0.55, width: 0.058, sweep: 0.36, lift: 0.038 }
|
|
2122
|
+
], -0.42);
|
|
2123
|
+
sidelocks(b, radius, p, 0.32, 0.08, { flick: 0.04, curlIn: 0.08 });
|
|
2124
|
+
crownTufts(b, radius, p, [
|
|
2125
|
+
[-0.35, TOP - 0.02, 0.2, 0.09, 0.08],
|
|
2126
|
+
[0.45, TOP - 0.03, 0.2, 0.09, 0.075]
|
|
2127
|
+
]);
|
|
2128
|
+
return together(ahoge(b, p, -1), hangs(locks));
|
|
2129
|
+
}
|
|
2130
|
+
},
|
|
2131
|
+
"long-waves": {
|
|
2132
|
+
palette: { color: "#c25b30", tip: "#ffbf86", inner: "#7a2f2a" },
|
|
2133
|
+
build(b, radius, p) {
|
|
2134
|
+
base(b, radius, p, 0.71, 0.4, 0.065, 0.28, 0.042);
|
|
2135
|
+
fringe(b, radius, p, [
|
|
2136
|
+
{ at: -0.58, length: 0.52, width: 0.12, sweep: -0.12 },
|
|
2137
|
+
{ at: -0.26, length: 0.54, width: 0.135, sweep: -0.16, lift: 0.012 },
|
|
2138
|
+
{ at: 0.06, length: 0.55, width: 0.125, sweep: -0.18, lift: 0.016 },
|
|
2139
|
+
{ at: 0.38, length: 0.55, width: 0.12, sweep: 0.12 },
|
|
2140
|
+
{ at: 0.64, length: 0.5, width: 0.11, sweep: 0.16 },
|
|
2141
|
+
{ at: -0.1, length: 0.51, width: 0.052, sweep: -0.2, lift: 0.03 }
|
|
2142
|
+
], 0.28);
|
|
2143
|
+
sidelocks(b, radius, p, -0.02, 0.095, { curlIn: 0.22 });
|
|
2144
|
+
const locks = back(b, radius, p, {
|
|
2145
|
+
count: 17,
|
|
2146
|
+
from: 1.12,
|
|
2147
|
+
end: -0.35,
|
|
2148
|
+
width: 0.15,
|
|
2149
|
+
wave: 0.085,
|
|
2150
|
+
curl: 0.14,
|
|
2151
|
+
layers: 2,
|
|
2152
|
+
spread: 0.09
|
|
2153
|
+
});
|
|
2154
|
+
strays(b, radius, p, [
|
|
2155
|
+
[1.3, 0.68, 0.18],
|
|
2156
|
+
[-2.1, 0.58, 0.2]
|
|
2157
|
+
]);
|
|
2158
|
+
ribbon(b, onHead(radius, -0.95, 0.86, 0.115), -0.95, "#ffffff", 0.95);
|
|
2159
|
+
return hangs(locks);
|
|
2160
|
+
}
|
|
2161
|
+
},
|
|
2162
|
+
ponytail: {
|
|
2163
|
+
palette: { color: "#f0c96a", tip: "#fff1c2", inner: "#b98a3a" },
|
|
2164
|
+
build(b, radius, p) {
|
|
2165
|
+
base(b, radius, p, 0.72, 0.52, 0.06, 0.18, 0.036);
|
|
2166
|
+
fringe(b, radius, p, [
|
|
2167
|
+
{ at: -0.5, length: 0.54, width: 0.12, sweep: 0.12 },
|
|
2168
|
+
{ at: -0.18, length: 0.55, width: 0.13, sweep: 0.2, lift: 0.014 },
|
|
2169
|
+
{ at: 0.16, length: 0.54, width: 0.125, sweep: 0.24, lift: 0.012 },
|
|
2170
|
+
{ at: 0.48, length: 0.56, width: 0.11, sweep: 0.24 },
|
|
2171
|
+
{ at: -0.02, length: 0.51, width: 0.05, sweep: 0.28, lift: 0.03 }
|
|
2172
|
+
], 0.18);
|
|
2173
|
+
sidelocks(b, radius, p, 0.24, 0.075, { curlIn: 0.24 });
|
|
2174
|
+
const tieY = TOP + 0.01;
|
|
2175
|
+
const locks = tail(radius, Math.PI, tieY, 1.05, 0.44, 6).map((path, i) => add(b, p, clump(path, 0.135, 0.055, 1, (i % 2 ? 1 : -1) * 0.7)));
|
|
2176
|
+
ribbon(b, onHead(radius, Math.PI, tieY, 0.095), Math.PI, "#e2574c", 1.25);
|
|
2177
|
+
return together(ahoge(b, p), hangs(locks));
|
|
2178
|
+
}
|
|
2179
|
+
},
|
|
2180
|
+
mohawk: {
|
|
2181
|
+
palette: { color: "#1fae8f", tip: "#a6f5dd", inner: "#127160" },
|
|
2182
|
+
build(b, radius, p) {
|
|
2183
|
+
base(b, radius, { color: "#2a2440", tip: "#3a3260", inner: "#1d1830", ring: 0.25 }, 0.72, 0.4, 0.016);
|
|
2184
|
+
for (let i = 0;i < 8; i += 1) {
|
|
2185
|
+
const s = i / 7;
|
|
2186
|
+
const phi = s < 0.45 ? 0 : Math.PI;
|
|
2187
|
+
const y = s < 0.45 ? 0.82 + s * 0.3 : TOP - (s - 0.45) * 0.5;
|
|
2188
|
+
const root = onHead(radius, phi, Math.min(y, TOP - 0.01), 0);
|
|
2189
|
+
root.x = 0;
|
|
2190
|
+
const tip = root.clone().add(new Vector3(0, 0.22 - Math.abs(s - 0.4) * 0.14, 0)).add(new Vector3(0, 0, -0.08 - s * 0.05));
|
|
2191
|
+
const mid = root.clone().lerp(tip, 0.5).add(new Vector3(0, 0.02, 0.02));
|
|
2192
|
+
add(b, p, clump([root, mid, tip], 0.032, 0.095));
|
|
2193
|
+
}
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
},
|
|
2197
|
+
"space-buns": {
|
|
2198
|
+
palette: { color: "#b9a6ff", tip: "#ffc2ec", inner: "#7d6ad1" },
|
|
2199
|
+
build(b, radius, p) {
|
|
2200
|
+
base(b, radius, p, 0.72, 0.42, 0.06, 0, 0.036);
|
|
2201
|
+
fringe(b, radius, p, [
|
|
2202
|
+
{ at: -0.56, length: 0.54, width: 0.12 },
|
|
2203
|
+
{ at: -0.26, length: 0.55, width: 0.125, sweep: -0.05 },
|
|
2204
|
+
{ at: 0.04, length: 0.56, width: 0.125, sweep: 0.05, lift: 0.012 },
|
|
2205
|
+
{ at: 0.34, length: 0.54, width: 0.12, sweep: 0.08 },
|
|
2206
|
+
{ at: 0.6, length: 0.55, width: 0.11, sweep: 0.1 },
|
|
2207
|
+
{ at: -0.1, length: 0.52, width: 0.05, sweep: 0.12, lift: 0.028 }
|
|
2208
|
+
]);
|
|
2209
|
+
sidelocks(b, radius, p, 0.22, 0.072, { curlIn: 0.24 });
|
|
2210
|
+
const tufts = [];
|
|
2211
|
+
for (const side of [-1, 1]) {
|
|
2212
|
+
const at = onHead(radius, side * 0.9, TOP - 0.08, 0.11).add(new Vector3(0, 0.05, 0));
|
|
2213
|
+
const coil = [];
|
|
2214
|
+
for (let k = 0;k <= 14; k += 1) {
|
|
2215
|
+
const a = k * 0.9;
|
|
2216
|
+
const r = 0.115 - k * 0.004;
|
|
2217
|
+
coil.push(new Vector3(at.x + Math.cos(a) * r, at.y + (k / 14 - 0.5) * 0.12, at.z + Math.sin(a) * r));
|
|
2218
|
+
}
|
|
2219
|
+
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
|
+
add(b, p, clump(coil, 0.065, 0.038, 0.7));
|
|
2221
|
+
ribbon(b, at.clone().add(new Vector3(0, -0.07, 0.06)), side * 0.9, "#ffd84d", 0.88);
|
|
2222
|
+
for (const path of tail(radius, side * 1.05, TOP - 0.16, 0.48, 0.24, 3))
|
|
2223
|
+
tufts.push(add(b, p, clump(path, 0.085, 0.034)));
|
|
2224
|
+
}
|
|
2225
|
+
return hangs(tufts);
|
|
2226
|
+
}
|
|
2227
|
+
},
|
|
2228
|
+
"hime-cut": {
|
|
2229
|
+
palette: { color: "#262348", tip: "#7d68de", inner: "#16142e", ring: 1.1 },
|
|
2230
|
+
build(b, radius, p) {
|
|
2231
|
+
base(b, radius, p, 0.72, 0.42, 0.065, 0, 0.036);
|
|
2232
|
+
fringe(b, radius, p, [
|
|
2233
|
+
{ at: -0.62, length: 0.56, width: 0.125, blunt: true },
|
|
2234
|
+
{ at: -0.37, length: 0.55, width: 0.135, blunt: true },
|
|
2235
|
+
{ at: -0.12, length: 0.545, width: 0.135, blunt: true },
|
|
2236
|
+
{ at: 0.12, length: 0.545, width: 0.135, blunt: true },
|
|
2237
|
+
{ at: 0.37, length: 0.55, width: 0.135, blunt: true },
|
|
2238
|
+
{ at: 0.62, length: 0.56, width: 0.125, blunt: true },
|
|
2239
|
+
{ at: 0.24, length: 0.53, width: 0.042, sweep: 0.06, lift: 0.022 }
|
|
2240
|
+
]);
|
|
2241
|
+
sidelocks(b, radius, p, 0.24, 0.1, { blunt: true });
|
|
2242
|
+
const locks = back(b, radius, p, {
|
|
2243
|
+
count: 18,
|
|
2244
|
+
from: 1.24,
|
|
2245
|
+
end: -0.3,
|
|
2246
|
+
width: 0.145,
|
|
2247
|
+
wave: 0.015,
|
|
2248
|
+
curl: 0,
|
|
2249
|
+
blunt: true,
|
|
2250
|
+
layers: 2,
|
|
2251
|
+
spread: 0.085
|
|
2252
|
+
});
|
|
2253
|
+
ribbon(b, onHead(radius, Math.PI, TOP - 0.02, 0.09), Math.PI, "#e8475f", 1.35);
|
|
2254
|
+
return hangs(locks);
|
|
2255
|
+
}
|
|
101
2256
|
}
|
|
102
2257
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
2258
|
+
function buildHair(key, kit) {
|
|
2259
|
+
const style = HAIR[key];
|
|
2260
|
+
const palette = resolvePalette(style.palette, kit.hairColor);
|
|
2261
|
+
const headR = kit.isFigure ? (y) => y < 0.08 ? Math.max(0.32, kit.radiusAt(0.22)) : kit.radiusAt(y) : kit.radiusAt;
|
|
2262
|
+
return piece(kit, (b) => style.build(b, headR, palette));
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// src/dress.ts
|
|
2266
|
+
function buildWear(key, kit) {
|
|
2267
|
+
return isHairKey(key) ? buildHair(key, kit) : buildGarment(key, kit);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
// src/proportions.ts
|
|
2271
|
+
var ARM_LENGTH = 0.3;
|
|
2272
|
+
var BELLY_HALF_WIDTH = 0.6;
|
|
2273
|
+
function plupProportions(shape, scale) {
|
|
2274
|
+
const body = clampBodyScale(scale);
|
|
2275
|
+
const torso = body.width.torso ?? 1;
|
|
2276
|
+
const girth = shape.x * torso;
|
|
2277
|
+
const arm = (width) => width ?? 1;
|
|
2278
|
+
const clear = (width) => girth > 1 ? Math.atan((girth - 1) * BELLY_HALF_WIDTH * 0.55 / (ARM_LENGTH * arm(width))) : 0;
|
|
2279
|
+
return {
|
|
2280
|
+
stature: body.stature,
|
|
2281
|
+
girth,
|
|
2282
|
+
armWidth: [arm(body.width.armL), arm(body.width.armR)],
|
|
2283
|
+
legWidth: [body.width.legL ?? 1, body.width.legR ?? 1],
|
|
2284
|
+
armClear: [clear(body.width.armL), clear(body.width.armR)],
|
|
2285
|
+
lift: body.stature * Math.min(1.2, Math.max(0.7, 1 / Math.sqrt(girth))),
|
|
2286
|
+
squash: Math.min(1.6, Math.max(0.6, girth))
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
// src/texture.ts
|
|
2291
|
+
import { LinearMipmapLinearFilter, NearestFilter } from "three";
|
|
2292
|
+
function pixelArtFiltering(texture) {
|
|
2293
|
+
texture.magFilter = NearestFilter;
|
|
2294
|
+
texture.minFilter = LinearMipmapLinearFilter;
|
|
2295
|
+
texture.generateMipmaps = true;
|
|
2296
|
+
return texture;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
// src/plup3d.ts
|
|
117
2300
|
function stampFor(face, type) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const parts = PARTS[face] ?? PARTS.idle;
|
|
121
|
-
const [eyeTop, eyeBottom] = (EYES[type] ?? EYES.dot)[parts.eyes];
|
|
122
|
-
const [mouthTop, mouthBottom] = MOUTHS[parts.mouth];
|
|
123
|
-
const blush = type === "derp" ? "........" : "p......p";
|
|
124
|
-
const merged = Array.from(mouthTop, (pixel, i) => pixel === "." ? blush[i] ?? "." : pixel).join("");
|
|
125
|
-
return [eyeTop, eyeBottom, merged, mouthBottom];
|
|
126
|
-
}
|
|
127
|
-
var BODY_WIDTH = 48;
|
|
128
|
-
var BODY_HEIGHT = 24;
|
|
129
|
-
var FACE_COLUMN = 20;
|
|
130
|
-
var FACE_ROW = 9;
|
|
131
|
-
var RADIUS_X = 0.54;
|
|
132
|
-
var RADIUS_Y = 0.64;
|
|
133
|
-
var RADIUS_Z = 0.54;
|
|
2301
|
+
return faceStamp(type, face);
|
|
2302
|
+
}
|
|
134
2303
|
var TOON_VERTEX = `
|
|
135
2304
|
varying vec3 vNormal;
|
|
136
2305
|
varying vec2 vUv;
|
|
137
2306
|
uniform vec2 uvOffset;
|
|
2307
|
+
uniform vec2 uvRepeat;
|
|
138
2308
|
void main() {
|
|
139
2309
|
vNormal = normalize(normalMatrix * (length(normal) > 0.001 ? normal : vec3(0.0, 0.0, 1.0)));
|
|
140
|
-
vUv = uv + uvOffset;
|
|
2310
|
+
vUv = uv * uvRepeat + uvOffset;
|
|
141
2311
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
142
2312
|
}`;
|
|
143
2313
|
var TOON_FRAGMENT = `
|
|
@@ -146,27 +2316,156 @@ varying vec2 vUv;
|
|
|
146
2316
|
uniform sampler2D map;
|
|
147
2317
|
uniform float useMap;
|
|
148
2318
|
uniform vec3 color;
|
|
2319
|
+
uniform vec3 backColor;
|
|
2320
|
+
uniform float sheen;
|
|
149
2321
|
void main() {
|
|
150
|
-
vec3 n = normalize(vNormal);
|
|
151
|
-
|
|
152
|
-
float
|
|
153
|
-
|
|
2322
|
+
vec3 n = normalize(vNormal) * (gl_FrontFacing ? 1.0 : -1.0);
|
|
2323
|
+
vec3 toLight = normalize(vec3(-0.35, 0.75, 0.55));
|
|
2324
|
+
float light = dot(n, toLight);
|
|
2325
|
+
float band = light > 0.18 ? 1.0 : light > -0.28 ? 0.84 : 0.68;
|
|
2326
|
+
vec3 tint = gl_FrontFacing ? color : backColor;
|
|
2327
|
+
vec3 base = useMap > 0.5 ? texture2D(map, vUv).rgb * tint : tint;
|
|
154
2328
|
vec3 lit = base * band;
|
|
2329
|
+
float glint = pow(max(dot(n, normalize(toLight + vec3(0.0, 0.0, 1.0))), 0.0), 36.0);
|
|
2330
|
+
if (sheen > 0.0 && glint > 0.45) lit = mix(lit, vec3(1.0), sheen);
|
|
155
2331
|
float rim = 1.0 - max(n.z, 0.0);
|
|
156
|
-
if (rim > 0.82 && n.y > -0.2) lit = mix(lit, vec3(1.0), 0.
|
|
2332
|
+
if (rim > 0.82 && n.y > -0.2) lit = mix(lit, vec3(1.0), 0.3);
|
|
157
2333
|
gl_FragColor = vec4(lit, 1.0);
|
|
158
2334
|
#include <colorspace_fragment>
|
|
159
2335
|
}`;
|
|
2336
|
+
var HAIR_VERTEX = `
|
|
2337
|
+
attribute float along;
|
|
2338
|
+
uniform vec3 center;
|
|
2339
|
+
varying vec3 vNormal;
|
|
2340
|
+
varying vec3 vDome;
|
|
2341
|
+
varying vec3 vDir;
|
|
2342
|
+
varying float vAlong;
|
|
2343
|
+
varying float vInward;
|
|
2344
|
+
void main() {
|
|
2345
|
+
vec3 dome = normalize(position - center);
|
|
2346
|
+
vec3 real = length(normal) > 0.001 ? normalize(normal) : dome;
|
|
2347
|
+
vNormal = normalize(normalMatrix * real);
|
|
2348
|
+
vDome = normalize(normalMatrix * normalize(mix(real, dome, 0.74)));
|
|
2349
|
+
vDir = dome;
|
|
2350
|
+
vAlong = along;
|
|
2351
|
+
vInward = dot(real, dome);
|
|
2352
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
2353
|
+
}`;
|
|
2354
|
+
var HAIR_FRAGMENT = `
|
|
2355
|
+
uniform vec3 color;
|
|
2356
|
+
uniform vec3 tip;
|
|
2357
|
+
uniform vec3 inner;
|
|
2358
|
+
uniform float ring;
|
|
2359
|
+
varying vec3 vNormal;
|
|
2360
|
+
varying vec3 vDome;
|
|
2361
|
+
varying vec3 vDir;
|
|
2362
|
+
varying float vAlong;
|
|
2363
|
+
varying float vInward;
|
|
2364
|
+
void main() {
|
|
2365
|
+
vec3 n = normalize(vDome) * (gl_FrontFacing ? 1.0 : -1.0);
|
|
2366
|
+
vec3 toLight = normalize(vec3(-0.32, 0.78, 0.54));
|
|
2367
|
+
float light = dot(n, toLight);
|
|
2368
|
+
// Root ambient occlusion + smooth ombre toward translucent-feeling tips + underside colour.
|
|
2369
|
+
float rootShade = mix(0.88, 1.0, smoothstep(0.0, 0.22, vAlong));
|
|
2370
|
+
float toTip = smoothstep(0.38, 1.0, vAlong);
|
|
2371
|
+
vec3 base = mix(color * rootShade, tip, toTip);
|
|
2372
|
+
base = mix(base, inner, smoothstep(-0.18, -0.58, vInward));
|
|
2373
|
+
vec3 shadow = base * vec3(0.74, 0.67, 0.88);
|
|
2374
|
+
vec3 deep = base * vec3(0.52, 0.46, 0.72);
|
|
2375
|
+
vec3 lit = light > 0.14 ? base : light > -0.34 ? shadow : deep;
|
|
2376
|
+
// Subtle light bounce through shaded tips
|
|
2377
|
+
if (light <= 0.14) lit = mix(lit, tip, 0.34 * toTip);
|
|
2378
|
+
// Organic broken glossy anime highlight band (smooth double-wave, NOT harsh sawtooth!)
|
|
2379
|
+
float around = atan(vDir.x, vDir.z);
|
|
2380
|
+
float wave = sin(around * 3.0 + 0.4) * 0.032 + sin(around * 7.0 - 0.8) * 0.014;
|
|
2381
|
+
float breakMask = smoothstep(-0.18, 0.25, sin(around * 5.0 + 1.1) + 0.35 * cos(around * 9.0));
|
|
2382
|
+
float centre = 0.56 + wave;
|
|
2383
|
+
float bandDist = abs(vDir.y - centre);
|
|
2384
|
+
float primary = (1.0 - smoothstep(0.022, 0.048, bandDist)) * breakMask;
|
|
2385
|
+
float secondary = (1.0 - smoothstep(0.008, 0.022, abs(vDir.y - (centre + 0.07)))) * (1.0 - breakMask * 0.5) * 0.55;
|
|
2386
|
+
float facingLit = smoothstep(-0.1, 0.25, n.z) * smoothstep(-0.15, 0.2, light) * (1.0 - toTip * 0.8);
|
|
2387
|
+
vec3 shine = mix(base, vec3(1.0, 0.98, 1.0), 0.44);
|
|
2388
|
+
lit = mix(lit, shine, clamp(primary + secondary, 0.0, 1.0) * facingLit * ring * 0.85);
|
|
2389
|
+
// Thin soft-cut rim separating hair silhouette from background
|
|
2390
|
+
float rim = 1.0 - max(normalize(vNormal).z, 0.0);
|
|
2391
|
+
if (rim > 0.85 && n.y > -0.05) lit = mix(lit, mix(tip, vec3(1.0), 0.55), 0.28);
|
|
2392
|
+
gl_FragColor = vec4(lit, 1.0);
|
|
2393
|
+
#include <colorspace_fragment>
|
|
2394
|
+
}`;
|
|
2395
|
+
function taperedHose(curve, muscle, baseRadius = 0.046) {
|
|
2396
|
+
const segments = 24;
|
|
2397
|
+
const radial = 14;
|
|
2398
|
+
const tube = new TubeGeometry(curve, segments, baseRadius, radial);
|
|
2399
|
+
const position = tube.attributes.position;
|
|
2400
|
+
const centre = new Vector32;
|
|
2401
|
+
const strength = Math.max(0, muscle - 1);
|
|
2402
|
+
const slim = muscle < 1 ? 0.72 + 0.28 * muscle : 1;
|
|
2403
|
+
for (let i = 0;i <= segments; i += 1) {
|
|
2404
|
+
const t = i / segments;
|
|
2405
|
+
curve.getPointAt(t, centre);
|
|
2406
|
+
const deltoid = 1 + strength * 0.65 * Math.exp(-(((t - 0.06) / 0.17) ** 2));
|
|
2407
|
+
const biceps = 1 + strength * 0.78 * Math.exp(-(((t - 0.34) / 0.21) ** 2));
|
|
2408
|
+
const forearm = 1 + strength * 0.48 * Math.exp(-(((t - 0.7) / 0.19) ** 2));
|
|
2409
|
+
const k = (1.12 - 0.38 * t) * slim * deltoid * biceps * forearm;
|
|
2410
|
+
for (let j = 0;j <= radial; j += 1) {
|
|
2411
|
+
const v = i * (radial + 1) + j;
|
|
2412
|
+
position.setXYZ(v, centre.x + (position.getX(v) - centre.x) * k, centre.y + (position.getY(v) - centre.y) * k, centre.z + (position.getZ(v) - centre.z) * k);
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
tube.computeVertexNormals();
|
|
2416
|
+
return tube;
|
|
2417
|
+
}
|
|
2418
|
+
function sculptedLeg(curve, hips, muscle) {
|
|
2419
|
+
const segments = 24;
|
|
2420
|
+
const radial = 14;
|
|
2421
|
+
const tube = new TubeGeometry(curve, segments, 0.095, radial);
|
|
2422
|
+
const position = tube.attributes.position;
|
|
2423
|
+
const centre = new Vector32;
|
|
2424
|
+
const thighScale = 0.88 + Math.max(0, hips - 0.85) * 0.52 + Math.max(0, muscle - 1) * 0.36;
|
|
2425
|
+
const calfScale = 0.78 + Math.max(0, muscle - 1) * 0.34 + Math.max(0, hips - 1) * 0.14;
|
|
2426
|
+
for (let i = 0;i <= segments; i += 1) {
|
|
2427
|
+
const t = i / segments;
|
|
2428
|
+
curve.getPointAt(t, centre);
|
|
2429
|
+
const upper = thighScale * Math.exp(-(((t - 0.1) / 0.32) ** 2));
|
|
2430
|
+
const calf = calfScale * 0.26 * Math.exp(-(((t - 0.65) / 0.18) ** 2));
|
|
2431
|
+
const base2 = 0.96 - 0.56 * t;
|
|
2432
|
+
const k = Math.max(0.36, base2 * (0.48 + 0.62 * upper) + calf * 0.4);
|
|
2433
|
+
for (let j = 0;j <= radial; j += 1) {
|
|
2434
|
+
const v = i * (radial + 1) + j;
|
|
2435
|
+
position.setXYZ(v, centre.x + (position.getX(v) - centre.x) * k, centre.y + (position.getY(v) - centre.y) * k, centre.z + (position.getZ(v) - centre.z) * k * 1.05);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
tube.computeVertexNormals();
|
|
2439
|
+
return tube;
|
|
2440
|
+
}
|
|
160
2441
|
function toon(options) {
|
|
2442
|
+
if (options.anime)
|
|
2443
|
+
return new ShaderMaterial({
|
|
2444
|
+
...options.double ? { side: DoubleSide } : {},
|
|
2445
|
+
vertexShader: HAIR_VERTEX,
|
|
2446
|
+
fragmentShader: HAIR_FRAGMENT,
|
|
2447
|
+
toneMapped: false,
|
|
2448
|
+
uniforms: {
|
|
2449
|
+
color: { value: new Color2(options.color ?? "#ffffff") },
|
|
2450
|
+
center: { value: new Vector32(...options.anime.center) },
|
|
2451
|
+
ring: { value: options.anime.ring ?? 1 },
|
|
2452
|
+
tip: { value: new Color2(options.anime.tip ?? options.color ?? "#ffffff") },
|
|
2453
|
+
inner: { value: new Color2(options.anime.inner ?? options.color ?? "#ffffff") }
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
161
2456
|
return new ShaderMaterial({
|
|
2457
|
+
...options.double ? { side: DoubleSide } : {},
|
|
162
2458
|
vertexShader: TOON_VERTEX,
|
|
163
2459
|
fragmentShader: TOON_FRAGMENT,
|
|
164
2460
|
toneMapped: false,
|
|
165
2461
|
uniforms: {
|
|
166
2462
|
map: { value: options.map ?? null },
|
|
167
2463
|
useMap: { value: options.map ? 1 : 0 },
|
|
168
|
-
color: { value: new
|
|
169
|
-
|
|
2464
|
+
color: { value: new Color2(options.color ?? "#ffffff") },
|
|
2465
|
+
backColor: { value: new Color2(options.back ?? options.color ?? "#ffffff") },
|
|
2466
|
+
sheen: { value: options.sheen ?? 0 },
|
|
2467
|
+
uvOffset: { value: [options.map?.offset.x ?? 0, 0] },
|
|
2468
|
+
uvRepeat: { value: options.repeat ?? [1, 1] }
|
|
170
2469
|
}
|
|
171
2470
|
});
|
|
172
2471
|
}
|
|
@@ -174,7 +2473,7 @@ function hull(color, width) {
|
|
|
174
2473
|
return new ShaderMaterial({
|
|
175
2474
|
side: BackSide,
|
|
176
2475
|
toneMapped: false,
|
|
177
|
-
uniforms: { color: { value: new
|
|
2476
|
+
uniforms: { color: { value: new Color2(color) }, width: { value: width } },
|
|
178
2477
|
vertexShader: `
|
|
179
2478
|
uniform float width;
|
|
180
2479
|
void main() {
|
|
@@ -188,33 +2487,27 @@ void main() {
|
|
|
188
2487
|
}`
|
|
189
2488
|
});
|
|
190
2489
|
}
|
|
191
|
-
function
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
minY = Math.min(minY, y * RADIUS_Y);
|
|
202
|
-
}
|
|
203
|
-
geometry.translate(0, -minY, 0);
|
|
204
|
-
geometry.computeVertexNormals();
|
|
205
|
-
return geometry;
|
|
2490
|
+
function hexChannels(hex) {
|
|
2491
|
+
const bare = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
2492
|
+
const full = 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) : "";
|
|
2493
|
+
if (!/^[0-9a-f]{6}$/i.test(full))
|
|
2494
|
+
return [0, 0, 0];
|
|
2495
|
+
return [
|
|
2496
|
+
Number.parseInt(full.slice(0, 2), 16),
|
|
2497
|
+
Number.parseInt(full.slice(2, 4), 16),
|
|
2498
|
+
Number.parseInt(full.slice(4, 6), 16)
|
|
2499
|
+
];
|
|
206
2500
|
}
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
function paintBody(canvas, color, face, skin) {
|
|
2501
|
+
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("")}`;
|
|
2502
|
+
function paintBody(canvas, color, face, skin, faceType, isFigure = false) {
|
|
210
2503
|
const ctx = canvas.getContext("2d");
|
|
211
2504
|
if (!ctx)
|
|
212
2505
|
return;
|
|
213
2506
|
const px = canvas.width / BODY_WIDTH;
|
|
214
|
-
const
|
|
215
|
-
const light = shade(color, 255, 0.
|
|
216
|
-
const belly = shade(color, 255, 0.62);
|
|
217
|
-
const dark = shade(color, 0, 0.
|
|
2507
|
+
const base2 = color;
|
|
2508
|
+
const light = shade(color, 255, 0.25);
|
|
2509
|
+
const belly = isFigure ? shade(color, 255, 0.1) : shade(color, 255, 0.62);
|
|
2510
|
+
const dark = shade(color, 0, 0.2);
|
|
218
2511
|
const palette = {
|
|
219
2512
|
...SKIN_PALETTE,
|
|
220
2513
|
B: color,
|
|
@@ -223,24 +2516,29 @@ function paintBody(canvas, color, face, skin) {
|
|
|
223
2516
|
};
|
|
224
2517
|
for (let y = 0;y < BODY_HEIGHT; y += 1) {
|
|
225
2518
|
for (let x = 0;x < BODY_WIDTH; x += 1) {
|
|
226
|
-
const drawn = skin?.body[y]?.[x];
|
|
2519
|
+
const drawn = !isFigure ? skin?.body[y]?.[x] : undefined;
|
|
227
2520
|
if (drawn) {
|
|
228
2521
|
ctx.fillStyle = palette[drawn] ?? color;
|
|
229
2522
|
ctx.fillRect(x * px, y * px, px, px);
|
|
230
2523
|
continue;
|
|
231
2524
|
}
|
|
232
|
-
let fill =
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
2525
|
+
let fill = base2;
|
|
2526
|
+
if (isFigure) {
|
|
2527
|
+
if (x >= 30 && x <= 35)
|
|
2528
|
+
fill = shade(color, 0, 0.08);
|
|
2529
|
+
} else {
|
|
2530
|
+
if (y >= 16)
|
|
2531
|
+
fill = belly;
|
|
2532
|
+
else if (y === 15)
|
|
2533
|
+
fill = light;
|
|
2534
|
+
else if (x >= 29 && x <= 35)
|
|
2535
|
+
fill = dark;
|
|
2536
|
+
}
|
|
239
2537
|
ctx.fillStyle = fill;
|
|
240
2538
|
ctx.fillRect(x * px, y * px, px, px);
|
|
241
2539
|
}
|
|
242
2540
|
}
|
|
243
|
-
if (!skin) {
|
|
2541
|
+
if (!skin && !isFigure) {
|
|
244
2542
|
ctx.fillStyle = shade(color, 255, 0.8);
|
|
245
2543
|
for (const [x, y] of [
|
|
246
2544
|
[19, 4],
|
|
@@ -251,7 +2549,10 @@ function paintBody(canvas, color, face, skin) {
|
|
|
251
2549
|
])
|
|
252
2550
|
ctx.fillRect(x * px, y * px, px, px);
|
|
253
2551
|
}
|
|
254
|
-
const
|
|
2552
|
+
const resolvedFaceType = skin?.faceType ?? faceType;
|
|
2553
|
+
if (isHighResFace(resolvedFaceType))
|
|
2554
|
+
return;
|
|
2555
|
+
const stamp = stampFor(face, resolvedFaceType ?? "dot");
|
|
255
2556
|
stamp.forEach((row, dy) => {
|
|
256
2557
|
for (let dx = 0;dx < row.length; dx += 1) {
|
|
257
2558
|
const key = row[dx] ?? ".";
|
|
@@ -263,64 +2564,249 @@ function paintBody(canvas, color, face, skin) {
|
|
|
263
2564
|
}
|
|
264
2565
|
});
|
|
265
2566
|
}
|
|
2567
|
+
function animeDecal(faceType, face, eyeColor, isFigure = false) {
|
|
2568
|
+
if (!isHighResFace(faceType))
|
|
2569
|
+
return null;
|
|
2570
|
+
const style = faceType;
|
|
2571
|
+
const canvas = document.createElement("canvas");
|
|
2572
|
+
canvas.width = ANIME_FACE_SIZE.width;
|
|
2573
|
+
canvas.height = ANIME_FACE_SIZE.height;
|
|
2574
|
+
const ctx = canvas.getContext("2d");
|
|
2575
|
+
const map = new CanvasTexture2(canvas);
|
|
2576
|
+
map.colorSpace = SRGBColorSpace2;
|
|
2577
|
+
map.anisotropy = 4;
|
|
2578
|
+
const { u0, u1, v0, v1 } = isFigure ? ANIME_FACE_UV : { u0: 0.07, u1: 0.43, v0: 0.37, v1: 0.7 };
|
|
2579
|
+
map.repeat.set(1 / (u1 - u0), 1 / (v1 - v0));
|
|
2580
|
+
map.offset.set(-u0 / (u1 - u0), -v0 / (v1 - v0));
|
|
2581
|
+
const material = new MeshBasicMaterial2({
|
|
2582
|
+
map,
|
|
2583
|
+
transparent: true,
|
|
2584
|
+
depthWrite: false,
|
|
2585
|
+
polygonOffset: true,
|
|
2586
|
+
polygonOffsetFactor: -4
|
|
2587
|
+
});
|
|
2588
|
+
const draw = (next) => {
|
|
2589
|
+
if (!ctx)
|
|
2590
|
+
return;
|
|
2591
|
+
drawAnimeFace(ctx, next, eyeColor, style);
|
|
2592
|
+
map.needsUpdate = true;
|
|
2593
|
+
};
|
|
2594
|
+
draw(face);
|
|
2595
|
+
return { material, draw };
|
|
2596
|
+
}
|
|
2597
|
+
var OUTFIT_LEG_COLOR = {
|
|
2598
|
+
"street-jacket": "#1a1a28",
|
|
2599
|
+
"blazer-coat": "#1e2542",
|
|
2600
|
+
tuxedo: "#181529",
|
|
2601
|
+
"brawler-vest": "#2c253b",
|
|
2602
|
+
"martial-gi": "#ede9e0",
|
|
2603
|
+
"chibi-overalls": "#5b8ff9"
|
|
2604
|
+
};
|
|
266
2605
|
var inkHull = null;
|
|
267
2606
|
var neonHull = null;
|
|
2607
|
+
var fineHull = null;
|
|
2608
|
+
var hairHull = null;
|
|
2609
|
+
var figureHull = null;
|
|
268
2610
|
function createPlup(options = {}) {
|
|
269
2611
|
inkHull ??= hull("#14102e", 0.022);
|
|
2612
|
+
figureHull ??= hull("#1b1438", 0.013);
|
|
270
2613
|
neonHull ??= hull("#b9a6ff", 0.04);
|
|
2614
|
+
fineHull ??= hull("#191233", 0.007);
|
|
2615
|
+
hairHull ??= hull("#1c1433", 0.0045);
|
|
2616
|
+
const fine = fineHull;
|
|
271
2617
|
const ink = inkHull;
|
|
272
2618
|
const neon = neonHull;
|
|
2619
|
+
const figureInk = figureHull;
|
|
2620
|
+
const hairInk = hairHull;
|
|
273
2621
|
let color = options.color ?? "#3d7bff";
|
|
274
2622
|
let face = options.face ?? "smug";
|
|
275
2623
|
const skin = options.skin ?? null;
|
|
276
2624
|
const shape = BODY_SHAPES[options.shape ?? "plup"] ?? BODY_SHAPES.plup;
|
|
2625
|
+
const fit = plupProportions(shape, options.bodyScale);
|
|
2626
|
+
const build = clampPlupBody(options.body);
|
|
2627
|
+
const isFigure = build.figure >= 0.5;
|
|
2628
|
+
const silhouette = {
|
|
2629
|
+
shoulders: build.shoulders,
|
|
2630
|
+
waist: build.waist,
|
|
2631
|
+
hips: build.hips,
|
|
2632
|
+
bust: build.bust,
|
|
2633
|
+
muscle: build.muscle,
|
|
2634
|
+
figure: build.figure
|
|
2635
|
+
};
|
|
2636
|
+
const legRaise = isFigure ? 0.28 + 0.16 * (build.legLength - 1) : 0.16 * (build.legLength - 1);
|
|
277
2637
|
const canvas = document.createElement("canvas");
|
|
278
2638
|
canvas.width = BODY_WIDTH * 4;
|
|
279
2639
|
canvas.height = BODY_HEIGHT * 4;
|
|
280
|
-
paintBody(canvas, color, face, skin);
|
|
281
|
-
const texture = new
|
|
282
|
-
texture
|
|
283
|
-
texture.
|
|
284
|
-
texture.
|
|
285
|
-
texture.colorSpace = SRGBColorSpace;
|
|
286
|
-
texture.wrapS = RepeatWrapping;
|
|
2640
|
+
paintBody(canvas, color, face, skin, options.faceType, isFigure);
|
|
2641
|
+
const texture = new CanvasTexture2(canvas);
|
|
2642
|
+
pixelArtFiltering(texture);
|
|
2643
|
+
texture.colorSpace = SRGBColorSpace2;
|
|
2644
|
+
texture.wrapS = RepeatWrapping2;
|
|
287
2645
|
texture.offset.x = (FACE_COLUMN + 4) / BODY_WIDTH - 0.25;
|
|
2646
|
+
const anime2 = animeDecal(skin?.faceType ?? options.faceType, face, options.eyeColor, isFigure);
|
|
288
2647
|
const bodyMaterial = toon({ map: texture });
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
const
|
|
2648
|
+
const torsoMaterial = toon({ color });
|
|
2649
|
+
const limbMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
|
|
2650
|
+
const legMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
|
|
2651
|
+
const tipMaterial = toon({ color: isFigure ? shade(color, 0, 0.12) : shade(color, 0, 0.3) });
|
|
2652
|
+
const shoeMaterial = toon({ color: "#221a3a", sheen: 0.35 });
|
|
2653
|
+
const root = new Group2;
|
|
2654
|
+
const lifted = new Group2;
|
|
293
2655
|
root.add(lifted);
|
|
294
|
-
const
|
|
2656
|
+
const headMetrics = figureHeadMetrics(build.headSize);
|
|
2657
|
+
const geometry = isFigure ? buildFigureHeadGeometry() : buildBlobGeometry(silhouette);
|
|
2658
|
+
const torsoGeometry = isFigure ? buildFigureTorsoGeometry(silhouette) : null;
|
|
2659
|
+
const headGroup = new Group2;
|
|
295
2660
|
if (!options.model) {
|
|
296
|
-
|
|
297
|
-
|
|
2661
|
+
if (isFigure && torsoGeometry) {
|
|
2662
|
+
const torsoMesh = new Mesh2(torsoGeometry, torsoMaterial);
|
|
2663
|
+
const torsoInk = new Mesh2(torsoGeometry, figureInk);
|
|
2664
|
+
lifted.add(torsoMesh, torsoInk);
|
|
2665
|
+
headGroup.position.set(0, headMetrics.originY, 0);
|
|
2666
|
+
headGroup.scale.setScalar(headMetrics.scale);
|
|
2667
|
+
const headMesh = new Mesh2(geometry, bodyMaterial);
|
|
2668
|
+
const headInk = new Mesh2(geometry, figureInk);
|
|
2669
|
+
headGroup.add(headMesh, headInk);
|
|
2670
|
+
if (anime2) {
|
|
2671
|
+
const decal = new Mesh2(geometry, anime2.material);
|
|
2672
|
+
decal.scale.setScalar(1.008);
|
|
2673
|
+
decal.renderOrder = 1;
|
|
2674
|
+
headGroup.add(decal);
|
|
2675
|
+
}
|
|
2676
|
+
lifted.add(headGroup);
|
|
2677
|
+
} else {
|
|
2678
|
+
const bodyMesh = new Mesh2(geometry, bodyMaterial);
|
|
2679
|
+
const blobMeshes = [bodyMesh, new Mesh2(geometry, ink), new Mesh2(geometry, neon)];
|
|
2680
|
+
for (const mesh of blobMeshes)
|
|
2681
|
+
mesh.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
|
|
2682
|
+
lifted.add(...blobMeshes);
|
|
2683
|
+
if (anime2) {
|
|
2684
|
+
const decal = new Mesh2(geometry, anime2.material);
|
|
2685
|
+
decal.scale.copy(bodyMesh.scale).multiplyScalar(1.006);
|
|
2686
|
+
decal.renderOrder = 1;
|
|
2687
|
+
lifted.add(decal);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
298
2690
|
for (const mesh of lifted.children)
|
|
299
2691
|
mesh.raycast = () => {};
|
|
300
2692
|
}
|
|
2693
|
+
const headWearRoot = new Group2;
|
|
2694
|
+
const bodyWearRoot = new Group2;
|
|
2695
|
+
if (isFigure) {
|
|
2696
|
+
headWearRoot.position.set(0, headMetrics.originY, 0);
|
|
2697
|
+
headWearRoot.scale.setScalar(headMetrics.scale);
|
|
2698
|
+
} else {
|
|
2699
|
+
headWearRoot.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
|
|
2700
|
+
bodyWearRoot.scale.copy(headWearRoot.scale);
|
|
2701
|
+
}
|
|
2702
|
+
lifted.add(headWearRoot, bodyWearRoot);
|
|
2703
|
+
const worn = new Map;
|
|
2704
|
+
const headKit = {
|
|
2705
|
+
radiusAt: (y) => isFigure ? figureHeadRadiusAt(y) : blobRadiusAt(y, silhouette),
|
|
2706
|
+
paint: (paint, more = {}) => toon({ ...more, color: paint }),
|
|
2707
|
+
ink: hairInk,
|
|
2708
|
+
hairColor: options.hairColor,
|
|
2709
|
+
isFigure
|
|
2710
|
+
};
|
|
2711
|
+
const bodyKit = {
|
|
2712
|
+
radiusAt: (y) => isFigure ? figureTorsoRadiusAt(y, silhouette) : blobRadiusAt(y, silhouette),
|
|
2713
|
+
surfaceAt: isFigure ? (y, phi, grow = 0) => {
|
|
2714
|
+
const pt = figureTorsoPoint(y, phi, silhouette);
|
|
2715
|
+
const len = Math.hypot(pt.x, pt.z) || 1;
|
|
2716
|
+
const nx = pt.x / len;
|
|
2717
|
+
const nz = pt.z / len;
|
|
2718
|
+
return { x: pt.x + nx * grow, z: pt.z + nz * grow };
|
|
2719
|
+
} : (y, phi, grow = 0) => {
|
|
2720
|
+
const r = blobRadiusAt(y, silhouette) + grow;
|
|
2721
|
+
return { x: Math.sin(phi) * r, z: Math.cos(phi) * r * (BLOB_RADIUS.z / BLOB_RADIUS.x) };
|
|
2722
|
+
},
|
|
2723
|
+
paint: (paint, more = {}) => toon({ ...more, color: paint }),
|
|
2724
|
+
ink: fine,
|
|
2725
|
+
hairColor: options.hairColor,
|
|
2726
|
+
isFigure,
|
|
2727
|
+
zones: isFigure ? {
|
|
2728
|
+
bottomY: FIGURE_TORSO_MIN_Y,
|
|
2729
|
+
hipY: 0.22,
|
|
2730
|
+
waistY: 0.41,
|
|
2731
|
+
bustY: 0.56,
|
|
2732
|
+
shoulderY: FIGURE_SHOULDER_Y,
|
|
2733
|
+
neckY: FIGURE_TORSO_MAX_Y - 0.08
|
|
2734
|
+
} : {
|
|
2735
|
+
bottomY: 0.04,
|
|
2736
|
+
hipY: 0.14,
|
|
2737
|
+
waistY: 0.25,
|
|
2738
|
+
bustY: 0.35,
|
|
2739
|
+
shoulderY: 0.42,
|
|
2740
|
+
neckY: 0.27
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
const isHeadPiece = (key) => isHairKey(key) || wearSlotOf(key) === "hat" || key === "sunglasses";
|
|
2744
|
+
let lastLift = 0;
|
|
2745
|
+
let lastYaw = 0;
|
|
2746
|
+
const setWear = (next) => {
|
|
2747
|
+
const wanted = new Set(next);
|
|
2748
|
+
for (const [key, piece2] of worn) {
|
|
2749
|
+
if (wanted.has(key))
|
|
2750
|
+
continue;
|
|
2751
|
+
headWearRoot.remove(piece2.object);
|
|
2752
|
+
bodyWearRoot.remove(piece2.object);
|
|
2753
|
+
piece2.dispose();
|
|
2754
|
+
worn.delete(key);
|
|
2755
|
+
}
|
|
2756
|
+
for (const key of wanted) {
|
|
2757
|
+
if (worn.has(key))
|
|
2758
|
+
continue;
|
|
2759
|
+
const onHead2 = isHeadPiece(key);
|
|
2760
|
+
const kit = onHead2 ? isHairKey(key) ? headKit : { ...headKit, ink: fine } : bodyKit;
|
|
2761
|
+
const piece2 = buildWear(key, kit);
|
|
2762
|
+
worn.set(key, piece2);
|
|
2763
|
+
(onHead2 ? headWearRoot : bodyWearRoot).add(piece2.object);
|
|
2764
|
+
}
|
|
2765
|
+
const volume = Math.max(0, ...[...worn.keys()].filter(isHairKey).map(hairVolume));
|
|
2766
|
+
for (const [key, piece2] of worn)
|
|
2767
|
+
if (wearSlotOf(key) === "hat")
|
|
2768
|
+
piece2.object.position.y = volume;
|
|
2769
|
+
const pantHex = isFigure ? [...worn.keys()].map((k) => OUTFIT_LEG_COLOR[k]).find(Boolean) ?? shade(color, 0, 0.05) : shade(color, 0, 0.12);
|
|
2770
|
+
legMaterial.uniforms.color?.value?.set(pantHex);
|
|
2771
|
+
legMaterial.uniforms.backColor?.value?.set(pantHex);
|
|
2772
|
+
};
|
|
2773
|
+
setWear(options.wear ?? []);
|
|
301
2774
|
const limbGeometry = new CapsuleGeometry(0.075, 0.2, 4, 10);
|
|
302
|
-
const handGeometry = new
|
|
303
|
-
const footGeometry = new
|
|
2775
|
+
const handGeometry = new SphereGeometry3(isFigure ? 0.056 : 0.11, 12, 10);
|
|
2776
|
+
const footGeometry = new SphereGeometry3(isFigure ? 0.072 : 0.13, 12, 10);
|
|
304
2777
|
const pivots = {
|
|
305
|
-
armL: new
|
|
306
|
-
armR: new
|
|
307
|
-
legL: new
|
|
308
|
-
legR: new
|
|
2778
|
+
armL: new Group2,
|
|
2779
|
+
armR: new Group2,
|
|
2780
|
+
legL: new Group2,
|
|
2781
|
+
legR: new Group2
|
|
309
2782
|
};
|
|
310
|
-
const
|
|
2783
|
+
const armGeometries = [];
|
|
2784
|
+
const limb = (name, x, y, length, tip, flat, bow2 = 0, legStyle = false) => {
|
|
311
2785
|
const pivot = pivots[name];
|
|
312
2786
|
pivot.position.set(x, y, 0);
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
2787
|
+
const curve = bow2 ? new QuadraticBezierCurve3(new Vector32(0, 0.02, 0), new Vector32(bow2 * (legStyle ? 0.025 : 0.07), -length * 0.5, legStyle ? 0.02 : 0.03), new Vector32(bow2 * (legStyle ? 0.01 : 0.03), -length, legStyle ? 0.01 : 0.04)) : null;
|
|
2788
|
+
const shaft = curve ? legStyle ? sculptedLeg(curve, build.hips, build.muscle) : taperedHose(curve, build.muscle, isFigure ? 0.042 : 0.046) : limbGeometry;
|
|
2789
|
+
if (curve)
|
|
2790
|
+
armGeometries.push(shaft);
|
|
2791
|
+
const tube = new Mesh2(shaft, flat ? legMaterial : limbMaterial);
|
|
2792
|
+
if (!curve) {
|
|
2793
|
+
tube.position.y = -length / 2;
|
|
2794
|
+
tube.scale.y = length / 0.35;
|
|
2795
|
+
}
|
|
2796
|
+
const end = new Mesh2(tip, flat && isFigure ? shoeMaterial : tipMaterial);
|
|
2797
|
+
if (curve)
|
|
2798
|
+
end.position.copy(curve.getPoint(1));
|
|
2799
|
+
else
|
|
2800
|
+
end.position.y = -length;
|
|
318
2801
|
if (flat)
|
|
319
|
-
end.scale.set(1.15, 0.5, 1.7);
|
|
320
|
-
|
|
2802
|
+
end.scale.set(isFigure ? 1.05 : 1.15, isFigure ? 0.65 : 0.5, isFigure ? 1.65 : 1.7);
|
|
2803
|
+
else
|
|
2804
|
+
end.scale.setScalar(isFigure ? 0.95 + Math.max(0, build.muscle - 1) * 0.25 : 0.85);
|
|
2805
|
+
const outlineMat = isFigure ? figureInk : ink;
|
|
2806
|
+
const inkTube = new Mesh2(shaft, outlineMat);
|
|
321
2807
|
inkTube.position.copy(tube.position);
|
|
322
2808
|
inkTube.scale.copy(tube.scale);
|
|
323
|
-
const inkEnd = new
|
|
2809
|
+
const inkEnd = new Mesh2(tip, outlineMat);
|
|
324
2810
|
inkEnd.position.copy(end.position);
|
|
325
2811
|
inkEnd.scale.copy(end.scale);
|
|
326
2812
|
pivot.add(tube, end, inkTube, inkEnd);
|
|
@@ -335,15 +2821,44 @@ function createPlup(options = {}) {
|
|
|
335
2821
|
if (found)
|
|
336
2822
|
pivots[name] = found;
|
|
337
2823
|
}
|
|
2824
|
+
} else if (isFigure) {
|
|
2825
|
+
const shPt = figureTorsoPoint(FIGURE_SHOULDER_Y, Math.PI / 2, silhouette);
|
|
2826
|
+
const shoulderX = Math.max(0.14, shPt.x * 0.9);
|
|
2827
|
+
const arm = 0.34 * build.armLength;
|
|
2828
|
+
const hipAnchorY = FIGURE_HIP_Y + 0.06;
|
|
2829
|
+
const hipPt = figureTorsoPoint(hipAnchorY, Math.PI / 2, silhouette);
|
|
2830
|
+
const hipX = Math.max(0.085, hipPt.x * 0.46);
|
|
2831
|
+
const leg = Math.max(0.36, legRaise + hipAnchorY - 0.03);
|
|
2832
|
+
limb("armL", -shoulderX, FIGURE_SHOULDER_Y, arm, handGeometry, false, -1, false);
|
|
2833
|
+
limb("armR", shoulderX, FIGURE_SHOULDER_Y, arm, handGeometry, false, 1, false);
|
|
2834
|
+
limb("legL", -hipX, hipAnchorY, leg, footGeometry, true, -0.25, true);
|
|
2835
|
+
limb("legR", hipX, hipAnchorY, leg, footGeometry, true, 0.25, true);
|
|
2836
|
+
const armBulk = build.muscle > 1 ? 1 + (build.muscle - 1) * 0.28 : 0.86 + build.muscle * 0.14;
|
|
2837
|
+
pivots.armL.scale.set(fit.armWidth[0] * armBulk, 1, fit.armWidth[0] * armBulk);
|
|
2838
|
+
pivots.armR.scale.set(fit.armWidth[1] * armBulk, 1, fit.armWidth[1] * armBulk);
|
|
2839
|
+
pivots.legL.scale.set(fit.legWidth[0], 1, fit.legWidth[0]);
|
|
2840
|
+
pivots.legR.scale.set(fit.legWidth[1], 1, fit.legWidth[1]);
|
|
338
2841
|
} else {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
2842
|
+
const torso = fit.girth / shape.x;
|
|
2843
|
+
const shoulderY = BLOB_HEIGHT * build.shoulderHeight;
|
|
2844
|
+
const shoulder = blobRadiusAt(shoulderY, silhouette) * 0.92 * torso;
|
|
2845
|
+
const arm = 0.27 * build.armLength;
|
|
2846
|
+
const hip = blobRadiusAt(BLOB_HEIGHT * 0.18, silhouette) * 0.42 * torso;
|
|
2847
|
+
const leg = 0.16 * build.legLength;
|
|
2848
|
+
limb("armL", -shoulder, shoulderY, arm, handGeometry, false, -1);
|
|
2849
|
+
limb("armR", shoulder, shoulderY, arm, handGeometry, false, 1);
|
|
2850
|
+
const knee = build.legLength > 1.2 ? 0.35 : 0;
|
|
2851
|
+
limb("legL", -hip, BLOB_HEIGHT * 0.18, leg, footGeometry, true, -knee);
|
|
2852
|
+
limb("legR", hip, BLOB_HEIGHT * 0.18, leg, footGeometry, true, knee);
|
|
2853
|
+
const bulk = build.muscle ** 0.6;
|
|
2854
|
+
pivots.armL.scale.set(fit.armWidth[0] * bulk, 1, fit.armWidth[0] * bulk);
|
|
2855
|
+
pivots.armR.scale.set(fit.armWidth[1] * bulk, 1, fit.armWidth[1] * bulk);
|
|
2856
|
+
pivots.legL.scale.set(fit.legWidth[0] * bulk, 1, fit.legWidth[0] * bulk);
|
|
2857
|
+
pivots.legR.scale.set(fit.legWidth[1] * bulk, 1, fit.legWidth[1] * bulk);
|
|
343
2858
|
}
|
|
344
2859
|
let shadow = null;
|
|
345
2860
|
if (options.shadow !== false) {
|
|
346
|
-
shadow = new
|
|
2861
|
+
shadow = new Mesh2(new SphereGeometry3(0.6, 20, 6), new MeshBasicMaterial2({
|
|
347
2862
|
color: "#0b0f18",
|
|
348
2863
|
transparent: true,
|
|
349
2864
|
opacity: 0.4,
|
|
@@ -354,53 +2869,107 @@ function createPlup(options = {}) {
|
|
|
354
2869
|
shadow.raycast = () => {};
|
|
355
2870
|
root.add(shadow);
|
|
356
2871
|
}
|
|
357
|
-
let
|
|
2872
|
+
let clip2 = "idle";
|
|
358
2873
|
let held = {};
|
|
2874
|
+
let ragdoll = null;
|
|
2875
|
+
let down = false;
|
|
2876
|
+
const ragdollOf = () => {
|
|
2877
|
+
ragdoll ??= createRagdoll("off", blobRadiusAt(BLOB_SEAT, silhouette) * fit.girth * fit.stature);
|
|
2878
|
+
return ragdoll;
|
|
2879
|
+
};
|
|
2880
|
+
if (options.ragdoll && options.ragdoll !== "off")
|
|
2881
|
+
ragdollOf().set(options.ragdoll);
|
|
2882
|
+
const here = new Vector32;
|
|
2883
|
+
const last = new Vector32;
|
|
2884
|
+
const turn = new Quaternion;
|
|
2885
|
+
let tracked = false;
|
|
359
2886
|
let seconds = 0;
|
|
360
2887
|
let clock = 0;
|
|
2888
|
+
let lastDelta = 0;
|
|
361
2889
|
const apply = () => {
|
|
362
|
-
const pose = resolvePose("plup", mergePoses(sampleClip(
|
|
2890
|
+
const pose = resolvePose("plup", mergePoses(sampleClip(clip2, seconds), held));
|
|
363
2891
|
const byAlias = {
|
|
364
2892
|
armL: "LeftArm",
|
|
365
2893
|
armR: "RightArm",
|
|
366
2894
|
legL: "LeftLeg",
|
|
367
2895
|
legR: "RightLeg"
|
|
368
2896
|
};
|
|
2897
|
+
const targets = {};
|
|
369
2898
|
for (const name of Object.keys(pivots)) {
|
|
370
2899
|
const rotation = pose.get(byAlias[name]);
|
|
371
|
-
|
|
2900
|
+
const clearance = name === "armL" ? fit.armClear[0] : name === "armR" ? -fit.armClear[1] : 0;
|
|
2901
|
+
const z = rotation?.z ?? 0;
|
|
2902
|
+
const side = name === "armL" ? -1 : name === "armR" ? 1 : 0;
|
|
2903
|
+
const restAngle = isFigure ? 0.16 : 0.42;
|
|
2904
|
+
const rest = options.model ? 0 : side * restAngle * Math.max(0, 1 - Math.abs(z) / 1.4);
|
|
2905
|
+
pivots[name].rotation.set(rotation?.x ?? 0, rotation?.y ?? 0, z + clearance + rest);
|
|
2906
|
+
targets[name] = { x: rotation?.x ?? 0, z: z + clearance + rest };
|
|
372
2907
|
}
|
|
373
2908
|
const body = pose.get("Body");
|
|
374
2909
|
lifted.rotation.set(body?.x ?? 0, body?.y ?? 0, body?.z ?? 0);
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
lifted.
|
|
2910
|
+
const clipLiftY = legRaise + clipLift(clip2, seconds) * 0.32 * fit.lift;
|
|
2911
|
+
const breath = Math.sin(clock * 3.2) * (isFigure ? 0.01 : 0.018) * fit.squash;
|
|
2912
|
+
lifted.scale.set((isFigure ? 1 : shape.x) * fit.stature * (1 - breath), (isFigure ? 1 : shape.y) * fit.stature * (1 + breath), (isFigure ? 1 : shape.x) * fit.stature * (1 - breath));
|
|
2913
|
+
lifted.position.y = clipLiftY;
|
|
2914
|
+
if (ragdoll) {
|
|
2915
|
+
root.getWorldPosition(here);
|
|
2916
|
+
const step2 = Math.max(0.001, lastDelta);
|
|
2917
|
+
const velocity = tracked ? here.clone().sub(last).divideScalar(step2) : new Vector32;
|
|
2918
|
+
last.copy(here);
|
|
2919
|
+
tracked = true;
|
|
2920
|
+
velocity.applyQuaternion(root.getWorldQuaternion(turn).invert());
|
|
2921
|
+
const out = ragdoll.step(lastDelta, {
|
|
2922
|
+
joints: targets,
|
|
2923
|
+
body: { x: body?.x ?? 0, z: body?.z ?? 0 },
|
|
2924
|
+
lift: clipLiftY,
|
|
2925
|
+
velocity: { x: velocity.x, z: velocity.z }
|
|
2926
|
+
});
|
|
2927
|
+
for (const name of RAGDOLL_JOINTS) {
|
|
2928
|
+
const at = out.joints[name];
|
|
2929
|
+
pivots[name].rotation.x = at.x;
|
|
2930
|
+
pivots[name].rotation.z = at.z;
|
|
2931
|
+
}
|
|
2932
|
+
lifted.rotation.x = out.body.x;
|
|
2933
|
+
lifted.rotation.z = out.body.z;
|
|
2934
|
+
lifted.position.set(out.offset.x, out.lift, out.offset.z);
|
|
2935
|
+
shadow?.position.set(out.offset.x, 0.005, out.offset.z);
|
|
2936
|
+
down = out.down;
|
|
2937
|
+
}
|
|
2938
|
+
const step = Math.max(0.001, lastDelta);
|
|
2939
|
+
const yaw = root.rotation.y + (root.parent?.rotation.y ?? 0);
|
|
2940
|
+
const motion = { lift: (lifted.position.y - lastLift) / step, yaw: (yaw - lastYaw) / step };
|
|
2941
|
+
lastLift = lifted.position.y;
|
|
2942
|
+
lastYaw = yaw;
|
|
2943
|
+
for (const piece2 of worn.values())
|
|
2944
|
+
piece2.tick?.(clock, lastDelta, motion);
|
|
378
2945
|
if (shadow) {
|
|
379
|
-
const air = Math.min(1, lifted.position.y / 0.5);
|
|
380
|
-
|
|
2946
|
+
const air = Math.min(1, (lifted.position.y - legRaise) / 0.5);
|
|
2947
|
+
const shadowR = isFigure ? 0.72 : 1;
|
|
2948
|
+
shadow.scale.set((1 - air * 0.3) * fit.stature * fit.girth * shadowR, 0.02, (0.9 - air * 0.3) * fit.stature * fit.girth * shadowR);
|
|
381
2949
|
shadow.material.opacity = 0.4 - air * 0.18;
|
|
382
2950
|
}
|
|
383
2951
|
};
|
|
384
2952
|
apply();
|
|
385
2953
|
const redraw = () => {
|
|
386
|
-
paintBody(canvas, color, face, skin);
|
|
2954
|
+
paintBody(canvas, color, face, skin, options.faceType, isFigure);
|
|
387
2955
|
texture.needsUpdate = true;
|
|
2956
|
+
anime2?.draw(face);
|
|
388
2957
|
};
|
|
389
2958
|
return {
|
|
390
2959
|
object: root,
|
|
391
2960
|
play(next) {
|
|
392
|
-
if (next !==
|
|
2961
|
+
if (next !== clip2)
|
|
393
2962
|
seconds = 0;
|
|
394
|
-
|
|
2963
|
+
clip2 = next;
|
|
395
2964
|
},
|
|
396
2965
|
emote(name, custom) {
|
|
397
2966
|
const found = custom ?? emoteOf(name);
|
|
398
2967
|
if (!found)
|
|
399
2968
|
return;
|
|
400
2969
|
const next = found.anim ?? found.clip;
|
|
401
|
-
if (next !==
|
|
2970
|
+
if (next !== clip2)
|
|
402
2971
|
seconds = 0;
|
|
403
|
-
|
|
2972
|
+
clip2 = next;
|
|
404
2973
|
if (found.face !== face) {
|
|
405
2974
|
face = found.face;
|
|
406
2975
|
redraw();
|
|
@@ -413,6 +2982,14 @@ function createPlup(options = {}) {
|
|
|
413
2982
|
bone(name) {
|
|
414
2983
|
return name === "body" ? lifted : pivots[name];
|
|
415
2984
|
},
|
|
2985
|
+
ragdoll(mode) {
|
|
2986
|
+
ragdollOf().set(mode);
|
|
2987
|
+
},
|
|
2988
|
+
push(x, y, z) {
|
|
2989
|
+
const local = new Vector32(x, y, z).applyQuaternion(root.getWorldQuaternion(turn).invert());
|
|
2990
|
+
ragdollOf().push(local.x, local.y, local.z);
|
|
2991
|
+
},
|
|
2992
|
+
isDown: () => down,
|
|
416
2993
|
setFace(next) {
|
|
417
2994
|
if (next === face)
|
|
418
2995
|
return;
|
|
@@ -424,23 +3001,43 @@ function createPlup(options = {}) {
|
|
|
424
3001
|
return;
|
|
425
3002
|
color = next;
|
|
426
3003
|
redraw();
|
|
427
|
-
|
|
428
|
-
|
|
3004
|
+
torsoMaterial.uniforms.color?.value?.set(color);
|
|
3005
|
+
torsoMaterial.uniforms.backColor?.value?.set(color);
|
|
3006
|
+
const limbHex = isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12);
|
|
3007
|
+
const pantHex = isFigure ? [...worn.keys()].map((k) => OUTFIT_LEG_COLOR[k]).find(Boolean) ?? limbHex : limbHex;
|
|
3008
|
+
const tipHex = isFigure ? shade(color, 0, 0.12) : shade(color, 0, 0.3);
|
|
3009
|
+
limbMaterial.uniforms.color?.value?.set(limbHex);
|
|
3010
|
+
limbMaterial.uniforms.backColor?.value?.set(limbHex);
|
|
3011
|
+
legMaterial.uniforms.color?.value?.set(pantHex);
|
|
3012
|
+
legMaterial.uniforms.backColor?.value?.set(pantHex);
|
|
3013
|
+
tipMaterial.uniforms.color?.value?.set(tipHex);
|
|
3014
|
+
tipMaterial.uniforms.backColor?.value?.set(tipHex);
|
|
429
3015
|
},
|
|
3016
|
+
setWear,
|
|
430
3017
|
update(delta) {
|
|
431
3018
|
seconds += delta;
|
|
432
3019
|
clock += delta;
|
|
3020
|
+
lastDelta = delta;
|
|
433
3021
|
apply();
|
|
434
3022
|
},
|
|
435
3023
|
dispose() {
|
|
3024
|
+
setWear([]);
|
|
436
3025
|
geometry.dispose();
|
|
3026
|
+
torsoGeometry?.dispose();
|
|
437
3027
|
limbGeometry.dispose();
|
|
3028
|
+
for (const arm of armGeometries)
|
|
3029
|
+
arm.dispose();
|
|
438
3030
|
handGeometry.dispose();
|
|
439
3031
|
footGeometry.dispose();
|
|
440
3032
|
texture.dispose();
|
|
3033
|
+
anime2?.material.map?.dispose();
|
|
3034
|
+
anime2?.material.dispose();
|
|
441
3035
|
bodyMaterial.dispose();
|
|
3036
|
+
torsoMaterial.dispose();
|
|
442
3037
|
limbMaterial.dispose();
|
|
3038
|
+
legMaterial.dispose();
|
|
443
3039
|
tipMaterial.dispose();
|
|
3040
|
+
shoeMaterial.dispose();
|
|
444
3041
|
if (shadow) {
|
|
445
3042
|
shadow.geometry.dispose();
|
|
446
3043
|
shadow.material.dispose();
|
|
@@ -466,15 +3063,14 @@ function faceTexture(sheet, source, fill) {
|
|
|
466
3063
|
}
|
|
467
3064
|
context.drawImage(sheet, source.x, source.y, source.w, source.h, 0, 0, canvas.width, canvas.height);
|
|
468
3065
|
}
|
|
469
|
-
const texture = new
|
|
470
|
-
texture
|
|
471
|
-
texture.
|
|
472
|
-
texture.colorSpace = SRGBColorSpace2;
|
|
3066
|
+
const texture = new CanvasTexture3(canvas);
|
|
3067
|
+
pixelArtFiltering(texture);
|
|
3068
|
+
texture.colorSpace = SRGBColorSpace3;
|
|
473
3069
|
return texture;
|
|
474
3070
|
}
|
|
475
|
-
function plupHandle(look,
|
|
476
|
-
const plup = createPlup({ color: look.bodyColor });
|
|
477
|
-
plup.object.scale.setScalar(3.4 / 1.1
|
|
3071
|
+
function plupHandle(look, bodyScale) {
|
|
3072
|
+
const plup = createPlup({ color: look.bodyColor, bodyScale });
|
|
3073
|
+
plup.object.scale.setScalar(3.4 / 1.1);
|
|
478
3074
|
return {
|
|
479
3075
|
object: plup.object,
|
|
480
3076
|
play: plup.play,
|
|
@@ -487,20 +3083,20 @@ function plupHandle(look, stature) {
|
|
|
487
3083
|
}
|
|
488
3084
|
function createCharacter(rigId = "plup", look = { bodyColor: "#3d7bff" }, bodyScale) {
|
|
489
3085
|
if (rigId === "plup")
|
|
490
|
-
return plupHandle(look,
|
|
3086
|
+
return plupHandle(look, bodyScale);
|
|
491
3087
|
const rig = RIGS[rigId];
|
|
492
3088
|
const body = clampBodyScale(bodyScale);
|
|
493
|
-
const root = new
|
|
3089
|
+
const root = new Group3;
|
|
494
3090
|
const joints = new Map;
|
|
495
3091
|
const materials = [];
|
|
496
3092
|
const geometries = [];
|
|
497
3093
|
for (const bone of rig.bones) {
|
|
498
3094
|
const box = scaleBone(bone, nativePartOf(bone.name), bone.parent ? nativePartOf(bone.parent) : null, body);
|
|
499
|
-
const joint = new
|
|
3095
|
+
const joint = new Group3;
|
|
500
3096
|
joint.position.set(box.joint[0], box.joint[1], box.joint[2]);
|
|
501
3097
|
joints.set(bone.name, joint);
|
|
502
3098
|
(bone.parent ? joints.get(bone.parent) : root)?.add(joint);
|
|
503
|
-
const geometry = new
|
|
3099
|
+
const geometry = new BoxGeometry2(box.size[0], box.size[1], box.size[2]);
|
|
504
3100
|
geometries.push(geometry);
|
|
505
3101
|
const color = bone.name === "Head" ? look.headColor ?? look.bodyColor : look.bodyColor;
|
|
506
3102
|
const faces = BOX_FACES.map((face) => {
|
|
@@ -520,36 +3116,36 @@ function createCharacter(rigId = "plup", look = { bodyColor: "#3d7bff" }, bodySc
|
|
|
520
3116
|
return new MeshStandardMaterial({ color, roughness: 0.8 });
|
|
521
3117
|
});
|
|
522
3118
|
materials.push(...faces);
|
|
523
|
-
const mesh = new
|
|
3119
|
+
const mesh = new Mesh3(geometry, faces);
|
|
524
3120
|
mesh.position.set(box.center[0], box.center[1], box.center[2]);
|
|
525
3121
|
joint.add(mesh);
|
|
526
3122
|
}
|
|
527
|
-
let
|
|
3123
|
+
let clip2 = "idle";
|
|
528
3124
|
let held = {};
|
|
529
3125
|
let seconds = 0;
|
|
530
3126
|
const apply = () => {
|
|
531
|
-
const pose = resolvePose(rigId, mergePoses(sampleClip(
|
|
3127
|
+
const pose = resolvePose(rigId, mergePoses(sampleClip(clip2, seconds), held));
|
|
532
3128
|
for (const [name, joint] of joints) {
|
|
533
3129
|
const rotation = pose.get(name);
|
|
534
3130
|
joint.rotation.set(rotation?.x ?? 0, rotation?.y ?? 0, rotation?.z ?? 0);
|
|
535
3131
|
}
|
|
536
|
-
root.position.y = clipLift(
|
|
3132
|
+
root.position.y = clipLift(clip2, seconds) * body.stature;
|
|
537
3133
|
};
|
|
538
3134
|
apply();
|
|
539
3135
|
return {
|
|
540
3136
|
object: root,
|
|
541
3137
|
play(next) {
|
|
542
|
-
if (next !==
|
|
3138
|
+
if (next !== clip2)
|
|
543
3139
|
seconds = 0;
|
|
544
|
-
|
|
3140
|
+
clip2 = next;
|
|
545
3141
|
},
|
|
546
3142
|
emote(name) {
|
|
547
3143
|
const found = emoteOf(name);
|
|
548
3144
|
if (found) {
|
|
549
3145
|
const next = found.anim ?? found.clip;
|
|
550
|
-
if (next !==
|
|
3146
|
+
if (next !== clip2)
|
|
551
3147
|
seconds = 0;
|
|
552
|
-
|
|
3148
|
+
clip2 = next;
|
|
553
3149
|
}
|
|
554
3150
|
return found;
|
|
555
3151
|
},
|
|
@@ -576,6 +3172,25 @@ function createCharacter(rigId = "plup", look = { bodyColor: "#3d7bff" }, bodySc
|
|
|
576
3172
|
};
|
|
577
3173
|
}
|
|
578
3174
|
export {
|
|
3175
|
+
wearSlotOf,
|
|
3176
|
+
toon,
|
|
3177
|
+
isWearKey,
|
|
3178
|
+
isHighResFace,
|
|
3179
|
+
isHairKey,
|
|
3180
|
+
hairVolume,
|
|
3181
|
+
figureTorsoPoint,
|
|
3182
|
+
drawAnimeFace,
|
|
579
3183
|
createPlup,
|
|
580
|
-
createCharacter
|
|
3184
|
+
createCharacter,
|
|
3185
|
+
buildWear,
|
|
3186
|
+
buildFigureTorsoGeometry,
|
|
3187
|
+
buildFigureHeadGeometry,
|
|
3188
|
+
buildBlobGeometry,
|
|
3189
|
+
blobRadiusAt,
|
|
3190
|
+
WEARABLES,
|
|
3191
|
+
EMOTES,
|
|
3192
|
+
BODY_PRESETS,
|
|
3193
|
+
AUTHORED_CLIPS,
|
|
3194
|
+
ANIME_FACE_UV,
|
|
3195
|
+
ANIME_FACE_SIZE
|
|
581
3196
|
};
|