katachi-runtime 0.3.0 → 0.6.1
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 +276 -9
- package/animation.d.ts +101 -0
- package/assets.d.ts +38 -1
- package/bones.d.ts +7 -0
- package/character.d.ts +165 -3
- package/clip.d.ts +101 -0
- package/index.d.ts +7 -3
- package/index.js +1896 -331
- package/loader.d.ts +26 -1
- package/material.d.ts +12 -0
- package/model.d.ts +18 -0
- package/overlays.d.ts +49 -0
- package/package.json +2 -2
- package/stage.d.ts +24 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Katachi
|
|
2
2
|
|
|
3
|
-
GTA V vehicles, characters and
|
|
3
|
+
GTA V vehicles, characters, objects and animations in the browser, from real game files. Animations can be checked, pictured, fixed and made from the command line, by people or by AI, and written back for the game.
|
|
4
4
|
|
|
5
5
|
## Quick start
|
|
6
6
|
|
|
@@ -20,10 +20,12 @@ Open the address it prints to browse what you converted. Click a model to try it
|
|
|
20
20
|
|
|
21
21
|
| Command | What it does |
|
|
22
22
|
| --- | --- |
|
|
23
|
-
| `bun run convert <files or folders>` | Converts `.rpf`, `.yft`, `.ydr`, `.ydd`, `.ytd`, `.ytyp`, `.meta` and `.ymt` files into `out/`. |
|
|
23
|
+
| `bun run convert <files or folders>` | Converts `.rpf`, `.yft`, `.ydr`, `.ydd`, `.ytd`, `.ytyp`, `.ycd`, `.meta` and `.ymt` files into `out/`. |
|
|
24
24
|
| `bun run thumbnails <folder>` | Renders a 512×512 transparent image of each model into `<folder>/thumbnails`, with Google Chrome or Microsoft Edge. Each model fills its image; one with nothing to draw is reported as failed. |
|
|
25
|
-
| `bun run pack <folder> <web folder>` | Prepares a converted folder for the web. Each vehicle and
|
|
25
|
+
| `bun run pack <folder> <web folder>` | Prepares a converted folder for the web. Each vehicle, character and clip dictionary moves into its own small file that loads when it is first shown, so the index stays small however many there are. Files are linked rather than copied when both folders are on one disk. |
|
|
26
26
|
| `bun run dev [folder]` | Starts the playground. Shows `out/` unless you name another folder. |
|
|
27
|
+
| `bun run anim <command>` | Checks, pictures, edits and makes animations. See [Animation tool](#animation-tool). |
|
|
28
|
+
| `converter/zig-out/bin/katachi ls <inputs> [--match text] [--textures] [--extract dir] [--keys dir]` | Lists what the game's archives hold, or the textures inside its `.ytd` files, and copies matching files out: resources with their header, others decompressed. |
|
|
27
29
|
|
|
28
30
|
### Convert options
|
|
29
31
|
|
|
@@ -32,10 +34,12 @@ Open the address it prints to browse what you converted. Click a model to try it
|
|
|
32
34
|
| `-o <folder>` | Output folder. Defaults to `out`. |
|
|
33
35
|
| `-j <n>` | Worker threads. Defaults to all cores. |
|
|
34
36
|
| `--keys <folder>` | Opens encrypted archives. |
|
|
35
|
-
| `--only <file>` | Converts only the models named in this file, one per line. |
|
|
37
|
+
| `--only <file>` | Converts only the models and clip dictionaries named in this file, one per line. |
|
|
36
38
|
| `--skeleton <file>` | Ped skeleton `.yft` for clothing that has none nearby. |
|
|
37
39
|
|
|
38
|
-
When a model exists more than once, the first input wins, so list mods before the game folder. Problems are listed in `<output>/report.json`.
|
|
40
|
+
When a model or clip dictionary exists more than once, the first input wins, so list mods before the game folder. Problems are listed in `<output>/report.json`.
|
|
41
|
+
|
|
42
|
+
Each clip in a `.ycd` becomes its own file in `clips/`, listed in the manifest under its dictionary, the name the game loads it by. Clips are skeleton-free: they name bones by tag, so one clip plays on any character with those bones.
|
|
39
43
|
|
|
40
44
|
### Thumbnail options
|
|
41
45
|
|
|
@@ -52,7 +56,7 @@ Without Chrome or Edge, run `bunx playwright install chromium` once.
|
|
|
52
56
|
|
|
53
57
|
| Option | Description |
|
|
54
58
|
| --- | --- |
|
|
55
|
-
| `--only <file>` | Keeps only the models named in this file, one per line, with the parts, wheels and
|
|
59
|
+
| `--only <file>` | Keeps only the models and clip dictionaries named in this file, one per line, with the parts, wheels, textures and clips they use. |
|
|
56
60
|
|
|
57
61
|
Packing again into the same folder adds what is new and rewrites the index last. It stops without writing an index if a file the models use is missing.
|
|
58
62
|
|
|
@@ -70,6 +74,10 @@ bun run convert path/to/game --keys path/to/keys --only models.txt
|
|
|
70
74
|
|
|
71
75
|
`playground/` is one plain page, and nothing depends on it. It lists every model. Clicking one opens it in 3D with native controls. Press the left and right arrow keys to step through models. Links open a model with its settings, such as `/#adder?primary=30&wrap=1&mods.0=2`.
|
|
72
76
|
|
|
77
|
+
When the folder holds clips, the Animation panel plays them on the model: search the dictionaries, pick a clip, then play, scrub, step frames with `,` and `.` (space plays and pauses), change the speed, loop, move the character along the clip's path with Root motion, and look from the front, back, sides, top or the game's own camera behind the character. Base plays a clip underneath for the bones the shown one leaves alone, as the game plays a clip over the character's idle. Check lists what looks wrong in the clip, the same report as `bun run anim inspect`; click a problem to see its moment. Links keep the clip and moment: `/#mp_m_freemode_01?clip=up_anims@wave/wave&t=0.3&view=game`.
|
|
78
|
+
|
|
79
|
+
Freemode characters (`mp_m_freemode_01`, `mp_f_freemode_01`) also get a Face and hair panel: pick the two parent heads, slide how much of each one's shape and skin the face takes, colour the hair and its highlights, pick an eye colour, put on eyebrows, beards, makeup and the other overlays, shape the face with the game's 20 sliders, and fly in close to the face or the hands. Links keep the whole look, clothes included: `/#mp_m_freemode_01?outfit=hair=4:a,jbib=5:a&head=4,21,0.4&hairColor=%232e221b&overlays=eyebrows:20:1:%232e221b,facialHair:10:1:%232e221b&eyes=3&features=13:0.4,14:0.5&clip=up_anims@wave/wave`.
|
|
80
|
+
|
|
73
81
|
## Runtime
|
|
74
82
|
|
|
75
83
|
`katachi-runtime` shows converted models with [three.js](https://threejs.org). Pack your output folder with `bun run pack`, then upload the packed folder to any static host, such as Cloudflare R2 with CORS enabled. Every file but `manifest.json.gz` is content-hashed, so it can be cached forever; upload `manifest.json.gz` last, with a short cache time. The runtime also opens an unpacked output folder, as the playground does.
|
|
@@ -88,6 +96,15 @@ await stage.show(assets, "adder", { primary: 30, secondary: "#ffcc00", wrap: 1,
|
|
|
88
96
|
|
|
89
97
|
Give the canvas a size with CSS. To draw into your own three.js scene, use `await assets.load(name, props)` and add `model.root`.
|
|
90
98
|
|
|
99
|
+
Play a clip on a character, by its dictionary and name as the game knows them:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const character = await stage.show(assets, "mp_m_freemode_01");
|
|
103
|
+
character.play(await assets.clip("up_anims@wave", "wave"), { loop: true });
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The stage plays it; in your own scene, call `model.update(seconds)` every frame. Clothing and props follow the bones.
|
|
107
|
+
|
|
91
108
|
Props use the game's own numbers, so saved vehicle data can be passed straight in:
|
|
92
109
|
|
|
93
110
|
| Prop | Value |
|
|
@@ -110,14 +127,18 @@ Not all cars have wraps or tuning, so check `wraps()` and `mods()` before offeri
|
|
|
110
127
|
class Assets {
|
|
111
128
|
static open(baseUrl: string): Promise<Assets>; // baseUrl ends with a slash
|
|
112
129
|
models: { kind: "vehicle" | "character" | "object" | "map"; name: string }[];
|
|
113
|
-
|
|
130
|
+
dictionaries: string[]; // clip dictionaries, sorted
|
|
131
|
+
load(name: string, props?: VehicleProps, look?: Look): Promise<Model>; // a Vehicle or Character when that is what it is; a character loads straight into `look`
|
|
132
|
+
clips(dictionary: string): Promise<Record<string, { path: string; frames: number; fps: number }>>;
|
|
133
|
+
clip(dictionary: string, name: string): Promise<Clip>;
|
|
114
134
|
clear(): void; // frees shared textures; dispose models first
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
class Stage {
|
|
118
138
|
constructor(canvas: HTMLCanvasElement, options?: StageOptions); // drag to orbit, scroll to zoom; draws nothing while off screen
|
|
119
|
-
show(assets: Assets, name: string, props?: VehicleProps): Promise<Model | undefined>; // resolves once drawn; undefined if another model was shown meanwhile
|
|
139
|
+
show(assets: Assets, name: string, props?: VehicleProps, look?: Look): Promise<Model | undefined>; // resolves once drawn; undefined if another model was shown meanwhile. A character in `look` loads only what the look wears, all at once
|
|
120
140
|
view(direction?: [number, number, number], options?: { duration?: number }): Promise<boolean>; // flies around the model to look from there, or back to model.view; false if the user took over
|
|
141
|
+
focus(sphere: FocusSphere, options?: { direction?: [number, number, number]; duration?: number }): Promise<boolean>; // flies in close to part of the model, such as character.part("face")
|
|
121
142
|
setAutoRotate(on: boolean): void;
|
|
122
143
|
setLighting(lighting: "studio" | "night", options?: { duration?: number }): void; // fades the studio light to night and back
|
|
123
144
|
pick(clientX: number, clientY: number): THREE.Object3D | null; // the bone or mesh under a pointer, read from the GPU
|
|
@@ -138,9 +159,49 @@ class Model {
|
|
|
138
159
|
bones: Map<string, THREE.Object3D>;
|
|
139
160
|
view: [number, number, number]; // best viewing direction
|
|
140
161
|
placeAtOrigin(): THREE.Box3;
|
|
162
|
+
play(clip: Clip, options?: PlayOptions): Playback; // blends in from the current pose; bones the clip leaves alone keep their rest pose
|
|
163
|
+
stop(options?: { blend?: number }): void; // blends back to rest
|
|
164
|
+
playback: Playback | null;
|
|
165
|
+
update(seconds: number): void; // advances the clip; Stage calls it every frame
|
|
166
|
+
refresh(): void; // shows the pose after changing playback.time while paused
|
|
167
|
+
setRootMotion(on: boolean): void;
|
|
141
168
|
dispose(): void;
|
|
142
169
|
}
|
|
143
170
|
|
|
171
|
+
interface PlayOptions {
|
|
172
|
+
loop?: boolean; // defaults to true
|
|
173
|
+
speed?: number; // defaults to 1
|
|
174
|
+
rootMotion?: boolean; // moves the model along the clip's mover track; defaults to false: in place
|
|
175
|
+
blend?: number; // seconds, defaults to 0.2
|
|
176
|
+
time?: number; // seconds into the clip to start at
|
|
177
|
+
paused?: boolean;
|
|
178
|
+
base?: Clip | null; // plays underneath, looping, for the bones this clip leaves alone
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
class Playback {
|
|
182
|
+
clip: Clip;
|
|
183
|
+
time: number; // seconds; set it to seek
|
|
184
|
+
speed: number;
|
|
185
|
+
loop: boolean;
|
|
186
|
+
paused: boolean;
|
|
187
|
+
duration: number;
|
|
188
|
+
frame: number; // fractional
|
|
189
|
+
finished: boolean; // a clip that does not loop has reached its end
|
|
190
|
+
missing: number[]; // tags of bones the clip moves that the model lacks
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
class Clip {
|
|
194
|
+
dictionary: string;
|
|
195
|
+
name: string;
|
|
196
|
+
hash: number; // the key the game plays it by
|
|
197
|
+
fps: number;
|
|
198
|
+
frames: number;
|
|
199
|
+
duration: number;
|
|
200
|
+
tracks: Track[]; // by bone tag; mover tracks have bone 0
|
|
201
|
+
static fromJSON(data: ClipData): Clip;
|
|
202
|
+
toJSON(): ClipData;
|
|
203
|
+
}
|
|
204
|
+
|
|
144
205
|
class Vehicle extends Model {
|
|
145
206
|
entry: VehicleEntry; // includes factory colors
|
|
146
207
|
apply(props: VehicleProps): Promise<void>;
|
|
@@ -166,10 +227,61 @@ class Vehicle extends Model {
|
|
|
166
227
|
}
|
|
167
228
|
|
|
168
229
|
class Character extends Model {
|
|
230
|
+
static views: { front; back; left; right; top; game }; // directions for Stage.view; game is the game's camera, behind and over the right shoulder
|
|
169
231
|
entry: PedEntry; // lists components and props
|
|
170
232
|
setComponent(component: string, piece: PieceEntry | null, variant?: string): Promise<void>;
|
|
171
233
|
setProp(component: string, piece: PieceEntry | null, variant?: string): Promise<void>;
|
|
172
234
|
selected(slot: string): { piece: PieceEntry; variant?: string } | undefined; // prop slots are p_<component>
|
|
235
|
+
dress(look: Look): Promise<string[]>; // puts on an outfit, face, hair colour, overlays, eyes and face shape; returns the choices it lacks, such as "jbib=500"
|
|
236
|
+
part(name: BodyPart): FocusSphere; // face, hands, left-hand, right-hand or feet, for Stage.focus
|
|
237
|
+
look(): Look; // what is worn: the slots changed from the defaults, the face, the hair colour
|
|
238
|
+
armsFor(top: number): number | undefined; // the arms the game pairs a base freemode top with
|
|
239
|
+
|
|
240
|
+
// Freemode characters
|
|
241
|
+
freemode: boolean; // mp_m_freemode_01 and mp_f_freemode_01
|
|
242
|
+
heads(): number[]; // the parent heads a face blends, by the game's numbers (0 to 45)
|
|
243
|
+
setHead(blend: HeadBlend): Promise<void>; // changing only the mixes of the worn face is immediate
|
|
244
|
+
head: HeadBlend | null;
|
|
245
|
+
setHairColor(color: Tone, highlight?: Tone): void; // a CSS colour or [r, g, b] from 0 to 255
|
|
246
|
+
hairColor(): { color: string; highlight: string };
|
|
247
|
+
setOverlay(name: OverlayName, overlay: Overlay | null): Promise<void>; // SetPedHeadOverlay and its colour
|
|
248
|
+
setOverlays(overlays: Partial<Record<OverlayName, Overlay | null>>): Promise<void>;
|
|
249
|
+
overlayStyles(name: OverlayName): number; // how many styles the game has
|
|
250
|
+
setEyeColor(color: number | null): Promise<void>; // 0 to 31, EYE_COLORS
|
|
251
|
+
setFaceFeature(feature: number | string, value: number): void; // SetPedFaceFeature: 0 to 19, -1 to 1
|
|
252
|
+
setFaceFeatures(values: number[]): void;
|
|
253
|
+
faceFeatures(): number[];
|
|
254
|
+
|
|
255
|
+
static parseOutfit(text: string): Record<string, string>; // "jbib=5:a,hair=12,p_head=none"
|
|
256
|
+
static formatOutfit(outfit: Record<string, string>): string;
|
|
257
|
+
static parseHead(text: string): HeadBlend; // "4,21,0.4", or "4,21,0.4,4,21,0.9" to mix skin apart from shape
|
|
258
|
+
static formatHead(blend: HeadBlend): string;
|
|
259
|
+
static parseOverlays(text: string): Partial<Record<OverlayName, Overlay>>; // "eyebrows:3,facialHair:10:0.8:#2e221b"
|
|
260
|
+
static parseFeatures(text: string): number[]; // "0:0.5,13:-0.4"
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
interface Overlay {
|
|
264
|
+
style: number; // in the game's list for that overlay
|
|
265
|
+
opacity?: number; // 0 to 1, 1 by default
|
|
266
|
+
color?: string; // for eyebrows, beards, chest hair, blush and lipstick
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
interface HeadBlend {
|
|
270
|
+
shapeFirst: number; // parent heads, 0 to 45
|
|
271
|
+
shapeSecond: number;
|
|
272
|
+
shapeMix: number; // 0 is all the first parent, 1 all the second
|
|
273
|
+
skinFirst: number;
|
|
274
|
+
skinSecond: number;
|
|
275
|
+
skinMix: number;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface Look {
|
|
279
|
+
outfit?: Record<string, string>; // { jbib: "5:a", hair: "12:a", p_head: "none" }; a DLC pack's piece names its pack: "mp_m_freemode_01_mp_m_xmas/5:a"
|
|
280
|
+
head?: HeadBlend;
|
|
281
|
+
hair?: { color: Tone; highlight?: Tone };
|
|
282
|
+
overlays?: Partial<Record<OverlayName, Overlay>>; // eyebrows, facialHair, makeup, blush, lipstick, ageing...
|
|
283
|
+
eyes?: number;
|
|
284
|
+
features?: number[];
|
|
173
285
|
}
|
|
174
286
|
|
|
175
287
|
class ThumbnailRenderer {
|
|
@@ -179,9 +291,164 @@ class ThumbnailRenderer {
|
|
|
179
291
|
}
|
|
180
292
|
```
|
|
181
293
|
|
|
294
|
+
`PED_BONES` names the standard ped skeleton's bone tags, and `boneName(tag)` reads one back, such as `SKEL_R_Hand` for 57005.
|
|
295
|
+
|
|
296
|
+
### Freemode faces and hair
|
|
297
|
+
|
|
298
|
+
The game builds an online character's face at runtime, and Katachi does the same from the converted pieces. `setHead` loads the two parent heads, which share their vertices, and morphs between their shapes; their skin textures mix in the shader. The mixed skin tone carries to the rest of the body: texels the colour of the body's own skin take it, and clothing keeps its colours. Freemode skin is also given skin's dull shine, where its pieces would make it look wet.
|
|
299
|
+
|
|
300
|
+
Freemode hair textures are templates rather than colours: green holds each strand's brightness and red where highlights show. The converter marks these variants in the manifest (`"tint": ["a", ...]` on the piece), and the character colours them with `setHairColor`, calibrated against the game's own coloured hair. All hair is drawn in two passes, as the game does: solid strands, then their soft ends blended over them.
|
|
301
|
+
|
|
302
|
+
Overlays are the game's 13 (`OVERLAYS`, in SetPedHeadOverlay's order: blemishes, facialHair, eyebrows, ageing, makeup, blush, complexion, sunDamage, lipstick, freckles, chestHair, bodyBlemishes, moreBodyBlemishes), read from `facial_overlays.meta` with every style the update and DLC packs add. The converter lists them in the manifest's `freemode` section; the character composites the ones worn into one layer over the face (and one over the torso for chest hair), with decals such as beards and lipstick covering the skin and details such as ageing darkening and lightening it. Eye colours swap the eyes' square of the face for a cell of the game's 32-eye palette. The 20 face features are the game's 38 morph targets (`micro_nose_thin.ydr` and the rest), offsets for the 1514 vertices every freemode head shares; the face carries them as morph targets beside the second parent's shape.
|
|
303
|
+
|
|
304
|
+
Pieces the game swaps in under hats and masks (`hair_010_u_1`, a 164-vertex head) are marked `alternate` in the manifest and never worn by number. A base top (`jbib` 0 to 15) goes on with the arms (`uppr`) the game pairs it with, unless the look names its own, so a jacket's sleeves never show skin through when the elbows bend; later tops carry their arms in the game's shop data, which a saved look stores. Clothing the game never offers carries a 64 px checkerboard stand-in for a texture; the converter leaves those variants out, and pieces with nothing else, so a freemode character starts in each slot's number 0 or, for masks, bags and armour, in nothing. Textures with no skin painted in them (the game's `_uni`) are marked `plain` and never take a skin tone; the rest take it only where their colour lies on the skin's own line from grey, so pale patches tint with the rest and tan cloth does not. Freemode hairstyles also carry a coarse shell of cards after their strands, which the game draws only on its own terms; the character leaves it off.
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
const character = (await stage.show(assets, "mp_f_freemode_01")) as Character;
|
|
308
|
+
await character.dress({
|
|
309
|
+
outfit: { hair: "10:a", jbib: "5:a" },
|
|
310
|
+
head: Character.parseHead("21,31,0.6"),
|
|
311
|
+
hair: { color: "#a79369", highlight: "#dac38e" },
|
|
312
|
+
overlays: { eyebrows: { style: 3, color: "#5a4030" }, lipstick: { style: 2, opacity: 0.9, color: "#a0303a" } },
|
|
313
|
+
eyes: 2,
|
|
314
|
+
features: Character.parseFeatures("0:-0.3,12:0.4"),
|
|
315
|
+
});
|
|
316
|
+
await stage.focus(character.part("face"));
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Animation tool
|
|
320
|
+
|
|
321
|
+
`bun run anim` reads clips from the game's `.ycd` files, finds what makes them look wrong, pictures them on a real character, fixes them, makes new ones from a short script, and writes `.ycd` files the game streams. Its output is plain text made to be read and acted on, by a person or by an AI.
|
|
322
|
+
|
|
323
|
+
The loop: inspect, look, edit, inspect again, and put the `.ycd` in the game's stream folder.
|
|
324
|
+
|
|
325
|
+
```sh
|
|
326
|
+
export KATACHI_ASSETS=out # a converted folder with a character, for pictures and measuring
|
|
327
|
+
bun run anim inspect stream/up_anims@hiphop.ycd
|
|
328
|
+
bun run anim render stream/up_anims@hiphop.ycd --views front,left,game --frames 6 -o hiphop.png
|
|
329
|
+
bun run anim edit stream/up_anims@hiphop.ycd -o fixed/up_anims@hiphop.ycd "smooth SKEL_L_Foot" "loop 0.4" "plant both"
|
|
330
|
+
bun run anim inspect fixed/up_anims@hiphop.ycd
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`inspect` names each problem with when it happens and the edit step that fixes it:
|
|
334
|
+
|
|
335
|
+
```text
|
|
336
|
+
up_anims@hiphop/hiphop: 191 frames at 30 fps, 6.333 s, 61 tracks (61 moving)
|
|
337
|
+
Turns: left arm 117.6°, right arm 112.8°, right leg 90.1°, left leg 62.7°, right fingers 32°, ...
|
|
338
|
+
10 problems:
|
|
339
|
+
! slide: the right foot slides 39.3 cm along the ground at 0.5–1.2 s → "plant right"
|
|
340
|
+
! pop: SKEL_L_Foot snaps 26.4° in one frame at 3.03–3.07 s → "smooth SKEL_L_Foot"
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
It checks loops that jump, frozen hands and limbs, limbs that stop dead mid-move, single-frame pops, knees and elbows bending backwards, feet that sink, float or slide, hands and elbows through the body, knees through each other, bone lengths that change (a clip made for another body), and a body that wanders from where it stands. `--json` prints the same report as data.
|
|
344
|
+
|
|
345
|
+
The checks are tuned on Rockstar's own clips, measured on the freemode skeleton: 453 of 660 come out with no warnings. Most of the rest are walks, turns and dances whose feet do skate along the floor, which the game's movement hides, so look at a picture before fixing a slide in such a clip.
|
|
346
|
+
|
|
347
|
+
### Commands
|
|
348
|
+
|
|
349
|
+
| Command | What it does |
|
|
350
|
+
| --- | --- |
|
|
351
|
+
| `anim list <clips>` | Lists clips with their frames, rate and length. |
|
|
352
|
+
| `anim inspect <clips>` | The report above. Feet, contacts, joints and drift need a skeleton. |
|
|
353
|
+
| `anim render <clip> -o <file.png>` | A sheet of pictures: a row per view (`--views`), a column per time (`--frames <n>` spread out, or `--at 0.2,0.8`). |
|
|
354
|
+
| `anim render <clip> -o <file.mp4 or .gif>` | A video of every frame from one view (`--view`), with ffmpeg. |
|
|
355
|
+
| `anim edit <clip> -o <out> <steps>` | Applies edit steps in order. Writing back to the same `.ycd` keeps its other clips. |
|
|
356
|
+
| `anim build <script.json> -o <out>` | Makes a new clip from keys. |
|
|
357
|
+
| `anim motions [bone]` | How each joint moves: the words `rotate` and `build` take. |
|
|
358
|
+
| `anim bones` | The skeleton's bones, tags and regions. |
|
|
359
|
+
|
|
360
|
+
A clip is `file.ycd`, `file.ycd:clip`, `file.json` or `file.json:clip`, or `dictionary/clip` with `--assets`. Output is a `.ycd` for the game, named as the dictionary it holds, or a `.json` for the runtime and this tool.
|
|
361
|
+
|
|
362
|
+
| Option | Description |
|
|
363
|
+
| --- | --- |
|
|
364
|
+
| `--skeleton <ped.yft or folder[:ped]>` | The body to measure and edit on: a ped's `.yft`, or a converted folder and character. Defaults to `KATACHI_SKELETON`, then `--assets`. |
|
|
365
|
+
| `--assets <folder>` | A converted folder: clips by `dictionary/clip`, and characters to render. Defaults to `KATACHI_ASSETS`. |
|
|
366
|
+
| `--ped <name>` | The character to render. Defaults to the first in `--assets`. |
|
|
367
|
+
| `--outfit <slot=index[:variant],...>` | Clothing to render in, such as `jbib=5:a,p_head=none`. |
|
|
368
|
+
| `--head <first,second,mix>` | A freemode face from two parent heads (0 to 45), such as `4,21,0.4`. Add `,skinFirst,skinSecond,skinMix` to mix the skin apart from the shape. |
|
|
369
|
+
| `--hair-color <color[,highlight]>` | Freemode hair colour, such as `#4b321f,#a79369`. |
|
|
370
|
+
| `--overlays <name:style[:opacity[:color]],...>` | Freemode eyebrows, beards, makeup and the rest, such as `eyebrows:20:1:#2e221b,facialHair:10`. |
|
|
371
|
+
| `--eyes <0-31>` | Freemode eye colour, in the game's order. |
|
|
372
|
+
| `--features <n:value,...>` | Freemode face features, -1 to 1 by SetPedFaceFeature's number, such as `13:0.4,14:0.5`. |
|
|
373
|
+
| `--focus <part>` | A close-up that follows `face`, `hands`, `left-hand`, `right-hand` or `feet` through the clip. |
|
|
374
|
+
| `--views <names>` | `front`, `back`, `left`, `right`, `top`, `game`, or `x,y,z` directions separated by `;`. |
|
|
375
|
+
| `--size <WxH>` | Picture size. Defaults to `320x400`. |
|
|
376
|
+
| `--recipe <file>` | Edit steps from a file, one per line, `#` for comments. |
|
|
377
|
+
|
|
378
|
+
### Edit steps
|
|
379
|
+
|
|
380
|
+
Each step is one argument: a word, then values and `key=value` settings. Times are seconds. `from=` and `to=` limit a step to part of the clip and `ease=` blends it in and out.
|
|
381
|
+
|
|
382
|
+
| Step | What it does |
|
|
383
|
+
| --- | --- |
|
|
384
|
+
| `trim <start> <end>` | Keeps the part between two times. |
|
|
385
|
+
| `speed <factor>` | Plays faster above 1, slower below. |
|
|
386
|
+
| `fps <n>` | Resamples to another frame rate, keeping the length. |
|
|
387
|
+
| `reverse` | Plays backwards, the mover's path too. |
|
|
388
|
+
| `loop [seconds]` | Bends the last seconds so the clip ends where it starts. |
|
|
389
|
+
| `mirror` | Swaps left and right. |
|
|
390
|
+
| `rotate <bone> <motion>=<degrees>...` | Turns a bone the way a body moves, such as `rotate SKEL_R_UpperArm raise=20 forward=-10 from=0.4 to=1.2`. |
|
|
391
|
+
| `hold <bones> at=<s>` | Keeps bones in the pose they have at one time. |
|
|
392
|
+
| `smooth <bones or all> [frames=<n>]` | Evens out jitter, pops and sudden stops. |
|
|
393
|
+
| `hands left=<pose> right=<pose>` or `both=<pose>` | Poses the fingers: `relaxed`, `open`, `flat` (straight and together, for a salute), `fist`, `grip`, `point` or `peace`, each knuckle bent from straight, not from the skeleton's already curled rest. They sway by `life=` degrees (2 by default) so they never look frozen. Mixamo's fingers come through a retarget clawed: `hands both=relaxed` replaces them. |
|
|
394
|
+
| `breathe [amount]` | Adds breathing, head drift and small arm and knee shifts, so still parts stop looking frozen. 1 is calm. |
|
|
395
|
+
| `plant [left, right or both]` | Pins each foot where it stands on the ground, bending the knee to keep it there. Off the ground the foot keeps its own path, eased from one spot to the next. Put it last: steps after it move the feet again. |
|
|
396
|
+
| `ground` | Raises or lowers the body so the lowest foot stands on the ground. |
|
|
397
|
+
| `center` | Keeps the body over the spot where it starts. |
|
|
398
|
+
| `unstretch` | Removes position tracks below the root, so every body keeps its own bone lengths. |
|
|
399
|
+
| `keep <bones or regions>` | Keeps only these bones' tracks; in game the rest of the body plays what is underneath. `keep upper` makes an upper-body clip. |
|
|
400
|
+
| `drop <bones, regions or mover>` | Removes tracks. |
|
|
401
|
+
| `name <clip name>` | Renames the clip; the game plays it by this name. |
|
|
402
|
+
|
|
403
|
+
Bones are named as in the game (`SKEL_R_Hand`), by region (`arm_l`, `arm_r`, `fingers_l`, `fingers_r`, `leg_l`, `leg_r`, `spine`, `head`, `pelvis`, `root`, `face`) or by group (`arms`, `hands`, `legs`, `upper`, `lower`, `body`), separated by commas.
|
|
404
|
+
|
|
405
|
+
Motions are what a body does, so the numbers read the same on either side and in any pose: `raise` lifts an arm out to its own side, `forward` swings it forward, `bend` bends an elbow, knee or the spine forward, `twist` rolls a limb's front inward, `curl` closes a finger into the palm. `anim motions` lists them all.
|
|
406
|
+
|
|
407
|
+
Positions are in metres in the character's own frame: X to its right, Y forward, Z up.
|
|
408
|
+
|
|
409
|
+
### Making a clip
|
|
410
|
+
|
|
411
|
+
A script lists keys over time. Each key changes the pose from the base, poses the hands, reaches a hand or foot to a point, and looks somewhere. Between keys the body eases from one to the next, and while it holds a pose it keeps breathing.
|
|
412
|
+
|
|
413
|
+
```json
|
|
414
|
+
{
|
|
415
|
+
"name": "point_you",
|
|
416
|
+
"duration": 2.4,
|
|
417
|
+
"loop": true,
|
|
418
|
+
"keys": [
|
|
419
|
+
{ "at": 0 },
|
|
420
|
+
{
|
|
421
|
+
"at": 0.55,
|
|
422
|
+
"ease": "out",
|
|
423
|
+
"pose": { "spine": { "twist": 8, "bend": 4 }, "SKEL_Head": { "nod": -4 } },
|
|
424
|
+
"reach": { "SKEL_R_Hand": { "to": [0.05, 0.55, 0.05] } },
|
|
425
|
+
"hands": { "right": "point" },
|
|
426
|
+
"look": { "to": [0, 3, 0] }
|
|
427
|
+
},
|
|
428
|
+
{ "at": 1.35 },
|
|
429
|
+
{ "at": 1.8, "pose": {} }
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
| Field | Description |
|
|
435
|
+
| --- | --- |
|
|
436
|
+
| `name` | The clip name the game plays it by. |
|
|
437
|
+
| `duration`, `fps` | Length in seconds, and frames per second (30 by default). |
|
|
438
|
+
| `base` | What keys change: `stand` (arms down, relaxed hands; the default), `rest` (the skeleton's own pose), or a clip to play over. |
|
|
439
|
+
| `bones` | The bones the clip drives: `all` the body (the default), `moved` (only those the keys change, for a clip that plays over another), or bones and regions. |
|
|
440
|
+
| `loop` | Ends on the first key's pose, so it loops without a jump. |
|
|
441
|
+
| `life` | How much the body breathes and shifts while it holds a pose: 1 by default, 0 for none. |
|
|
442
|
+
| `keys[].at` | Seconds. |
|
|
443
|
+
| `keys[].ease` | How the body arrives: `inOut` (the default), `in`, `out`, `linear` or `hold`. |
|
|
444
|
+
| `keys[].pose` | Motions by bone, as `rotate` takes them; `spine` spreads a motion over the four spine bones. `{}` returns to the base. A key without `pose` holds the key before. |
|
|
445
|
+
| `keys[].hands` | `left`, `right` or `both`: a hand pose. |
|
|
446
|
+
| `keys[].reach` | `SKEL_L_Hand`, `SKEL_R_Hand`, `SKEL_L_Foot` or `SKEL_R_Foot`: `to` a point in metres from `from` (the shoulder or hip by default), with an optional `hint`, the way the elbow or knee points. |
|
|
447
|
+
| `keys[].look` | `to` a point in metres from `from` (the head by default). |
|
|
448
|
+
|
|
182
449
|
## Not supported yet
|
|
183
450
|
|
|
184
|
-
Tire smoke, dirt and damage, assembled buildings,
|
|
451
|
+
Tire smoke, dirt and damage, assembled buildings, tattoos and hair fades (ped decorations), the overlays' normal and specular maps, server clothing numbers, facial animation, and clip tags (events such as footsteps), which are read but not written to `.ycd` files.
|
|
185
452
|
|
|
186
453
|
## Legal
|
|
187
454
|
|
package/animation.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type Clip } from "./clip";
|
|
3
|
+
/** How a clip plays. */
|
|
4
|
+
export interface PlayOptions {
|
|
5
|
+
/** Starts over at the end. Defaults to true. */
|
|
6
|
+
loop?: boolean;
|
|
7
|
+
/** Playback rate: 1 is the game's speed. Defaults to 1. */
|
|
8
|
+
speed?: number;
|
|
9
|
+
/** Moves the whole model along the clip's mover track, as the game moves the ped. Defaults to false: in place. */
|
|
10
|
+
rootMotion?: boolean;
|
|
11
|
+
/** Seconds to blend in from the current pose. Defaults to 0.2. */
|
|
12
|
+
blend?: number;
|
|
13
|
+
/** Seconds into the clip to start at. */
|
|
14
|
+
time?: number;
|
|
15
|
+
/** Starts paused, showing the pose at `time`. */
|
|
16
|
+
paused?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A clip that plays underneath, looping, for the bones this one does not move, the way the game plays a clip over
|
|
19
|
+
* the ped's idle. Without one, those bones keep their rest pose.
|
|
20
|
+
*/
|
|
21
|
+
base?: Clip | null;
|
|
22
|
+
}
|
|
23
|
+
/** A clip playing on a model. */
|
|
24
|
+
export declare class Playback {
|
|
25
|
+
readonly clip: Clip;
|
|
26
|
+
/** Tags of the bones the clip moves that the model does not have. */
|
|
27
|
+
readonly missing: readonly number[];
|
|
28
|
+
/** How many of the model's bones the clip moves. */
|
|
29
|
+
readonly moved: number;
|
|
30
|
+
/** Seconds into the clip. */
|
|
31
|
+
time: number;
|
|
32
|
+
speed: number;
|
|
33
|
+
loop: boolean;
|
|
34
|
+
paused: boolean;
|
|
35
|
+
/** Seconds into the base clip. */
|
|
36
|
+
baseTime: number;
|
|
37
|
+
readonly base: Clip | null;
|
|
38
|
+
constructor(clip: Clip, options: PlayOptions,
|
|
39
|
+
/** Tags of the bones the clip moves that the model does not have. */
|
|
40
|
+
missing: readonly number[],
|
|
41
|
+
/** How many of the model's bones the clip moves. */
|
|
42
|
+
moved: number);
|
|
43
|
+
/** Seconds from the first frame to the last. */
|
|
44
|
+
get duration(): number;
|
|
45
|
+
/** The fractional frame being shown. */
|
|
46
|
+
get frame(): number;
|
|
47
|
+
/** True when a clip that does not loop has reached its end. */
|
|
48
|
+
get finished(): boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Finds each bone by its tag: from the model when the converter stored it, else from the standard ped bone names. */
|
|
51
|
+
export declare function bonesByTag(bones: ReadonlyMap<string, THREE.Object3D>): Map<number, THREE.Object3D>;
|
|
52
|
+
/** Plays clips on one model's bones, blending from pose to pose. */
|
|
53
|
+
export declare class Animator {
|
|
54
|
+
private readonly root;
|
|
55
|
+
private readonly byTag;
|
|
56
|
+
private readonly rest;
|
|
57
|
+
private origin;
|
|
58
|
+
private bindings;
|
|
59
|
+
private current;
|
|
60
|
+
private from;
|
|
61
|
+
/** Bones a clip has moved and that have not settled back at rest: the only ones the animator touches outside a clip. */
|
|
62
|
+
private readonly touched;
|
|
63
|
+
private blend;
|
|
64
|
+
private blended;
|
|
65
|
+
private rootMotion;
|
|
66
|
+
private carried;
|
|
67
|
+
private carriedTurn;
|
|
68
|
+
private readonly sample;
|
|
69
|
+
private readonly target;
|
|
70
|
+
private readonly moverPosition;
|
|
71
|
+
private readonly moverTurn;
|
|
72
|
+
/**
|
|
73
|
+
* The turn from the game's ped frame to the model's. A ped skeleton rests turned half round, facing the camera, while
|
|
74
|
+
* clips turn its root to face the ped's way: the root's tracks and the mover are turned the same, so every clip faces
|
|
75
|
+
* where the model rests.
|
|
76
|
+
*/
|
|
77
|
+
private readonly entity;
|
|
78
|
+
private readonly entityInverse;
|
|
79
|
+
constructor(root: THREE.Object3D, bones: ReadonlyMap<string, THREE.Object3D>);
|
|
80
|
+
get playback(): Playback | null;
|
|
81
|
+
play(clip: Clip, options?: PlayOptions): Playback;
|
|
82
|
+
stop(blend?: number): void;
|
|
83
|
+
/** Moves the model along the clip's mover track, or puts it back where it stood. */
|
|
84
|
+
setRootMotion(on: boolean): void;
|
|
85
|
+
update(seconds: number): void;
|
|
86
|
+
/** Shows the clip's pose at its current time. */
|
|
87
|
+
apply(): void;
|
|
88
|
+
/** Puts every bone back in its rest pose and the model where it stood. */
|
|
89
|
+
dispose(): void;
|
|
90
|
+
/** Starts blending every bone that moves, or will, from where it is now. */
|
|
91
|
+
private startBlend;
|
|
92
|
+
/** Moves a bone from where the blend started toward the pose it now holds. */
|
|
93
|
+
private mix;
|
|
94
|
+
private advance;
|
|
95
|
+
/** At each loop, the mover's whole journey is kept, so a walk goes on rather than jumping back. */
|
|
96
|
+
private carryLap;
|
|
97
|
+
private moverAt;
|
|
98
|
+
/** Where the mover is at `time`, from where it was on the first frame. */
|
|
99
|
+
private mover;
|
|
100
|
+
private moveRoot;
|
|
101
|
+
}
|
package/assets.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type Look } from "./character";
|
|
2
|
+
import { Clip, type AnimationEntry, type ClipEntry } from "./clip";
|
|
1
3
|
import { Model } from "./model";
|
|
2
4
|
import { type VehicleProps } from "./vehicle";
|
|
3
5
|
/** A tuning option a vehicle can fit. */
|
|
@@ -39,6 +41,30 @@ export interface PieceEntry {
|
|
|
39
41
|
mesh: string;
|
|
40
42
|
/** Texture paths by variant name. */
|
|
41
43
|
diffuse: Record<string, string>;
|
|
44
|
+
/** Variants that are hair templates the character colours with `setHairColor`, rather than colours of their own. */
|
|
45
|
+
tint?: string[];
|
|
46
|
+
/** Variants whose texture has no skin painted in it (the game's `_uni`), so no skin tone carries onto them. */
|
|
47
|
+
plain?: string[];
|
|
48
|
+
/** Set on the game's alternate meshes of a piece (1 or 2), which it swaps in under hats and masks, rather than a style. */
|
|
49
|
+
alternate?: number;
|
|
50
|
+
}
|
|
51
|
+
/** One style of a freemode overlay: its colour texture with coverage in alpha, and its normal and specular maps. */
|
|
52
|
+
export interface OverlayEntry {
|
|
53
|
+
name: string;
|
|
54
|
+
diffuse: string;
|
|
55
|
+
normal?: string;
|
|
56
|
+
specular?: string;
|
|
57
|
+
}
|
|
58
|
+
/** What freemode faces are made with: every head overlay's styles by category, and the 32 eye colours. */
|
|
59
|
+
export interface FreemodeEntry {
|
|
60
|
+
overlays: Record<string, (OverlayEntry | null)[]>;
|
|
61
|
+
eyeColors?: string;
|
|
62
|
+
/** The face feature targets: one file of each target's offsets for every head vertex, in `targets` order. */
|
|
63
|
+
features?: {
|
|
64
|
+
path: string;
|
|
65
|
+
vertices: number;
|
|
66
|
+
targets: string[];
|
|
67
|
+
};
|
|
42
68
|
}
|
|
43
69
|
/** A character in the manifest. */
|
|
44
70
|
export interface PedEntry {
|
|
@@ -57,6 +83,10 @@ export interface Manifest {
|
|
|
57
83
|
models: Record<string, string>;
|
|
58
84
|
/** Paths of map pieces, such as buildings, rooms and interior layers, by name. */
|
|
59
85
|
map: Record<string, string>;
|
|
86
|
+
/** Clip dictionaries by name. In version 3, each is a path to its own entry file. */
|
|
87
|
+
animations?: Record<string, AnimationEntry | string>;
|
|
88
|
+
/** Freemode overlays and eye colours, when the folder was converted with the freemode characters. */
|
|
89
|
+
freemode?: FreemodeEntry;
|
|
60
90
|
}
|
|
61
91
|
/** The manifest sections a model can come from. */
|
|
62
92
|
export type ModelKind = "vehicle" | "character" | "object" | "map";
|
|
@@ -71,12 +101,19 @@ export declare class Assets {
|
|
|
71
101
|
private readonly loader;
|
|
72
102
|
/** Every model in the folder: vehicles, characters, objects, then map pieces, each sorted by name. */
|
|
73
103
|
readonly models: ModelEntry[];
|
|
104
|
+
/** Every clip dictionary in the folder, sorted by name. */
|
|
105
|
+
readonly dictionaries: string[];
|
|
74
106
|
private readonly entries;
|
|
107
|
+
private readonly loadedClips;
|
|
75
108
|
private constructor();
|
|
76
109
|
/** Opens an assets folder. `baseUrl` must end with a slash. */
|
|
77
110
|
static open(baseUrl: string): Promise<Assets>;
|
|
78
111
|
/** Loads a model by name, ready to show. Vehicles take `props`, and characters wear their default clothing. */
|
|
79
|
-
load(name: string, props?: VehicleProps): Promise<Model>;
|
|
112
|
+
load(name: string, props?: VehicleProps, look?: Look): Promise<Model>;
|
|
113
|
+
/** The clips of a dictionary, by name. */
|
|
114
|
+
clips(dictionary: string): Promise<Record<string, ClipEntry>>;
|
|
115
|
+
/** Loads a clip to play on a model. */
|
|
116
|
+
clip(dictionary: string, name: string): Promise<Clip>;
|
|
80
117
|
/** Frees every shared texture and clothing piece. Dispose the models using them first. */
|
|
81
118
|
clear(): void;
|
|
82
119
|
private entry;
|
package/bones.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tags of the standard GTA V ped skeleton's bones. Clips name bones by tag, and the converter stores each bone's tag
|
|
3
|
+
* in the model; this table names them for people, and lets models converted before tags were stored still be animated.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PED_BONES: Readonly<Record<string, number>>;
|
|
6
|
+
/** The name of a standard ped bone tag, such as `SKEL_R_Hand` for 57005, or undefined. */
|
|
7
|
+
export declare function boneName(tag: number): string | undefined;
|