@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
package/dist/index.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EMOTES,
|
|
3
|
+
RAGDOLL_JOINTS,
|
|
4
|
+
createRagdoll,
|
|
3
5
|
emoteOf
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-yd5zzkkg.js";
|
|
7
|
+
import {
|
|
8
|
+
WEARABLES,
|
|
9
|
+
WEAR_KEYS,
|
|
10
|
+
isWearKey,
|
|
11
|
+
wearKeyOf,
|
|
12
|
+
wearKeysOf,
|
|
13
|
+
wearSlotOf,
|
|
14
|
+
wearView,
|
|
15
|
+
wearableItems
|
|
16
|
+
} from "./chunk-60p135hw.js";
|
|
5
17
|
import {
|
|
6
18
|
BODY_SCALE_LIMITS,
|
|
7
19
|
CANONICAL_BODY_SCALE,
|
|
20
|
+
CANONICAL_PLUP_BODY,
|
|
8
21
|
CLASSIC_BONES,
|
|
9
22
|
CLASSIC_HEIGHT,
|
|
10
23
|
CLASSIC_LEFT_LIMB,
|
|
@@ -24,9 +37,11 @@ import {
|
|
|
24
37
|
NATIVE_SHEET_CAPS,
|
|
25
38
|
NATIVE_TORSO,
|
|
26
39
|
NATIVE_WIDTH,
|
|
40
|
+
PLUP_BODY_LIMITS,
|
|
27
41
|
boneSkin,
|
|
28
42
|
canonicalFootprint,
|
|
29
43
|
clampBodyScale,
|
|
44
|
+
clampPlupBody,
|
|
30
45
|
classicFaceRect,
|
|
31
46
|
nativeFaceRect,
|
|
32
47
|
nativePartOf,
|
|
@@ -34,14 +49,11 @@ import {
|
|
|
34
49
|
validateClassicTemplate,
|
|
35
50
|
validateVariantSheet,
|
|
36
51
|
visualEnvelope
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import {
|
|
39
|
-
FACE_STAMP_PALETTE,
|
|
40
|
-
NAMED_FACES,
|
|
41
|
-
NAMED_FACE_STAMPS,
|
|
42
|
-
isNamedFace
|
|
43
|
-
} from "./chunk-aa5nstet.js";
|
|
52
|
+
} from "./chunk-sa2r1cxz.js";
|
|
44
53
|
import {
|
|
54
|
+
AUTHORED_BONES,
|
|
55
|
+
AUTHORED_CLIPS,
|
|
56
|
+
AUTHORED_CLIP_NAMES,
|
|
45
57
|
CLIPS,
|
|
46
58
|
RIGS,
|
|
47
59
|
boneOf,
|
|
@@ -51,8 +63,58 @@ import {
|
|
|
51
63
|
mergePoses,
|
|
52
64
|
resolvePose,
|
|
53
65
|
sampleClip
|
|
54
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-g1c0wdcj.js";
|
|
67
|
+
import {
|
|
68
|
+
FACE_STAMP_PALETTE,
|
|
69
|
+
NAMED_FACES,
|
|
70
|
+
NAMED_FACE_STAMPS,
|
|
71
|
+
isNamedFace
|
|
72
|
+
} from "./chunk-aa5nstet.js";
|
|
73
|
+
|
|
74
|
+
// src/body-presets.ts
|
|
75
|
+
var BODY_PRESETS = {
|
|
76
|
+
round: { name: "Round", shape: "plup", body: {} },
|
|
77
|
+
"tall-slim": {
|
|
78
|
+
name: "Tall & Slim",
|
|
79
|
+
shape: "tall",
|
|
80
|
+
body: { shoulders: 0.9, waist: 0.84, hips: 0.9, legLength: 2.6, armLength: 1.4, muscle: 0.78 }
|
|
81
|
+
},
|
|
82
|
+
athletic: {
|
|
83
|
+
name: "Athletic",
|
|
84
|
+
shape: "tall",
|
|
85
|
+
body: { shoulders: 1.2, waist: 0.84, hips: 0.95, legLength: 2.1, armLength: 1.3, muscle: 1.35 }
|
|
86
|
+
},
|
|
87
|
+
muscular: {
|
|
88
|
+
name: "Muscular",
|
|
89
|
+
shape: "tall",
|
|
90
|
+
body: {
|
|
91
|
+
shoulders: 1.32,
|
|
92
|
+
waist: 0.82,
|
|
93
|
+
hips: 0.88,
|
|
94
|
+
legLength: 1.7,
|
|
95
|
+
armLength: 1.25,
|
|
96
|
+
muscle: 1.9
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
curvy: {
|
|
100
|
+
name: "Curvy",
|
|
101
|
+
shape: "tall",
|
|
102
|
+
body: { shoulders: 0.9, waist: 0.66, hips: 1.32, legLength: 2.4, armLength: 1.3, muscle: 0.85 }
|
|
103
|
+
},
|
|
104
|
+
chubby: {
|
|
105
|
+
name: "Chubby",
|
|
106
|
+
shape: "wide",
|
|
107
|
+
body: { shoulders: 1, waist: 1.15, hips: 1.25, legLength: 1, armLength: 1, muscle: 1.2 }
|
|
108
|
+
},
|
|
109
|
+
tiny: { name: "Tiny", shape: "mini", body: {} },
|
|
110
|
+
bean: { name: "Bean", shape: "bean", body: { legLength: 1.3 } }
|
|
111
|
+
};
|
|
55
112
|
export {
|
|
113
|
+
wearableItems,
|
|
114
|
+
wearView,
|
|
115
|
+
wearSlotOf,
|
|
116
|
+
wearKeysOf,
|
|
117
|
+
wearKeyOf,
|
|
56
118
|
visualEnvelope,
|
|
57
119
|
validateVariantSheet,
|
|
58
120
|
validateClassicTemplate,
|
|
@@ -62,17 +124,24 @@ export {
|
|
|
62
124
|
nativePartOf,
|
|
63
125
|
nativeFaceRect,
|
|
64
126
|
mergePoses,
|
|
127
|
+
isWearKey,
|
|
65
128
|
isNamedFace,
|
|
66
129
|
isCustomClip,
|
|
67
130
|
emoteOf,
|
|
68
131
|
customDuration,
|
|
132
|
+
createRagdoll,
|
|
69
133
|
clipLift,
|
|
70
134
|
classicFaceRect,
|
|
135
|
+
clampPlupBody,
|
|
71
136
|
clampBodyScale,
|
|
72
137
|
canonicalFootprint,
|
|
73
138
|
boneSkin,
|
|
74
139
|
boneOf,
|
|
140
|
+
WEAR_KEYS,
|
|
141
|
+
WEARABLES,
|
|
75
142
|
RIGS,
|
|
143
|
+
RAGDOLL_JOINTS,
|
|
144
|
+
PLUP_BODY_LIMITS,
|
|
76
145
|
NATIVE_WIDTH,
|
|
77
146
|
NATIVE_TORSO,
|
|
78
147
|
NATIVE_SHEET_CAPS,
|
|
@@ -97,6 +166,11 @@ export {
|
|
|
97
166
|
CLASSIC_LEFT_LIMB,
|
|
98
167
|
CLASSIC_HEIGHT,
|
|
99
168
|
CLASSIC_BONES,
|
|
169
|
+
CANONICAL_PLUP_BODY,
|
|
100
170
|
CANONICAL_BODY_SCALE,
|
|
101
|
-
BODY_SCALE_LIMITS
|
|
171
|
+
BODY_SCALE_LIMITS,
|
|
172
|
+
BODY_PRESETS,
|
|
173
|
+
AUTHORED_CLIP_NAMES,
|
|
174
|
+
AUTHORED_CLIPS,
|
|
175
|
+
AUTHORED_BONES
|
|
102
176
|
};
|
package/dist/listing.d.ts
CHANGED
|
@@ -184,7 +184,7 @@ export declare function itemAssetKindOf(assetConfig: unknown): ItemAssetKind | n
|
|
|
184
184
|
* `{glyph, face, clip}` or `{color}` config, and the same renderer explains them.
|
|
185
185
|
*/
|
|
186
186
|
export declare function renderListingPreview(input: {
|
|
187
|
-
slot: ListingSlot | "face";
|
|
187
|
+
slot: ListingSlot | "face" | "hat";
|
|
188
188
|
name: string;
|
|
189
189
|
assetConfig: unknown;
|
|
190
190
|
}): string;
|
package/dist/listing.js
CHANGED
|
@@ -7,19 +7,19 @@ import {
|
|
|
7
7
|
NATIVE_SHEET_CAPS,
|
|
8
8
|
NATIVE_TORSO,
|
|
9
9
|
clampBodyScale
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-sa2r1cxz.js";
|
|
11
|
+
import {
|
|
12
|
+
CLIPS
|
|
13
|
+
} from "./chunk-g1c0wdcj.js";
|
|
11
14
|
import {
|
|
12
15
|
FACE_STAMP_PALETTE,
|
|
13
16
|
NAMED_FACES,
|
|
14
17
|
NAMED_FACE_STAMPS,
|
|
15
18
|
isNamedFace
|
|
16
19
|
} from "./chunk-aa5nstet.js";
|
|
17
|
-
import {
|
|
18
|
-
CLIPS
|
|
19
|
-
} from "./chunk-wpbgtn0y.js";
|
|
20
20
|
|
|
21
21
|
// src/png.ts
|
|
22
|
-
import { unzlibSync } from "fflate";
|
|
22
|
+
import { unzlibSync, zlibSync } from "fflate";
|
|
23
23
|
var MAX_PIXELS = 4000000;
|
|
24
24
|
var SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
25
25
|
var CHANNELS = { 0: 1, 2: 3, 4: 2, 6: 4 };
|
|
@@ -189,6 +189,16 @@ function decodeBase64(value) {
|
|
|
189
189
|
}
|
|
190
190
|
return bytes;
|
|
191
191
|
}
|
|
192
|
+
var CRC_TABLE = (() => {
|
|
193
|
+
const table = new Uint32Array(256);
|
|
194
|
+
for (let index = 0;index < 256; index++) {
|
|
195
|
+
let value = index;
|
|
196
|
+
for (let bit = 0;bit < 8; bit++)
|
|
197
|
+
value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
|
|
198
|
+
table[index] = value >>> 0;
|
|
199
|
+
}
|
|
200
|
+
return table;
|
|
201
|
+
})();
|
|
192
202
|
|
|
193
203
|
// src/listing.ts
|
|
194
204
|
var LISTABLE_SLOTS = ["outfit", "hair", "accessory", "emote"];
|
|
@@ -699,7 +709,7 @@ function renderListingPreview(input) {
|
|
|
699
709
|
const colour = typeof assetConfig.color === "string" && COLOR_PATTERN.test(assetConfig.color) ? assetConfig.color.toLowerCase() : BODY;
|
|
700
710
|
const pixels = new Map;
|
|
701
711
|
if (kind === "sheet" || kind === "bodyVariant" || kind === "accessory") {
|
|
702
|
-
paintArtItem(pixels, assetConfig, kind, input.slot);
|
|
712
|
+
paintArtItem(pixels, assetConfig, kind, input.slot === "hat" ? "hair" : input.slot);
|
|
703
713
|
} else {
|
|
704
714
|
paint(pixels, 5, 17, 14, 4, input.slot === "emote" ? BODY : colour);
|
|
705
715
|
paint(pixels, 7, 4, 10, 12, SKIN);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by `bun run platform:bodies`. Do not edit by hand.
|
|
3
|
+
*
|
|
4
|
+
* Each value is the 512 x 256 native-grid PNG of a platform body model as the data URL a listing
|
|
5
|
+
* manifest stores. `paintPlatformBody()` in `platform-body.ts` is the code that draws it and
|
|
6
|
+
* `tests/platform-body.test.ts` re-encodes that painter and refuses a mismatch, so these strings
|
|
7
|
+
* cannot drift from the art by hand-editing either one.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PLATFORM_BODY_SHEETS: Readonly<Record<string, string>>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { PngImage } from "./png";
|
|
2
|
+
import type { CanonicalBone } from "./rig";
|
|
3
|
+
import type { FaceName } from "./skin";
|
|
4
|
+
/**
|
|
5
|
+
* The platform's own body models: the one place a character's height comes from.
|
|
6
|
+
*
|
|
7
|
+
* Owner direction (20 Nov): a player does not type a stature. Height is a property of the body you
|
|
8
|
+
* are wearing, the way a Roblox body bundle decides proportions — you equip the kid-sized model to
|
|
9
|
+
* be small, and the tall model to be tall. So the three models below are ordinary outfit listings
|
|
10
|
+
* (`slot: "outfit"`, free starter rows, seeded by `00NN_platform_body_variants.sql` and by
|
|
11
|
+
* `ensureStarterCatalog`), each carrying a native-grid sheet and one authored `scale.stature`:
|
|
12
|
+
* 0.5 (bocil), 1.0 (normal) and 1.5 (tall), which is the whole usable range in
|
|
13
|
+
* `BODY_SCALE_LIMITS.stature`.
|
|
14
|
+
*
|
|
15
|
+
* The sheet is painted here as pixels and encoded by `png.ts`, so the bytes are reproducible from
|
|
16
|
+
* this file: `platform-body-data.ts` holds the stored data URL, `paintPlatformBody()` is the code
|
|
17
|
+
* that produces it, and a test compares the two. Nothing is fetched and nothing is hand-drawn in an
|
|
18
|
+
* image editor, so a change to a colour or a detail is a source change with a diff.
|
|
19
|
+
*
|
|
20
|
+
* The head is deliberately not one of the painted parts. A variant that listed the head would own
|
|
21
|
+
* the face rect and hide the player's face stamp; the platform body changes the body, and the face
|
|
22
|
+
* stays the player's.
|
|
23
|
+
*/
|
|
24
|
+
/** What one model is: its listing id, the label a player reads, and the stature it draws at. */
|
|
25
|
+
export interface PlatformBody {
|
|
26
|
+
/** The `cosmetic_item.id` this model is seeded as. */
|
|
27
|
+
id: string;
|
|
28
|
+
/** The listing name, in the platform's Indonesian item-copy style. */
|
|
29
|
+
name: string;
|
|
30
|
+
/** The authored `scale.stature`: the only knob that differs between the three models. */
|
|
31
|
+
stature: number;
|
|
32
|
+
/** Base cloth, the trim on cuffs/belt/boots, and the shade stripe on each front. */
|
|
33
|
+
colors: {
|
|
34
|
+
base: Rgb;
|
|
35
|
+
trim: Rgb;
|
|
36
|
+
shade: Rgb;
|
|
37
|
+
highlight: Rgb;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
type Rgb = readonly [number, number, number];
|
|
41
|
+
/**
|
|
42
|
+
* The three models. The colours differ so the size is not the only signal: a kid in mint, the
|
|
43
|
+
* canonical body in the platform blue, the tall one in ochre. Nothing here is a stat.
|
|
44
|
+
*/
|
|
45
|
+
export declare const PLATFORM_BODIES: readonly PlatformBody[];
|
|
46
|
+
/**
|
|
47
|
+
* The model as a 512 x 256 native-grid raster: every face of every painted part filled with its
|
|
48
|
+
* cloth, a belt on the torso, cuffs on the arms, boots on the legs, and one shade stripe down each
|
|
49
|
+
* front and back so a flat box still reads as a box. The head's rects stay transparent — the rig
|
|
50
|
+
* paints them at the player's skin tone.
|
|
51
|
+
*/
|
|
52
|
+
export declare function paintPlatformBody(body: PlatformBody): PngImage;
|
|
53
|
+
/** The manifest parts: every painted part, all six faces, no head. */
|
|
54
|
+
export declare function platformBodyParts(): {
|
|
55
|
+
part: CanonicalBone;
|
|
56
|
+
faces: FaceName[];
|
|
57
|
+
}[];
|
|
58
|
+
/** The proportion profile a model authors: one number, the rest canonical. */
|
|
59
|
+
export declare function platformBodyScale(body: PlatformBody): {
|
|
60
|
+
stature: number;
|
|
61
|
+
};
|
|
62
|
+
/** A seedable platform body as a `cosmetic_item` row: free, a starter, worn on the outfit slot. */
|
|
63
|
+
export interface PlatformBodyItem {
|
|
64
|
+
id: string;
|
|
65
|
+
slot: "outfit";
|
|
66
|
+
name: string;
|
|
67
|
+
/** The listing manifest the wardrobe and the renderer read. */
|
|
68
|
+
assetConfig: {
|
|
69
|
+
/** The generated sheet, as `data:image/png;base64,…`: the native grid itself. */
|
|
70
|
+
variant: string;
|
|
71
|
+
parts: {
|
|
72
|
+
part: CanonicalBone;
|
|
73
|
+
faces: FaceName[];
|
|
74
|
+
}[];
|
|
75
|
+
scale: {
|
|
76
|
+
stature: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Every platform body as the catalogue row it is seeded as. The three rows are ordinary free
|
|
82
|
+
* outfit listings, which is why a player picks a size by equipping one: `ensureStarterCatalog`
|
|
83
|
+
* inserts them and the starter flag owns them for everyone, so nothing is bought and nothing is a
|
|
84
|
+
* slider. The same list is what the migration `0068_platform_body_variants.sql` inserts, and
|
|
85
|
+
* `tests/platform-body.test.ts` compares the two.
|
|
86
|
+
*
|
|
87
|
+
* Built on first use rather than at import: a few kilobytes of base64 are not worth an API isolate's
|
|
88
|
+
* cold start, and a test that only reads `PLATFORM_BODIES` should not pay for the sheets.
|
|
89
|
+
*/
|
|
90
|
+
export declare function platformBodyItems(): readonly PlatformBodyItem[];
|
|
91
|
+
export {};
|
package/dist/plup3d.d.ts
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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: the round mascot the lobby shows, as a plain scene object any game can add.
|
|
11
|
+
*
|
|
12
|
+
* What makes it Plup and not a box: a bottom-heavy blob body wearing a 48 x 24 pixel map (sampled
|
|
13
|
+
* with no filtering, so the pixels stay pixels), a hard-banded toon shader with a rim, a dark ink
|
|
14
|
+
* outline and a neon edge from inverted hulls, rubber stub arms with round hands, flat round feet and
|
|
15
|
+
* a face stamped from the same named faces the films and the emotes use. Poses come from the same
|
|
16
|
+
* clips as every rig (a built-in, an emote's keyframes, a CC0 bake), so one animation moves it.
|
|
17
|
+
*
|
|
18
|
+
* Feet stand at y = 0, it faces +z, and the body is about 1.1 units tall: scale the group to taste.
|
|
19
|
+
*/
|
|
20
|
+
/** The expressions a face rule shows (the 8 x 4 stamp is built by `faceStamp` in skin-map, shared with the app). */
|
|
31
21
|
export type Expression = "idle" | "blink" | "happy" | "surprised" | "sad" | "wee";
|
|
32
22
|
export type PlupFace = NamedFace | Expression;
|
|
23
|
+
export type { BodyShapeId, FaceType } from "./skin-map";
|
|
24
|
+
export { BODY_SHAPES };
|
|
25
|
+
export interface ToonOptions {
|
|
26
|
+
map?: Texture;
|
|
27
|
+
color?: string;
|
|
28
|
+
/** Seen from both sides (an open shell). */
|
|
29
|
+
double?: boolean;
|
|
30
|
+
/** The inside's colour, for a lined cape; the outside's by default. */
|
|
31
|
+
back?: string;
|
|
32
|
+
/** How many times the map repeats across the surface. */
|
|
33
|
+
repeat?: readonly [number, number];
|
|
34
|
+
/** 0 cloth, ~0.5 satin, ~0.8 metal and glass. */
|
|
35
|
+
sheen?: number;
|
|
36
|
+
/** Anime hair: the skull's centre the shading wraps round, and how strong its angel ring is. */
|
|
37
|
+
anime?: {
|
|
38
|
+
center: readonly [number, number, number];
|
|
39
|
+
ring?: number;
|
|
40
|
+
/** The colour the hair runs to at the tips. */
|
|
41
|
+
tip?: string;
|
|
42
|
+
/** The underside of a lock, seen where it twists. */
|
|
43
|
+
inner?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export declare function toon(options: ToonOptions): ShaderMaterial;
|
|
33
47
|
/** A player's drawn skin: 24 rows of 48 palette letters and the face type they chose. */
|
|
34
48
|
export interface PlupSkin {
|
|
35
49
|
body: readonly string[];
|
|
@@ -42,8 +56,17 @@ export interface PlupOptions {
|
|
|
42
56
|
face?: PlupFace;
|
|
43
57
|
/** The player's own pixel skin (the platform's look). Without one the default Plup is drawn. */
|
|
44
58
|
skin?: PlupSkin;
|
|
59
|
+
/** The face type (dot, sparkle, sleepy, derp, anime) when no drawn skin is given. Default dot. */
|
|
60
|
+
faceType?: string;
|
|
61
|
+
/** The iris colour of the anime face. Default violet. */
|
|
62
|
+
eyeColor?: string;
|
|
45
63
|
/** The body proportions the player picked. Default `plup`. */
|
|
46
64
|
shape?: BodyShapeId;
|
|
65
|
+
/**
|
|
66
|
+
* An unusual body: stature, how thick the belly, arms and legs are, how big the head. The clips keep their
|
|
67
|
+
* angles and adapt (arms clear a wide belly, a heavy body jumps lower), see `plupProportions`.
|
|
68
|
+
*/
|
|
69
|
+
bodyScale?: Partial<BodyScale> | null;
|
|
47
70
|
/** A soft contact shadow under the feet. Default true. */
|
|
48
71
|
shadow?: boolean;
|
|
49
72
|
/**
|
|
@@ -53,6 +76,19 @@ export interface PlupOptions {
|
|
|
53
76
|
* clip's lift and sway, so any animation plays on any shape.
|
|
54
77
|
*/
|
|
55
78
|
model?: Object3D;
|
|
79
|
+
/**
|
|
80
|
+
* The outline and limbs: broad shoulders, a pinched waist, full hips, long legs, thick arms. With
|
|
81
|
+
* `shape` and `bodyScale` this is how a muscular, a curvy or a tall-and-slim Plup is made; see
|
|
82
|
+
* `BODY_PRESETS`. Everything it wears is fitted to it.
|
|
83
|
+
*/
|
|
84
|
+
body?: Partial<PlupBody> | null;
|
|
85
|
+
/** What it has on: real 3D pieces (`WEARABLES`), hair, headwear and clothes at once. */
|
|
86
|
+
wear?: readonly WearKey[];
|
|
87
|
+
/**
|
|
88
|
+
* A floppy body (see `ragdoll.ts`): `wobbly` limbs lag and overshoot like Human: Fall Flat, `limp`
|
|
89
|
+
* falls over. Default `off`: the clip is played exactly. A game can switch it any time with `ragdoll`.
|
|
90
|
+
*/
|
|
91
|
+
ragdoll?: RagdollMode;
|
|
56
92
|
}
|
|
57
93
|
export interface PlupHandle {
|
|
58
94
|
/** Add this to a scene. Feet at y = 0, facing +z, about 1.1 units tall. */
|
|
@@ -66,7 +102,19 @@ export interface PlupHandle {
|
|
|
66
102
|
/** A joint to attach things to (`armR`, `armL`, `legR`, `legL`) or the lifted body (`body`). */
|
|
67
103
|
bone: (name: string) => Object3D | undefined;
|
|
68
104
|
setFace: (face: PlupFace) => void;
|
|
105
|
+
/** Switch the floppy body: `off`, `wobbly` (active ragdoll) or `limp` (falls over). */
|
|
106
|
+
ragdoll: (mode: RagdollMode) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Shove it, in world units per second. A small push makes a wobbly body stagger; a big one (over about
|
|
109
|
+
* 2.5) knocks any body over. A body knocked over while `off` stays down until `ragdoll("off")`; a
|
|
110
|
+
* wobbly one gets back up by itself.
|
|
111
|
+
*/
|
|
112
|
+
push: (x: number, y: number, z: number) => void;
|
|
113
|
+
/** Lying on the ground after a fall. */
|
|
114
|
+
isDown: () => boolean;
|
|
69
115
|
setColor: (color: string) => void;
|
|
116
|
+
/** Put these on (and take off anything else). */
|
|
117
|
+
setWear: (wear: readonly WearKey[]) => void;
|
|
70
118
|
update: (deltaSeconds: number) => void;
|
|
71
119
|
dispose: () => void;
|
|
72
120
|
}
|
package/dist/png.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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.
|
|
@@ -53,9 +56,23 @@ export declare function decodePng(bytes: Uint8Array): {
|
|
|
53
56
|
ok: false;
|
|
54
57
|
reason: PngProblem;
|
|
55
58
|
};
|
|
59
|
+
/** Base64 without a DOM: the manifest's data URL is built on the Worker as well as in a test. */
|
|
60
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
56
61
|
/**
|
|
57
62
|
* Strict base64, because the manifest is a string a reader may have edited: `atob` accepts
|
|
58
63
|
* whitespace and silently ignores what it does not understand, and two spellings of one image would
|
|
59
64
|
* then hash differently. Anything that is not `A-Za-z0-9+/` padded to a multiple of four is refused.
|
|
60
65
|
*/
|
|
61
66
|
export declare function decodeBase64(value: string): Uint8Array<ArrayBuffer> | null;
|
|
67
|
+
/**
|
|
68
|
+
* The mirror of `decodePng`: an RGBA raster as PNG-24 with an alpha channel, 8 bits per channel,
|
|
69
|
+
* filter 0. That is exactly the format `NATIVE_SHEET_CAPS` describes, so the bytes a platform body
|
|
70
|
+
* model is seeded with are the bytes a creator could have uploaded — the same reader, the same
|
|
71
|
+
* clip-to-rect renderer, the same cap.
|
|
72
|
+
*
|
|
73
|
+
* `level` exists for the one caller that wants the smallest file it can get (a manifest stored in a
|
|
74
|
+
* SQL migration); the default matches `fflate`'s own.
|
|
75
|
+
*/
|
|
76
|
+
export declare function encodePng(image: PngImage, options?: {
|
|
77
|
+
level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
78
|
+
}): 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;
|