@plupin/character 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anime-face.d.ts +42 -0
- package/dist/anime-face.js +14 -0
- package/dist/blob.d.ts +32 -0
- package/dist/blob.js +18 -0
- package/dist/body-presets.d.ts +85 -0
- package/dist/canvas.js +7 -7
- package/dist/chunk-09c5tps4.js +337 -0
- package/dist/chunk-60p135hw.js +103 -0
- package/dist/chunk-dpb0rnw9.js +37 -0
- package/dist/chunk-g1c0wdcj.js +825 -0
- package/dist/chunk-kber92gm.js +415 -0
- package/dist/{chunk-k5gwaq6t.js → chunk-sa2r1cxz.js} +30 -3
- package/dist/chunk-yd5zzkkg.js +313 -0
- package/dist/clips.d.ts +40 -0
- package/dist/dress.d.ts +4 -0
- package/dist/emote.d.ts +5 -3
- package/dist/gaze.d.ts +81 -0
- package/dist/gaze.js +113 -0
- package/dist/hair3d.d.ts +3 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +84 -10
- package/dist/listing.d.ts +1 -1
- package/dist/listing.js +16 -6
- package/dist/platform-body-data.d.ts +9 -0
- package/dist/platform-body.d.ts +91 -0
- package/dist/plup3d.d.ts +75 -27
- package/dist/png.d.ts +19 -2
- package/dist/pose.d.ts +7 -1
- package/dist/pose.js +1 -1
- package/dist/proportions.d.ts +31 -0
- package/dist/ragdoll.d.ts +51 -0
- package/dist/resolution.d.ts +21 -0
- package/dist/skin-map.d.ts +155 -0
- package/dist/skin-map.js +55 -0
- package/dist/skin-native.d.ts +55 -6
- package/dist/texture.d.ts +8 -0
- package/dist/three.d.ts +3 -0
- package/dist/three.js +1909 -188
- package/dist/wear3d.d.ts +99 -0
- package/dist/wearables.d.ts +203 -0
- package/dist/wearables.js +26 -0
- package/package.json +21 -1
- package/dist/chunk-ae7gp5cc.js +0 -101
- package/dist/chunk-wpbgtn0y.js +0 -179
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime eyes for Plup, drawn as vector shapes on a high-resolution face decal (the 48 x 24 body map
|
|
3
|
+
* has 8 x 4 cells for a face, far too few for an anime eye). Rules and their sources are in
|
|
4
|
+
* docs/product/research-anime-hair-and-bodies.md:
|
|
5
|
+
*
|
|
6
|
+
* - Big eyes sitting low on the face, a small mouth, blush on the cheeks (chibi proportions).
|
|
7
|
+
* - A tall oval iris, dark at the top and light at the bottom, shadowed under the upper lid, with a
|
|
8
|
+
* round pupil; two highlights, a big one up and to one side and a small one down and to the other.
|
|
9
|
+
* - A thick upper lash line that flicks out at the outer corner, a thin lower one, thin brows.
|
|
10
|
+
* - Expressions change the eyes first: happy closes them into upward arcs, shock shrinks the pupils,
|
|
11
|
+
* sadness makes the highlights wet, anger loses them and slants the brows.
|
|
12
|
+
*
|
|
13
|
+
* Pure canvas drawing, no three.js: `plup3d.ts` puts the canvas on the body.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ANIME_FACE_SIZE: {
|
|
16
|
+
readonly width: 512;
|
|
17
|
+
readonly height: 256;
|
|
18
|
+
};
|
|
19
|
+
/** Where the decal sits on the body's UV sphere (see `plup3d.ts`): a band round the front. */
|
|
20
|
+
export declare const ANIME_FACE_UV: {
|
|
21
|
+
readonly u0: 0.07;
|
|
22
|
+
readonly u1: 0.43;
|
|
23
|
+
readonly v0: 0.37;
|
|
24
|
+
readonly v1: 0.7;
|
|
25
|
+
};
|
|
26
|
+
type Eyes = "open" | "closed" | "happy" | "wide" | "sad" | "half" | "angry" | "stars" | "dead" | "wink" | "cry";
|
|
27
|
+
type Mouth = "smile" | "open" | "o" | "frown" | "smirk" | "cat" | "flat" | "yell" | "tongue" | "grin";
|
|
28
|
+
type Brows = "calm" | "up" | "angry" | "sad" | "none";
|
|
29
|
+
interface FaceParts {
|
|
30
|
+
eyes: Eyes;
|
|
31
|
+
mouth: Mouth;
|
|
32
|
+
brows: Brows;
|
|
33
|
+
blush: number;
|
|
34
|
+
tears?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The parts of a face by its name (unknown names rest). */
|
|
37
|
+
export declare function animeFaceParts(face: string): FaceParts;
|
|
38
|
+
/** How far down the face canvas the eyes sit, for drawing it over a flat icon. */
|
|
39
|
+
export declare const ANIME_EYE_LINE: number;
|
|
40
|
+
/** Draw an anime face for `face` on a canvas of `ANIME_FACE_SIZE`, with irises in `iris`. */
|
|
41
|
+
export declare function drawAnimeFace(ctx: CanvasRenderingContext2D, face: string, iris?: string): void;
|
|
42
|
+
export {};
|
package/dist/blob.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SphereGeometry } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* Plup's body: one round blob, bottom-heavy (a soft triangle), resting on a flat seat. The app's lobby, the
|
|
4
|
+
* games and the films all build it from here (ADR 0024), so the silhouette cannot drift between them.
|
|
5
|
+
* These numbers are the lobby's, which is the look the owner signed off.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BLOB_RADIUS: {
|
|
8
|
+
readonly x: 0.6;
|
|
9
|
+
readonly y: 0.56;
|
|
10
|
+
readonly z: 0.58;
|
|
11
|
+
};
|
|
12
|
+
/** The blob's height with the seat flattened: feet on y = 0. */
|
|
13
|
+
export declare const BLOB_HEIGHT: number;
|
|
14
|
+
/**
|
|
15
|
+
* A body's silhouette on top of the blob: how broad the shoulders are, how much the waist pinches, how
|
|
16
|
+
* wide the hips spread. 1 everywhere is the round Plup; a muscular body is broad on top and narrow below,
|
|
17
|
+
* a curvy one pinched at the waist and full at the hips. Everything that has to fit the body (the
|
|
18
|
+
* wearables, the arms' shoulders) reads the same `silhouetteAt`, so clothes follow the shape.
|
|
19
|
+
*/
|
|
20
|
+
export interface Silhouette {
|
|
21
|
+
shoulders: number;
|
|
22
|
+
waist: number;
|
|
23
|
+
hips: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const ROUND: Silhouette;
|
|
26
|
+
/** The radius multiplier at a height on the unit sphere (-1 bottom, 1 top). */
|
|
27
|
+
export declare function silhouetteAt(unitY: number, silhouette?: Silhouette): number;
|
|
28
|
+
/** How far the seat was raised so the feet stand on y = 0. */
|
|
29
|
+
export declare const BLOB_SEAT: number;
|
|
30
|
+
/** The body's half-width across (x) at a height above the feet, for this silhouette. Front to back is `BLOB_RADIUS.z / BLOB_RADIUS.x` of it. */
|
|
31
|
+
export declare function blobRadiusAt(y: number, silhouette?: Silhouette): number;
|
|
32
|
+
export declare function buildBlobGeometry(silhouette?: Silhouette): SphereGeometry;
|
package/dist/blob.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLOB_HEIGHT,
|
|
3
|
+
BLOB_RADIUS,
|
|
4
|
+
BLOB_SEAT,
|
|
5
|
+
ROUND,
|
|
6
|
+
blobRadiusAt,
|
|
7
|
+
buildBlobGeometry,
|
|
8
|
+
silhouetteAt
|
|
9
|
+
} from "./chunk-dpb0rnw9.js";
|
|
10
|
+
export {
|
|
11
|
+
silhouetteAt,
|
|
12
|
+
buildBlobGeometry,
|
|
13
|
+
blobRadiusAt,
|
|
14
|
+
ROUND,
|
|
15
|
+
BLOB_SEAT,
|
|
16
|
+
BLOB_RADIUS,
|
|
17
|
+
BLOB_HEIGHT
|
|
18
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bodies a player starts from, then tunes with the sliders: each is a shape (height and girth) and a
|
|
3
|
+
* Plup body (outline, limb length and bulk). Data only, so the app, the games and the films offer the
|
|
4
|
+
* same list. Names are English; the app translates them for display.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BODY_PRESETS: {
|
|
7
|
+
readonly round: {
|
|
8
|
+
readonly name: "Round";
|
|
9
|
+
readonly shape: "plup";
|
|
10
|
+
readonly body: {};
|
|
11
|
+
};
|
|
12
|
+
readonly "tall-slim": {
|
|
13
|
+
readonly name: "Tall & Slim";
|
|
14
|
+
readonly shape: "tall";
|
|
15
|
+
readonly body: {
|
|
16
|
+
readonly shoulders: 0.9;
|
|
17
|
+
readonly waist: 0.84;
|
|
18
|
+
readonly hips: 0.9;
|
|
19
|
+
readonly legLength: 2.6;
|
|
20
|
+
readonly armLength: 1.4;
|
|
21
|
+
readonly muscle: 0.78;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly athletic: {
|
|
25
|
+
readonly name: "Athletic";
|
|
26
|
+
readonly shape: "tall";
|
|
27
|
+
readonly body: {
|
|
28
|
+
readonly shoulders: 1.2;
|
|
29
|
+
readonly waist: 0.84;
|
|
30
|
+
readonly hips: 0.95;
|
|
31
|
+
readonly legLength: 2.1;
|
|
32
|
+
readonly armLength: 1.3;
|
|
33
|
+
readonly muscle: 1.35;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly muscular: {
|
|
37
|
+
readonly name: "Muscular";
|
|
38
|
+
readonly shape: "tall";
|
|
39
|
+
readonly body: {
|
|
40
|
+
readonly shoulders: 1.32;
|
|
41
|
+
readonly waist: 0.82;
|
|
42
|
+
readonly hips: 0.88;
|
|
43
|
+
readonly legLength: 1.7;
|
|
44
|
+
readonly armLength: 1.25;
|
|
45
|
+
readonly muscle: 1.9;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly curvy: {
|
|
49
|
+
readonly name: "Curvy";
|
|
50
|
+
readonly shape: "tall";
|
|
51
|
+
readonly body: {
|
|
52
|
+
readonly shoulders: 0.9;
|
|
53
|
+
readonly waist: 0.66;
|
|
54
|
+
readonly hips: 1.32;
|
|
55
|
+
readonly legLength: 2.4;
|
|
56
|
+
readonly armLength: 1.3;
|
|
57
|
+
readonly muscle: 0.85;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly chubby: {
|
|
61
|
+
readonly name: "Chubby";
|
|
62
|
+
readonly shape: "wide";
|
|
63
|
+
readonly body: {
|
|
64
|
+
readonly shoulders: 1;
|
|
65
|
+
readonly waist: 1.15;
|
|
66
|
+
readonly hips: 1.25;
|
|
67
|
+
readonly legLength: 1;
|
|
68
|
+
readonly armLength: 1;
|
|
69
|
+
readonly muscle: 1.2;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly tiny: {
|
|
73
|
+
readonly name: "Tiny";
|
|
74
|
+
readonly shape: "mini";
|
|
75
|
+
readonly body: {};
|
|
76
|
+
};
|
|
77
|
+
readonly bean: {
|
|
78
|
+
readonly name: "Bean";
|
|
79
|
+
readonly shape: "bean";
|
|
80
|
+
readonly body: {
|
|
81
|
+
readonly legLength: 1.3;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export type BodyPresetId = keyof typeof BODY_PRESETS;
|
package/dist/canvas.js
CHANGED
|
@@ -6,19 +6,19 @@ import {
|
|
|
6
6
|
clampBodyScale,
|
|
7
7
|
nativePartOf,
|
|
8
8
|
scaleBone
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
FACE_STAMP_PALETTE,
|
|
12
|
-
NAMED_FACES,
|
|
13
|
-
NAMED_FACE_STAMPS
|
|
14
|
-
} from "./chunk-aa5nstet.js";
|
|
9
|
+
} from "./chunk-sa2r1cxz.js";
|
|
15
10
|
import {
|
|
16
11
|
RIGS,
|
|
17
12
|
clipLift,
|
|
18
13
|
mergePoses,
|
|
19
14
|
resolvePose,
|
|
20
15
|
sampleClip
|
|
21
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-g1c0wdcj.js";
|
|
17
|
+
import {
|
|
18
|
+
FACE_STAMP_PALETTE,
|
|
19
|
+
NAMED_FACES,
|
|
20
|
+
NAMED_FACE_STAMPS
|
|
21
|
+
} from "./chunk-aa5nstet.js";
|
|
22
22
|
|
|
23
23
|
// src/plup2d.ts
|
|
24
24
|
var hex = (color) => {
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// src/anime-face.ts
|
|
2
|
+
var ANIME_FACE_SIZE = { width: 512, height: 256 };
|
|
3
|
+
var ANIME_FACE_UV = { u0: 0.07, u1: 0.43, v0: 0.37, v1: 0.7 };
|
|
4
|
+
var PARTS = {
|
|
5
|
+
idle: { eyes: "open", mouth: "smile", brows: "calm", blush: 0.55 },
|
|
6
|
+
blink: { eyes: "closed", mouth: "smile", brows: "calm", blush: 0.55 },
|
|
7
|
+
happy: { eyes: "happy", mouth: "open", brows: "up", blush: 0.8 },
|
|
8
|
+
surprised: { eyes: "wide", mouth: "o", brows: "up", blush: 0.4 },
|
|
9
|
+
sad: { eyes: "sad", mouth: "frown", brows: "sad", blush: 0.3 },
|
|
10
|
+
wee: { eyes: "happy", mouth: "o", brows: "up", blush: 0.9 },
|
|
11
|
+
sparkle: { eyes: "stars", mouth: "open", brows: "up", blush: 0.9 },
|
|
12
|
+
shock: { eyes: "wide", mouth: "o", brows: "up", blush: 0.2 },
|
|
13
|
+
yell: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
|
|
14
|
+
pain: { eyes: "closed", mouth: "frown", brows: "sad", blush: 0.2 },
|
|
15
|
+
dead: { eyes: "dead", mouth: "flat", brows: "none", blush: 0 },
|
|
16
|
+
rage: { eyes: "angry", mouth: "grin", brows: "angry", blush: 0.2 },
|
|
17
|
+
speechless: { eyes: "half", mouth: "flat", brows: "calm", blush: 0.2 },
|
|
18
|
+
idea: { eyes: "wide", mouth: "smile", brows: "up", blush: 0.5 },
|
|
19
|
+
smug: { eyes: "half", mouth: "cat", brows: "calm", blush: 0.6 },
|
|
20
|
+
cry: { eyes: "cry", mouth: "frown", brows: "sad", blush: 0.5, tears: true },
|
|
21
|
+
smirk: { eyes: "wink", mouth: "smirk", brows: "calm", blush: 0.6 },
|
|
22
|
+
tongue: { eyes: "wink", mouth: "tongue", brows: "up", blush: 0.7 },
|
|
23
|
+
cool: { eyes: "half", mouth: "smirk", brows: "calm", blush: 0.2 },
|
|
24
|
+
serious: { eyes: "angry", mouth: "flat", brows: "angry", blush: 0 },
|
|
25
|
+
stars: { eyes: "stars", mouth: "grin", brows: "up", blush: 0.9 },
|
|
26
|
+
licik: { eyes: "half", mouth: "grin", brows: "angry", blush: 0.3 },
|
|
27
|
+
tidur: { eyes: "closed", mouth: "o", brows: "calm", blush: 0.5 },
|
|
28
|
+
teriak: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
|
|
29
|
+
ngomel: { eyes: "angry", mouth: "frown", brows: "angry", blush: 0.3 }
|
|
30
|
+
};
|
|
31
|
+
var INK = "#1d1430";
|
|
32
|
+
var LASH = "#24152e";
|
|
33
|
+
function animeFaceParts(face) {
|
|
34
|
+
return PARTS[face] ?? PARTS.idle ?? { eyes: "open", mouth: "smile", brows: "calm", blush: 0.5 };
|
|
35
|
+
}
|
|
36
|
+
var W = ANIME_FACE_SIZE.width;
|
|
37
|
+
var H = ANIME_FACE_SIZE.height;
|
|
38
|
+
var EYE_Y = 112;
|
|
39
|
+
var EYE_X = 88;
|
|
40
|
+
var EYE_W = 74;
|
|
41
|
+
var EYE_H = 100;
|
|
42
|
+
var MOUTH_Y = 192;
|
|
43
|
+
var ANIME_EYE_LINE = EYE_Y / H;
|
|
44
|
+
var mix = (a, b, t) => {
|
|
45
|
+
const ch = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
|
|
46
|
+
return `#${[0, 1, 2].map((i) => Math.round(ch(a, i) + (ch(b, i) - ch(a, i)) * t).toString(16).padStart(2, "0")).join("")}`;
|
|
47
|
+
};
|
|
48
|
+
function ellipse(ctx, x, y, rx, ry) {
|
|
49
|
+
ctx.beginPath();
|
|
50
|
+
ctx.ellipse(x, y, Math.max(0.5, rx), Math.max(0.5, ry), 0, 0, Math.PI * 2);
|
|
51
|
+
}
|
|
52
|
+
function eyeShape(ctx, x, y, side) {
|
|
53
|
+
const w = EYE_W / 2;
|
|
54
|
+
const h = EYE_H / 2;
|
|
55
|
+
ctx.beginPath();
|
|
56
|
+
ctx.moveTo(x - w, y - h * 0.25);
|
|
57
|
+
ctx.bezierCurveTo(x - w * 0.9, y - h * 1.05, x + w * 0.9, y - h * 1.12 - side * 2, x + w, y - h * 0.3);
|
|
58
|
+
ctx.bezierCurveTo(x + w * 1.05, y + h * 0.75, x + w * 0.5, y + h, x, y + h);
|
|
59
|
+
ctx.bezierCurveTo(x - w * 0.55, y + h, x - w * 1.05, y + h * 0.7, x - w, y - h * 0.25);
|
|
60
|
+
ctx.closePath();
|
|
61
|
+
}
|
|
62
|
+
function lashes(ctx, x, y, side, lift = 0) {
|
|
63
|
+
const w = EYE_W / 2;
|
|
64
|
+
const h = EYE_H / 2;
|
|
65
|
+
const outer = side;
|
|
66
|
+
ctx.fillStyle = LASH;
|
|
67
|
+
ctx.beginPath();
|
|
68
|
+
ctx.moveTo(x - outer * w * 1.02, y - h * 0.2 + lift);
|
|
69
|
+
ctx.bezierCurveTo(x - outer * w * 0.9, y - h * 1.12 + lift, x + outer * w * 0.85, y - h * 1.2 + lift, x + outer * w * 1.22, y - h * 0.62 + lift);
|
|
70
|
+
ctx.lineTo(x + outer * w * 1.42, y - h * 0.72 + lift);
|
|
71
|
+
ctx.lineTo(x + outer * w * 1.08, y - h * 0.3 + lift);
|
|
72
|
+
ctx.bezierCurveTo(x + outer * w * 0.8, y - h * 0.92 + lift, x - outer * w * 0.8, y - h * 0.86 + lift, x - outer * w * 1.02, y - h * 0.2 + lift);
|
|
73
|
+
ctx.closePath();
|
|
74
|
+
ctx.fill();
|
|
75
|
+
}
|
|
76
|
+
function lowerLash(ctx, x, y, side) {
|
|
77
|
+
const w = EYE_W / 2;
|
|
78
|
+
const h = EYE_H / 2;
|
|
79
|
+
ctx.strokeStyle = LASH;
|
|
80
|
+
ctx.lineWidth = 3;
|
|
81
|
+
ctx.lineCap = "round";
|
|
82
|
+
ctx.beginPath();
|
|
83
|
+
ctx.moveTo(x + side * w * 0.95, y + h * 0.35);
|
|
84
|
+
ctx.quadraticCurveTo(x + side * w * 0.6, y + h * 0.95, x + side * w * 0.05, y + h * 1);
|
|
85
|
+
ctx.stroke();
|
|
86
|
+
}
|
|
87
|
+
function openEye(ctx, x, y, side, iris, { pupil = 1, wet = false, catchlights = 2, squint = 0 } = {}) {
|
|
88
|
+
ctx.save();
|
|
89
|
+
eyeShape(ctx, x, y, side);
|
|
90
|
+
ctx.fillStyle = "#fffaff";
|
|
91
|
+
ctx.fill();
|
|
92
|
+
ctx.clip();
|
|
93
|
+
const ix = x + side * 2;
|
|
94
|
+
const iy = y + 6;
|
|
95
|
+
const irx = EYE_W * 0.4;
|
|
96
|
+
const iry = EYE_H * 0.47;
|
|
97
|
+
const gradient = ctx.createLinearGradient(0, iy - iry, 0, iy + iry);
|
|
98
|
+
gradient.addColorStop(0, mix(iris, "#100818", 0.55));
|
|
99
|
+
gradient.addColorStop(0.55, iris);
|
|
100
|
+
gradient.addColorStop(1, mix(iris, "#ffffff", 0.55));
|
|
101
|
+
ellipse(ctx, ix, iy, irx, iry);
|
|
102
|
+
ctx.fillStyle = gradient;
|
|
103
|
+
ctx.fill();
|
|
104
|
+
ctx.lineWidth = 3;
|
|
105
|
+
ctx.strokeStyle = mix(iris, "#100818", 0.6);
|
|
106
|
+
ctx.stroke();
|
|
107
|
+
ellipse(ctx, ix, iy + 2, irx * 0.42 * pupil, iry * 0.46 * pupil);
|
|
108
|
+
ctx.fillStyle = mix(iris, "#0a0410", 0.8);
|
|
109
|
+
ctx.fill();
|
|
110
|
+
ellipse(ctx, ix, iy + iry * 0.5, irx * 0.6, iry * 0.28);
|
|
111
|
+
ctx.fillStyle = `${mix(iris, "#ffffff", 0.7)}88`;
|
|
112
|
+
ctx.fill();
|
|
113
|
+
ctx.fillStyle = "rgba(40, 20, 70, 0.35)";
|
|
114
|
+
ctx.fillRect(x - EYE_W, y - EYE_H, EYE_W * 2, EYE_H * 0.42 + squint);
|
|
115
|
+
ctx.restore();
|
|
116
|
+
ctx.fillStyle = "#ffffff";
|
|
117
|
+
if (catchlights > 0) {
|
|
118
|
+
ellipse(ctx, ix - side * irx * 0.4, iy - iry * 0.4, irx * 0.34, iry * 0.26);
|
|
119
|
+
ctx.fill();
|
|
120
|
+
}
|
|
121
|
+
if (catchlights > 1) {
|
|
122
|
+
ellipse(ctx, ix + side * irx * 0.42, iy + iry * 0.38, irx * 0.14, iry * 0.1);
|
|
123
|
+
ctx.fill();
|
|
124
|
+
}
|
|
125
|
+
if (wet) {
|
|
126
|
+
ctx.globalAlpha = 0.8;
|
|
127
|
+
ellipse(ctx, ix, iy + iry * 0.62, irx * 0.75, iry * 0.12);
|
|
128
|
+
ctx.fill();
|
|
129
|
+
ctx.globalAlpha = 1;
|
|
130
|
+
}
|
|
131
|
+
lashes(ctx, x, y, side, squint);
|
|
132
|
+
lowerLash(ctx, x, y, side);
|
|
133
|
+
}
|
|
134
|
+
function closedEye(ctx, x, y, side, happy) {
|
|
135
|
+
const w = EYE_W / 2;
|
|
136
|
+
ctx.strokeStyle = LASH;
|
|
137
|
+
ctx.lineWidth = 7;
|
|
138
|
+
ctx.lineCap = "round";
|
|
139
|
+
ctx.beginPath();
|
|
140
|
+
if (happy) {
|
|
141
|
+
ctx.moveTo(x - w, y + 10);
|
|
142
|
+
ctx.quadraticCurveTo(x, y - 26, x + w, y + 10);
|
|
143
|
+
} else {
|
|
144
|
+
ctx.moveTo(x - w, y + 2);
|
|
145
|
+
ctx.quadraticCurveTo(x, y + 22, x + w, y + 2);
|
|
146
|
+
ctx.moveTo(x + side * w, y + 2);
|
|
147
|
+
ctx.lineTo(x + side * w * 1.3, y - 6);
|
|
148
|
+
}
|
|
149
|
+
ctx.stroke();
|
|
150
|
+
}
|
|
151
|
+
function star(ctx, x, y, r, color) {
|
|
152
|
+
ctx.beginPath();
|
|
153
|
+
for (let i = 0;i < 10; i += 1) {
|
|
154
|
+
const a = i / 10 * Math.PI * 2 - Math.PI / 2;
|
|
155
|
+
const k = i % 2 ? r * 0.45 : r;
|
|
156
|
+
ctx.lineTo(x + Math.cos(a) * k, y + Math.sin(a) * k);
|
|
157
|
+
}
|
|
158
|
+
ctx.closePath();
|
|
159
|
+
ctx.fillStyle = color;
|
|
160
|
+
ctx.fill();
|
|
161
|
+
}
|
|
162
|
+
function eye(ctx, side, parts, iris) {
|
|
163
|
+
const x = W / 2 + side * EYE_X;
|
|
164
|
+
const y = EYE_Y;
|
|
165
|
+
switch (parts.eyes) {
|
|
166
|
+
case "closed":
|
|
167
|
+
return closedEye(ctx, x, y, side, false);
|
|
168
|
+
case "happy":
|
|
169
|
+
return closedEye(ctx, x, y, side, true);
|
|
170
|
+
case "wink":
|
|
171
|
+
return side > 0 ? closedEye(ctx, x, y, side, true) : openEye(ctx, x, y, side, iris);
|
|
172
|
+
case "wide":
|
|
173
|
+
return openEye(ctx, x, y, side, iris, { pupil: 0.45, catchlights: 1 });
|
|
174
|
+
case "sad":
|
|
175
|
+
case "cry":
|
|
176
|
+
return openEye(ctx, x, y, side, iris, { wet: true, pupil: 1.1 });
|
|
177
|
+
case "half":
|
|
178
|
+
openEye(ctx, x, y, side, iris, { squint: 26 });
|
|
179
|
+
return;
|
|
180
|
+
case "angry":
|
|
181
|
+
openEye(ctx, x, y, side, iris, { catchlights: 0, squint: 14, pupil: 0.7 });
|
|
182
|
+
return;
|
|
183
|
+
case "stars":
|
|
184
|
+
openEye(ctx, x, y, side, iris, { catchlights: 0 });
|
|
185
|
+
star(ctx, x + side * 2, y + 6, 22, "#fff4a8");
|
|
186
|
+
return;
|
|
187
|
+
case "dead": {
|
|
188
|
+
ctx.strokeStyle = LASH;
|
|
189
|
+
ctx.lineWidth = 7;
|
|
190
|
+
ctx.lineCap = "round";
|
|
191
|
+
ctx.beginPath();
|
|
192
|
+
ctx.moveTo(x - 20, y - 20);
|
|
193
|
+
ctx.lineTo(x + 20, y + 20);
|
|
194
|
+
ctx.moveTo(x + 20, y - 20);
|
|
195
|
+
ctx.lineTo(x - 20, y + 20);
|
|
196
|
+
ctx.stroke();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
default:
|
|
200
|
+
openEye(ctx, x, y, side, iris);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function brow(ctx, side, brows) {
|
|
204
|
+
if (brows === "none")
|
|
205
|
+
return;
|
|
206
|
+
const x = W / 2 + side * EYE_X;
|
|
207
|
+
const y = EYE_Y - EYE_H * 0.72;
|
|
208
|
+
const tilt = brows === "angry" ? 16 : brows === "sad" ? -12 : 0;
|
|
209
|
+
const lift = brows === "up" ? -6 : 0;
|
|
210
|
+
ctx.strokeStyle = mix(LASH, "#ffffff", 0.15);
|
|
211
|
+
ctx.lineWidth = 4;
|
|
212
|
+
ctx.lineCap = "round";
|
|
213
|
+
ctx.beginPath();
|
|
214
|
+
ctx.moveTo(x - side * 22, y + lift + tilt);
|
|
215
|
+
ctx.quadraticCurveTo(x, y + lift - 6, x + side * 22, y + lift - tilt * 0.2);
|
|
216
|
+
ctx.stroke();
|
|
217
|
+
}
|
|
218
|
+
function mouth(ctx, shape) {
|
|
219
|
+
const x = W / 2;
|
|
220
|
+
const y = MOUTH_Y;
|
|
221
|
+
ctx.strokeStyle = INK;
|
|
222
|
+
ctx.lineWidth = 4;
|
|
223
|
+
ctx.lineCap = "round";
|
|
224
|
+
ctx.lineJoin = "round";
|
|
225
|
+
const fillOpen = (w, h, round = false) => {
|
|
226
|
+
ctx.beginPath();
|
|
227
|
+
if (round)
|
|
228
|
+
ctx.ellipse(x, y + h / 2, w, h / 2 + 2, 0, 0, Math.PI * 2);
|
|
229
|
+
else {
|
|
230
|
+
ctx.moveTo(x - w, y);
|
|
231
|
+
ctx.quadraticCurveTo(x, y + h * 2, x + w, y);
|
|
232
|
+
ctx.closePath();
|
|
233
|
+
}
|
|
234
|
+
ctx.fillStyle = "#8a2a3e";
|
|
235
|
+
ctx.fill();
|
|
236
|
+
ctx.stroke();
|
|
237
|
+
ctx.save();
|
|
238
|
+
ctx.clip();
|
|
239
|
+
ellipse(ctx, x, y + h * 1.05, w * 0.6, h * 0.5);
|
|
240
|
+
ctx.fillStyle = "#f07a95";
|
|
241
|
+
ctx.fill();
|
|
242
|
+
ctx.restore();
|
|
243
|
+
};
|
|
244
|
+
ctx.beginPath();
|
|
245
|
+
switch (shape) {
|
|
246
|
+
case "smile":
|
|
247
|
+
ctx.moveTo(x - 10, y);
|
|
248
|
+
ctx.quadraticCurveTo(x, y + 8, x + 10, y);
|
|
249
|
+
ctx.stroke();
|
|
250
|
+
return;
|
|
251
|
+
case "cat":
|
|
252
|
+
ctx.moveTo(x - 14, y - 2);
|
|
253
|
+
ctx.quadraticCurveTo(x - 7, y + 9, x, y);
|
|
254
|
+
ctx.quadraticCurveTo(x + 7, y + 9, x + 14, y - 2);
|
|
255
|
+
ctx.stroke();
|
|
256
|
+
return;
|
|
257
|
+
case "open":
|
|
258
|
+
return fillOpen(13, 11);
|
|
259
|
+
case "grin":
|
|
260
|
+
return fillOpen(18, 12);
|
|
261
|
+
case "yell":
|
|
262
|
+
return fillOpen(16, 22, true);
|
|
263
|
+
case "o":
|
|
264
|
+
return fillOpen(8, 14, true);
|
|
265
|
+
case "frown":
|
|
266
|
+
ctx.moveTo(x - 10, y + 6);
|
|
267
|
+
ctx.quadraticCurveTo(x, y - 3, x + 10, y + 6);
|
|
268
|
+
ctx.stroke();
|
|
269
|
+
return;
|
|
270
|
+
case "smirk":
|
|
271
|
+
ctx.moveTo(x - 8, y + 3);
|
|
272
|
+
ctx.quadraticCurveTo(x + 6, y + 6, x + 14, y - 4);
|
|
273
|
+
ctx.stroke();
|
|
274
|
+
return;
|
|
275
|
+
case "tongue":
|
|
276
|
+
ctx.moveTo(x - 12, y);
|
|
277
|
+
ctx.quadraticCurveTo(x, y + 8, x + 12, y);
|
|
278
|
+
ctx.stroke();
|
|
279
|
+
ellipse(ctx, x + 4, y + 8, 7, 8);
|
|
280
|
+
ctx.fillStyle = "#f07a95";
|
|
281
|
+
ctx.fill();
|
|
282
|
+
ctx.stroke();
|
|
283
|
+
return;
|
|
284
|
+
default:
|
|
285
|
+
ctx.moveTo(x - 9, y + 2);
|
|
286
|
+
ctx.lineTo(x + 9, y + 2);
|
|
287
|
+
ctx.stroke();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function blush(ctx, amount) {
|
|
291
|
+
if (amount <= 0)
|
|
292
|
+
return;
|
|
293
|
+
for (const side of [-1, 1]) {
|
|
294
|
+
const x = W / 2 + side * (EYE_X + 14);
|
|
295
|
+
const y = EYE_Y + EYE_H * 0.72;
|
|
296
|
+
const glow = ctx.createRadialGradient(x, y, 2, x, y, 34);
|
|
297
|
+
glow.addColorStop(0, `rgba(255, 120, 150, ${0.55 * amount})`);
|
|
298
|
+
glow.addColorStop(1, "rgba(255, 120, 150, 0)");
|
|
299
|
+
ctx.fillStyle = glow;
|
|
300
|
+
ctx.fillRect(x - 40, y - 26, 80, 52);
|
|
301
|
+
ctx.strokeStyle = `rgba(230, 80, 120, ${0.7 * amount})`;
|
|
302
|
+
ctx.lineWidth = 2.5;
|
|
303
|
+
ctx.lineCap = "round";
|
|
304
|
+
for (let i = -1;i <= 1; i += 1) {
|
|
305
|
+
ctx.beginPath();
|
|
306
|
+
ctx.moveTo(x + i * 10 - 3, y + 5);
|
|
307
|
+
ctx.lineTo(x + i * 10 + 4, y - 5);
|
|
308
|
+
ctx.stroke();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function tears(ctx) {
|
|
313
|
+
for (const side of [-1, 1]) {
|
|
314
|
+
const x = W / 2 + side * (EYE_X - 8);
|
|
315
|
+
const y = EYE_Y + EYE_H * 0.5;
|
|
316
|
+
ctx.fillStyle = "rgba(140, 220, 255, 0.85)";
|
|
317
|
+
ctx.beginPath();
|
|
318
|
+
ctx.moveTo(x, y);
|
|
319
|
+
ctx.quadraticCurveTo(x + side * 10, y + 30, x, y + 44);
|
|
320
|
+
ctx.quadraticCurveTo(x - side * 8, y + 30, x, y);
|
|
321
|
+
ctx.fill();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function drawAnimeFace(ctx, face, iris = "#6a4cff") {
|
|
325
|
+
ctx.clearRect(0, 0, W, H);
|
|
326
|
+
const parts = animeFaceParts(face);
|
|
327
|
+
blush(ctx, parts.blush);
|
|
328
|
+
for (const side of [-1, 1]) {
|
|
329
|
+
eye(ctx, side, parts, iris);
|
|
330
|
+
brow(ctx, side, parts.brows);
|
|
331
|
+
}
|
|
332
|
+
if (parts.tears)
|
|
333
|
+
tears(ctx);
|
|
334
|
+
mouth(ctx, parts.mouth);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export { ANIME_FACE_SIZE, ANIME_FACE_UV, animeFaceParts, ANIME_EYE_LINE, drawAnimeFace };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/wearables.ts
|
|
2
|
+
var WEARABLES = {
|
|
3
|
+
"fluffy-bob": {
|
|
4
|
+
slot: "hair",
|
|
5
|
+
name: "Fluffy Bob",
|
|
6
|
+
rarity: "common",
|
|
7
|
+
sigmaPrice: 40,
|
|
8
|
+
volume: 0.06
|
|
9
|
+
},
|
|
10
|
+
"twin-tails": { slot: "hair", name: "Twin Tails", rarity: "rare", sigmaPrice: 70, volume: 0.05 },
|
|
11
|
+
"spiky-hero": { slot: "hair", name: "Spiky Hero", rarity: "rare", sigmaPrice: 65, volume: 0.12 },
|
|
12
|
+
afro: { slot: "hair", name: "Afro", rarity: "rare", sigmaPrice: 60, volume: 0.2 },
|
|
13
|
+
"swoosh-quiff": {
|
|
14
|
+
slot: "hair",
|
|
15
|
+
name: "Swoosh Quiff",
|
|
16
|
+
rarity: "common",
|
|
17
|
+
sigmaPrice: 35,
|
|
18
|
+
volume: 0.08
|
|
19
|
+
},
|
|
20
|
+
"long-waves": {
|
|
21
|
+
slot: "hair",
|
|
22
|
+
name: "Long Waves",
|
|
23
|
+
rarity: "epic",
|
|
24
|
+
sigmaPrice: 110,
|
|
25
|
+
volume: 0.05,
|
|
26
|
+
view: -0.9
|
|
27
|
+
},
|
|
28
|
+
ponytail: {
|
|
29
|
+
slot: "hair",
|
|
30
|
+
name: "Ponytail",
|
|
31
|
+
rarity: "common",
|
|
32
|
+
sigmaPrice: 45,
|
|
33
|
+
volume: 0.05,
|
|
34
|
+
view: -1.2
|
|
35
|
+
},
|
|
36
|
+
mohawk: {
|
|
37
|
+
slot: "hair",
|
|
38
|
+
name: "Mohawk",
|
|
39
|
+
rarity: "rare",
|
|
40
|
+
sigmaPrice: 55,
|
|
41
|
+
volume: 0.14,
|
|
42
|
+
view: -0.8
|
|
43
|
+
},
|
|
44
|
+
"space-buns": { slot: "hair", name: "Space Buns", rarity: "rare", sigmaPrice: 60, volume: 0.06 },
|
|
45
|
+
"hime-cut": {
|
|
46
|
+
slot: "hair",
|
|
47
|
+
name: "Hime Cut",
|
|
48
|
+
rarity: "epic",
|
|
49
|
+
sigmaPrice: 120,
|
|
50
|
+
volume: 0.06,
|
|
51
|
+
view: -0.6
|
|
52
|
+
},
|
|
53
|
+
"bunny-ears": { slot: "hat", name: "Bunny Ears", rarity: "rare", sigmaPrice: 60 },
|
|
54
|
+
"cat-ears": { slot: "hat", name: "Cat Ears", rarity: "common", sigmaPrice: 45 },
|
|
55
|
+
"top-hat": { slot: "hat", name: "Top Hat", rarity: "rare", sigmaPrice: 70 },
|
|
56
|
+
crown: { slot: "hat", name: "Crown", rarity: "epic", sigmaPrice: 150 },
|
|
57
|
+
"party-hat": { slot: "hat", name: "Party Hat", rarity: "common", sigmaPrice: 35 },
|
|
58
|
+
halo: { slot: "hat", name: "Halo", rarity: "epic", sigmaPrice: 120 },
|
|
59
|
+
bow: { slot: "hat", name: "Bow", rarity: "common", sigmaPrice: 30 },
|
|
60
|
+
"pleated-skirt": { slot: "accessory", name: "Pleated Skirt", rarity: "common", sigmaPrice: 50 },
|
|
61
|
+
tuxedo: { slot: "accessory", name: "Tuxedo", rarity: "epic", sigmaPrice: 140 },
|
|
62
|
+
"hero-cape": { slot: "accessory", name: "Hero Cape", rarity: "rare", sigmaPrice: 90, view: 2.6 },
|
|
63
|
+
scarf: { slot: "accessory", name: "Scarf", rarity: "common", sigmaPrice: 40 },
|
|
64
|
+
sunglasses: { slot: "accessory", name: "Sunglasses", rarity: "rare", sigmaPrice: 65 }
|
|
65
|
+
};
|
|
66
|
+
var WEAR_KEYS = Object.keys(WEARABLES);
|
|
67
|
+
var PREFIX = "wear-";
|
|
68
|
+
var entry = (key) => WEARABLES[key];
|
|
69
|
+
var isWearKey = (value) => typeof value === "string" && Object.hasOwn(WEARABLES, value);
|
|
70
|
+
var isHairKey = (key) => entry(key).slot === "hair";
|
|
71
|
+
var hairVolume = (key) => entry(key).volume ?? 0;
|
|
72
|
+
var wearSlotOf = (key) => entry(key).slot;
|
|
73
|
+
function wearKeyOf(itemId) {
|
|
74
|
+
if (!itemId?.startsWith(PREFIX))
|
|
75
|
+
return null;
|
|
76
|
+
const key = itemId.slice(PREFIX.length);
|
|
77
|
+
return isWearKey(key) ? key : null;
|
|
78
|
+
}
|
|
79
|
+
var wearItemId = (key) => `${PREFIX}${key}`;
|
|
80
|
+
function wearKeysOf(itemIds) {
|
|
81
|
+
const keys = new Set;
|
|
82
|
+
for (const id of itemIds) {
|
|
83
|
+
const key = wearKeyOf(id);
|
|
84
|
+
if (key)
|
|
85
|
+
keys.add(key);
|
|
86
|
+
}
|
|
87
|
+
return WEAR_KEYS.filter((key) => keys.has(key));
|
|
88
|
+
}
|
|
89
|
+
function wearableItems() {
|
|
90
|
+
return WEAR_KEYS.map((key) => ({
|
|
91
|
+
id: wearItemId(key),
|
|
92
|
+
slot: entry(key).slot,
|
|
93
|
+
name: entry(key).name,
|
|
94
|
+
rarity: entry(key).rarity,
|
|
95
|
+
sigmaPrice: entry(key).sigmaPrice,
|
|
96
|
+
assetConfig: { wear: key }
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
function wearView(key) {
|
|
100
|
+
return key ? entry(key).view ?? -0.3 : -0.3;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { WEARABLES, WEAR_KEYS, isWearKey, isHairKey, hairVolume, wearSlotOf, wearKeyOf, wearItemId, wearKeysOf, wearableItems, wearView };
|