@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/clips.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CustomClip } from "./pose";
|
|
2
|
+
import type { CanonicalBone } from "./rig";
|
|
3
|
+
/**
|
|
4
|
+
* The hand-keyed clips: one authored pose at a time, expanded into the same keyframe format a creator
|
|
5
|
+
* ships (`CustomClip`), so the built-in vocabulary and an uploaded animation are one shape. The rig
|
|
6
|
+
* has six bones, and every frame lists them in `AUTHORED_BONES` order, then one lift in studs.
|
|
7
|
+
*
|
|
8
|
+
* A named clip in `CLIPS` is this data sampled at `t`; an emote may name it or ship its own `anim`.
|
|
9
|
+
* Nothing here touches three.js, a DOM or the network, and every number stays inside `ANIM_CAPS`
|
|
10
|
+
* (`listing.ts`) so a creator can copy any of these into a listing unchanged.
|
|
11
|
+
*
|
|
12
|
+
* Angles follow the rig's euler order (x, y, z):
|
|
13
|
+
* - `z` swings a limb out to the side; for arms `armR` is positive and `armL` negative, and about
|
|
14
|
+
* 2.6 rad is overhead.
|
|
15
|
+
* - `x` swings a limb forward (negative) or back (positive); on the torso and head it pitches the
|
|
16
|
+
* body forward (positive) or back.
|
|
17
|
+
* - `y` turns the head left or right.
|
|
18
|
+
* - `lift` raises the whole character in studs. It never goes below 0: the rig has no knees, so a
|
|
19
|
+
* negative lift would push the feet through the floor.
|
|
20
|
+
*/
|
|
21
|
+
export declare const AUTHORED_BONES: readonly CanonicalBone[];
|
|
22
|
+
/** Every clip keyed by hand: the vocabulary an emote or a creator may name. */
|
|
23
|
+
export declare const AUTHORED_CLIP_NAMES: readonly ["recoil", "flail", "topple", "collapse", "sneak", "cheer", "laugh", "pose", "rage", "sob", "nod", "brazil-funk", "pacu-jalur", "velocity", "griddy", "floss", "caramel"];
|
|
24
|
+
export type AuthoredClipName = (typeof AUTHORED_CLIP_NAMES)[number];
|
|
25
|
+
/**
|
|
26
|
+
* The keyed library. Each entry is a motion a viewer can name from the pose alone:
|
|
27
|
+
*
|
|
28
|
+
* - `recoil` snaps the body back with both arms thrown up, then settles: a fright or a flinch.
|
|
29
|
+
* - `flail` is airborne, arms windmilling and legs kicking, held up by `lift`.
|
|
30
|
+
* - `topple` tips over sideways and stays down.
|
|
31
|
+
* - `collapse` buckles at the knees and folds forward until it is still.
|
|
32
|
+
* - `sneak` creeps forward, low, hands up, head scanning left and right.
|
|
33
|
+
* - `cheer` throws both arms overhead and hops.
|
|
34
|
+
* - `laugh` folds forward and shakes, arms hugged across the belly.
|
|
35
|
+
* - `pose` puts a hand on the hip and cocks its head.
|
|
36
|
+
* - `rage` stomps and shakes with the arms clenched low.
|
|
37
|
+
* - `sob` brings both hands to the face while the shoulders heave.
|
|
38
|
+
* - `nod` is a slow, deliberate nod: the quiet yes.
|
|
39
|
+
*/
|
|
40
|
+
export declare const AUTHORED_CLIPS: Readonly<Record<AuthoredClipName, CustomClip>>;
|
package/dist/dress.d.ts
ADDED
package/dist/emote.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { NamedFace } from "./faces";
|
|
2
2
|
import type { ClipName, CustomClip } from "./pose";
|
|
3
3
|
/**
|
|
4
|
-
* An emote is a name, a face and a clip the rig
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* An emote is a name, a face and a clip the rig plays. Every clip here is an authored motion: the six
|
|
5
|
+
* procedural loops plus the keyframe library in `clips.ts` (`recoil`, `sneak`, `collapse`, ...), so a
|
|
6
|
+
* label like "Tewas" performs a collapse instead of borrowing idle. `sigmaPrice` 0 is free for
|
|
7
|
+
* everyone; anything else is bought in the shop (wardrobe), and the catalogue row has the same id. A
|
|
8
|
+
* game plays the face and the clip; whether a player may is the platform's to say.
|
|
7
9
|
*/
|
|
8
10
|
export interface Emote {
|
|
9
11
|
/** The catalogue id, also what a game passes: `emote-ngakak`. */
|
package/dist/gaze.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Damped spring step (semi-implicit Euler), shared by Character's squash, sway and gaze springs.
|
|
3
|
+
* Returns the new [value, velocity].
|
|
4
|
+
*/
|
|
5
|
+
/** One step of a damped spring, shared by the gaze and the body. */
|
|
6
|
+
export declare function spring(value: number, velocity: number, target: number, stiffness: number, damping: number, dt: number): readonly [number, number];
|
|
7
|
+
/**
|
|
8
|
+
* Character eye gaze (landing spec section D2; numbers from section 0, N9). The pointer offset from
|
|
9
|
+
* the face, in body widths (BW), becomes one eye cell: X -2..2, Y -1..0 (Q9: the eyes never move down). Only the eyes move; the
|
|
10
|
+
* mouth never does (skin.ts composeSkin). Pure, so the cell table is tested without a renderer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const GAZE: {
|
|
13
|
+
/** Spring: stiffness 400, damping 36 (omega = 20 rad/s, zeta = 0.9). */
|
|
14
|
+
readonly k: 400;
|
|
15
|
+
readonly c: 36;
|
|
16
|
+
/** Gaze units per BW. */
|
|
17
|
+
readonly gain: 1.6;
|
|
18
|
+
readonly clampX: 2.4;
|
|
19
|
+
readonly clampY: 1.4;
|
|
20
|
+
/** An offset under this many BW is a dead zone. */
|
|
21
|
+
readonly deadBW: 0.25;
|
|
22
|
+
/** Beyond nearBW the gaze starts to fade; by farBW it is gone. */
|
|
23
|
+
readonly nearBW: 3;
|
|
24
|
+
readonly farBW: 5;
|
|
25
|
+
/** Cell hysteresis in gaze units: enter 0.6 (1 to 2 at 1.6), leave 0.4 (2 to 1 at 1.4). */
|
|
26
|
+
readonly enter1: 0.6;
|
|
27
|
+
readonly enter2: 1.6;
|
|
28
|
+
readonly exit1: 0.4;
|
|
29
|
+
readonly exit2: 1.4;
|
|
30
|
+
/** Reduced motion (D5): the cell may update at most this often, in seconds. */
|
|
31
|
+
readonly snapEveryS: 0.25;
|
|
32
|
+
};
|
|
33
|
+
export interface Point {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
}
|
|
37
|
+
export interface Spring {
|
|
38
|
+
value: number;
|
|
39
|
+
velocity: number;
|
|
40
|
+
}
|
|
41
|
+
export interface Gaze {
|
|
42
|
+
x: Spring;
|
|
43
|
+
y: Spring;
|
|
44
|
+
cellX: number;
|
|
45
|
+
cellY: number;
|
|
46
|
+
}
|
|
47
|
+
export declare const NO_GAZE: Gaze;
|
|
48
|
+
/** Gaze target for a pointer offset in BW: the D2 mapping, with its dead zone. */
|
|
49
|
+
export declare function gazeTarget(dxBW: number, dyBW: number): Point;
|
|
50
|
+
/** One step of the gaze spring (k 400, c 36). */
|
|
51
|
+
export declare function springStep(s: Spring, target: number, dt: number): Spring;
|
|
52
|
+
/**
|
|
53
|
+
* Eye cell for a gaze value, with hysteresis. `twoCells` lets X reach +-2; Y stops at +-1.
|
|
54
|
+
* Crossing the centre resets the cell, so the eyes never jump across it.
|
|
55
|
+
*/
|
|
56
|
+
export declare function nextCell(prev: number, value: number, twoCells: boolean): number;
|
|
57
|
+
export declare function stepGaze(gaze: Gaze, target: Point, dt: number): Gaze;
|
|
58
|
+
/** Reduced motion (D5): the gaze cell may update only this often (at most 4 times a second). */
|
|
59
|
+
export declare function snapDue(lastAt: number, now: number): boolean;
|
|
60
|
+
/** Reduced motion (D5): no spring, the cell follows the target at once. The caller paces it with snapDue. */
|
|
61
|
+
export declare function snapGaze(gaze: Gaze, target: Point): Gaze;
|
|
62
|
+
/**
|
|
63
|
+
* Where a pointer is from a Character, as a direction whose length grows with distance, levels off below 1
|
|
64
|
+
* and fades to nothing for a pointer that is not near. Pure, so the mapping is tested without a page.
|
|
65
|
+
*/
|
|
66
|
+
export declare function towardFrom(at: {
|
|
67
|
+
px: number;
|
|
68
|
+
py: number;
|
|
69
|
+
moved: boolean;
|
|
70
|
+
}, rect: {
|
|
71
|
+
left: number;
|
|
72
|
+
top: number;
|
|
73
|
+
width: number;
|
|
74
|
+
height: number;
|
|
75
|
+
}): {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
};
|
|
79
|
+
/** How far away (in Character heights) the pointer still draws the eyes and the turn, in full and not at all. */
|
|
80
|
+
export declare const NEAR_FULL = 1.4;
|
|
81
|
+
export declare const NEAR_NONE = 2.4;
|
package/dist/gaze.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/gaze.ts
|
|
2
|
+
function spring(value, velocity, target, stiffness, damping, dt) {
|
|
3
|
+
const acceleration = -stiffness * (value - target) - damping * velocity;
|
|
4
|
+
const nextVelocity = velocity + acceleration * dt;
|
|
5
|
+
return [value + nextVelocity * dt, nextVelocity];
|
|
6
|
+
}
|
|
7
|
+
var GAZE = {
|
|
8
|
+
k: 400,
|
|
9
|
+
c: 36,
|
|
10
|
+
gain: 1.6,
|
|
11
|
+
clampX: 2.4,
|
|
12
|
+
clampY: 1.4,
|
|
13
|
+
deadBW: 0.25,
|
|
14
|
+
nearBW: 3,
|
|
15
|
+
farBW: 5,
|
|
16
|
+
enter1: 0.6,
|
|
17
|
+
enter2: 1.6,
|
|
18
|
+
exit1: 0.4,
|
|
19
|
+
exit2: 1.4,
|
|
20
|
+
snapEveryS: 0.25
|
|
21
|
+
};
|
|
22
|
+
var MAX_CELL_Y = 0;
|
|
23
|
+
var lookCellY = (cell) => Math.min(MAX_CELL_Y, cell);
|
|
24
|
+
var NO_GAZE = {
|
|
25
|
+
x: { value: 0, velocity: 0 },
|
|
26
|
+
y: { value: 0, velocity: 0 },
|
|
27
|
+
cellX: 0,
|
|
28
|
+
cellY: 0
|
|
29
|
+
};
|
|
30
|
+
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
31
|
+
function gazeTarget(dxBW, dyBW) {
|
|
32
|
+
const dx = Math.abs(dxBW) < GAZE.deadBW ? 0 : dxBW;
|
|
33
|
+
const dy = Math.abs(dyBW) < GAZE.deadBW ? 0 : dyBW;
|
|
34
|
+
const distance = Math.hypot(dxBW, dyBW);
|
|
35
|
+
const near = 1 - clamp((distance - GAZE.nearBW) / (GAZE.farBW - GAZE.nearBW), 0, 1);
|
|
36
|
+
return {
|
|
37
|
+
x: clamp(GAZE.gain * dx, -GAZE.clampX, GAZE.clampX) * near,
|
|
38
|
+
y: clamp(GAZE.gain * dy, -GAZE.clampY, GAZE.clampY) * near
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function springStep(s, target, dt) {
|
|
42
|
+
const [value, velocity] = spring(s.value, s.velocity, target, GAZE.k, GAZE.c, dt);
|
|
43
|
+
return { value, velocity };
|
|
44
|
+
}
|
|
45
|
+
function nextCell(prev, value, twoCells) {
|
|
46
|
+
const magnitude = Math.abs(value);
|
|
47
|
+
const sign = Math.sign(value);
|
|
48
|
+
const prevSign = Math.sign(prev);
|
|
49
|
+
let cell = prevSign !== 0 && sign !== 0 && sign !== prevSign ? 0 : Math.abs(prev);
|
|
50
|
+
if (cell === 0 && magnitude > GAZE.enter1)
|
|
51
|
+
cell = 1;
|
|
52
|
+
if (twoCells && cell === 1 && magnitude > GAZE.enter2)
|
|
53
|
+
cell = 2;
|
|
54
|
+
if (cell === 2 && magnitude < GAZE.exit2)
|
|
55
|
+
cell = 1;
|
|
56
|
+
if (cell === 1 && magnitude < GAZE.exit1)
|
|
57
|
+
cell = 0;
|
|
58
|
+
if (cell === 0)
|
|
59
|
+
return 0;
|
|
60
|
+
return sign < 0 ? -cell : cell;
|
|
61
|
+
}
|
|
62
|
+
function stepGaze(gaze, target, dt) {
|
|
63
|
+
const x = springStep(gaze.x, target.x, dt);
|
|
64
|
+
const y = springStep(gaze.y, target.y, dt);
|
|
65
|
+
return {
|
|
66
|
+
x,
|
|
67
|
+
y,
|
|
68
|
+
cellX: nextCell(gaze.cellX, x.value, true),
|
|
69
|
+
cellY: lookCellY(nextCell(gaze.cellY, y.value, false))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function snapDue(lastAt, now) {
|
|
73
|
+
return now - lastAt >= GAZE.snapEveryS;
|
|
74
|
+
}
|
|
75
|
+
function snapGaze(gaze, target) {
|
|
76
|
+
const x = { value: target.x, velocity: 0 };
|
|
77
|
+
const y = { value: target.y, velocity: 0 };
|
|
78
|
+
return {
|
|
79
|
+
x,
|
|
80
|
+
y,
|
|
81
|
+
cellX: nextCell(gaze.cellX, x.value, true),
|
|
82
|
+
cellY: lookCellY(nextCell(gaze.cellY, y.value, false))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function towardFrom(at, rect) {
|
|
86
|
+
if (!at.moved)
|
|
87
|
+
return { x: 0, y: 0 };
|
|
88
|
+
const size = Math.max(1, rect.height);
|
|
89
|
+
const dx = (at.px - (rect.left + rect.width / 2)) / size;
|
|
90
|
+
const dy = (at.py - (rect.top + rect.height * 0.45)) / size;
|
|
91
|
+
const distance = Math.hypot(dx, dy);
|
|
92
|
+
if (distance < 0.0001)
|
|
93
|
+
return { x: 0, y: 0 };
|
|
94
|
+
const reach = Math.tanh(distance * 1.4) / distance;
|
|
95
|
+
const near = 1 - Math.min(1, Math.max(0, (distance - NEAR_FULL) / (NEAR_NONE - NEAR_FULL)));
|
|
96
|
+
return { x: dx * reach * near + 0, y: dy * reach * near + 0 };
|
|
97
|
+
}
|
|
98
|
+
var NEAR_FULL = 1.4;
|
|
99
|
+
var NEAR_NONE = 2.4;
|
|
100
|
+
export {
|
|
101
|
+
towardFrom,
|
|
102
|
+
stepGaze,
|
|
103
|
+
springStep,
|
|
104
|
+
spring,
|
|
105
|
+
snapGaze,
|
|
106
|
+
snapDue,
|
|
107
|
+
nextCell,
|
|
108
|
+
gazeTarget,
|
|
109
|
+
NO_GAZE,
|
|
110
|
+
NEAR_NONE,
|
|
111
|
+
NEAR_FULL,
|
|
112
|
+
GAZE
|
|
113
|
+
};
|
package/dist/hair3d.d.ts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
export type { BodyPresetId } from "./body-presets";
|
|
2
|
+
export { BODY_PRESETS } from "./body-presets";
|
|
3
|
+
export type { AuthoredClipName } from "./clips";
|
|
4
|
+
export { AUTHORED_BONES, AUTHORED_CLIP_NAMES, AUTHORED_CLIPS } from "./clips";
|
|
1
5
|
export type { Emote } from "./emote";
|
|
2
6
|
export { EMOTES, emoteOf } from "./emote";
|
|
3
7
|
export type { NamedFace } from "./faces";
|
|
4
8
|
export { FACE_STAMP_PALETTE, isNamedFace, NAMED_FACE_STAMPS, NAMED_FACES } from "./faces";
|
|
5
9
|
export type { ClipName, ClipRef, CustomClip, Pose, Rotation } from "./pose";
|
|
6
10
|
export { CLIPS, clipLift, customDuration, isCustomClip, mergePoses, resolvePose, sampleClip, } from "./pose";
|
|
11
|
+
export { createRagdoll, RAGDOLL_JOINTS, type Ragdoll, type RagdollMode } from "./ragdoll";
|
|
7
12
|
export type { Bone, CanonicalBone, Rig, RigId, Vec3 } from "./rig";
|
|
8
13
|
export { boneOf, RIGS } from "./rig";
|
|
9
14
|
export type { FaceName, PartFaces, Rect } from "./skin";
|
|
10
15
|
export { CLASSIC_BONES, CLASSIC_HEIGHT, CLASSIC_LEFT_LIMB, CLASSIC_RIGHT_LIMB, CLASSIC_TORSO, CLASSIC_WIDTH, classicFaceRect, validateClassicTemplate, } from "./skin";
|
|
11
|
-
export type { BodyScale, BodyVariant, BoneSkin, CanonicalBox, CanonicalFootprint, CharacterLook, ClassicConversion, NativeMapping, NativePart, ScaledBone, SkinImage, VariantPart, VariantSheetCheck, VariantSheetFacts, VariantSheetProblem, } from "./skin-native";
|
|
12
|
-
export { BODY_SCALE_LIMITS, boneSkin, CANONICAL_BODY_SCALE, CLASSIC_TO_NATIVE, canonicalFootprint, clampBodyScale, NATIVE_ARM_LEFT, NATIVE_ARM_RIGHT, NATIVE_BONES, NATIVE_HEAD, NATIVE_HEIGHT, NATIVE_LEG_LEFT, NATIVE_LEG_RIGHT, NATIVE_PARTS, NATIVE_PX_PER_STUD, NATIVE_SHEET_CAPS, NATIVE_TORSO, NATIVE_WIDTH, nativeFaceRect, nativePartOf, scaleBone, validateVariantSheet, visualEnvelope, } from "./skin-native";
|
|
16
|
+
export type { BodyScale, BodyVariant, BoneSkin, CanonicalBox, CanonicalFootprint, CharacterLook, ClassicConversion, NativeMapping, NativePart, PlupBody, ScaledBone, SkinImage, VariantPart, VariantSheetCheck, VariantSheetFacts, VariantSheetProblem, } from "./skin-native";
|
|
17
|
+
export { BODY_SCALE_LIMITS, boneSkin, CANONICAL_BODY_SCALE, CANONICAL_PLUP_BODY, CLASSIC_TO_NATIVE, canonicalFootprint, clampBodyScale, clampPlupBody, NATIVE_ARM_LEFT, NATIVE_ARM_RIGHT, NATIVE_BONES, NATIVE_HEAD, NATIVE_HEIGHT, NATIVE_LEG_LEFT, NATIVE_LEG_RIGHT, NATIVE_PARTS, NATIVE_PX_PER_STUD, NATIVE_SHEET_CAPS, NATIVE_TORSO, NATIVE_WIDTH, nativeFaceRect, nativePartOf, PLUP_BODY_LIMITS, scaleBone, validateVariantSheet, visualEnvelope, } from "./skin-native";
|
|
18
|
+
export type { WearKey } from "./wearables";
|
|
19
|
+
export { isWearKey, WEAR_KEYS, WEARABLES, wearableItems, wearKeyOf, wearKeysOf, wearSlotOf, wearView, } from "./wearables";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BODY_PRESETS,
|
|
2
3
|
EMOTES,
|
|
4
|
+
RAGDOLL_JOINTS,
|
|
5
|
+
createRagdoll,
|
|
3
6
|
emoteOf
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-rqenm9tn.js";
|
|
8
|
+
import {
|
|
9
|
+
WEARABLES,
|
|
10
|
+
WEAR_KEYS,
|
|
11
|
+
isWearKey,
|
|
12
|
+
wearKeyOf,
|
|
13
|
+
wearKeysOf,
|
|
14
|
+
wearSlotOf,
|
|
15
|
+
wearView,
|
|
16
|
+
wearableItems
|
|
17
|
+
} from "./chunk-kf7f1tdx.js";
|
|
5
18
|
import {
|
|
6
19
|
BODY_SCALE_LIMITS,
|
|
7
20
|
CANONICAL_BODY_SCALE,
|
|
21
|
+
CANONICAL_PLUP_BODY,
|
|
8
22
|
CLASSIC_BONES,
|
|
9
23
|
CLASSIC_HEIGHT,
|
|
10
24
|
CLASSIC_LEFT_LIMB,
|
|
@@ -24,9 +38,11 @@ import {
|
|
|
24
38
|
NATIVE_SHEET_CAPS,
|
|
25
39
|
NATIVE_TORSO,
|
|
26
40
|
NATIVE_WIDTH,
|
|
41
|
+
PLUP_BODY_LIMITS,
|
|
27
42
|
boneSkin,
|
|
28
43
|
canonicalFootprint,
|
|
29
44
|
clampBodyScale,
|
|
45
|
+
clampPlupBody,
|
|
30
46
|
classicFaceRect,
|
|
31
47
|
nativeFaceRect,
|
|
32
48
|
nativePartOf,
|
|
@@ -34,14 +50,11 @@ import {
|
|
|
34
50
|
validateClassicTemplate,
|
|
35
51
|
validateVariantSheet,
|
|
36
52
|
visualEnvelope
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import {
|
|
39
|
-
FACE_STAMP_PALETTE,
|
|
40
|
-
NAMED_FACES,
|
|
41
|
-
NAMED_FACE_STAMPS,
|
|
42
|
-
isNamedFace
|
|
43
|
-
} from "./chunk-aa5nstet.js";
|
|
53
|
+
} from "./chunk-ew73g2v7.js";
|
|
44
54
|
import {
|
|
55
|
+
AUTHORED_BONES,
|
|
56
|
+
AUTHORED_CLIPS,
|
|
57
|
+
AUTHORED_CLIP_NAMES,
|
|
45
58
|
CLIPS,
|
|
46
59
|
RIGS,
|
|
47
60
|
boneOf,
|
|
@@ -51,8 +64,19 @@ import {
|
|
|
51
64
|
mergePoses,
|
|
52
65
|
resolvePose,
|
|
53
66
|
sampleClip
|
|
54
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-7ry0n8cw.js";
|
|
68
|
+
import {
|
|
69
|
+
FACE_STAMP_PALETTE,
|
|
70
|
+
NAMED_FACES,
|
|
71
|
+
NAMED_FACE_STAMPS,
|
|
72
|
+
isNamedFace
|
|
73
|
+
} from "./chunk-aa5nstet.js";
|
|
55
74
|
export {
|
|
75
|
+
wearableItems,
|
|
76
|
+
wearView,
|
|
77
|
+
wearSlotOf,
|
|
78
|
+
wearKeysOf,
|
|
79
|
+
wearKeyOf,
|
|
56
80
|
visualEnvelope,
|
|
57
81
|
validateVariantSheet,
|
|
58
82
|
validateClassicTemplate,
|
|
@@ -62,17 +86,24 @@ export {
|
|
|
62
86
|
nativePartOf,
|
|
63
87
|
nativeFaceRect,
|
|
64
88
|
mergePoses,
|
|
89
|
+
isWearKey,
|
|
65
90
|
isNamedFace,
|
|
66
91
|
isCustomClip,
|
|
67
92
|
emoteOf,
|
|
68
93
|
customDuration,
|
|
94
|
+
createRagdoll,
|
|
69
95
|
clipLift,
|
|
70
96
|
classicFaceRect,
|
|
97
|
+
clampPlupBody,
|
|
71
98
|
clampBodyScale,
|
|
72
99
|
canonicalFootprint,
|
|
73
100
|
boneSkin,
|
|
74
101
|
boneOf,
|
|
102
|
+
WEAR_KEYS,
|
|
103
|
+
WEARABLES,
|
|
75
104
|
RIGS,
|
|
105
|
+
RAGDOLL_JOINTS,
|
|
106
|
+
PLUP_BODY_LIMITS,
|
|
76
107
|
NATIVE_WIDTH,
|
|
77
108
|
NATIVE_TORSO,
|
|
78
109
|
NATIVE_SHEET_CAPS,
|
|
@@ -97,6 +128,11 @@ export {
|
|
|
97
128
|
CLASSIC_LEFT_LIMB,
|
|
98
129
|
CLASSIC_HEIGHT,
|
|
99
130
|
CLASSIC_BONES,
|
|
131
|
+
CANONICAL_PLUP_BODY,
|
|
100
132
|
CANONICAL_BODY_SCALE,
|
|
101
|
-
BODY_SCALE_LIMITS
|
|
133
|
+
BODY_SCALE_LIMITS,
|
|
134
|
+
BODY_PRESETS,
|
|
135
|
+
AUTHORED_CLIP_NAMES,
|
|
136
|
+
AUTHORED_CLIPS,
|
|
137
|
+
AUTHORED_BONES
|
|
102
138
|
};
|
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-ew73g2v7.js";
|
|
11
|
+
import {
|
|
12
|
+
CLIPS
|
|
13
|
+
} from "./chunk-7ry0n8cw.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 {
|
|
22
|
+
import { Unzlib, 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 };
|
|
@@ -115,6 +115,37 @@ function unfilter(raw, width, height, channels) {
|
|
|
115
115
|
}
|
|
116
116
|
return out;
|
|
117
117
|
}
|
|
118
|
+
var INFLATE_INPUT_CHUNK = 512;
|
|
119
|
+
var INFLATE_OVERFLOW = new Error("zlib output cap exceeded");
|
|
120
|
+
function unzlibBounded(compressed, maxBytes) {
|
|
121
|
+
if (compressed.length < 6)
|
|
122
|
+
return null;
|
|
123
|
+
const bodyEnd = compressed.length - 4;
|
|
124
|
+
const output = [];
|
|
125
|
+
let total = 0;
|
|
126
|
+
const stream = new Unzlib((data) => {
|
|
127
|
+
total += data.length;
|
|
128
|
+
if (total > maxBytes)
|
|
129
|
+
throw INFLATE_OVERFLOW;
|
|
130
|
+
if (data.length > 0)
|
|
131
|
+
output.push(data);
|
|
132
|
+
});
|
|
133
|
+
try {
|
|
134
|
+
for (let at2 = 0;at2 < bodyEnd; at2 += INFLATE_INPUT_CHUNK) {
|
|
135
|
+
stream.push(compressed.subarray(at2, Math.min(at2 + INFLATE_INPUT_CHUNK, bodyEnd)), false);
|
|
136
|
+
}
|
|
137
|
+
stream.push(compressed.subarray(bodyEnd), true);
|
|
138
|
+
} catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const raw = new Uint8Array(total);
|
|
142
|
+
let at = 0;
|
|
143
|
+
for (const part of output) {
|
|
144
|
+
raw.set(part, at);
|
|
145
|
+
at += part.length;
|
|
146
|
+
}
|
|
147
|
+
return raw;
|
|
148
|
+
}
|
|
118
149
|
function decodePng(bytes) {
|
|
119
150
|
const header = readPngHeader(bytes);
|
|
120
151
|
if (!header.ok)
|
|
@@ -141,13 +172,9 @@ function decodePng(bytes) {
|
|
|
141
172
|
compressed.set(part, offset);
|
|
142
173
|
offset += part.length;
|
|
143
174
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} catch {
|
|
148
|
-
return { ok: false, reason: "corrupt" };
|
|
149
|
-
}
|
|
150
|
-
if (raw.length < (width * channels + 1) * height)
|
|
175
|
+
const expected = (width * channels + 1) * height;
|
|
176
|
+
const raw = unzlibBounded(compressed, expected + 1024);
|
|
177
|
+
if (!raw || raw.length < expected)
|
|
151
178
|
return { ok: false, reason: "corrupt" };
|
|
152
179
|
const pixels = unfilter(raw, width, height, channels);
|
|
153
180
|
if (!pixels)
|
|
@@ -189,6 +216,16 @@ function decodeBase64(value) {
|
|
|
189
216
|
}
|
|
190
217
|
return bytes;
|
|
191
218
|
}
|
|
219
|
+
var CRC_TABLE = (() => {
|
|
220
|
+
const table = new Uint32Array(256);
|
|
221
|
+
for (let index = 0;index < 256; index++) {
|
|
222
|
+
let value = index;
|
|
223
|
+
for (let bit = 0;bit < 8; bit++)
|
|
224
|
+
value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
|
|
225
|
+
table[index] = value >>> 0;
|
|
226
|
+
}
|
|
227
|
+
return table;
|
|
228
|
+
})();
|
|
192
229
|
|
|
193
230
|
// src/listing.ts
|
|
194
231
|
var LISTABLE_SLOTS = ["outfit", "hair", "accessory", "emote"];
|
|
@@ -593,10 +630,9 @@ function drawnFace(assetConfig) {
|
|
|
593
630
|
}
|
|
594
631
|
function namedFace(assetConfig) {
|
|
595
632
|
const face = assetConfig.face;
|
|
596
|
-
if (typeof face !== "string")
|
|
633
|
+
if (typeof face !== "string" || !Object.hasOwn(NAMED_FACE_STAMPS, face))
|
|
597
634
|
return null;
|
|
598
|
-
|
|
599
|
-
return rows ?? null;
|
|
635
|
+
return NAMED_FACE_STAMPS[face] ?? null;
|
|
600
636
|
}
|
|
601
637
|
function escapeXml(value) {
|
|
602
638
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
@@ -699,7 +735,7 @@ function renderListingPreview(input) {
|
|
|
699
735
|
const colour = typeof assetConfig.color === "string" && COLOR_PATTERN.test(assetConfig.color) ? assetConfig.color.toLowerCase() : BODY;
|
|
700
736
|
const pixels = new Map;
|
|
701
737
|
if (kind === "sheet" || kind === "bodyVariant" || kind === "accessory") {
|
|
702
|
-
paintArtItem(pixels, assetConfig, kind, input.slot);
|
|
738
|
+
paintArtItem(pixels, assetConfig, kind, input.slot === "hat" ? "hair" : input.slot);
|
|
703
739
|
} else {
|
|
704
740
|
paint(pixels, 5, 17, 14, 4, input.slot === "emote" ? BODY : colour);
|
|
705
741
|
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 {};
|