@plupin/character 0.0.0-stage → 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.d.ts +79 -0
- package/dist/canvas.js +315 -0
- package/dist/chunk-09c5tps4.js +337 -0
- package/dist/chunk-60p135hw.js +103 -0
- package/dist/chunk-aa5nstet.js +39 -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-sa2r1cxz.js +342 -0
- package/dist/chunk-yd5zzkkg.js +313 -0
- package/dist/clip-bake.d.ts +48 -0
- package/dist/clip-bake.js +132 -0
- package/dist/clips.d.ts +40 -0
- package/dist/dress.d.ts +4 -0
- package/dist/emote.d.ts +25 -0
- package/dist/faces.d.ts +10 -0
- package/dist/faces.js +12 -0
- 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 +19 -0
- package/dist/index.js +176 -0
- package/dist/listing.d.ts +195 -0
- package/dist/listing.js +763 -0
- package/dist/named-faces.d.ts +22 -0
- package/dist/platform-body-data.d.ts +9 -0
- package/dist/platform-body.d.ts +91 -0
- package/dist/plup2d.d.ts +29 -0
- package/dist/plup3d.d.ts +121 -0
- package/dist/png.d.ts +78 -0
- package/dist/pose.d.ts +49 -0
- package/dist/pose.js +18 -0
- package/dist/proportions.d.ts +31 -0
- package/dist/ragdoll.d.ts +51 -0
- package/dist/resolution.d.ts +21 -0
- package/dist/rig.d.ts +29 -0
- package/dist/skin-map.d.ts +155 -0
- package/dist/skin-map.js +55 -0
- package/dist/skin-native.d.ts +301 -0
- package/dist/skin.d.ts +35 -0
- package/dist/texture.d.ts +8 -0
- package/dist/three.d.ts +25 -0
- package/dist/three.js +2302 -0
- package/dist/wear3d.d.ts +99 -0
- package/dist/wearables.d.ts +203 -0
- package/dist/wearables.js +26 -0
- package/package.json +78 -4
- package/README.md +0 -3
|
@@ -0,0 +1,155 @@
|
|
|
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` is 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"];
|
|
19
|
+
export type FaceType = (typeof FACE_TYPES)[number];
|
|
20
|
+
/**
|
|
21
|
+
* The six the face rule picks from, plus every named face of the content films (`@plupin/character`
|
|
22
|
+
* faces): an emote forces one of those through `expression`, and the rule never picks them itself.
|
|
23
|
+
*/
|
|
24
|
+
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")[]];
|
|
25
|
+
export type CharacterExpression = (typeof EXPRESSIONS)[number];
|
|
26
|
+
export declare function isNamedExpression(expression: CharacterExpression): expression is NamedFace;
|
|
27
|
+
export interface CharacterSkin {
|
|
28
|
+
/** BODY_HEIGHT rows of BODY_WIDTH palette keys. */
|
|
29
|
+
body: readonly string[];
|
|
30
|
+
face: FaceType;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Drawing palette. `B`, `L` and `D` follow the equipped outfit colour; every
|
|
34
|
+
* other key is a fixed colour the user can paint with.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SKIN_PALETTE: Readonly<Record<string, string>>;
|
|
37
|
+
/** Order of swatches in the editor. */
|
|
38
|
+
export declare const PAINT_KEYS: string[];
|
|
39
|
+
/** Colours used only by face stamps; never tinted. */
|
|
40
|
+
export declare const FACE_PALETTE: Readonly<Record<string, string>>;
|
|
41
|
+
type Rows2 = readonly [string, string];
|
|
42
|
+
interface FaceDefinition {
|
|
43
|
+
eyes: Record<"open" | "blink" | "happy" | "wide" | "sad", Rows2>;
|
|
44
|
+
mouth: Record<"idle" | "open" | "o" | "frown", Rows2>;
|
|
45
|
+
blush: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const FACES: Readonly<Record<FaceType, FaceDefinition>>;
|
|
48
|
+
/** Face stamp (8 x 4) for a face type and expression; `.` is transparent. */
|
|
49
|
+
export declare function faceStamp(face: FaceType, expression: CharacterExpression): string[];
|
|
50
|
+
/** Body palette with the outfit colour applied to the `B`/`L`/`D` keys. */
|
|
51
|
+
export declare function bodyPalette(outfitColor?: string): Record<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Final colour of every body-map pixel: the drawing, with the face stamp for
|
|
54
|
+
* the expression painted over the front. Row-major, BODY_HEIGHT x BODY_WIDTH.
|
|
55
|
+
*/
|
|
56
|
+
export declare function composeSkin(skin: CharacterSkin, expression: CharacterExpression, outfitColor?: string,
|
|
57
|
+
/** Columns the eyes slide by. The mouth and blush never move (the eyes-only gaze rule). */
|
|
58
|
+
look?: number,
|
|
59
|
+
/**
|
|
60
|
+
* Rows the eyes slide by: -1 up. Down (+1) is clamped to 0 (Q9, owner decision 2026-10-21, PR #327), so no eye
|
|
61
|
+
* pixel lands on the mouth row. The mouth and blush never move.
|
|
62
|
+
*/
|
|
63
|
+
lookY?: number,
|
|
64
|
+
/** Off for the 3D body: the face is a decal on the front, not a stamp in the body texture. */
|
|
65
|
+
drawFace?: boolean,
|
|
66
|
+
/** 2 draws every face pixel as a 2x2 block, for the 3D body where the texture is stretched. */
|
|
67
|
+
faceScale?: number): string[][];
|
|
68
|
+
/** A blank body map filled with one key. */
|
|
69
|
+
export declare function blankBody(key?: string): string[];
|
|
70
|
+
/** Outfit colours used to show a crowd of buddies. */
|
|
71
|
+
export declare const BUDDY_TINTS: readonly ["#2f6fed", "#e2574c", "#3fae74", "#e6a23c", "#8a5ad8"];
|
|
72
|
+
/**
|
|
73
|
+
* Plup's own look, for every surface that shows Plup without a player's drawing: the landing, a guest in
|
|
74
|
+
* the lobby, headshots. The sparkle face (eyes with a catch-light, a resting smile) is the face the
|
|
75
|
+
* films and the landing use; the guest lobby wore the plain dot face, so one character read as two.
|
|
76
|
+
*/
|
|
77
|
+
export declare const DEFAULT_BUDDY_SKIN: CharacterSkin;
|
|
78
|
+
/** Clamp unknown or malformed stored drawings back to a valid map. */
|
|
79
|
+
export declare function sanitizeSkin(value: unknown): CharacterSkin;
|
|
80
|
+
/**
|
|
81
|
+
* A random character worth keeping: a colour, a face and one of a few patterns painted over the
|
|
82
|
+
* default body (none, a belly, stripes, spots), in a second colour that is not the body's own.
|
|
83
|
+
*/
|
|
84
|
+
export declare function randomSkin(): {
|
|
85
|
+
skin: CharacterSkin;
|
|
86
|
+
tint: string;
|
|
87
|
+
};
|
|
88
|
+
/** Texels per skin pixel when a skin is painted for display (body texture, headshot). */
|
|
89
|
+
export declare const SKIN_DETAIL = 4;
|
|
90
|
+
/**
|
|
91
|
+
* Which face key sits on which skin pixel, with the same placement rules as `composeSkin` (eyes follow
|
|
92
|
+
* the gaze, up only; mouth and blush never move). `painSkinDetailed` uses it to draw the face finer.
|
|
93
|
+
*/
|
|
94
|
+
export declare function faceKeys(skin: CharacterSkin, expression: CharacterExpression, look?: number, lookY?: number,
|
|
95
|
+
/** False leaves the eyes out: `paintEyesSmooth` draws them, so they can move between cells. */
|
|
96
|
+
withEyes?: boolean): Map<string, string>;
|
|
97
|
+
/**
|
|
98
|
+
* Paint a composed skin at `SKIN_DETAIL` texels per pixel. The body stays chunky pixel art; the face
|
|
99
|
+
* keeps its exact cells and size but is drawn finer, so a large character does not read as black bars
|
|
100
|
+
* and a red block: eyes are rounded with a light glint, the mouth is a thin rounded stroke, blush is a
|
|
101
|
+
* soft dash. `body` is the skin without the face (composeSkin with drawFace off), for what lies under it.
|
|
102
|
+
*/
|
|
103
|
+
export declare function paintSkinDetailed(context: CanvasRenderingContext2D, pixels: string[][], body: string[][], keys: Map<string, string>, from?: {
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
w: number;
|
|
107
|
+
h: number;
|
|
108
|
+
}, soften?: (fill: string) => string): void;
|
|
109
|
+
/**
|
|
110
|
+
* The eyes, drawn on their own so they move smoothly. Pixel is how the character is drawn, not how it moves:
|
|
111
|
+
* the eyes keep their pixel-art cells and rounded shape, but they slide by a fraction of a cell (the canvas
|
|
112
|
+
* antialiases the edge) and a blink is the eye closing by `openness` (1 open, 0 shut), not one stamp swapped
|
|
113
|
+
* for another. Call after `paintSkinDetailed` with the face drawn without eyes (`faceKeys`' `withEyes` off).
|
|
114
|
+
*/
|
|
115
|
+
export declare function paintEyesSmooth(context: CanvasRenderingContext2D, skin: CharacterSkin, expression: CharacterExpression, offset: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
}, openness: number, from?: {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
w: number;
|
|
122
|
+
h: number;
|
|
123
|
+
}): void;
|
|
124
|
+
/** Bodies a character can wear. Same skeleton in each: only the blob's proportions change. */
|
|
125
|
+
export declare const BODY_SHAPES: {
|
|
126
|
+
readonly plup: {
|
|
127
|
+
readonly x: 1;
|
|
128
|
+
readonly y: 1;
|
|
129
|
+
};
|
|
130
|
+
readonly tall: {
|
|
131
|
+
readonly x: 0.88;
|
|
132
|
+
readonly y: 1.25;
|
|
133
|
+
};
|
|
134
|
+
readonly wide: {
|
|
135
|
+
readonly x: 1.2;
|
|
136
|
+
readonly y: 0.85;
|
|
137
|
+
};
|
|
138
|
+
readonly mini: {
|
|
139
|
+
readonly x: 0.82;
|
|
140
|
+
readonly y: 0.82;
|
|
141
|
+
};
|
|
142
|
+
readonly bean: {
|
|
143
|
+
readonly x: 0.72;
|
|
144
|
+
readonly y: 1.35;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export type BodyShapeId = keyof typeof BODY_SHAPES;
|
|
148
|
+
/** Roblox-format clothing templates (585x559), as data URLs, painted onto Plup's own body. */
|
|
149
|
+
export type PlupClothing = {
|
|
150
|
+
shirt?: string;
|
|
151
|
+
pants?: string;
|
|
152
|
+
};
|
|
153
|
+
/** A stable colour for someone whose look we do not have: the same name always gets the same tint. */
|
|
154
|
+
export declare function tintForName(name: string): string | undefined;
|
|
155
|
+
export {};
|
package/dist/skin-map.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
isNamedExpression,
|
|
22
|
+
paintEyesSmooth,
|
|
23
|
+
paintSkinDetailed,
|
|
24
|
+
randomSkin,
|
|
25
|
+
sanitizeSkin,
|
|
26
|
+
tintForName
|
|
27
|
+
} from "./chunk-kber92gm.js";
|
|
28
|
+
import"./chunk-aa5nstet.js";
|
|
29
|
+
export {
|
|
30
|
+
tintForName,
|
|
31
|
+
sanitizeSkin,
|
|
32
|
+
randomSkin,
|
|
33
|
+
paintSkinDetailed,
|
|
34
|
+
paintEyesSmooth,
|
|
35
|
+
isNamedExpression,
|
|
36
|
+
faceStamp,
|
|
37
|
+
faceKeys,
|
|
38
|
+
composeSkin,
|
|
39
|
+
bodyPalette,
|
|
40
|
+
blankBody,
|
|
41
|
+
SKIN_PALETTE,
|
|
42
|
+
SKIN_DETAIL,
|
|
43
|
+
PAINT_KEYS,
|
|
44
|
+
FACE_TYPES,
|
|
45
|
+
FACE_ROW,
|
|
46
|
+
FACE_PALETTE,
|
|
47
|
+
FACE_COLUMN,
|
|
48
|
+
FACES,
|
|
49
|
+
EXPRESSIONS,
|
|
50
|
+
DEFAULT_BUDDY_SKIN,
|
|
51
|
+
BUDDY_TINTS,
|
|
52
|
+
BODY_WIDTH,
|
|
53
|
+
BODY_SHAPES,
|
|
54
|
+
BODY_HEIGHT
|
|
55
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { type Bone, type CanonicalBone, type RigId, type Vec3 } from "./rig";
|
|
2
|
+
import { type FaceName, type PartFaces, type Rect } from "./skin";
|
|
3
|
+
/**
|
|
4
|
+
* The Plupin-native body template: the platform's own part faces over the six canonical bones of
|
|
5
|
+
* `rig.ts`, the caps a body variant has to fit in, and the converter that brings a Roblox classic
|
|
6
|
+
* shirt/pants pair onto this grid. `skin.ts` stays the import format; this is the one the platform
|
|
7
|
+
* authors and renders.
|
|
8
|
+
*
|
|
9
|
+
* Resolutions. One stud is `NATIVE_PX_PER_STUD` = 32 px. The parts are the R6 proportions the rigs
|
|
10
|
+
* already share (torso 2x2x1, head 2x1x1, limb 1x2x1 studs), so a rig that is not R6 only scales
|
|
11
|
+
* the same faces: bone lengths and proportions live in `rig.ts` and nothing here restates them.
|
|
12
|
+
*
|
|
13
|
+
* Why 32 px per stud:
|
|
14
|
+
* - The 24 x 24 headshot `listing.ts` draws (`GRID`) must not upscale the skin. The smallest head
|
|
15
|
+
* face here is a 32 x 32 side, so a 24 px preview still samples 1.33 source texels per preview
|
|
16
|
+
* pixel; 16 px per stud would make the head side 32 x 16 and upscale it 1.5x vertically.
|
|
17
|
+
* - 32 is a power of two, so the sheet halves to 16 px per stud and quarters to 8 without landing
|
|
18
|
+
* on fractional pixels, and the classic template's 64 px per stud limb face lands on this grid
|
|
19
|
+
* by an exact 2:1 downscale.
|
|
20
|
+
* - The whole sheet is 512 x 256 px, a quarter of the proposed 512 x 512 ceiling. The layer is
|
|
21
|
+
* what keeps a variant small, and 32 px per stud is the resolution that buys it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const NATIVE_PX_PER_STUD = 32;
|
|
24
|
+
export declare const NATIVE_WIDTH = 512;
|
|
25
|
+
export declare const NATIVE_HEIGHT = 256;
|
|
26
|
+
export interface NativePart {
|
|
27
|
+
/** The block this part's net occupies on the sheet, for layout assertions. */
|
|
28
|
+
block: Rect;
|
|
29
|
+
/** Canonical size in studs, w x h x d, as `rig.ts`'s R6 pins it. */
|
|
30
|
+
studs: readonly [number, number, number];
|
|
31
|
+
faces: PartFaces;
|
|
32
|
+
}
|
|
33
|
+
export declare const NATIVE_TORSO: PartFaces;
|
|
34
|
+
export declare const NATIVE_HEAD: PartFaces;
|
|
35
|
+
export declare const NATIVE_ARM_LEFT: PartFaces;
|
|
36
|
+
export declare const NATIVE_ARM_RIGHT: PartFaces;
|
|
37
|
+
export declare const NATIVE_LEG_LEFT: PartFaces;
|
|
38
|
+
export declare const NATIVE_LEG_RIGHT: PartFaces;
|
|
39
|
+
export declare const NATIVE_PARTS: Readonly<Record<CanonicalBone, NativePart>>;
|
|
40
|
+
/** Which grid part a rig's bone draws from, and which slice of it. */
|
|
41
|
+
export interface NativeMapping {
|
|
42
|
+
part: CanonicalBone;
|
|
43
|
+
/** Vertical slice of the part's face this bone shows: R15 splits one R6 limb into segments. */
|
|
44
|
+
slice?: readonly [number, number];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Bone name to grid part. The names are `rig.ts`'s own, so every rig's bones resolve: R6 and R15
|
|
48
|
+
* cover the six canonical names, and Plup's single body box becomes the torso face (its `head`
|
|
49
|
+
* alias points at the same box, and a box is drawn once).
|
|
50
|
+
*/
|
|
51
|
+
export declare const NATIVE_BONES: Readonly<Record<string, NativeMapping>>;
|
|
52
|
+
export declare function nativePartOf(bone: string): CanonicalBone | null;
|
|
53
|
+
/**
|
|
54
|
+
* The rectangle of one face of one bone, with any R15 slice applied. Sides slice vertically only:
|
|
55
|
+
* the top face belongs to the first segment, the bottom face to the last, like the classic map.
|
|
56
|
+
* Slice boundaries are rounded once and each slice starts where the previous one ended, so the
|
|
57
|
+
* segments of one part always tile its face with no gap and no overlap.
|
|
58
|
+
*/
|
|
59
|
+
export declare function nativeFaceRect(bone: string, face: FaceName): Rect | null;
|
|
60
|
+
/**
|
|
61
|
+
* The image type the renderers accept: anything a canvas can draw.
|
|
62
|
+
*
|
|
63
|
+
* The DOM calls this `CanvasImageSource`, and that name only exists in a program compiled with the
|
|
64
|
+
* DOM lib. `@plupin/api` and `apps/server` type-check this package without it (they validate and
|
|
65
|
+
* serve listings; they never draw one), so the type is owned here instead of borrowed.
|
|
66
|
+
*
|
|
67
|
+
* It is deliberately `object`: every DOM image source, every canvas element and every test raster is
|
|
68
|
+
* one, and nothing in this package reads a property off it — the canvas renderer and the three.js
|
|
69
|
+
* renderer hand it straight to their own `drawImage`, which is where the real contract lives.
|
|
70
|
+
*/
|
|
71
|
+
export type SkinImage = object;
|
|
72
|
+
/**
|
|
73
|
+
* The clamps every proportion change passes through. Owner direction (20 Nov): proportions are
|
|
74
|
+
* bounded, not fixed, because a kid-sized ("bocil") and a tall character are the same rig at a
|
|
75
|
+
* different stature, and a muscular arm is the same bone with a wider box.
|
|
76
|
+
*
|
|
77
|
+
* - stature 0.5-1.5: the whole body, uniformly. 0.5 is "bocil" — half size, still the same
|
|
78
|
+
* creature — and it is the floor because at 32 px per stud the smallest screen a character is
|
|
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.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.
|
|
85
|
+
* - width 0.9-1.3: across the body only (x in the front view, z in the side view), so an arm can
|
|
86
|
+
* be 30% thicker without getting 30% longer. 0.9 is the thinnest silhouette that still covers the
|
|
87
|
+
* native face rect's edges; 1.3 is the widest a limb may be before it reads as a different part.
|
|
88
|
+
* - head 0.9-1.25: a big head is a style, and 1.25 is where it stops swallowing the torso.
|
|
89
|
+
*
|
|
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.
|
|
92
|
+
*/
|
|
93
|
+
export declare const BODY_SCALE_LIMITS: {
|
|
94
|
+
readonly stature: {
|
|
95
|
+
readonly min: 0.5;
|
|
96
|
+
readonly max: 1.5;
|
|
97
|
+
};
|
|
98
|
+
readonly width: {
|
|
99
|
+
readonly min: 0.9;
|
|
100
|
+
readonly max: 1.3;
|
|
101
|
+
};
|
|
102
|
+
readonly head: {
|
|
103
|
+
readonly min: 0.9;
|
|
104
|
+
readonly max: 1.25;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** The round Plup's own knobs, beyond the box rig's: its outline, its limbs' length and bulk. */
|
|
108
|
+
export declare const PLUP_BODY_LIMITS: {
|
|
109
|
+
readonly shoulders: {
|
|
110
|
+
readonly min: 0.7;
|
|
111
|
+
readonly max: 1.45;
|
|
112
|
+
};
|
|
113
|
+
readonly waist: {
|
|
114
|
+
readonly min: 0.62;
|
|
115
|
+
readonly max: 1.2;
|
|
116
|
+
};
|
|
117
|
+
readonly hips: {
|
|
118
|
+
readonly min: 0.75;
|
|
119
|
+
readonly max: 1.4;
|
|
120
|
+
};
|
|
121
|
+
/** Leg length: 1 is Plup's stubs, 3 is a long-legged runway walker. */
|
|
122
|
+
readonly legLength: {
|
|
123
|
+
readonly min: 1;
|
|
124
|
+
readonly max: 3;
|
|
125
|
+
};
|
|
126
|
+
readonly armLength: {
|
|
127
|
+
readonly min: 0.8;
|
|
128
|
+
readonly max: 1.8;
|
|
129
|
+
};
|
|
130
|
+
/** Arm and leg bulk, a muscular body's biceps. */
|
|
131
|
+
readonly muscle: {
|
|
132
|
+
readonly min: 0.7;
|
|
133
|
+
readonly max: 1.9;
|
|
134
|
+
};
|
|
135
|
+
/** Where the arms come out, as a share of the body's height (the films' rig puts them at 0.34). */
|
|
136
|
+
readonly shoulderHeight: {
|
|
137
|
+
readonly min: 0.2;
|
|
138
|
+
readonly max: 0.55;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
export interface PlupBody {
|
|
142
|
+
shoulders: number;
|
|
143
|
+
waist: number;
|
|
144
|
+
hips: number;
|
|
145
|
+
legLength: number;
|
|
146
|
+
armLength: number;
|
|
147
|
+
muscle: number;
|
|
148
|
+
shoulderHeight: number;
|
|
149
|
+
}
|
|
150
|
+
export declare const CANONICAL_PLUP_BODY: PlupBody;
|
|
151
|
+
/** Clamp a Plup body the same way `clampBodyScale` clamps the rig's: missing or broken is canonical. */
|
|
152
|
+
export declare function clampPlupBody(body?: Partial<PlupBody> | null): PlupBody;
|
|
153
|
+
export interface BodyScale {
|
|
154
|
+
/** Uniform stature: every joint offset, bone length, pixel and the clip's lift. 0.5 is bocil. */
|
|
155
|
+
stature: number;
|
|
156
|
+
/** Across-the-body thickness of a part: the muscular-arm path. The head has its own knob. */
|
|
157
|
+
width: Partial<Readonly<Record<Exclude<CanonicalBone, "head">, number>>>;
|
|
158
|
+
/** Extra multiplier on the head box only. */
|
|
159
|
+
head: number;
|
|
160
|
+
}
|
|
161
|
+
/** No change: the proportions `rig.ts` declares. */
|
|
162
|
+
export declare const CANONICAL_BODY_SCALE: BodyScale;
|
|
163
|
+
/**
|
|
164
|
+
* The one place a proportion becomes a number: anything a player, a listing or a game sends lands
|
|
165
|
+
* inside the clamps above, and a missing or non-finite value falls back to canonical rather than
|
|
166
|
+
* to a limit.
|
|
167
|
+
*/
|
|
168
|
+
export declare function clampBodyScale(scale?: Partial<BodyScale> | null): BodyScale;
|
|
169
|
+
export interface ScaledBone {
|
|
170
|
+
joint: Vec3;
|
|
171
|
+
size: Vec3;
|
|
172
|
+
center: Vec3;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* One bone's box after a clamped scale. Size and centre multiply around the joint, so a part grows
|
|
176
|
+
* away from its pivot and the joint itself never moves; the joint's across offset also follows the
|
|
177
|
+
* parent's width, so a limb stays on the edge of a wider torso instead of sinking into it.
|
|
178
|
+
*
|
|
179
|
+
* Rotations are not touched here. That is why one clip drives every stature, every width and every
|
|
180
|
+
* head size: the renderer changes boxes, never angles.
|
|
181
|
+
*/
|
|
182
|
+
export declare function scaleBone(bone: Bone, part: CanonicalBone | null, parentPart: CanonicalBone | null, scale: BodyScale): ScaledBone;
|
|
183
|
+
export interface CanonicalBox {
|
|
184
|
+
size: Vec3;
|
|
185
|
+
/** Centre in studs relative to the character's feet, facing +z. */
|
|
186
|
+
center: Vec3;
|
|
187
|
+
}
|
|
188
|
+
export interface CanonicalFootprint {
|
|
189
|
+
width: number;
|
|
190
|
+
height: number;
|
|
191
|
+
depth: number;
|
|
192
|
+
bones: Readonly<Record<string, CanonicalBox>>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* What a game may rely on, and the answer to "the game stays balanced": the box is read from
|
|
196
|
+
* `rig.ts` only. There is no `BodyScale` parameter, so a player's visual stature, arms or head can
|
|
197
|
+
* never widen the box a game collides with. Visual scale is cosmetic; this is the identity.
|
|
198
|
+
*/
|
|
199
|
+
export declare function canonicalFootprint(rigId: RigId): CanonicalFootprint;
|
|
200
|
+
/**
|
|
201
|
+
* The largest box a fully clamped character may draw, in studs: the canonical footprint times the
|
|
202
|
+
* clamp maxima. A loose upper bound on purpose — a renderer may draw inside it and never outside.
|
|
203
|
+
*/
|
|
204
|
+
export declare function visualEnvelope(rigId: RigId): {
|
|
205
|
+
width: number;
|
|
206
|
+
height: number;
|
|
207
|
+
depth: number;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* The caps a body-variant sheet is measured against before it can be listed. `wardrobe` and the
|
|
211
|
+
* moderation queue read one answer from `validateVariantSheet`; the renderer only ever draws the
|
|
212
|
+
* part rects above, so a sheet inside these caps cannot reach past them.
|
|
213
|
+
*
|
|
214
|
+
* - PNG-24: 8-bit truecolour, optional 8-bit alpha, no palette and no 16-bit channel. Pixel art is
|
|
215
|
+
* the house style and `imageSmoothingEnabled = false` is the renderer's only path, so a sheet
|
|
216
|
+
* the browser decodes as 16-bit or through a palette is a different picture than the moderator
|
|
217
|
+
* approved.
|
|
218
|
+
* - 512 x 256: the native grid itself, not a resized copy. A variant is authored on these
|
|
219
|
+
* coordinates, so every face rect in this file is also the variant's rect, and a sheet of
|
|
220
|
+
* another size is refused rather than resampled.
|
|
221
|
+
* - 64 KiB: the sheet is 131072 px, which is 384 KiB at 8 bits per channel, so the cap asks for
|
|
222
|
+
* 1.4 bits per sheet pixel. Flat pixel art clears it by a wide margin (the largest block, the
|
|
223
|
+
* torso net, is 24576 px and stays under 8 KiB), so the cap only bites on noisy or photographic
|
|
224
|
+
* art, which is what it is for. It also bounds the wardrobe: eight variants download at most
|
|
225
|
+
* half a megabyte.
|
|
226
|
+
*/
|
|
227
|
+
export declare const NATIVE_SHEET_CAPS: {
|
|
228
|
+
readonly format: "png-24";
|
|
229
|
+
readonly width: 512;
|
|
230
|
+
readonly height: 256;
|
|
231
|
+
readonly maxBytes: number;
|
|
232
|
+
};
|
|
233
|
+
export interface VariantSheetFacts {
|
|
234
|
+
width: number;
|
|
235
|
+
height: number;
|
|
236
|
+
bytes: number;
|
|
237
|
+
}
|
|
238
|
+
export type VariantSheetProblem = "wrong_size" | "over_byte_cap";
|
|
239
|
+
export type VariantSheetCheck = {
|
|
240
|
+
ok: true;
|
|
241
|
+
} | {
|
|
242
|
+
ok: false;
|
|
243
|
+
reason: VariantSheetProblem;
|
|
244
|
+
};
|
|
245
|
+
/** The one check every writer runs on a decoded variant sheet, before the digest or the queue. */
|
|
246
|
+
export declare function validateVariantSheet(facts: VariantSheetFacts): VariantSheetCheck;
|
|
247
|
+
/**
|
|
248
|
+
* One part of a body variant: the whole native sheet, painted only where this part's faces are.
|
|
249
|
+
* The renderer samples this part's rects, so art outside them is never drawn.
|
|
250
|
+
*/
|
|
251
|
+
export interface VariantPart {
|
|
252
|
+
image: SkinImage;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A body variant is cosmetic only: it carries art and nothing else. There is no stat, no height,
|
|
256
|
+
* no reach and no gameplay field a variant could add, and the renderer never reads the id.
|
|
257
|
+
*/
|
|
258
|
+
export interface BodyVariant {
|
|
259
|
+
/** The listing id the creator bought; the renderer only carries it. */
|
|
260
|
+
id: string;
|
|
261
|
+
/** One sheet per part this variant redraws. An absent part keeps the skin's own art. */
|
|
262
|
+
parts: Partial<Readonly<Record<CanonicalBone, VariantPart>>>;
|
|
263
|
+
}
|
|
264
|
+
export interface CharacterLook {
|
|
265
|
+
/** Skin tone of bare parts, one per region, or a single colour for all. */
|
|
266
|
+
bodyColor: string;
|
|
267
|
+
headColor?: string;
|
|
268
|
+
/** Classic template images. Any image type the renderer can draw. */
|
|
269
|
+
shirt?: SkinImage | null;
|
|
270
|
+
pants?: SkinImage | null;
|
|
271
|
+
/** Drawn on the front of the head, or on Plup's body. */
|
|
272
|
+
face?: SkinImage | null;
|
|
273
|
+
/** A whole body on the native grid, as `convertClassicToNative` produces. */
|
|
274
|
+
native?: SkinImage | null;
|
|
275
|
+
/** Per-part art that replaces a part's own art. Cosmetic only: the rig never reads it. */
|
|
276
|
+
variant?: BodyVariant | null;
|
|
277
|
+
}
|
|
278
|
+
export interface BoneSkin {
|
|
279
|
+
image: SkinImage;
|
|
280
|
+
/** The source rect of this face, already sliced for an R15 segment. */
|
|
281
|
+
source: Rect;
|
|
282
|
+
/** A variant owns the part, so the renderer must not paint the skin tone behind it. */
|
|
283
|
+
redraw: boolean;
|
|
284
|
+
}
|
|
285
|
+
/** Which image and which rect one bone's face reads, in the renderers' order of preference. */
|
|
286
|
+
export declare function boneSkin(bone: string, face: FaceName, look: CharacterLook): BoneSkin | null;
|
|
287
|
+
/** One draw the classic converter performs: a classic face rect into its native face rect. */
|
|
288
|
+
export interface ClassicConversion {
|
|
289
|
+
part: CanonicalBone;
|
|
290
|
+
face: FaceName;
|
|
291
|
+
sheet: "shirt" | "pants";
|
|
292
|
+
source: Rect;
|
|
293
|
+
dest: Rect;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The classic template mapped onto the native grid, one entry per face, in a fixed order. Head
|
|
297
|
+
* faces are absent on purpose: a Roblox classic shirt/pants pair carries no head skin (Roblox
|
|
298
|
+
* paints the head with a separate face), so the converter leaves the head rects empty and the
|
|
299
|
+
* rig's skin tone shows through.
|
|
300
|
+
*/
|
|
301
|
+
export declare const CLASSIC_TO_NATIVE: readonly ClassicConversion[];
|
package/dist/skin.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A skin is an image plus a map of where each face of each part sits on it. The maps below are the
|
|
3
|
+
* Roblox classic clothing template, so a shirt or pants PNG made for Roblox works unchanged.
|
|
4
|
+
*/
|
|
5
|
+
export interface Rect {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
}
|
|
11
|
+
export type FaceName = "front" | "back" | "left" | "right" | "up" | "down";
|
|
12
|
+
export type PartFaces = Readonly<Record<FaceName, Rect>>;
|
|
13
|
+
export declare const CLASSIC_WIDTH = 585;
|
|
14
|
+
export declare const CLASSIC_HEIGHT = 559;
|
|
15
|
+
export declare const CLASSIC_TORSO: PartFaces;
|
|
16
|
+
/** The block on the template's left: right arm on a shirt, right leg on pants. */
|
|
17
|
+
export declare const CLASSIC_RIGHT_LIMB: PartFaces;
|
|
18
|
+
/** The block on the template's right: left arm on a shirt, left leg on pants. */
|
|
19
|
+
export declare const CLASSIC_LEFT_LIMB: PartFaces;
|
|
20
|
+
/** Where a rig's bone reads from in a classic template, and from which image. */
|
|
21
|
+
export interface ClassicMapping {
|
|
22
|
+
sheet: "shirt" | "pants";
|
|
23
|
+
faces: PartFaces;
|
|
24
|
+
/** Which vertical slice of the part this bone shows: R15 splits one R6 limb into segments. */
|
|
25
|
+
slice?: readonly [number, number];
|
|
26
|
+
}
|
|
27
|
+
export declare const CLASSIC_BONES: Readonly<Record<string, ClassicMapping>>;
|
|
28
|
+
/** The rectangle of one face of one bone, with any R15 slice applied. Sides slice vertically only. */
|
|
29
|
+
export declare function classicFaceRect(bone: string, face: FaceName): Rect | null;
|
|
30
|
+
export interface ClassicValidation {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
reason?: "wrong_size";
|
|
33
|
+
}
|
|
34
|
+
/** Roblox rejects a classic template of any other size, and a mapped one would land wrong. */
|
|
35
|
+
export declare function validateClassicTemplate(width: number, height: number): ClassicValidation;
|
|
@@ -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
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Group } from "three";
|
|
2
|
+
import { type Emote } from "./emote";
|
|
3
|
+
export { buildWear } from "./dress";
|
|
4
|
+
export type { WearKit, WornPiece } from "./wear3d";
|
|
5
|
+
import { type ClipRef, type Pose } from "./pose";
|
|
6
|
+
export { type BodyShapeId, createPlup, type Expression, type PlupFace, type PlupHandle, type PlupOptions, type PlupSkin, } from "./plup3d";
|
|
7
|
+
export type { RagdollMode } from "./ragdoll";
|
|
8
|
+
import { type RigId } from "./rig";
|
|
9
|
+
import { type BodyScale, type CharacterLook } from "./skin-native";
|
|
10
|
+
export interface CharacterHandle {
|
|
11
|
+
/** Add this to a scene. Feet stand at y = 0, facing +z, one unit is one stud. */
|
|
12
|
+
object: Group;
|
|
13
|
+
/** Set the current clip. Call `update` every frame. */
|
|
14
|
+
play: (clip: ClipRef) => void;
|
|
15
|
+
/** Play an emote by name (`"ngakak"` or `"emote-ngakak"`): its clip, now. Returns it so the game can show its face and glyph; undefined for an unknown name. */
|
|
16
|
+
emote: (name: string) => Emote | undefined;
|
|
17
|
+
/** Hold a joint, for example `{ armR: { x: -1.2 } }` to aim. Pass `{}` to let go. */
|
|
18
|
+
pose: (pose: Pose) => void;
|
|
19
|
+
update: (deltaSeconds: number) => void;
|
|
20
|
+
/** The joint itself, to attach a hat or a sword: `bone("armR").add(sword)`. */
|
|
21
|
+
bone: (name: string) => Group | undefined;
|
|
22
|
+
dispose: () => void;
|
|
23
|
+
}
|
|
24
|
+
/** Builds a skinned, posable character. Everything a game needs is on the returned handle. */
|
|
25
|
+
export declare function createCharacter(rigId?: RigId, look?: CharacterLook, bodyScale?: Partial<BodyScale> | null): CharacterHandle;
|