@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/plup3d.d.ts
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
|
-
import { Group, type Object3D } from "three";
|
|
1
|
+
import { Group, type Object3D, ShaderMaterial, type Texture } from "three";
|
|
2
2
|
import { type Emote } from "./emote";
|
|
3
3
|
import { type NamedFace } from "./faces";
|
|
4
4
|
import { type ClipRef, type Pose } from "./pose";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly x: 1.2;
|
|
17
|
-
readonly y: 0.85;
|
|
18
|
-
};
|
|
19
|
-
readonly mini: {
|
|
20
|
-
readonly x: 0.82;
|
|
21
|
-
readonly y: 0.82;
|
|
22
|
-
};
|
|
23
|
-
readonly bean: {
|
|
24
|
-
readonly x: 0.72;
|
|
25
|
-
readonly y: 1.35;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export type BodyShapeId = keyof typeof BODY_SHAPES;
|
|
29
|
-
/** The face types a player draws with, and the expressions they show (the stamp is 8 x 4). */
|
|
30
|
-
export type FaceType = "dot" | "sparkle" | "sleepy" | "derp";
|
|
5
|
+
import { type RagdollMode } from "./ragdoll";
|
|
6
|
+
import { BODY_SHAPES, type BodyShapeId } from "./skin-map";
|
|
7
|
+
import { type BodyScale, type PlupBody } from "./skin-native";
|
|
8
|
+
import { type WearKey } from "./wearables";
|
|
9
|
+
/**
|
|
10
|
+
* Plup in three.js: supports both the classic round toon mascot (`figure = 0`) and the stylized
|
|
11
|
+
* anime/Roblox-proportioned figure (`figure = 1`) with a sleek customizable head (`headSize`),
|
|
12
|
+
* slender neck, and sculpted directional torso (bust/chest, pinched waist, curvy hips, or broad
|
|
13
|
+
* V-taper muscular shoulders & arms). Both modes share the same animation clips, wearables, hair,
|
|
14
|
+
* anime/ikemen faces, and optional active ragdoll.
|
|
15
|
+
*/
|
|
31
16
|
export type Expression = "idle" | "blink" | "happy" | "surprised" | "sad" | "wee";
|
|
32
17
|
export type PlupFace = NamedFace | Expression;
|
|
33
|
-
|
|
18
|
+
export type { BodyShapeId, FaceType } from "./skin-map";
|
|
19
|
+
export { BODY_SHAPES };
|
|
20
|
+
export interface ToonOptions {
|
|
21
|
+
map?: Texture;
|
|
22
|
+
color?: string;
|
|
23
|
+
double?: boolean;
|
|
24
|
+
back?: string;
|
|
25
|
+
repeat?: readonly [number, number];
|
|
26
|
+
sheen?: number;
|
|
27
|
+
anime?: {
|
|
28
|
+
center: readonly [number, number, number];
|
|
29
|
+
ring?: number;
|
|
30
|
+
tip?: string;
|
|
31
|
+
inner?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare function toon(options: ToonOptions): ShaderMaterial;
|
|
34
35
|
export interface PlupSkin {
|
|
35
36
|
body: readonly string[];
|
|
36
37
|
faceType?: string;
|
|
37
38
|
}
|
|
38
39
|
export interface PlupOptions {
|
|
39
|
-
/** The body colour. Default Plup blue. */
|
|
40
40
|
color?: string;
|
|
41
|
-
/** A named face or an expression. Default `smug`. */
|
|
42
41
|
face?: PlupFace;
|
|
43
|
-
/** The player's own pixel skin (the platform's look). Without one the default Plup is drawn. */
|
|
44
42
|
skin?: PlupSkin;
|
|
45
|
-
/** The
|
|
43
|
+
/** The face type (`dot`, `sparkle`, `sleepy`, `derp`, `anime`, `ikemen`). Default `dot`. */
|
|
44
|
+
faceType?: string;
|
|
45
|
+
/** The iris colour of `anime` or `ikemen` eyes. */
|
|
46
|
+
eyeColor?: string;
|
|
47
|
+
/** Optional hair colour override (derives matching tip/inner shades automatically). */
|
|
48
|
+
hairColor?: string;
|
|
46
49
|
shape?: BodyShapeId;
|
|
47
|
-
|
|
50
|
+
bodyScale?: Partial<BodyScale> | null;
|
|
48
51
|
shadow?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* A body of a different shape. The 48 x 24 pixel map, the blob and the stub limbs are only the
|
|
51
|
-
* default Plup: pass any scene object (a glTF scene, a hand-built mesh) and it is posed instead.
|
|
52
|
-
* Nodes named `armL`, `armR`, `legL`, `legR` follow the clips; a model with none still gets the
|
|
53
|
-
* clip's lift and sway, so any animation plays on any shape.
|
|
54
|
-
*/
|
|
55
52
|
model?: Object3D;
|
|
53
|
+
body?: Partial<PlupBody> | null;
|
|
54
|
+
wear?: readonly WearKey[];
|
|
55
|
+
ragdoll?: RagdollMode;
|
|
56
56
|
}
|
|
57
57
|
export interface PlupHandle {
|
|
58
|
-
/** Add this to a scene. Feet at y = 0, facing +z, about 1.1 units tall. */
|
|
59
58
|
object: Group;
|
|
60
|
-
/** Set the current clip (a name or keyframes). Call `update` every frame. */
|
|
61
59
|
play: (clip: ClipRef) => void;
|
|
62
|
-
/** Play an emote by name and pull its face. Returns it so the game can show its glyph. */
|
|
63
60
|
emote: (name: string, custom?: Emote) => Emote | undefined;
|
|
64
|
-
/** Hold a joint on top of the clip, e.g. `{ armR: { x: -1.2 } }`. Pass `{}` to let go. */
|
|
65
61
|
pose: (pose: Pose) => void;
|
|
66
|
-
/** A joint to attach things to (`armR`, `armL`, `legR`, `legL`) or the lifted body (`body`). */
|
|
67
62
|
bone: (name: string) => Object3D | undefined;
|
|
68
63
|
setFace: (face: PlupFace) => void;
|
|
64
|
+
ragdoll: (mode: RagdollMode) => void;
|
|
65
|
+
push: (x: number, y: number, z: number) => void;
|
|
66
|
+
isDown: () => boolean;
|
|
69
67
|
setColor: (color: string) => void;
|
|
68
|
+
setWear: (wear: readonly WearKey[]) => void;
|
|
70
69
|
update: (deltaSeconds: number) => void;
|
|
71
70
|
dispose: () => void;
|
|
72
71
|
}
|
package/dist/png.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The PNG reader the listing kinds
|
|
2
|
+
* The PNG reader and writer the listing kinds and the platform's own body models need.
|
|
3
3
|
*
|
|
4
4
|
* A body variant is a sprite sheet the platform clips to its part rects, so the server has to do
|
|
5
5
|
* two things the browser would otherwise do for it: know the sheet's dimensions *before* it trusts
|
|
6
6
|
* them, and be able to draw the art into the stored preview the moderator decides on. Both mean
|
|
7
|
-
* reading the file's bytes on the Worker, where there is no canvas — hence this module.
|
|
7
|
+
* reading the file's bytes on the Worker, where there is no canvas — hence this module. The writer
|
|
8
|
+
* is its mirror image: the seeded platform bodies are painted from `platform-body.ts` as pixels, so
|
|
9
|
+
* a PNG has to be produced without a canvas too, and a fixture can then be the same bytes the
|
|
10
|
+
* migration stores.
|
|
8
11
|
*
|
|
9
12
|
* It is deliberately strict about the format the caps describe (`NATIVE_SHEET_CAPS`,
|
|
10
13
|
* `LISTING_ASSET_CAPS`): 8-bit truecolour with or without 8-bit alpha, non-interlaced, no palette.
|
|
11
14
|
* A palette PNG or a 16-bit one is a different picture than the one the moderator approved once a
|
|
12
15
|
* second decoder is involved, so it is refused instead of converted.
|
|
13
16
|
*
|
|
14
|
-
* Inflate is `fflate`'s synchronous
|
|
15
|
-
* that four surfaces already call without awaiting, and a
|
|
16
|
-
* async and every caller with it.
|
|
17
|
+
* Inflate is `fflate`'s synchronous streaming `Unzlib` fed in bounded chunks: the renderer is a
|
|
18
|
+
* pure function (`renderListingPreview`) that four surfaces already call without awaiting, and a
|
|
19
|
+
* `DecompressionStream` would have made it async and every caller with it. Streaming chunk by chunk
|
|
20
|
+
* lets us abort immediately if a crafted IDAT expands beyond the image's scanlines.
|
|
17
21
|
*
|
|
18
22
|
* It checks structure and pixels, not chunk CRCs: zlib's own Adler-32 rejects a damaged IDAT, and
|
|
19
23
|
* the one thing a checksum would add here — "this file was edited after it was written" — is not a
|
|
@@ -53,9 +57,23 @@ export declare function decodePng(bytes: Uint8Array): {
|
|
|
53
57
|
ok: false;
|
|
54
58
|
reason: PngProblem;
|
|
55
59
|
};
|
|
60
|
+
/** Base64 without a DOM: the manifest's data URL is built on the Worker as well as in a test. */
|
|
61
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
56
62
|
/**
|
|
57
63
|
* Strict base64, because the manifest is a string a reader may have edited: `atob` accepts
|
|
58
64
|
* whitespace and silently ignores what it does not understand, and two spellings of one image would
|
|
59
65
|
* then hash differently. Anything that is not `A-Za-z0-9+/` padded to a multiple of four is refused.
|
|
60
66
|
*/
|
|
61
67
|
export declare function decodeBase64(value: string): Uint8Array<ArrayBuffer> | null;
|
|
68
|
+
/**
|
|
69
|
+
* The mirror of `decodePng`: an RGBA raster as PNG-24 with an alpha channel, 8 bits per channel,
|
|
70
|
+
* filter 0. That is exactly the format `NATIVE_SHEET_CAPS` describes, so the bytes a platform body
|
|
71
|
+
* model is seeded with are the bytes a creator could have uploaded — the same reader, the same
|
|
72
|
+
* clip-to-rect renderer, the same cap.
|
|
73
|
+
*
|
|
74
|
+
* `level` exists for the one caller that wants the smallest file it can get (a manifest stored in a
|
|
75
|
+
* SQL migration); the default matches `fflate`'s own.
|
|
76
|
+
*/
|
|
77
|
+
export declare function encodePng(image: PngImage, options?: {
|
|
78
|
+
level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
79
|
+
}): Uint8Array<ArrayBuffer>;
|
package/dist/pose.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AuthoredClipName } from "./clips";
|
|
1
2
|
import { type CanonicalBone, type RigId } from "./rig";
|
|
2
3
|
/** Euler rotation in radians, applied at the joint. */
|
|
3
4
|
export interface Rotation {
|
|
@@ -7,7 +8,12 @@ export interface Rotation {
|
|
|
7
8
|
}
|
|
8
9
|
/** Keys are canonical names (armL) or a rig's own bone names (LeftLowerArm). */
|
|
9
10
|
export type Pose = Readonly<Record<string, Rotation>>;
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Every clip the rig has by name. The first six are procedural loops; the rest are the authored
|
|
13
|
+
* keyframe library in `clips.ts`, which is why a game and a creator emote can name a real motion
|
|
14
|
+
* (`sneak`, `topple`) instead of borrowing `idle`.
|
|
15
|
+
*/
|
|
16
|
+
export type ClipName = "idle" | "walk" | "run" | "jump" | "wave" | "dance" | AuthoredClipName;
|
|
11
17
|
type Clip = (t: number) => Partial<Record<CanonicalBone, Rotation>> & {
|
|
12
18
|
lift?: number;
|
|
13
19
|
};
|
package/dist/pose.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BodyScale } from "./skin-native";
|
|
2
|
+
/**
|
|
3
|
+
* How a Plup's size changes what its motion has to do. A clip is authored on the normal body: angles for the
|
|
4
|
+
* arms and legs, a lift for a jump. A big, wide, tall or small body keeps those angles but needs three things
|
|
5
|
+
* adjusted so the same clip still reads as the same move (ADR 0024):
|
|
6
|
+
*
|
|
7
|
+
* - the arms start further out on a wide belly, and swing out a little more so they do not sink into it;
|
|
8
|
+
* - a jump's height scales with the stature, and a heavier (wider) body jumps a bit lower and squashes more;
|
|
9
|
+
* - limbs get thicker or thinner with their own width, without changing the clip.
|
|
10
|
+
*
|
|
11
|
+
* Pure numbers, no three, so the rules are tested and every surface (app, games, films) reads the same ones.
|
|
12
|
+
*/
|
|
13
|
+
export interface PlupProportions {
|
|
14
|
+
/** The whole figure's scale (stature). */
|
|
15
|
+
stature: number;
|
|
16
|
+
/** Girth of the belly across and front to back, shape included. 1 is the normal Plup. */
|
|
17
|
+
girth: number;
|
|
18
|
+
/** Arm and leg thickness factors, left then right. */
|
|
19
|
+
armWidth: readonly [number, number];
|
|
20
|
+
legWidth: readonly [number, number];
|
|
21
|
+
/** Radians the arms swing outward on top of the clip, so a wide belly is cleared. */
|
|
22
|
+
armClear: readonly [number, number];
|
|
23
|
+
/** Multiplier on a clip's lift: the jump of this body. */
|
|
24
|
+
lift: number;
|
|
25
|
+
/** Multiplier on the breathing squash: a heavier body moves more. */
|
|
26
|
+
squash: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function plupProportions(shape: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
}, scale?: Partial<BodyScale> | null): PlupProportions;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An optional floppy body, the way Human: Fall Flat and Gang Beasts feel: an **active ragdoll**. The clip
|
|
3
|
+
* still says where every joint should be, but each joint is pulled there by a damped spring instead of
|
|
4
|
+
* being set, so limbs lag, overshoot and wobble when the body speeds up, stops or is pushed. Push hard
|
|
5
|
+
* enough (or call `limp`) and the springs let go: the body tips over under gravity, lands, bounces and lies
|
|
6
|
+
* there with its limbs flopped out until it gets up again.
|
|
7
|
+
*
|
|
8
|
+
* No physics engine: per-joint springs and a position-based fall (Verlet style), cheap enough for a crowd.
|
|
9
|
+
* Sources and the rules taken from them are in docs/product/research-anime-hair-and-bodies.md.
|
|
10
|
+
*
|
|
11
|
+
* Angles are radians in the body's own frame: `x` tips forward (+z), `z` rolls sideways.
|
|
12
|
+
*/
|
|
13
|
+
export type RagdollMode = "off" | "wobbly" | "limp";
|
|
14
|
+
export declare const RAGDOLL_JOINTS: readonly ["armL", "armR", "legL", "legR"];
|
|
15
|
+
export type RagdollJoint = (typeof RAGDOLL_JOINTS)[number];
|
|
16
|
+
export interface Tilt {
|
|
17
|
+
x: number;
|
|
18
|
+
z: number;
|
|
19
|
+
}
|
|
20
|
+
/** What the clip wants this frame, and how the game moved the body. */
|
|
21
|
+
export interface RagdollInput {
|
|
22
|
+
joints: Record<RagdollJoint, Tilt>;
|
|
23
|
+
body: Tilt;
|
|
24
|
+
lift: number;
|
|
25
|
+
/** The body's velocity in its own frame (x sideways, z forward), from how the game moved it. */
|
|
26
|
+
velocity: {
|
|
27
|
+
x: number;
|
|
28
|
+
z: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface RagdollOutput {
|
|
32
|
+
joints: Record<RagdollJoint, Tilt>;
|
|
33
|
+
body: Tilt;
|
|
34
|
+
lift: number;
|
|
35
|
+
/** How far the fall carried the body from where the game put it, in its own frame. */
|
|
36
|
+
offset: {
|
|
37
|
+
x: number;
|
|
38
|
+
z: number;
|
|
39
|
+
};
|
|
40
|
+
/** Lying on the ground (or on the way there). */
|
|
41
|
+
down: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface Ragdoll {
|
|
44
|
+
mode: () => RagdollMode;
|
|
45
|
+
set: (mode: RagdollMode) => void;
|
|
46
|
+
/** Shove the body: `x` sideways, `z` forward, `y` up, in its own frame (units per second). */
|
|
47
|
+
push: (x: number, y: number, z: number) => void;
|
|
48
|
+
step: (dt: number, input: RagdollInput) => RagdollOutput;
|
|
49
|
+
}
|
|
50
|
+
/** `radius`: how far the body's middle sits from its base, so it lies on the ground, not in it. */
|
|
51
|
+
export declare function createRagdoll(initial?: RagdollMode, radius?: number): Ragdoll;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many pixels Plup is drawn with, for every surface (ADR 0024). Plup is pixel art: the pixel grid
|
|
3
|
+
* must scale with Plup, not with the page. A fixed render scale gave a big Plup a fine grid and a small
|
|
4
|
+
* one a handful of coarse pixels, so a Plup in a header or a section slot lost its face. Here the
|
|
5
|
+
* render scale follows the size Plup is shown at, so Plup keeps about the same number of pixels from
|
|
6
|
+
* the landing hero down to a lobby rail, and never more than the screen has.
|
|
7
|
+
*/
|
|
8
|
+
/** Render pixels from Plup's feet to the top of its head, at any size on screen. */
|
|
9
|
+
export declare const PLUP_PIXELS = 120;
|
|
10
|
+
/**
|
|
11
|
+
* Device pixels per CSS pixel to render a Plup that is `plupCssHeight` CSS pixels tall with, so it is
|
|
12
|
+
* drawn with about `pixels` rows: chunky when it is big, the screen's full resolution when it is small.
|
|
13
|
+
*/
|
|
14
|
+
export declare function plupPixelRatio(plupCssHeight: number, devicePixelRatio: number, pixels?: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Draws pixel art onto a canvas of any size, the way the eye expects it: every source pixel becomes a
|
|
17
|
+
* whole block (nearest neighbour up to the next whole multiple), then that is filtered down to the
|
|
18
|
+
* target, so a source pixel never comes out one or two device pixels wide at random and a small
|
|
19
|
+
* headshot averages its pixels instead of dropping every other row (an eye of two rows lost one).
|
|
20
|
+
*/
|
|
21
|
+
export declare function drawPixelArt(context: CanvasRenderingContext2D, source: HTMLCanvasElement, width: number, height: number): void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The skin map, the face painter and the eyes: the one place that says how Plup's pixels are made, for the app,
|
|
3
|
+
* the games and the films (ADR 0024). Pure TypeScript, no DOM and no three.
|
|
4
|
+
*
|
|
5
|
+
* Character skins are pixel art, not geometry. A skin is a hand-drawable body map
|
|
6
|
+
* (48 x 24, equirectangular around the Character blob, column 24 faces the camera)
|
|
7
|
+
* plus a face type. The face is stamped onto the front of the body map per
|
|
8
|
+
* expression, so the same drawing renders on the 3D Character and in the editor.
|
|
9
|
+
* One character = one pixel.
|
|
10
|
+
*/
|
|
11
|
+
export declare const BODY_WIDTH = 48;
|
|
12
|
+
export declare const BODY_HEIGHT = 24;
|
|
13
|
+
/** Face stamp position on the body map (8 x 4, centred on the front). */
|
|
14
|
+
export declare const FACE_COLUMN = 20;
|
|
15
|
+
export declare const FACE_ROW = 9;
|
|
16
|
+
import { type NamedFace } from "./faces";
|
|
17
|
+
/** `anime` (cute) and `ikemen` (handsome) are drawn at high resolution on the 3D body (`anime-face.ts`); pixel-only surfaces fall back to sparkle. */
|
|
18
|
+
export declare const FACE_TYPES: readonly ["dot", "sparkle", "sleepy", "derp", "anime", "ikemen"];
|
|
19
|
+
export type FaceType = (typeof FACE_TYPES)[number];
|
|
20
|
+
export declare const isHighResFace: (faceType: string | undefined) => faceType is "anime" | "ikemen";
|
|
21
|
+
/**
|
|
22
|
+
* The six the face rule picks from, plus every named face of the content films (`@plupin/character`
|
|
23
|
+
* faces): an emote forces one of those through `expression`, and the rule never picks them itself.
|
|
24
|
+
*/
|
|
25
|
+
export declare const EXPRESSIONS: readonly ["idle", "blink", "happy", "surprised", "sad", "wee", ...("stars" | "dead" | "cry" | "smirk" | "yell" | "tongue" | "sparkle" | "shock" | "pain" | "rage" | "speechless" | "idea" | "smug" | "cool" | "serious" | "licik" | "tidur" | "teriak" | "ngomel")[]];
|
|
26
|
+
export type CharacterExpression = (typeof EXPRESSIONS)[number];
|
|
27
|
+
export declare function isNamedExpression(expression: CharacterExpression): expression is NamedFace;
|
|
28
|
+
export interface CharacterSkin {
|
|
29
|
+
/** BODY_HEIGHT rows of BODY_WIDTH palette keys. */
|
|
30
|
+
body: readonly string[];
|
|
31
|
+
face: FaceType;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Drawing palette. `B`, `L` and `D` follow the equipped outfit colour; every
|
|
35
|
+
* other key is a fixed colour the user can paint with.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SKIN_PALETTE: Readonly<Record<string, string>>;
|
|
38
|
+
/** Order of swatches in the editor. */
|
|
39
|
+
export declare const PAINT_KEYS: string[];
|
|
40
|
+
/** Colours used only by face stamps; never tinted. */
|
|
41
|
+
export declare const FACE_PALETTE: Readonly<Record<string, string>>;
|
|
42
|
+
type Rows2 = readonly [string, string];
|
|
43
|
+
interface FaceDefinition {
|
|
44
|
+
eyes: Record<"open" | "blink" | "happy" | "wide" | "sad", Rows2>;
|
|
45
|
+
mouth: Record<"idle" | "open" | "o" | "frown", Rows2>;
|
|
46
|
+
blush: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare const FACES: Readonly<Record<FaceType, FaceDefinition>>;
|
|
49
|
+
/** Face stamp (8 x 4) for a face type and expression; `.` is transparent. */
|
|
50
|
+
export declare function faceStamp(face: FaceType, expression: CharacterExpression): string[];
|
|
51
|
+
/** Body palette with the outfit colour applied to the `B`/`L`/`D` keys. */
|
|
52
|
+
export declare function bodyPalette(outfitColor?: string): Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Final colour of every body-map pixel: the drawing, with the face stamp for
|
|
55
|
+
* the expression painted over the front. Row-major, BODY_HEIGHT x BODY_WIDTH.
|
|
56
|
+
*/
|
|
57
|
+
export declare function composeSkin(skin: CharacterSkin, expression: CharacterExpression, outfitColor?: string,
|
|
58
|
+
/** Columns the eyes slide by. The mouth and blush never move (the eyes-only gaze rule). */
|
|
59
|
+
look?: number,
|
|
60
|
+
/**
|
|
61
|
+
* Rows the eyes slide by: -1 up. Down (+1) is clamped to 0 (Q9, owner decision 2026-10-21, PR #327), so no eye
|
|
62
|
+
* pixel lands on the mouth row. The mouth and blush never move.
|
|
63
|
+
*/
|
|
64
|
+
lookY?: number,
|
|
65
|
+
/** Off for the 3D body: the face is a decal on the front, not a stamp in the body texture. */
|
|
66
|
+
drawFace?: boolean,
|
|
67
|
+
/** 2 draws every face pixel as a 2x2 block, for the 3D body where the texture is stretched. */
|
|
68
|
+
faceScale?: number): string[][];
|
|
69
|
+
/** A blank body map filled with one key. */
|
|
70
|
+
export declare function blankBody(key?: string): string[];
|
|
71
|
+
/** Outfit colours used to show a crowd of buddies. */
|
|
72
|
+
export declare const BUDDY_TINTS: readonly ["#2f6fed", "#e2574c", "#3fae74", "#e6a23c", "#8a5ad8"];
|
|
73
|
+
/**
|
|
74
|
+
* Plup's own look, for every surface that shows Plup without a player's drawing: the landing, a guest in
|
|
75
|
+
* the lobby, headshots. The sparkle face (eyes with a catch-light, a resting smile) is the face the
|
|
76
|
+
* films and the landing use; the guest lobby wore the plain dot face, so one character read as two.
|
|
77
|
+
*/
|
|
78
|
+
export declare const DEFAULT_BUDDY_SKIN: CharacterSkin;
|
|
79
|
+
/** Clamp unknown or malformed stored drawings back to a valid map. */
|
|
80
|
+
export declare function sanitizeSkin(value: unknown): CharacterSkin;
|
|
81
|
+
/**
|
|
82
|
+
* A random character worth keeping: a colour, a face and one of a few patterns painted over the
|
|
83
|
+
* default body (none, a belly, stripes, spots), in a second colour that is not the body's own.
|
|
84
|
+
*/
|
|
85
|
+
export declare function randomSkin(): {
|
|
86
|
+
skin: CharacterSkin;
|
|
87
|
+
tint: string;
|
|
88
|
+
};
|
|
89
|
+
/** Texels per skin pixel when a skin is painted for display (body texture, headshot). */
|
|
90
|
+
export declare const SKIN_DETAIL = 4;
|
|
91
|
+
/**
|
|
92
|
+
* Which face key sits on which skin pixel, with the same placement rules as `composeSkin` (eyes follow
|
|
93
|
+
* the gaze, up only; mouth and blush never move). `painSkinDetailed` uses it to draw the face finer.
|
|
94
|
+
*/
|
|
95
|
+
export declare function faceKeys(skin: CharacterSkin, expression: CharacterExpression, look?: number, lookY?: number,
|
|
96
|
+
/** False leaves the eyes out: `paintEyesSmooth` draws them, so they can move between cells. */
|
|
97
|
+
withEyes?: boolean): Map<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* Paint a composed skin at `SKIN_DETAIL` texels per pixel. The body stays chunky pixel art; the face
|
|
100
|
+
* keeps its exact cells and size but is drawn finer, so a large character does not read as black bars
|
|
101
|
+
* and a red block: eyes are rounded with a light glint, the mouth is a thin rounded stroke, blush is a
|
|
102
|
+
* soft dash. `body` is the skin without the face (composeSkin with drawFace off), for what lies under it.
|
|
103
|
+
*/
|
|
104
|
+
export declare function paintSkinDetailed(context: CanvasRenderingContext2D, pixels: string[][], body: string[][], keys: Map<string, string>, from?: {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
w: number;
|
|
108
|
+
h: number;
|
|
109
|
+
}, soften?: (fill: string) => string): void;
|
|
110
|
+
/**
|
|
111
|
+
* The eyes, drawn on their own so they move smoothly. Pixel is how the character is drawn, not how it moves:
|
|
112
|
+
* the eyes keep their pixel-art cells and rounded shape, but they slide by a fraction of a cell (the canvas
|
|
113
|
+
* antialiases the edge) and a blink is the eye closing by `openness` (1 open, 0 shut), not one stamp swapped
|
|
114
|
+
* for another. Call after `paintSkinDetailed` with the face drawn without eyes (`faceKeys`' `withEyes` off).
|
|
115
|
+
*/
|
|
116
|
+
export declare function paintEyesSmooth(context: CanvasRenderingContext2D, skin: CharacterSkin, expression: CharacterExpression, offset: {
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
}, openness: number, from?: {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
w: number;
|
|
123
|
+
h: number;
|
|
124
|
+
}): void;
|
|
125
|
+
/** Bodies a character can wear. Same skeleton in each: only the blob's proportions change. */
|
|
126
|
+
export declare const BODY_SHAPES: {
|
|
127
|
+
readonly plup: {
|
|
128
|
+
readonly x: 1;
|
|
129
|
+
readonly y: 1;
|
|
130
|
+
};
|
|
131
|
+
readonly tall: {
|
|
132
|
+
readonly x: 0.88;
|
|
133
|
+
readonly y: 1.25;
|
|
134
|
+
};
|
|
135
|
+
readonly wide: {
|
|
136
|
+
readonly x: 1.2;
|
|
137
|
+
readonly y: 0.85;
|
|
138
|
+
};
|
|
139
|
+
readonly mini: {
|
|
140
|
+
readonly x: 0.82;
|
|
141
|
+
readonly y: 0.82;
|
|
142
|
+
};
|
|
143
|
+
readonly bean: {
|
|
144
|
+
readonly x: 0.72;
|
|
145
|
+
readonly y: 1.35;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
export type BodyShapeId = keyof typeof BODY_SHAPES;
|
|
149
|
+
/** Roblox-format clothing templates (585x559), as data URLs, painted onto Plup's own body. */
|
|
150
|
+
export type PlupClothing = {
|
|
151
|
+
shirt?: string;
|
|
152
|
+
pants?: string;
|
|
153
|
+
};
|
|
154
|
+
/** A stable colour for someone whose look we do not have: the same name always gets the same tint. */
|
|
155
|
+
export declare function tintForName(name: string): string | undefined;
|
|
156
|
+
export {};
|
package/dist/skin-map.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BODY_HEIGHT,
|
|
3
|
+
BODY_SHAPES,
|
|
4
|
+
BODY_WIDTH,
|
|
5
|
+
BUDDY_TINTS,
|
|
6
|
+
DEFAULT_BUDDY_SKIN,
|
|
7
|
+
EXPRESSIONS,
|
|
8
|
+
FACES,
|
|
9
|
+
FACE_COLUMN,
|
|
10
|
+
FACE_PALETTE,
|
|
11
|
+
FACE_ROW,
|
|
12
|
+
FACE_TYPES,
|
|
13
|
+
PAINT_KEYS,
|
|
14
|
+
SKIN_DETAIL,
|
|
15
|
+
SKIN_PALETTE,
|
|
16
|
+
blankBody,
|
|
17
|
+
bodyPalette,
|
|
18
|
+
composeSkin,
|
|
19
|
+
faceKeys,
|
|
20
|
+
faceStamp,
|
|
21
|
+
isHighResFace,
|
|
22
|
+
isNamedExpression,
|
|
23
|
+
paintEyesSmooth,
|
|
24
|
+
paintSkinDetailed,
|
|
25
|
+
randomSkin,
|
|
26
|
+
sanitizeSkin,
|
|
27
|
+
tintForName
|
|
28
|
+
} from "./chunk-nx2wbkfn.js";
|
|
29
|
+
import"./chunk-aa5nstet.js";
|
|
30
|
+
export {
|
|
31
|
+
tintForName,
|
|
32
|
+
sanitizeSkin,
|
|
33
|
+
randomSkin,
|
|
34
|
+
paintSkinDetailed,
|
|
35
|
+
paintEyesSmooth,
|
|
36
|
+
isNamedExpression,
|
|
37
|
+
isHighResFace,
|
|
38
|
+
faceStamp,
|
|
39
|
+
faceKeys,
|
|
40
|
+
composeSkin,
|
|
41
|
+
bodyPalette,
|
|
42
|
+
blankBody,
|
|
43
|
+
SKIN_PALETTE,
|
|
44
|
+
SKIN_DETAIL,
|
|
45
|
+
PAINT_KEYS,
|
|
46
|
+
FACE_TYPES,
|
|
47
|
+
FACE_ROW,
|
|
48
|
+
FACE_PALETTE,
|
|
49
|
+
FACE_COLUMN,
|
|
50
|
+
FACES,
|
|
51
|
+
EXPRESSIONS,
|
|
52
|
+
DEFAULT_BUDDY_SKIN,
|
|
53
|
+
BUDDY_TINTS,
|
|
54
|
+
BODY_WIDTH,
|
|
55
|
+
BODY_SHAPES,
|
|
56
|
+
BODY_HEIGHT
|
|
57
|
+
};
|
package/dist/skin-native.d.ts
CHANGED
|
@@ -74,23 +74,26 @@ export type SkinImage = object;
|
|
|
74
74
|
* bounded, not fixed, because a kid-sized ("bocil") and a tall character are the same rig at a
|
|
75
75
|
* different stature, and a muscular arm is the same bone with a wider box.
|
|
76
76
|
*
|
|
77
|
-
* - stature 0.5-1.
|
|
77
|
+
* - stature 0.5-1.5: the whole body, uniformly. 0.5 is "bocil" — half size, still the same
|
|
78
78
|
* creature — and it is the floor because at 32 px per stud the smallest screen a character is
|
|
79
79
|
* drawn on still gets one device pixel per native texel at 0.5; below it the 32 x 64 limb faces
|
|
80
|
-
* and the face stamp stop reading as art. 1.
|
|
81
|
-
*
|
|
80
|
+
* and the face stamp stop reading as art. 1.5 is the tall end of the usable range: the owner
|
|
81
|
+
* raised the ceiling from 1.15 to 1.5 when height became a property of the equipped body model
|
|
82
|
+
* (`platform-body.ts`) instead of a free slider, so the three platform bodies — bocil, normal and
|
|
83
|
+
* tall — span the whole clamp. Nothing collides differently: `canonicalFootprint` ignores this
|
|
84
|
+
* number, and `visualEnvelope` is what grows.
|
|
82
85
|
* - width 0.9-1.3: across the body only (x in the front view, z in the side view), so an arm can
|
|
83
86
|
* be 30% thicker without getting 30% longer. 0.9 is the thinnest silhouette that still covers the
|
|
84
87
|
* native face rect's edges; 1.3 is the widest a limb may be before it reads as a different part.
|
|
85
88
|
* - head 0.9-1.25: a big head is a style, and 1.25 is where it stops swallowing the torso.
|
|
86
89
|
*
|
|
87
|
-
* These are the numbers
|
|
88
|
-
* copied clamp is a second balance rule; there is one.
|
|
90
|
+
* These are the numbers every surface imports — the listing validator, the renderer, the sandbox's
|
|
91
|
+
* sliders and the seeded platform bodies. A copied clamp is a second balance rule; there is one.
|
|
89
92
|
*/
|
|
90
93
|
export declare const BODY_SCALE_LIMITS: {
|
|
91
94
|
readonly stature: {
|
|
92
95
|
readonly min: 0.5;
|
|
93
|
-
readonly max: 1.
|
|
96
|
+
readonly max: 1.5;
|
|
94
97
|
};
|
|
95
98
|
readonly width: {
|
|
96
99
|
readonly min: 0.9;
|
|
@@ -101,6 +104,70 @@ export declare const BODY_SCALE_LIMITS: {
|
|
|
101
104
|
readonly max: 1.25;
|
|
102
105
|
};
|
|
103
106
|
};
|
|
107
|
+
/** The character body knobs, beyond the box rig's: silhouette, curves, limbs, bulk, and stylized figure mode. */
|
|
108
|
+
export declare const PLUP_BODY_LIMITS: {
|
|
109
|
+
readonly shoulders: {
|
|
110
|
+
readonly min: 0.65;
|
|
111
|
+
readonly max: 1.6;
|
|
112
|
+
};
|
|
113
|
+
readonly waist: {
|
|
114
|
+
readonly min: 0.48;
|
|
115
|
+
readonly max: 1.25;
|
|
116
|
+
};
|
|
117
|
+
readonly hips: {
|
|
118
|
+
readonly min: 0.75;
|
|
119
|
+
readonly max: 1.55;
|
|
120
|
+
};
|
|
121
|
+
/** Forward chest / bust fullness (0 flat/neutral, up to 1.4 full curvy bust). */
|
|
122
|
+
readonly bust: {
|
|
123
|
+
readonly min: 0;
|
|
124
|
+
readonly max: 1.4;
|
|
125
|
+
};
|
|
126
|
+
/** Leg length: 1 is Plup's stubs, 3 is a long-legged runway walker. */
|
|
127
|
+
readonly legLength: {
|
|
128
|
+
readonly min: 1;
|
|
129
|
+
readonly max: 3;
|
|
130
|
+
};
|
|
131
|
+
readonly armLength: {
|
|
132
|
+
readonly min: 0.8;
|
|
133
|
+
readonly max: 1.8;
|
|
134
|
+
};
|
|
135
|
+
/** Arm, shoulder, chest and leg bulk (muscular / kekar build). */
|
|
136
|
+
readonly muscle: {
|
|
137
|
+
readonly min: 0.7;
|
|
138
|
+
readonly max: 2.2;
|
|
139
|
+
};
|
|
140
|
+
/** Where the arms come out on the round Plup, as a share of the body's height (films' rig puts them at 0.34). */
|
|
141
|
+
readonly shoulderHeight: {
|
|
142
|
+
readonly min: 0.2;
|
|
143
|
+
readonly max: 0.55;
|
|
144
|
+
};
|
|
145
|
+
/** Head size multiplier: lower (0.55–0.8) makes the sculpted body stand out like anime/Roblox; 1+ is chibi. */
|
|
146
|
+
readonly headSize: {
|
|
147
|
+
readonly min: 0.55;
|
|
148
|
+
readonly max: 1.25;
|
|
149
|
+
};
|
|
150
|
+
/** 0 = classic round Plup blob, 1 = stylized anime/chibi figure (round head + neck + sculpted torso). */
|
|
151
|
+
readonly figure: {
|
|
152
|
+
readonly min: 0;
|
|
153
|
+
readonly max: 1;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export interface PlupBody {
|
|
157
|
+
shoulders: number;
|
|
158
|
+
waist: number;
|
|
159
|
+
hips: number;
|
|
160
|
+
bust: number;
|
|
161
|
+
legLength: number;
|
|
162
|
+
armLength: number;
|
|
163
|
+
muscle: number;
|
|
164
|
+
shoulderHeight: number;
|
|
165
|
+
headSize: number;
|
|
166
|
+
figure: number;
|
|
167
|
+
}
|
|
168
|
+
export declare const CANONICAL_PLUP_BODY: PlupBody;
|
|
169
|
+
/** Clamp a Plup body the same way `clampBodyScale` clamps the rig's: missing or broken is canonical. */
|
|
170
|
+
export declare function clampPlupBody(body?: Partial<PlupBody> | null): PlupBody;
|
|
104
171
|
export interface BodyScale {
|
|
105
172
|
/** Uniform stature: every joint offset, bone length, pixel and the clip's lift. 0.5 is bocil. */
|
|
106
173
|
stature: number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Texture } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* The filtering every Plup skin texture uses (ADR 0024). Up close a texel is a hard pixel (nearest);
|
|
4
|
+
* from far away the texture is mip-mapped and filtered, so a small Plup shows the average of the pixels
|
|
5
|
+
* under each screen pixel instead of a random one of them: with nearest both ways a small Plup's eye
|
|
6
|
+
* lost rows and columns and its face came out ragged.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pixelArtFiltering<T extends Texture>(texture: T): T;
|
package/dist/three.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { Group } from "three";
|
|
2
2
|
import { type Emote } from "./emote";
|
|
3
|
+
export { ANIME_FACE_SIZE, ANIME_FACE_UV, drawAnimeFace } from "./anime-face";
|
|
4
|
+
export { blobRadiusAt, buildBlobGeometry, buildFigureHeadGeometry, buildFigureTorsoGeometry, figureTorsoPoint, } from "./blob";
|
|
5
|
+
export { BODY_PRESETS } from "./body-presets";
|
|
6
|
+
export { AUTHORED_CLIPS } from "./clips";
|
|
7
|
+
export { buildWear } from "./dress";
|
|
8
|
+
export { EMOTES } from "./emote";
|
|
9
|
+
export { isHighResFace } from "./skin-map";
|
|
10
|
+
export type { WearKit, WornPiece } from "./wear3d";
|
|
11
|
+
export { hairVolume, isHairKey, isWearKey, WEARABLES, wearSlotOf } from "./wearables";
|
|
3
12
|
import { type ClipRef, type Pose } from "./pose";
|
|
4
|
-
export { type BodyShapeId, createPlup, type Expression, type PlupFace, type PlupHandle, type PlupOptions, type PlupSkin, } from "./plup3d";
|
|
13
|
+
export { type BodyShapeId, createPlup, type Expression, type PlupFace, type PlupHandle, type PlupOptions, type PlupSkin, toon, } from "./plup3d";
|
|
14
|
+
export type { RagdollMode } from "./ragdoll";
|
|
5
15
|
import { type RigId } from "./rig";
|
|
6
16
|
import { type BodyScale, type CharacterLook } from "./skin-native";
|
|
7
17
|
export interface CharacterHandle {
|