ara3d 0.0.0-stage → 0.2.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/README.md +40 -2
- package/dist/cli.js +57 -0
- package/dist/index.js +1806 -0
- package/dist/types/packages/cli/src/index.d.ts +89 -0
- package/dist/types/packages/cli/src/library/colors.d.ts +9 -0
- package/dist/types/packages/cli/src/library/generate.d.ts +40 -0
- package/dist/types/packages/cli/src/library/worker.d.ts +22 -0
- package/dist/types/src/app/character-assist.d.ts +73 -0
- package/dist/types/src/app/share.d.ts +19 -0
- package/dist/types/src/core/anim/boarding.d.ts +4 -0
- package/dist/types/src/core/anim/clips/actions.d.ts +9 -0
- package/dist/types/src/core/anim/clips/aerial.d.ts +7 -0
- package/dist/types/src/core/anim/clips/basic.d.ts +4 -0
- package/dist/types/src/core/anim/clips/climbing.d.ts +37 -0
- package/dist/types/src/core/anim/clips/combat.d.ts +6 -0
- package/dist/types/src/core/anim/clips/cover.d.ts +19 -0
- package/dist/types/src/core/anim/clips/dodge.d.ts +8 -0
- package/dist/types/src/core/anim/clips/emotes.d.ts +21 -0
- package/dist/types/src/core/anim/clips/everyday.d.ts +15 -0
- package/dist/types/src/core/anim/clips/faces.d.ts +11 -0
- package/dist/types/src/core/anim/clips/gait.d.ts +17 -0
- package/dist/types/src/core/anim/clips/gunshot.d.ts +8 -0
- package/dist/types/src/core/anim/clips/helpers.d.ts +26 -0
- package/dist/types/src/core/anim/clips/index.d.ts +8 -0
- package/dist/types/src/core/anim/clips/interaction.d.ts +18 -0
- package/dist/types/src/core/anim/clips/lying.d.ts +8 -0
- package/dist/types/src/core/anim/clips/melee.d.ts +3 -0
- package/dist/types/src/core/anim/clips/mocap-data.d.ts +6 -0
- package/dist/types/src/core/anim/clips/reactions.d.ts +34 -0
- package/dist/types/src/core/anim/clips/recorded.d.ts +12 -0
- package/dist/types/src/core/anim/clips/runner.d.ts +10 -0
- package/dist/types/src/core/anim/clips/shooter.d.ts +15 -0
- package/dist/types/src/core/anim/clips/speech.d.ts +10 -0
- package/dist/types/src/core/anim/clips/swimming.d.ts +17 -0
- package/dist/types/src/core/anim/clips/types.d.ts +152 -0
- package/dist/types/src/core/anim/clips/vehicles.d.ts +28 -0
- package/dist/types/src/core/anim/evaluate.d.ts +188 -0
- package/dist/types/src/core/anim/mocap.d.ts +120 -0
- package/dist/types/src/core/anim/quat.d.ts +14 -0
- package/dist/types/src/core/anim/riding-weapons.d.ts +13 -0
- package/dist/types/src/core/anim/stage.d.ts +5 -0
- package/dist/types/src/core/assets.d.ts +114 -0
- package/dist/types/src/core/face.d.ts +56 -0
- package/dist/types/src/core/garments/bags.d.ts +2 -0
- package/dist/types/src/core/garments/beach.d.ts +9 -0
- package/dist/types/src/core/garments/body.d.ts +70 -0
- package/dist/types/src/core/garments/catalog.d.ts +8 -0
- package/dist/types/src/core/garments/drape.d.ts +86 -0
- package/dist/types/src/core/garments/dress-shoes.d.ts +7 -0
- package/dist/types/src/core/garments/earpiece.d.ts +2 -0
- package/dist/types/src/core/garments/gowns.d.ts +2 -0
- package/dist/types/src/core/garments/gulf.d.ts +2 -0
- package/dist/types/src/core/garments/heels.d.ts +8 -0
- package/dist/types/src/core/garments/index.d.ts +36 -0
- package/dist/types/src/core/garments/kit.d.ts +173 -0
- package/dist/types/src/core/garments/last.d.ts +78 -0
- package/dist/types/src/core/garments/layering.d.ts +4 -0
- package/dist/types/src/core/garments/necklaces.d.ts +2 -0
- package/dist/types/src/core/garments/outfit-cut.d.ts +30 -0
- package/dist/types/src/core/garments/prison.d.ts +2 -0
- package/dist/types/src/core/garments/project.d.ts +61 -0
- package/dist/types/src/core/garments/ring.d.ts +100 -0
- package/dist/types/src/core/garments/sets.d.ts +41 -0
- package/dist/types/src/core/garments/shell.d.ts +37 -0
- package/dist/types/src/core/garments/sheriff.d.ts +2 -0
- package/dist/types/src/core/garments/shirts.d.ts +31 -0
- package/dist/types/src/core/garments/sneakers.d.ts +7 -0
- package/dist/types/src/core/garments/street.d.ts +2 -0
- package/dist/types/src/core/garments/suit.d.ts +2 -0
- package/dist/types/src/core/garments/swimwear.d.ts +2 -0
- package/dist/types/src/core/garments/textures.d.ts +53 -0
- package/dist/types/src/core/garments/wrist.d.ts +2 -0
- package/dist/types/src/core/garments/yoruba.d.ts +2 -0
- package/dist/types/src/core/geometry.d.ts +31 -0
- package/dist/types/src/core/human.d.ts +42 -0
- package/dist/types/src/core/looks/hair.d.ts +64 -0
- package/dist/types/src/core/looks/index.d.ts +38 -0
- package/dist/types/src/core/looks/jewelry.d.ts +20 -0
- package/dist/types/src/core/looks/mouth.d.ts +12 -0
- package/dist/types/src/core/looks/overlay.d.ts +42 -0
- package/dist/types/src/core/looks/tattoos.d.ts +11 -0
- package/dist/types/src/core/looks/textures.d.ts +8 -0
- package/dist/types/src/core/math.d.ts +29 -0
- package/dist/types/src/core/mesh.d.ts +75 -0
- package/dist/types/src/core/morph.d.ts +11 -0
- package/dist/types/src/core/pack.d.ts +7 -0
- package/dist/types/src/core/params.d.ts +103 -0
- package/dist/types/src/core/props/bicycle.d.ts +26 -0
- package/dist/types/src/core/props/carry.d.ts +67 -0
- package/dist/types/src/core/props/helicopter-layout.d.ts +11 -0
- package/dist/types/src/core/props/horse-gait.d.ts +11 -0
- package/dist/types/src/core/props/parachute.d.ts +14 -0
- package/dist/types/src/core/props/stage-props.d.ts +23 -0
- package/dist/types/src/core/props/vehicle-actions.d.ts +23 -0
- package/dist/types/src/core/props/vehicle-bodies.d.ts +5 -0
- package/dist/types/src/core/props/vehicle-car.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-doors.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-helicopter.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-horse.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-kit.d.ts +61 -0
- package/dist/types/src/core/props/vehicle-land.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-merge.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-motion.d.ts +104 -0
- package/dist/types/src/core/props/vehicle-special.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-stunt.d.ts +16 -0
- package/dist/types/src/core/props/vehicle-water.d.ts +2 -0
- package/dist/types/src/core/props/vehicle.d.ts +49 -0
- package/dist/types/src/core/props/vehicles.d.ts +60 -0
- package/dist/types/src/core/props/weapons.d.ts +21 -0
- package/dist/types/src/core/rig/poses.d.ts +7 -0
- package/dist/types/src/core/rig/rig.d.ts +75 -0
- package/dist/types/src/core/rig/skeletons.d.ts +33 -0
- package/dist/types/src/core/rig/socket.d.ts +21 -0
- package/dist/types/src/core/skin-rough.d.ts +11 -0
- package/dist/types/src/export/fbx.d.ts +10 -0
- package/dist/types/src/export/glb.d.ts +9 -0
- package/dist/types/src/export/index.d.ts +22 -0
- package/dist/types/src/export/obj.d.ts +6 -0
- package/dist/types/src/export/plan.d.ts +63 -0
- package/package.json +21 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation clips, defined procedurally against the game-rig bone names.
|
|
3
|
+
*
|
|
4
|
+
* Channels are degrees about each bone's own axes in the "animation rest"
|
|
5
|
+
* (relaxed arms): X = flex (+ swings the bone's tip forward: thigh forward,
|
|
6
|
+
* spine lean forward, elbow bend, toes up; knee bend is negative), Y = twist
|
|
7
|
+
* (+ turns left on vertical bones), Z = side (+ raises the left arm out).
|
|
8
|
+
* Right-side values are written as the mirror of the left via `side()`.
|
|
9
|
+
*/
|
|
10
|
+
export type Ch = [number, number, number];
|
|
11
|
+
export interface Root {
|
|
12
|
+
/** Metres (scaled to the character's height), in the character's rest frame. */
|
|
13
|
+
x?: number;
|
|
14
|
+
y?: number;
|
|
15
|
+
z?: number;
|
|
16
|
+
/** Degrees about world up (+ = turn left) and world X (+ = pitch forward). */
|
|
17
|
+
yaw?: number;
|
|
18
|
+
pitch?: number;
|
|
19
|
+
/** 0..1: lowers the hips from standing height to lying height. */
|
|
20
|
+
drop?: number;
|
|
21
|
+
/** Keep the lowest foot on the floor (adjusts hip height after posing). */
|
|
22
|
+
ground?: boolean;
|
|
23
|
+
/** Metres added after grounding (jumps). */
|
|
24
|
+
lift?: number;
|
|
25
|
+
/** Lift the body so no joint sinks below the floor (lying, crawling, getting up). */
|
|
26
|
+
floor?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Raise the body (never lower it) until the hands can reach their floor-space targets with the arms just short of
|
|
29
|
+
* straight, so a hang fits every body's arm length.
|
|
30
|
+
*/
|
|
31
|
+
reach?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Hand IK target in "chest space": metres (at 1.8 m height) from the base of
|
|
35
|
+
* the neck, axes following the chest (+X character's left, +Y up, +Z forward).
|
|
36
|
+
* The shoulder joints sit about 0.1 m below and 0.2 m to each side of it.
|
|
37
|
+
*/
|
|
38
|
+
export interface HandTarget {
|
|
39
|
+
pos: [number, number, number];
|
|
40
|
+
/** Direction the elbow should point (chest space). */
|
|
41
|
+
pole: [number, number, number];
|
|
42
|
+
/** Optional hand orientation: direction from wrist to fingers, and palm normal (chest space). */
|
|
43
|
+
dir?: [number, number, number];
|
|
44
|
+
palm?: [number, number, number];
|
|
45
|
+
/** `pos` is the tip of a straight index finger (pointing along `dir`), not the wrist: placed with the rig's own finger length. */
|
|
46
|
+
tip?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Support hand on a weapon held in the other hand's WeaponR socket: the target is taken
|
|
49
|
+
* from where the weapon actually is (pos/dir/palm above are only a fallback).
|
|
50
|
+
*/
|
|
51
|
+
support?: 'rifle';
|
|
52
|
+
/**
|
|
53
|
+
* 'floor': pos is in the character's floor space (metres at 1.8 m height, from the floor under
|
|
54
|
+
* the character, +Z forward) and the directions are too, so the hand stays put while the chest
|
|
55
|
+
* moves: hands on handlebars and other fixed things.
|
|
56
|
+
*/
|
|
57
|
+
space?: 'floor';
|
|
58
|
+
}
|
|
59
|
+
/** Ankle target in floor space; `rise` (0..1) is how much of a Root.reach lift it follows (feet braced on a wall rise with the body, feet on a ledge stay). */
|
|
60
|
+
export interface FootTarget {
|
|
61
|
+
pos: [number, number, number];
|
|
62
|
+
pole: [number, number, number];
|
|
63
|
+
rise?: number;
|
|
64
|
+
/** How firmly the ankle follows the target (0..1, default 1): eases a foot from its FK pose onto a hold. */
|
|
65
|
+
weight?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface Sample {
|
|
68
|
+
bones: Record<string, Ch>;
|
|
69
|
+
root: Root;
|
|
70
|
+
ik?: {
|
|
71
|
+
Left?: HandTarget;
|
|
72
|
+
Right?: HandTarget;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Ankle targets in floor space (metres at 1.8 m, from the character's origin), for feet on rungs or ledges:
|
|
76
|
+
* the leg is solved to reach them with the knee towards `pole`. Like floor-space hands, they move with root motion.
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Planted feet (0..1 per side): the ankle stays where it stood in the clip's first frame on this body, so turning
|
|
80
|
+
* hips and twisting stances don't slide it. For clips that don't travel; fade a foot out before it steps or kicks.
|
|
81
|
+
*/
|
|
82
|
+
plant?: {
|
|
83
|
+
Left?: number;
|
|
84
|
+
Right?: number;
|
|
85
|
+
};
|
|
86
|
+
/** How firmly each hand follows its IK target (0..1, default 1): fades a hand onto or off a contact. */
|
|
87
|
+
ikWeight?: {
|
|
88
|
+
Left?: number;
|
|
89
|
+
Right?: number;
|
|
90
|
+
};
|
|
91
|
+
feet?: {
|
|
92
|
+
Left?: FootTarget;
|
|
93
|
+
Right?: FootTarget;
|
|
94
|
+
};
|
|
95
|
+
/** A hand-held prop on its own joint (the phone), placed in chest space: centre, screen normal (+X) and top (+Z). */
|
|
96
|
+
prop?: {
|
|
97
|
+
pos: [number, number, number];
|
|
98
|
+
x: [number, number, number];
|
|
99
|
+
z: [number, number, number];
|
|
100
|
+
};
|
|
101
|
+
/** 0..1: wrap the thumb across the front of the index/middle fingers (fists). */
|
|
102
|
+
thumbs?: {
|
|
103
|
+
Left?: number;
|
|
104
|
+
Right?: number;
|
|
105
|
+
};
|
|
106
|
+
/** Facial blend-shape weights added on top of the character's expression (see core/face.ts). */
|
|
107
|
+
face?: Partial<Record<string, number>>;
|
|
108
|
+
/** Where the eyes look, degrees: [left (+) / right (-), up (+) / down (-)]. Replaces automatic glances. */
|
|
109
|
+
gaze?: [number, number];
|
|
110
|
+
/** Motion capture (test): retargeted by the evaluator onto the rig (see anim/mocap.ts). */
|
|
111
|
+
mocap?: import('../mocap').MocapSample;
|
|
112
|
+
/** Blend the solved pose toward another sample's (w: 0 = this pose, 1 = the other), e.g. easing a
|
|
113
|
+
* captured clip into a keyframed rest pose. */
|
|
114
|
+
blend?: {
|
|
115
|
+
sample: Sample;
|
|
116
|
+
w: number; /** Keep interpolated feet from sinking below the floor. */
|
|
117
|
+
ground?: boolean;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Where a bullet hits, for blood effects: at clip time `t`, on `bone` (game-rig name), travelling along `dir`
|
|
122
|
+
* (character frame: +X left, +Y up, +Z forward), so blood sprays out along it. `pool`: the clip time a pool starts
|
|
123
|
+
* spreading under that bone once the body is down.
|
|
124
|
+
*/
|
|
125
|
+
export interface Wound {
|
|
126
|
+
t: number;
|
|
127
|
+
bone: 'Head' | 'Spine2' | 'Spine' | 'LeftUpLeg' | 'RightArm';
|
|
128
|
+
dir: [number, number, number];
|
|
129
|
+
pool?: number;
|
|
130
|
+
}
|
|
131
|
+
export type ClipCategory = 'Aerial' | 'Idle & stance' | 'Locomotion' | 'Turns' | 'Actions' | 'Emotes' | 'Shooter' | 'Vehicles' | 'Reactions' | 'Sitting & lying' | 'Interaction' | 'Swimming' | 'Everyday' | 'Climbing' | 'Combat';
|
|
132
|
+
export interface Clip {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
category: ClipCategory;
|
|
136
|
+
duration: number;
|
|
137
|
+
loop: boolean;
|
|
138
|
+
/** Rigid vehicle/rider stunt transform, applied after solving control contacts. */
|
|
139
|
+
vehicleStunt?: {
|
|
140
|
+
model: string;
|
|
141
|
+
ride: string;
|
|
142
|
+
};
|
|
143
|
+
/** Share (0..1) of the vehicle floor height applied at time t: 1 in the seat, 0 once the rider is on the ground. */
|
|
144
|
+
liftWeight?: (t: number) => number;
|
|
145
|
+
/** Fitted, non-looping entry/exit, solved against this rig's actual riding pose. */
|
|
146
|
+
vehicleTransition?: import('../../props/vehicle-actions').VehicleTransition;
|
|
147
|
+
/** Root-motion velocity (metres/second at 1.8 m height, character frame: +X left, +Z forward). */
|
|
148
|
+
travel?: [number, number, number];
|
|
149
|
+
/** Bullet hits (gunshot reactions). */
|
|
150
|
+
wounds?: Wound[];
|
|
151
|
+
sample(t: number): Sample;
|
|
152
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Vehicle riders: car, passenger, bicycle, motorcycle, horse, canoe, kayak, rowing, boat helm. */
|
|
2
|
+
import { type Clip, type HandTarget } from './types';
|
|
3
|
+
type V3 = [number, number, number];
|
|
4
|
+
/**
|
|
5
|
+
* Hands on a steering wheel (car or boat) at 9 and 3 o'clock, turned by `steer` degrees.
|
|
6
|
+
* The wheel faces the driver, its top tilted away by `tilt` degrees.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wheelHands(centre: V3, radius: number, tilt: number, steer: number): {
|
|
9
|
+
Left: HandTarget;
|
|
10
|
+
Right: HandTarget;
|
|
11
|
+
};
|
|
12
|
+
export declare const VEHICLE_CRASHES: Clip[];
|
|
13
|
+
/**
|
|
14
|
+
* Tank machine gunner: standing on the driver's floor, head and shoulders out of the open hatch behind the gun
|
|
15
|
+
* shield, both hands on the spade grips. The gun traverses slowly and fires in short bursts.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TANK_GUN: {
|
|
18
|
+
pivot: number;
|
|
19
|
+
traverse: number;
|
|
20
|
+
burst: readonly [1.5, 0.6];
|
|
21
|
+
};
|
|
22
|
+
export declare const tankGunFiring: (t: number) => boolean;
|
|
23
|
+
export declare const VEHICLES: Clip[];
|
|
24
|
+
/** Exact contact poses are fitted by Animator, shared by previews and exports. */
|
|
25
|
+
export declare const BOARDING: Clip[];
|
|
26
|
+
/** Controlled, complete stunt rolls; they return to the exact native driving pose. */
|
|
27
|
+
export declare const VEHICLE_TUMBLES: Clip[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluates clips on any rig: forward kinematics in world space from an
|
|
3
|
+
* "animation rest" (bind pose with relaxed arms), producing per-bone local
|
|
4
|
+
* rotations and the root position. Shared by the viewer and the exporters,
|
|
5
|
+
* so what you preview is exactly what gets exported.
|
|
6
|
+
*/
|
|
7
|
+
import type { Vec3 } from '../math';
|
|
8
|
+
import { type Rig } from '../rig/rig';
|
|
9
|
+
import { type Clip } from './clips';
|
|
10
|
+
import { type Q } from './quat';
|
|
11
|
+
import { type WeaponPose } from './riding-weapons';
|
|
12
|
+
export interface Frame {
|
|
13
|
+
/** Unarmed controls for fitted props: an aiming hand must not drag the wheel or bars away. */
|
|
14
|
+
vehicleControls?: Frame;
|
|
15
|
+
ridingWeapon?: import('../props/weapons').WeaponId;
|
|
16
|
+
/** Local rotation per bone (relative to its parent), as exported / applied to three.js bones. */
|
|
17
|
+
rot: Q[];
|
|
18
|
+
/** Local position of root bones (parent = -1); other bones keep their rest offsets. */
|
|
19
|
+
rootPos: Map<number, Vec3>;
|
|
20
|
+
/** Optional relative scales for articulated props (rider clips keep unit scale). */
|
|
21
|
+
scale?: Map<number, Vec3>;
|
|
22
|
+
/** Facial blend-shape weights (0..1, in the character's face-shape order), when it has face shapes. */
|
|
23
|
+
morph?: number[];
|
|
24
|
+
}
|
|
25
|
+
/** Range of the rifle's support grip down the barrel from the pistol grip (metres; matches the rifle model). */
|
|
26
|
+
export declare const SUPPORT_MIN = 0.16, SUPPORT_MAX = 0.42;
|
|
27
|
+
export interface BakedClip {
|
|
28
|
+
name: string;
|
|
29
|
+
loop: boolean;
|
|
30
|
+
times: number[];
|
|
31
|
+
frames: Frame[];
|
|
32
|
+
}
|
|
33
|
+
export declare class Animator {
|
|
34
|
+
readonly rig: Rig;
|
|
35
|
+
readonly face?: {
|
|
36
|
+
names: string[];
|
|
37
|
+
defaults: number[];
|
|
38
|
+
} | undefined;
|
|
39
|
+
readonly restLocal: Q[];
|
|
40
|
+
private restOffset;
|
|
41
|
+
/** Per finger bone: curl axis (toward the palm) in the bone's animation-rest frame. */
|
|
42
|
+
private flexAxis;
|
|
43
|
+
/**
|
|
44
|
+
* Limb segments split into several bones (the full rig's upperleg01/02, lowerarm01/02...): the
|
|
45
|
+
* direction (in the first bone's frame) from it to the next animated bone, for aiming the whole
|
|
46
|
+
* segment rather than its first part.
|
|
47
|
+
*/
|
|
48
|
+
private segAxis;
|
|
49
|
+
/** Channel frame (in the bone's rest frame) for bones that don't point along their segment. */
|
|
50
|
+
private chanFrame;
|
|
51
|
+
/** A root bone that starts behind the hips (the full rig's): the hips joint, in its rest frame, which it turns about. */
|
|
52
|
+
private hipPivot;
|
|
53
|
+
/** Per side: palm normal in the hand's animation-rest frame. */
|
|
54
|
+
private palmLocal;
|
|
55
|
+
private idx;
|
|
56
|
+
private feet;
|
|
57
|
+
/** Ankle positions in each planting clip's first frame (see Sample.plant). */
|
|
58
|
+
private planted;
|
|
59
|
+
private restFootY;
|
|
60
|
+
private recoveryFeet;
|
|
61
|
+
private recoveryFloor;
|
|
62
|
+
private restWorld;
|
|
63
|
+
private animRest;
|
|
64
|
+
private names;
|
|
65
|
+
private scale;
|
|
66
|
+
/** WeaponR socket bone (-1 if the rig has none) and cached weapon fits. */
|
|
67
|
+
private socket;
|
|
68
|
+
private parcel;
|
|
69
|
+
private broom;
|
|
70
|
+
private bag;
|
|
71
|
+
private floorShift;
|
|
72
|
+
private phone;
|
|
73
|
+
private fits;
|
|
74
|
+
/** `face`: the character's blend-shape names and resting (expression) weights, if it has face shapes. */
|
|
75
|
+
constructor(rig: Rig, face?: {
|
|
76
|
+
names: string[];
|
|
77
|
+
defaults: number[];
|
|
78
|
+
} | undefined);
|
|
79
|
+
/**
|
|
80
|
+
* Fit a weapon held in the WeaponR socket to a reference frame (e.g. rifle aim):
|
|
81
|
+
* returns the weapon-model -> socket rotation that makes the barrel point along the
|
|
82
|
+
* chest's forward axis, and how far down the barrel the support (left) hand is.
|
|
83
|
+
*/
|
|
84
|
+
weaponFit(f: Frame, socket: number): {
|
|
85
|
+
rot: Q;
|
|
86
|
+
supportZ: number;
|
|
87
|
+
};
|
|
88
|
+
/** World-space joint positions for a frame (forward kinematics). */
|
|
89
|
+
positions(f: Frame): Vec3[];
|
|
90
|
+
/** Bind pose (no animation). */
|
|
91
|
+
bind(): Frame;
|
|
92
|
+
/**
|
|
93
|
+
* `faceTime`: blink and glance on this continuous clock (seconds) instead of at fixed times inside
|
|
94
|
+
* the clip. The live preview uses it so every clip blinks, as a game layering a face would.
|
|
95
|
+
*/
|
|
96
|
+
frame(clip: Clip, time: number, opts?: {
|
|
97
|
+
rootMotion?: boolean;
|
|
98
|
+
noSupport?: boolean;
|
|
99
|
+
faceTime?: number;
|
|
100
|
+
parcelGrounded?: boolean;
|
|
101
|
+
vehicleLift?: number; /** false: Studio supplies vehicle flight motion. */
|
|
102
|
+
vehicleMotion?: boolean;
|
|
103
|
+
weaponPose?: WeaponPose;
|
|
104
|
+
weaponYaw?: number;
|
|
105
|
+
weaponPitch?: number;
|
|
106
|
+
}): Frame;
|
|
107
|
+
/** Visual release only: deterministic, exportable and independent of the throwing hand. */
|
|
108
|
+
private placeGrenade;
|
|
109
|
+
private placeParachute;
|
|
110
|
+
/** Pin an existing solved limb without changing any bone offset or scale. Handles split full-rig chains. */
|
|
111
|
+
pinLimb(frame: Frame, side: 'Left' | 'Right', kind: 'arm' | 'leg', target: Vec3, pole: Vec3, endOrientation?: Q): void;
|
|
112
|
+
/** A rigid, level box: on the floor before pickup, then between the two solved wrists. */
|
|
113
|
+
/** The phone shows only in clips that place it (phone call, texting), exactly where the clip's chest-space pose puts it. */
|
|
114
|
+
private placePhone;
|
|
115
|
+
/** The broom only shows while sweeping: its handle runs through both hands and the bristles rest on the floor. */
|
|
116
|
+
private placeBroom;
|
|
117
|
+
placeParcel(frame: Frame, clip: Clip, time: number, rootMotion?: boolean, grounded?: boolean): void;
|
|
118
|
+
/**
|
|
119
|
+
* World rotation and position of a bone (by generic name, e.g. 'LeftHand') in the animation rest
|
|
120
|
+
* pose: arms relaxed at the sides. Props carried in a hand are fitted to this pose.
|
|
121
|
+
*/
|
|
122
|
+
relaxedBone(name: string): {
|
|
123
|
+
rot: Q;
|
|
124
|
+
pos: Vec3;
|
|
125
|
+
} | undefined;
|
|
126
|
+
/** The resting face (expression + live blinks) for the bind pose, on a continuous clock. */
|
|
127
|
+
restFace(faceTime: number): number[] | undefined;
|
|
128
|
+
/** Eye bones follow the clip's gaze, or small automatic glances. */
|
|
129
|
+
/**
|
|
130
|
+
* Hands holding a bag's handle: fingers closed round it and the thumb wrapped over them, whatever
|
|
131
|
+
* the clip does with them.
|
|
132
|
+
*/
|
|
133
|
+
private holding;
|
|
134
|
+
private withEyes;
|
|
135
|
+
/** Blend-shape weights: expression + the clip's face + blinks (a blink overrides wide/squinting eyes). */
|
|
136
|
+
private faceWeights;
|
|
137
|
+
private frameOf;
|
|
138
|
+
/** See Root.reach: lift the root just enough for each held floor-space hand target to be within 98% of the arm. */
|
|
139
|
+
private reachHands;
|
|
140
|
+
/** Fade hands with an `ikWeight` below 1 between their IK pose and their posed (FK) arm. */
|
|
141
|
+
private weighIK;
|
|
142
|
+
/** See Sample.plant: each planted foot becomes an ankle target where it stood in the clip's first frame on this body. */
|
|
143
|
+
private plantFeet;
|
|
144
|
+
/** Legs reach the sample's floor-space ankle targets (rungs, ledges), keeping each foot's posed orientation. */
|
|
145
|
+
private placeFeet;
|
|
146
|
+
/** Socket-space fit of a weapon to its reference aiming clip (cached): see weaponFit. */
|
|
147
|
+
fitFor(kind: 'rifle' | 'pistol'): {
|
|
148
|
+
rot: Q;
|
|
149
|
+
supportZ: number;
|
|
150
|
+
};
|
|
151
|
+
/** Support-hand IK target (chest space) on the rifle's handguard, from the solved weapon pose. */
|
|
152
|
+
private supportTarget;
|
|
153
|
+
/**
|
|
154
|
+
* Largest distance down the barrel (<= zMax, >= zMin) at which the support hand's wrist
|
|
155
|
+
* is within `margin` of the left arm's full reach.
|
|
156
|
+
*/
|
|
157
|
+
private reachableZ;
|
|
158
|
+
private mocapRests;
|
|
159
|
+
private mocapGrounds;
|
|
160
|
+
/** Grounding key: per clip, or shared by chained cuts. */
|
|
161
|
+
private groundKey;
|
|
162
|
+
private mocapGround;
|
|
163
|
+
/**
|
|
164
|
+
* Rest alignment for a motion-captured bone: our animation-rest bone swung onto the source's rest
|
|
165
|
+
* direction, so source rotations (relative to its rest) can be applied directly.
|
|
166
|
+
*/
|
|
167
|
+
private mocapRest;
|
|
168
|
+
/** Chest frame (rotation from the animation rest) and the IK origin at the base of the neck. */
|
|
169
|
+
private chestSpace;
|
|
170
|
+
/** Root position `p` (its head unturned) moved so the root turns about the hips joint (see hipPivot). */
|
|
171
|
+
private pivot;
|
|
172
|
+
private solve;
|
|
173
|
+
/** Fist thumb: aim the thumb across the front of the index/middle fingers. */
|
|
174
|
+
private wrapThumb;
|
|
175
|
+
/** Two-bone arm IK + hand orientation, applied as the FK pass reaches Arm / ForeArm / Hand. */
|
|
176
|
+
private solveIK;
|
|
177
|
+
/** Frames sampled at `fps` over the clip (inclusive end), quaternion signs kept continuous. */
|
|
178
|
+
bake(clip: Clip, fps?: number, opts?: {
|
|
179
|
+
rootMotion?: boolean;
|
|
180
|
+
vehicleLift?: number;
|
|
181
|
+
weaponPose?: WeaponPose;
|
|
182
|
+
weaponYaw?: number;
|
|
183
|
+
weaponPitch?: number;
|
|
184
|
+
}): {
|
|
185
|
+
times: number[];
|
|
186
|
+
frames: Frame[];
|
|
187
|
+
};
|
|
188
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Motion-capture import: BVH files retargeted onto our skeletons.
|
|
3
|
+
*
|
|
4
|
+
* Retargeting copies each bone's world-space rotation relative to the source's rest pose. The
|
|
5
|
+
* source rest (all channels zero) is not a clean T-pose (CMU's legs splay out), so every target
|
|
6
|
+
* bone is first swung from our T-pose to the source's rest direction; the motion is applied on
|
|
7
|
+
* top of that. Hips height and travel are scaled by leg length. Both use +Y up, +Z forward,
|
|
8
|
+
* +X = the character's left.
|
|
9
|
+
*/
|
|
10
|
+
import type { Vec3 } from '../math';
|
|
11
|
+
import type { Clip, ClipCategory } from './clips/types';
|
|
12
|
+
import { type Q } from './quat';
|
|
13
|
+
interface BvhJoint {
|
|
14
|
+
name: string;
|
|
15
|
+
parent: number;
|
|
16
|
+
offset: Vec3;
|
|
17
|
+
channels: string[];
|
|
18
|
+
/** Offset of the first child (or end site): the bone's rest direction. */
|
|
19
|
+
tip?: Vec3;
|
|
20
|
+
/** Children (zero-length ones are followed to find the tip). */
|
|
21
|
+
kids: number[];
|
|
22
|
+
}
|
|
23
|
+
export interface Bvh {
|
|
24
|
+
joints: BvhJoint[];
|
|
25
|
+
frames: Float32Array[];
|
|
26
|
+
frameTime: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function parseBvh(text: string): Bvh;
|
|
29
|
+
/** The recording mirrored left to right (x -> -x): a sidestep to the right becomes one to the left. */
|
|
30
|
+
export declare function mirrorBvh(b: Bvh): Bvh;
|
|
31
|
+
export interface MocapSample {
|
|
32
|
+
/** World rotation (relative to the source rest pose) per target bone. */
|
|
33
|
+
rot: Record<string, Q>;
|
|
34
|
+
/** Source rest direction per target bone (world). */
|
|
35
|
+
dir: Record<string, Vec3>;
|
|
36
|
+
/** Calibration rotations (world, at rest) per target bone, applied before the motion. */
|
|
37
|
+
bias: Record<string, Q>;
|
|
38
|
+
/** Hips position in leg lengths (x/z relative to the start; y above the floor, 1 = standing). */
|
|
39
|
+
hips: Vec3;
|
|
40
|
+
/** Key for caching rest alignments. */
|
|
41
|
+
key: string;
|
|
42
|
+
/**
|
|
43
|
+
* Chained cuts of one take: the pose at their shared reference (feet planted) and a key shared
|
|
44
|
+
* by the group. They are grounded once from that pose, so they meet where they join.
|
|
45
|
+
*/
|
|
46
|
+
anchor?: {
|
|
47
|
+
rot: Record<string, Q>;
|
|
48
|
+
hips: Vec3;
|
|
49
|
+
key: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface MocapOptions {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
category: ClipCategory;
|
|
56
|
+
loop: boolean;
|
|
57
|
+
/** Seconds into the recording to start / end (end defaults to the recording's end). */
|
|
58
|
+
start?: number;
|
|
59
|
+
end?: number;
|
|
60
|
+
/** Loops: search this range (seconds after start) for the frame that best matches the start. */
|
|
61
|
+
loopSearch?: [number, number];
|
|
62
|
+
/** Seconds in the recording where the actor holds their head neutrally (default: the whole cut),
|
|
63
|
+
* for clips whose head pose is the point (a sob keeps the head bowed). */
|
|
64
|
+
neutral?: [number, number];
|
|
65
|
+
/**
|
|
66
|
+
* Seconds in the recording of a shared reference, for clips cut from one take that chain (sit
|
|
67
|
+
* down -> sit idle -> stand up): they all face the way the hips face then, place the hips
|
|
68
|
+
* relative to that moment (no travel removed or centring), and share the take's floor and foot
|
|
69
|
+
* calibration, so they meet where they join.
|
|
70
|
+
*/
|
|
71
|
+
ref?: number;
|
|
72
|
+
/** With `ref`: seconds in the recording whose hips position is the origin (default: `ref`). */
|
|
73
|
+
origin?: number;
|
|
74
|
+
/** Name of the take (groups chained cuts that share `ref`). */
|
|
75
|
+
take?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Degrees each leg is turned out at the hip and again at the knee (default 4: keeps the knees of
|
|
78
|
+
* our wider bodies apart). Less closes the legs, so the feet land on one line.
|
|
79
|
+
*/
|
|
80
|
+
legSpread?: number;
|
|
81
|
+
/** Degrees the swinging leg turns out at the hip as it passes the other (closed legs' feet clear each other). */
|
|
82
|
+
swing?: number;
|
|
83
|
+
/** Adapt a recorded turn's unwrapped heading to an exact angle, retaining its recorded steps. */
|
|
84
|
+
turn?: number;
|
|
85
|
+
}
|
|
86
|
+
export declare function mocapClip(bvh: Bvh, o: MocapOptions): Clip;
|
|
87
|
+
/** Compact, retarget-ready motion for one clip (generated by scripts/build-mocap.ts). */
|
|
88
|
+
export interface MocapData {
|
|
89
|
+
duration: number;
|
|
90
|
+
loop: boolean;
|
|
91
|
+
travel?: [number, number, number];
|
|
92
|
+
/** Frames are evenly spaced from 0 to duration (inclusive). */
|
|
93
|
+
frames: number;
|
|
94
|
+
bones: string[];
|
|
95
|
+
/** Per frame, per bone: quaternion xyzw as int16 / 32767 (base64, little-endian). */
|
|
96
|
+
rot: string;
|
|
97
|
+
/** Per frame: hips position in leg lengths as int16 / 10000 (base64). */
|
|
98
|
+
hips: string;
|
|
99
|
+
dir: Record<string, Vec3>;
|
|
100
|
+
bias: Record<string, Q>;
|
|
101
|
+
/** Hand pose (the capture has no fingers): relaxed (default) or closed fists. */
|
|
102
|
+
hands?: 'fist';
|
|
103
|
+
/** Pin the lowest foot to the floor every frame (clips whose feet stay planted, like sitting). */
|
|
104
|
+
ground?: boolean;
|
|
105
|
+
/** Chained cuts: the shared reference pose (bones in `bones` order, xyzw) and its group. */
|
|
106
|
+
anchor?: {
|
|
107
|
+
rot: number[];
|
|
108
|
+
hips: Vec3;
|
|
109
|
+
key: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Sample a retargeted BVH clip (mocapClip) into compact data, `fps` frames per second. */
|
|
113
|
+
export declare function bakeMocap(clip: Clip, fps?: number, hands?: 'fist', ground?: boolean): MocapData;
|
|
114
|
+
/** A playable clip from baked data. */
|
|
115
|
+
export declare function clipFromMocap(d: MocapData, meta: {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
category: ClipCategory;
|
|
119
|
+
}): Clip;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Minimal quaternion helpers, [x, y, z, w]. */
|
|
2
|
+
import type { Vec3 } from '../math';
|
|
3
|
+
export type Q = [number, number, number, number];
|
|
4
|
+
export declare const QI: Q;
|
|
5
|
+
export declare function qmul(a: Q, b: Q): Q;
|
|
6
|
+
export declare const qconj: (q: Q) => Q;
|
|
7
|
+
export declare function qaxis(axis: Vec3, deg: number): Q;
|
|
8
|
+
export declare function qrot(q: Q, v: Vec3): Vec3;
|
|
9
|
+
/** Shortest rotation taking direction a onto direction b. */
|
|
10
|
+
export declare function qfromTo(a: Vec3, b: Vec3): Q;
|
|
11
|
+
/** Euler XYZ (degrees, R = Rz * Ry * Rx) from a quaternion, FBX's default order. */
|
|
12
|
+
export declare function qToEulerXYZ(q: Q): Vec3;
|
|
13
|
+
/** Spherical interpolation between unit quaternions (shortest way), renormalised. */
|
|
14
|
+
export declare function qslerp(a: Q, b: Q, t: number): Q;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Right-hand mounted weapon layer; original seat, gait and control hand stay intact. */
|
|
2
|
+
import type { Clip, Sample } from './clips/types';
|
|
3
|
+
import { type Q } from './quat';
|
|
4
|
+
import { type WeaponId } from '../props/weapons';
|
|
5
|
+
export declare const WEAPON_POSES: readonly ['hold', 'aim', 'fire', 'hidden'];
|
|
6
|
+
export type WeaponPose = typeof WEAPON_POSES[number];
|
|
7
|
+
export declare const PADDLING_CLIPS: Set<string>;
|
|
8
|
+
export declare function defaultWeaponYaw(clip: string, seat?: string): -80 | -55 | -35 | 80;
|
|
9
|
+
/** Operators sealed inside armour or busy with a manoeuvre (runway, bail-out, tank gun) never wield their own weapon. */
|
|
10
|
+
export declare const ENCLOSED_CLIPS: Set<string>;
|
|
11
|
+
export declare function supportsWeaponAim(id: string): boolean;
|
|
12
|
+
export declare function mountedWeaponSample(base: Sample, clip: Clip, time: number, weapon: WeaponId, pose: WeaponPose, yaw?: number, chestCounter?: Q, pitch?: number): Sample;
|
|
13
|
+
export declare function directedWeaponSample(base: Sample, yaw?: number, pitch?: number): Sample;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Stage props: the fixed objects some clips are authored against (a ladder, a vault obstacle, a ledge wall, low cover). */
|
|
2
|
+
export type StageProp = 'ladder' | 'obstacle' | 'ledge' | 'cover';
|
|
3
|
+
export declare const STAGE_PROP_LABELS: Record<StageProp, string>;
|
|
4
|
+
/** The prop a clip is authored against, or undefined for clips without one. */
|
|
5
|
+
export declare const stagePropFor: (clipId: string) => StageProp | undefined;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asset pack formats (produced by scripts/build-assets.ts from the CC0
|
|
3
|
+
* MakeHuman data) and a loader that works in both the browser and Node.
|
|
4
|
+
*/
|
|
5
|
+
import { type Pack } from './pack';
|
|
6
|
+
export interface AssetMaterial {
|
|
7
|
+
name: string;
|
|
8
|
+
color: string;
|
|
9
|
+
roughness: number;
|
|
10
|
+
metalness: number;
|
|
11
|
+
diffuse?: string;
|
|
12
|
+
normal?: string;
|
|
13
|
+
alpha: 'opaque' | 'mask' | 'blend';
|
|
14
|
+
doubleSided: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface BaseMeta {
|
|
17
|
+
vertexCount: number;
|
|
18
|
+
faceCount: number;
|
|
19
|
+
/** Skeleton joint name -> base-mesh vertex indices (joint position = their mean). */
|
|
20
|
+
joints: Record<string, number[]>;
|
|
21
|
+
bones: {
|
|
22
|
+
name: string;
|
|
23
|
+
parent: string | null;
|
|
24
|
+
head: string;
|
|
25
|
+
tail: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export interface TargetsMeta {
|
|
29
|
+
/** 2 = values delta-coded per target and stored as low/high byte planes (see decodeTargets). */
|
|
30
|
+
format?: number;
|
|
31
|
+
/** name -> [entry offset, entry count, quantisation scale] */
|
|
32
|
+
targets: Record<string, [number, number, number]>;
|
|
33
|
+
}
|
|
34
|
+
/** Turn a format-2 targets pack back into idx/dx/dy/dz arrays (format 1 packs pass through). */
|
|
35
|
+
export declare function decodeTargets(p: Pack<TargetsMeta>): Pack<TargetsMeta>;
|
|
36
|
+
export type ProxyKind = 'body' | 'eyes' | 'eyebrows' | 'eyelashes' | 'hair' | 'outfit' | 'shoes' | 'hat' | 'teeth' | 'tongue';
|
|
37
|
+
export interface ProxyMeta {
|
|
38
|
+
id: string;
|
|
39
|
+
kind: ProxyKind;
|
|
40
|
+
zDepth: number;
|
|
41
|
+
/** Per-axis scale reference: [vertA, vertB, referenceDistance] or null. */
|
|
42
|
+
scale: ([number, number, number] | null)[];
|
|
43
|
+
material?: AssetMaterial;
|
|
44
|
+
vertexCount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CatalogItem {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
tags: string[];
|
|
50
|
+
thumb?: string;
|
|
51
|
+
/** Proxy pack file (relative to assets/), for mesh assets. */
|
|
52
|
+
file?: string;
|
|
53
|
+
material?: AssetMaterial;
|
|
54
|
+
}
|
|
55
|
+
export interface Slider {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
/** Pairs of [min target, max target]; several pairs = symmetric left/right. null = no target on that side. */
|
|
59
|
+
targets: [string | null, string | null][];
|
|
60
|
+
/** Unipolar sliders run 0..1, bipolar -1..1. */
|
|
61
|
+
bipolar: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface SliderGroup {
|
|
64
|
+
category: string;
|
|
65
|
+
group: string;
|
|
66
|
+
sliders: Slider[];
|
|
67
|
+
}
|
|
68
|
+
export interface Catalog {
|
|
69
|
+
skins: CatalogItem[];
|
|
70
|
+
eyes: CatalogItem[];
|
|
71
|
+
eyebrows: CatalogItem[];
|
|
72
|
+
eyelashes: CatalogItem[];
|
|
73
|
+
hair: CatalogItem[];
|
|
74
|
+
outfits: CatalogItem[];
|
|
75
|
+
shoes: CatalogItem[];
|
|
76
|
+
hats: CatalogItem[];
|
|
77
|
+
bodies: CatalogItem[];
|
|
78
|
+
eyeMesh: string;
|
|
79
|
+
/** Teeth variants and the tongue (mouth interior). */
|
|
80
|
+
teeth: CatalogItem[];
|
|
81
|
+
tongue: CatalogItem;
|
|
82
|
+
sliders: SliderGroup[];
|
|
83
|
+
}
|
|
84
|
+
/** Where asset bytes come from: fetch() in the browser, the filesystem in Node. */
|
|
85
|
+
export interface AssetSource {
|
|
86
|
+
read(path: string): Promise<Uint8Array>;
|
|
87
|
+
/** URL usable by the viewer for textures (browser only). */
|
|
88
|
+
url?(path: string): string;
|
|
89
|
+
}
|
|
90
|
+
export declare function fetchSource(base?: string): AssetSource;
|
|
91
|
+
/** Loads and caches packs, catalog and textures. */
|
|
92
|
+
export declare class AssetLibrary {
|
|
93
|
+
readonly source: AssetSource;
|
|
94
|
+
catalog: Catalog;
|
|
95
|
+
base: Pack<BaseMeta>;
|
|
96
|
+
targets: Pack<TargetsMeta>;
|
|
97
|
+
private proxies;
|
|
98
|
+
private textures;
|
|
99
|
+
/** Textures generated at runtime (procedural garments), by file name. */
|
|
100
|
+
private generated;
|
|
101
|
+
private blobUrls;
|
|
102
|
+
registerTexture(name: string, data: Uint8Array): void;
|
|
103
|
+
hasTexture(name: string): boolean;
|
|
104
|
+
peekTexture(name: string): Uint8Array | undefined;
|
|
105
|
+
/** Names of all runtime-generated textures. */
|
|
106
|
+
generatedNames(): string[];
|
|
107
|
+
constructor(source: AssetSource);
|
|
108
|
+
init(): Promise<this>;
|
|
109
|
+
/** Catalog only (for UIs that delegate building to a worker). */
|
|
110
|
+
initCatalog(): Promise<this>;
|
|
111
|
+
proxy(file: string): Promise<Pack<ProxyMeta>>;
|
|
112
|
+
texture(name: string): Promise<Uint8Array>;
|
|
113
|
+
textureUrl(name: string): string;
|
|
114
|
+
}
|