@plupin/character 0.3.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.
@@ -1,28 +1,28 @@
1
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:
2
+ * High-resolution anime faces for Plup (`anime` cute/pretty and `ikemen` cool/handsome), drawn as
3
+ * crisp vector layers on a 512 x 256 face decal wrapped onto the front of the head.
5
4
  *
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.
5
+ * - `anime` (Cute / Pretty): softly proportioned jewel eyes with curved velvety upper lashes,
6
+ * delicate multi-lash flicks, double eyelid crease (futae), luminous lower iris crescent,
7
+ * triple catchlights + star micro-glint, dainty nose dot, soft airbrushed cheek glow & lip tint.
8
+ * - `ikemen` (Cool / Handsome): sleeker horizontal almond eyes (`tsurime`), sharp sculpted brows
9
+ * set closer to the lid, refined dark upper lash line, intense crisp iris with angular highlights,
10
+ * subtle nose-bridge shadow, confident smirk/smile, and clean subtle shading.
12
11
  *
13
- * Pure canvas drawing, no three.js: `plup3d.ts` puts the canvas on the body.
12
+ * Pure canvas drawing, no three.js: `plup3d.ts` puts the canvas on the head.
14
13
  */
15
14
  export declare const ANIME_FACE_SIZE: {
16
15
  readonly width: 512;
17
16
  readonly height: 256;
18
17
  };
19
- /** Where the decal sits on the body's UV sphere (see `plup3d.ts`): a band round the front. */
18
+ /** Where the decal sits on the head/body UV sphere: slightly lower on the front so bangs have lush forehead room. */
20
19
  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;
20
+ readonly u0: 0.1;
21
+ readonly u1: 0.4;
22
+ readonly v0: 0.27;
23
+ readonly v1: 0.61;
25
24
  };
25
+ export type AnimeFaceStyle = "anime" | "ikemen";
26
26
  type Eyes = "open" | "closed" | "happy" | "wide" | "sad" | "half" | "angry" | "stars" | "dead" | "wink" | "cry";
27
27
  type Mouth = "smile" | "open" | "o" | "frown" | "smirk" | "cat" | "flat" | "yell" | "tongue" | "grin";
28
28
  type Brows = "calm" | "up" | "angry" | "sad" | "none";
