@plupin/character 0.5.0 → 0.6.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/dance-clips.d.ts +27 -0
- package/dist/ik-skeleton.d.ts +98 -0
- package/dist/plup3d.d.ts +9 -1
- package/dist/three.d.ts +3 -0
- package/dist/three.js +1536 -389
- package/dist/wear3d.d.ts +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JointFrame } from "./ik-skeleton";
|
|
2
|
+
/**
|
|
3
|
+
* High-detail 18-joint 3D IK Viral Dance Choreography Engine (`@plupin/character`).
|
|
4
|
+
*
|
|
5
|
+
* Uses the exact same 18-joint humanoid skeleton, 2-bone analytic knee IK, smootherstep timing,
|
|
6
|
+
* snap-and-drift beat holds, and `sampleLead` overlap/follow-through architecture proven in
|
|
7
|
+
* `content/kartun/tools/klip_tulis.mjs` (Passinho do Jamal), running continuously at full framerate.
|
|
8
|
+
*
|
|
9
|
+
* Every dance is an 8-beat musical phrase with real footwork, grounded foot planting, pelvis weight
|
|
10
|
+
* shift, torso twist, head lag, and accurate hand targets:
|
|
11
|
+
* - `brazil-funk`: Exact Passinho do Jamal 8-beat phrase (cross R/L, knee pop-in & heel-up,
|
|
12
|
+
* spread hop, deep squat fists low, squat bounce, hand-to-mouth "oh!").
|
|
13
|
+
* - `pacu-jalur`: Authentic "Aura Farming" (Rayyan Arkan Dikha, Kuansing Riau) — boat-wave knee
|
|
14
|
+
* balance, chest hand-roll ("gulung tangan"), wide right & left aura sweeps, alternating wave push.
|
|
15
|
+
* - `velocity`: TikTok Velocity / Jedag Jedug — silky slow-motion glide contrasting with razor-sharp
|
|
16
|
+
* beat-drop freezes & moving holds.
|
|
17
|
+
* - `griddy`: Authentic Griddy — alternating heel-dig taps (toe up!) + low-back arm swing curving up
|
|
18
|
+
* into "B / eye goggles" directly in front of the eyes.
|
|
19
|
+
* - `floss`: Authentic Backpack Kid Floss — wide planted stance, crisp opposite-phase pelvis snaps,
|
|
20
|
+
* and 4-beat front-hip / back-hip parallel arm passes.
|
|
21
|
+
* - `caramel`: Authentic Caramelldansen / Idol Bounce — wide bouncy hip sway, alternating heel-pops,
|
|
22
|
+
* raised elbows with double-time flapping cat/bunny-ear hands & joyful hop.
|
|
23
|
+
*/
|
|
24
|
+
export type IkDanceName = "brazil-funk" | "pacu-jalur" | "velocity" | "griddy" | "floss" | "caramel";
|
|
25
|
+
export declare function isIkDanceName(name: unknown): name is IkDanceName;
|
|
26
|
+
/** Sample a smooth 18-joint humanoid frame for any of the 6 viral dances at `seconds`. */
|
|
27
|
+
export declare function sampleIkDance(name: IkDanceName, seconds: number): JointFrame;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Quaternion, Vector3 } from "three";
|
|
2
|
+
import type { BakedClip } from "./clip-bake";
|
|
3
|
+
/**
|
|
4
|
+
* Unified 18-joint humanoid skeleton & Two-Bone Analytic Inverse Kinematics solver for `@plupin/character`.
|
|
5
|
+
*
|
|
6
|
+
* Plays BOTH:
|
|
7
|
+
* - Any Mixamo / Quaternius / CMU BVH mocap clip baked via `content/kartun/tools/klip_bake.mjs` (`BakedClip`)
|
|
8
|
+
* - Our 60fps 18-joint IK viral dance engine (`dance-clips.ts`)
|
|
9
|
+
*
|
|
10
|
+
* Solves exact foot-planted 2-bone knee IK, 2-bone arm IK with bust/torso clearance, pelvis/chest/head
|
|
11
|
+
* basis orientations, and spring follow-through so animations look fluid and grounded — never stiff FK sticks.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SKELETON_JOINTS: readonly ["pelvis", "spine", "neck", "head", "shoulder_l", "elbow_l", "wrist_l", "shoulder_r", "elbow_r", "wrist_r", "hip_l", "knee_l", "ankle_l", "toe_l", "hip_r", "knee_r", "ankle_r", "toe_r"];
|
|
14
|
+
export type JointName = (typeof SKELETON_JOINTS)[number];
|
|
15
|
+
/** World/character-space 3D position for every joint (pelvis ~1.0m at rest, floor y = 0, facing +Z). */
|
|
16
|
+
export type JointFrame = Record<JointName, Vector3>;
|
|
17
|
+
export interface RetargetMetrics {
|
|
18
|
+
/** Character pelvis/hip rest height above y = 0. */
|
|
19
|
+
hipHeight: number;
|
|
20
|
+
/** Half-distance between left and right hip pivots. */
|
|
21
|
+
hipHalfWidth: number;
|
|
22
|
+
/** Local hip anchor Y inside `lifted`. */
|
|
23
|
+
hipLocalY: number;
|
|
24
|
+
/** Half-distance between left and right shoulder pivots. */
|
|
25
|
+
shoulderHalfWidth: number;
|
|
26
|
+
/** Local shoulder anchor Y inside `lifted`. */
|
|
27
|
+
shoulderLocalY: number;
|
|
28
|
+
/** Total arm length (upper + lower). */
|
|
29
|
+
armLength: number;
|
|
30
|
+
/** Total leg length (thigh + shin). */
|
|
31
|
+
legLength: number;
|
|
32
|
+
/** Approximate torso clearance radius (x, z) so forearms/wrists never clip into bust/chest. */
|
|
33
|
+
torsoRadiusX: number;
|
|
34
|
+
torsoRadiusZ: number;
|
|
35
|
+
/** Local torso vertical center Y for clearance push-out. */
|
|
36
|
+
torsoCenterY: number;
|
|
37
|
+
/** True for classic round Plup (needs wider out-of-body push). */
|
|
38
|
+
isClassic: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface RetargetedPose {
|
|
41
|
+
/** Offset of `lifted` relative to character root (includes grounded pelvis drop + lateral hip shift). */
|
|
42
|
+
rootPos: Vector3;
|
|
43
|
+
/** Torso/pelvis world-local orientation. */
|
|
44
|
+
torsoQ: Quaternion;
|
|
45
|
+
/** Head local orientation relative to torso. */
|
|
46
|
+
headQ: Quaternion;
|
|
47
|
+
/** Arms in `lifted`-local space: `[shoulder, elbow, wrist]`. */
|
|
48
|
+
armL: [Vector3, Vector3, Vector3];
|
|
49
|
+
armR: [Vector3, Vector3, Vector3];
|
|
50
|
+
/** Legs in `lifted`-local space: `[hip, knee, ankle]` + foot orientation relative to shin. */
|
|
51
|
+
legL: {
|
|
52
|
+
pts: [Vector3, Vector3, Vector3];
|
|
53
|
+
footPitch: number;
|
|
54
|
+
footYaw: number;
|
|
55
|
+
};
|
|
56
|
+
legR: {
|
|
57
|
+
pts: [Vector3, Vector3, Vector3];
|
|
58
|
+
footPitch: number;
|
|
59
|
+
footYaw: number;
|
|
60
|
+
};
|
|
61
|
+
/** Elastic squash hint derived from vertical pelvis velocity. */
|
|
62
|
+
squash: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Exact analytic Two-Bone Inverse Kinematics solver (law of cosines):
|
|
66
|
+
* Given root joint `a`, end-effector target `c`, segment lengths `len1` & `len2`, and bend hint `pole`,
|
|
67
|
+
* returns the exact mid-joint (`elbow` or `knee`) position `b` and clamped reachable target `cOut`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function solveTwoBoneIK(a: Vector3, target: Vector3, len1: number, len2: number, poleDir: Vector3): {
|
|
70
|
+
mid: Vector3;
|
|
71
|
+
end: Vector3;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Sample an 18-joint `BakedClip` (Mixamo / Quaternius / CMU JSON from `klip_bake.mjs`) at time `seconds`
|
|
75
|
+
* using smooth Catmull-Rom cubic interpolation across frames.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sampleBakedJoints(clip: BakedClip, seconds: number): JointFrame;
|
|
78
|
+
/**
|
|
79
|
+
* Retarget a normalised 18-joint humanoid frame (`pelvis` ~1.0m at rest, floor `y = 0`, facing `+Z`)
|
|
80
|
+
* onto a Plup character (stylized anime Figure or Classic Plup) using exact 2-bone IK for both legs
|
|
81
|
+
* and arms, with floor-grounded foot planting and bust/torso clearance.
|
|
82
|
+
*/
|
|
83
|
+
export declare function retarget18JointPose(F: JointFrame, m: RetargetMetrics): RetargetedPose;
|
|
84
|
+
/**
|
|
85
|
+
* Aim a two-segment articulated limb (`upperPivot` -> `lowerPivot` -> `tip`) directly through
|
|
86
|
+
* 3 local points `a -> b -> c` using exact quaternions (zero gimbal lock, zero joint drift!).
|
|
87
|
+
*/
|
|
88
|
+
export declare function aimTwoBoneLimb(upperPivot: {
|
|
89
|
+
position: Vector3;
|
|
90
|
+
quaternion: Quaternion;
|
|
91
|
+
}, lowerPivot: {
|
|
92
|
+
position: Vector3;
|
|
93
|
+
quaternion: Quaternion;
|
|
94
|
+
}, a: Vector3, b: Vector3, c: Vector3): void;
|
|
95
|
+
/** Apply foot pitch/yaw cleanly to a shoe mesh inside a shin pivot. */
|
|
96
|
+
export declare function orientFoot(foot: {
|
|
97
|
+
quaternion: Quaternion;
|
|
98
|
+
}, pitch: number, yaw: number): void;
|
package/dist/plup3d.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Group, type Object3D, ShaderMaterial, type Texture } from "three";
|
|
1
|
+
import { Group, type Object3D, ShaderMaterial, type Texture, Vector2, Vector3 } from "three";
|
|
2
|
+
import type { BakedClip } from "./clip-bake";
|
|
2
3
|
import { type Emote } from "./emote";
|
|
3
4
|
import { type NamedFace } from "./faces";
|
|
4
5
|
import { type ClipRef, type Pose } from "./pose";
|
|
@@ -24,6 +25,11 @@ export interface ToonOptions {
|
|
|
24
25
|
back?: string;
|
|
25
26
|
repeat?: readonly [number, number];
|
|
26
27
|
sheen?: number;
|
|
28
|
+
/** Shared soft-body jiggle uniform (torso + fitted clothes deform in lockstep with zero clipping). */
|
|
29
|
+
jiggle?: {
|
|
30
|
+
value: Vector3;
|
|
31
|
+
band: Vector2;
|
|
32
|
+
};
|
|
27
33
|
anime?: {
|
|
28
34
|
center: readonly [number, number, number];
|
|
29
35
|
ring?: number;
|
|
@@ -57,6 +63,8 @@ export interface PlupOptions {
|
|
|
57
63
|
export interface PlupHandle {
|
|
58
64
|
object: Group;
|
|
59
65
|
play: (clip: ClipRef) => void;
|
|
66
|
+
/** Play any 18-joint Mixamo / Quaternius / CMU mocap JSON baked via `klip_bake.mjs` using full 2-bone IK. Pass `null` to stop. */
|
|
67
|
+
playBaked: (clip: BakedClip | null) => void;
|
|
60
68
|
emote: (name: string, custom?: Emote) => Emote | undefined;
|
|
61
69
|
pose: (pose: Pose) => void;
|
|
62
70
|
bone: (name: string) => Object3D | undefined;
|
package/dist/three.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { type Emote } from "./emote";
|
|
|
3
3
|
export { ANIME_FACE_SIZE, ANIME_FACE_UV, drawAnimeFace } from "./anime-face";
|
|
4
4
|
export { blobRadiusAt, buildBlobGeometry, buildFigureHeadGeometry, buildFigureTorsoGeometry, figureTorsoPoint, } from "./blob";
|
|
5
5
|
export { BODY_PRESETS } from "./body-presets";
|
|
6
|
+
export type { BakedClip } from "./clip-bake";
|
|
6
7
|
export { AUTHORED_CLIPS } from "./clips";
|
|
8
|
+
export { type IkDanceName, isIkDanceName, sampleIkDance } from "./dance-clips";
|
|
7
9
|
export { buildWear } from "./dress";
|
|
8
10
|
export { EMOTES } from "./emote";
|
|
11
|
+
export { aimTwoBoneLimb, type JointFrame, type JointName, orientFoot, type RetargetedPose, type RetargetMetrics, retarget18JointPose, SKELETON_JOINTS, sampleBakedJoints, solveTwoBoneIK, } from "./ik-skeleton";
|
|
9
12
|
export { isHighResFace } from "./skin-map";
|
|
10
13
|
export type { WearKit, WornPiece } from "./wear3d";
|
|
11
14
|
export { hairVolume, isHairKey, isWearKey, WEARABLES, wearSlotOf } from "./wearables";
|