@@ -37,6 +37,6 @@ interface FaceParts {
37
37
  export declare function animeFaceParts(face: string): FaceParts;
38
38
  /** How far down the face canvas the eyes sit, for drawing it over a flat icon. */
39
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;
40
+ /** Draw an anime (`anime` cute/pretty or `ikemen` cool/handsome) face on a canvas of `ANIME_FACE_SIZE`. */
41
+ export declare function drawAnimeFace(ctx: CanvasRenderingContext2D, face: string, iris?: string, style?: AnimeFaceStyle): void;
42
42
  export {};
@@ -4,7 +4,7 @@ import {
4
4
  ANIME_FACE_UV,
5
5
  animeFaceParts,
6
6
  drawAnimeFace
7
- } from "./chunk-09c5tps4.js";
7
+ } from "./chunk-ewkkvpte.js";
8
8
  export {
9
9
  drawAnimeFace,
10
10
  animeFaceParts,
package/dist/blob.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import { SphereGeometry } from "three";
2
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.
3
+ * Plup's body:
4
+ * 1. Classic Plup (`figure === 0`): one round blob, bottom-heavy (a soft triangle), resting on a
5
+ * flat seat (ADR 0024).
6
+ * 2. Stylized Anime / Roblox Figure (`figure > 0`): sleek anime oval head with soft chin + slender
7
+ * neck + smooth sculpted torso (rounded feminine bust, tiny hourglass waist, graceful hips flowing
8
+ * seamlessly into shapely thighs, or broad muscular V-taper with sloped traps & pecs).
6
9
  */
7
10
  export declare const BLOB_RADIUS: {
8
11
  readonly x: 0.6;
@@ -11,22 +14,57 @@ export declare const BLOB_RADIUS: {
11
14
  };
12
15
  /** The blob's height with the seat flattened: feet on y = 0. */
13
16
  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
17
  export interface Silhouette {
21
18
  shoulders: number;
22
19
  waist: number;
23
20
  hips: number;
21
+ bust?: number;
22
+ muscle?: number;
23
+ figure?: number;
24
24
  }
25
25
  export declare const ROUND: Silhouette;
26
- /** The radius multiplier at a height on the unit sphere (-1 bottom, 1 top). */
26
+ /** The radius multiplier at a height on the classic round unit sphere (-1 bottom, 1 top). */
27
27
  export declare function silhouetteAt(unitY: number, silhouette?: Silhouette): number;
28
28
  /** How far the seat was raised so the feet stand on y = 0. */
29
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. */
30
+ /** The classic body's half-width across (x) at a height above the feet, for this silhouette. */
31
31
  export declare function blobRadiusAt(y: number, silhouette?: Silhouette): number;
32
32
  export declare function buildBlobGeometry(silhouette?: Silhouette): SphereGeometry;
33
+ export declare const FIGURE_TORSO_MIN_Y = 0.04;
34
+ export declare const FIGURE_TORSO_MAX_Y = 0.84;
35
+ export declare const FIGURE_TORSO_CENTER_Y: number;
36
+ export declare const FIGURE_TORSO_HALF_H: number;
37
+ export declare const FIGURE_HEAD_BASE_SCALE = 0.46;
38
+ export declare const FIGURE_NECK_TOP_Y = 0.8;
39
+ export declare const FIGURE_SHOULDER_Y = 0.64;
40
+ export declare const FIGURE_HIP_Y = 0.17;
41
+ /** Head scale and origin Y for a given `headSize` knob (0.55..1.25). */
42
+ export declare function figureHeadMetrics(headSize?: number): {
43
+ scale: number;
44
+ originY: number;
45
+ centerY: number;
46
+ };
47
+ /**
48
+ * Exact (x, z) point on the stylized torso surface at height `y` and azimuth `phi` (0 = front +Z,
49
+ * +pi/2 = +X left, pi = back -Z). Smooth anatomical curves:
50
+ * - Graceful neck & sloped traps (`u > 0.65`)
51
+ * - Rounded twin feminine bust domes (circular spherical profile, NEVER a sharp triangle!)
52
+ * - Clean pinched hourglass waist (`waist`)
53
+ * - Smooth long hip curve flowing seamlessly into full upper thighs (NO mushroom shelf!)
54
+ * - Broad V-taper chest/pecs & lats for muscular builds
55
+ */
56
+ export declare function figureTorsoPoint(y: number, phi: number, silhouette?: Silhouette): {
57
+ x: number;
58
+ z: number;
59
+ };
60
+ /** Average horizontal half-width of the stylized torso at height `y`. */
61
+ export declare function figureTorsoRadiusAt(y: number, silhouette?: Silhouette, phi?: number): number;
62
+ /**
63
+ * Cute/handsome anime oval head in local head space: slightly taller than wide (`0.54 x 0.59 x 0.54`)
64
+ * with soft cheeks and a gentle delicate chin taper — NEVER a squished wide pancake!
65
+ */
66
+ export declare function buildFigureHeadGeometry(): SphereGeometry;
67
+ /** Head radius at local `y` matching `buildFigureHeadGeometry` so anime hair wraps the oval head seamlessly! */
68
+ export declare function figureHeadRadiusAt(y: number): number;
69
+ /** Sculpted anatomical torso mesh for `figure > 0`, driven by `figureTorsoPoint`. */
70
+ export declare function buildFigureTorsoGeometry(silhouette?: Silhouette): SphereGeometry;
package/dist/blob.js CHANGED
@@ -2,16 +2,44 @@ import {
2
2
  BLOB_HEIGHT,
3
3
  BLOB_RADIUS,
4
4
  BLOB_SEAT,
5
+ FIGURE_HEAD_BASE_SCALE,
6
+ FIGURE_HIP_Y,
7
+ FIGURE_NECK_TOP_Y,
8
+ FIGURE_SHOULDER_Y,
9
+ FIGURE_TORSO_CENTER_Y,
10
+ FIGURE_TORSO_HALF_H,
11
+ FIGURE_TORSO_MAX_Y,
12
+ FIGURE_TORSO_MIN_Y,
5
13
  ROUND,
6
14
  blobRadiusAt,
7
15
  buildBlobGeometry,
16
+ buildFigureHeadGeometry,
17
+ buildFigureTorsoGeometry,
18
+ figureHeadMetrics,
19
+ figureHeadRadiusAt,
20
+ figureTorsoPoint,
21
+ figureTorsoRadiusAt,
8
22
  silhouetteAt
9
- } from "./chunk-dpb0rnw9.js";
23
+ } from "./chunk-vy9w8as2.js";
10
24
  export {
11
25
  silhouetteAt,
26
+ figureTorsoRadiusAt,
27
+ figureTorsoPoint,
28
+ figureHeadRadiusAt,
29
+ figureHeadMetrics,
30
+ buildFigureTorsoGeometry,
31
+ buildFigureHeadGeometry,
12
32
  buildBlobGeometry,
13
33
  blobRadiusAt,
14
34
  ROUND,
35
+ FIGURE_TORSO_MIN_Y,
36
+ FIGURE_TORSO_MAX_Y,
37
+ FIGURE_TORSO_HALF_H,
38
+ FIGURE_TORSO_CENTER_Y,
39
+ FIGURE_SHOULDER_Y,
40
+ FIGURE_NECK_TOP_Y,
41
+ FIGURE_HIP_Y,
42
+ FIGURE_HEAD_BASE_SCALE,
15
43
  BLOB_SEAT,
16
44
  BLOB_RADIUS,
17
45
  BLOB_HEIGHT
@@ -1,66 +1,129 @@
1
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.
2
+ * Bodies a player starts from, then tunes with the sliders: classic round Plup shapes (`figure: 0`)
3
+ * and stylized anime/Roblox-proportioned figures (`figure: 1`) with a sleek customizable head,
4
+ * slender neck, and prominent sculpted chest/bust, tiny waist, wide curvy hips, or broad muscular
5
+ * V-taper torso and arms. Data only, so the app, the games and the films offer the same list.
5
6
  */
6
7
  export declare const BODY_PRESETS: {
7
8
  readonly round: {
8
9
  readonly name: "Round";
9
10
  readonly shape: "plup";
10
- readonly body: {};
11
+ readonly body: {
12
+ readonly figure: 0;
13
+ readonly headSize: 1;
14
+ };
11
15
  };
12
- readonly "tall-slim": {
13
- readonly name: "Tall & Slim";
14
- readonly shape: "tall";
16
+ readonly curvy: {
17
+ readonly name: "Curvy";
18
+ readonly shape: "plup";
15
19
  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;
20
+ readonly figure: 1;
21
+ readonly headSize: 0.78;
22
+ readonly shoulders: 0.86;
23
+ readonly bust: 0.9;
24
+ readonly waist: 0.54;
25
+ readonly hips: 1.4;
26
+ readonly legLength: 2.35;
27
+ readonly armLength: 1.35;
28
+ readonly muscle: 0.82;
22
29
  };
23
30
  };
24
- readonly athletic: {
25
- readonly name: "Athletic";
26
- readonly shape: "tall";
31
+ readonly glam: {
32
+ readonly name: "Hourglass";
33
+ readonly shape: "plup";
27
34
  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;
35
+ readonly figure: 1;
36
+ readonly headSize: 0.74;
37
+ readonly shoulders: 0.84;
38
+ readonly bust: 1.32;
39
+ readonly waist: 0.48;
40
+ readonly hips: 1.54;
41
+ readonly legLength: 2.55;
42
+ readonly armLength: 1.38;
43
+ readonly muscle: 0.8;
44
+ };
45
+ };
46
+ readonly ikemen: {
47
+ readonly name: "Ikemen";
48
+ readonly shape: "plup";
49
+ readonly body: {
50
+ readonly figure: 1;
51
+ readonly headSize: 0.72;
52
+ readonly shoulders: 1.28;
53
+ readonly bust: 0;
54
+ readonly waist: 0.74;
55
+ readonly hips: 0.92;
56
+ readonly legLength: 2.6;
57
+ readonly armLength: 1.48;
58
+ readonly muscle: 1.22;
34
59
  };
35
60
  };
36
61
  readonly muscular: {
37
62
  readonly name: "Muscular";
38
- readonly shape: "tall";
63
+ readonly shape: "plup";
39
64
  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;
65
+ readonly figure: 1;
66
+ readonly headSize: 0.7;
67
+ readonly shoulders: 1.56;
68
+ readonly bust: 0;
69
+ readonly waist: 0.72;
70
+ readonly hips: 0.96;
71
+ readonly legLength: 2.25;
72
+ readonly armLength: 1.52;
73
+ readonly muscle: 2.15;
46
74
  };
47
75
  };
48
- readonly curvy: {
49
- readonly name: "Curvy";
50
- readonly shape: "tall";
76
+ readonly "tall-slim": {
77
+ readonly name: "Tall & Slim";
78
+ readonly shape: "plup";
51
79
  readonly body: {
80
+ readonly figure: 1;
81
+ readonly headSize: 0.76;
52
82
  readonly shoulders: 0.9;
83
+ readonly bust: 0.28;
53
84
  readonly waist: 0.66;
54
- readonly hips: 1.32;
55
- readonly legLength: 2.4;
56
- readonly armLength: 1.3;
57
- readonly muscle: 0.85;
85
+ readonly hips: 0.98;
86
+ readonly legLength: 2.5;
87
+ readonly armLength: 1.38;
88
+ readonly muscle: 0.8;
89
+ };
90
+ };
91
+ readonly athletic: {
92
+ readonly name: "Athletic";
93
+ readonly shape: "plup";
94
+ readonly body: {
95
+ readonly figure: 1;
96
+ readonly headSize: 0.75;
97
+ readonly shoulders: 1.32;
98
+ readonly bust: 0.12;
99
+ readonly waist: 0.74;
100
+ readonly hips: 1;
101
+ readonly legLength: 2.3;
102
+ readonly armLength: 1.44;
103
+ readonly muscle: 1.55;
104
+ };
105
+ };
106
+ readonly chibi: {
107
+ readonly name: "Chibi";
108
+ readonly shape: "plup";
109
+ readonly body: {
110
+ readonly figure: 1;
111
+ readonly headSize: 1.16;
112
+ readonly shoulders: 0.78;
113
+ readonly bust: 0.15;
114
+ readonly waist: 0.84;
115
+ readonly hips: 1.06;
116
+ readonly legLength: 1.25;
117
+ readonly armLength: 0.92;
118
+ readonly muscle: 0.82;
58
119
  };
59
120
  };
60
121
  readonly chubby: {
61
122
  readonly name: "Chubby";
62
123
  readonly shape: "wide";
63
124
  readonly body: {
125
+ readonly figure: 0;
126
+ readonly headSize: 1;
64
127
  readonly shoulders: 1;
65
128
  readonly waist: 1.15;
66
129
  readonly hips: 1.25;
@@ -72,12 +135,17 @@ export declare const BODY_PRESETS: {
72
135
  readonly tiny: {
73
136
  readonly name: "Tiny";
74
137
  readonly shape: "mini";
75
- readonly body: {};
138
+ readonly body: {
139
+ readonly figure: 0;
140
+ readonly headSize: 1;
141
+ };
76
142
  };
77
143
  readonly bean: {
78
144
  readonly name: "Bean";
79
145
  readonly shape: "bean";
80
146
  readonly body: {
147
+ readonly figure: 0;
148
+ readonly headSize: 1;
81
149
  readonly legLength: 1.3;
82
150
  };
83
151
  };
package/dist/canvas.js CHANGED
@@ -6,14 +6,14 @@ import {
6
6
  clampBodyScale,
7
7
  nativePartOf,
8
8
  scaleBone
9
- } from "./chunk-sa2r1cxz.js";
9
+ } from "./chunk-ew73g2v7.js";
10
10
  import {
11
11
  RIGS,
12
12
  clipLift,
13
13
  mergePoses,
14
14
  resolvePose,
15
15
  sampleClip
16
- } from "./chunk-g1c0wdcj.js";
16
+ } from "./chunk-7ry0n8cw.js";
17
17
  import {
18
18
  FACE_STAMP_PALETTE,
19
19
  NAMED_FACES,
@@ -34,6 +34,25 @@ var mix = (a, b, t) => {
34
34
  };
35
35
  var ORDER = ["LeftLeg", "RightLeg", "Body", "LeftArm", "RightArm"];
36
36
  var scratch = null;
37
+ var MAX_FACE_CACHE = 64;
38
+ var faceCache = new Map;
39
+ function cachedFaceCanvas(face, size) {
40
+ const key = `${face}:${size}`;
41
+ const hit = faceCache.get(key);
42
+ if (hit) {
43
+ faceCache.delete(key);
44
+ faceCache.set(key, hit);
45
+ return hit;
46
+ }
47
+ const canvas = faceCanvas(face, size);
48
+ if (faceCache.size >= MAX_FACE_CACHE) {
49
+ const oldest = faceCache.keys().next().value;
50
+ if (oldest !== undefined)
51
+ faceCache.delete(oldest);
52
+ }
53
+ faceCache.set(key, canvas);
54
+ return canvas;
55
+ }
37
56
  function roundRect(ctx, x, y, w, h, r) {
38
57
  const radius = Math.min(r, w / 2, h / 2);
39
58
  ctx.beginPath();
@@ -81,7 +100,7 @@ function paintBone(ctx, op, color, ink, face) {
81
100
  bodyPath(ctx, x, y, w, h);
82
101
  ctx.strokeStyle = ink;
83
102
  ctx.stroke();
84
- const stamp = faceCanvas(face, 32);
103
+ const stamp = cachedFaceCanvas(face, 32);
85
104
  const faceW = w * 0.82;
86
105
  ctx.imageSmoothingEnabled = false;
87
106
  ctx.drawImage(stamp, 0, 0, 32, 16, x + (w - faceW) / 2, y + h * 0.2, faceW, faceW / 2);