Feature: Animated legendary camouflages

Legendary camo add-ons now play their garage animations in the Tankopedia viewer, and a new menu next to the camo column triggers their battle reactions.

**Export (`model.glb` / `skins/[skin].glb`)**
- Customization parts export skeletons, skin weights and one clip per `.anim` motion file (`core/blitzkit/skinAnimations`)
- Sockets bound to skeleton joints follow their joint
- Action lists and scenario graphs are carried in glTF extras
- Part batches with no LODs (`lodIndex` -1) are now exported, fixing meshes that were missing entirely (e.g. the Tiger II cat body, the BDT-5A engine rings)
- Base tank models are unchanged

**Viewer**
- A runtime plays the clips and drives state switchers, action lists and the game's scenario graphs (a small interpreter for the node types the camos use)
- Camo parts render as primitives so their bones can animate
- Garage animations play once rather than looping, so the camo settles

**Animation menu**
- Floats left of the camo column when the selected camo has triggerable animations
- Icon buttons use the game's own white icons, served from `/icons/skin-events/[event].webp`
- Idle replays the garage animation
- Triggers: Shoot, Kill, Take damage, Damage enemy, Ricochet / No penetration, Start moving, Consumable, Reload. Only events that actually animate get a button
- Buttons are disabled while a triggered animation plays; triggering cuts any garage animation short

All legendary skin files together grow from 1.32 GB to 1.35 GB (+2.4%), almost all of it in the 102 animated camos.
This commit is contained in:
Mark Greene committed 2026-10-20 18:48:35 +13:00
1 parent 85e03d3b42
commit ffb5a1f9c8
15 files changed
+1778 -11

No files matched your search

@@ -0,0 +1,85 @@
import { invalidate, useFrame } from "@react-three/fiber";
import { Quicklime, type QuicklimeEvent } from "quicklime";
import { useEffect, useRef } from "react";
import {
createSkinRuntime,
GARAGE_EVENT,
type SkinRuntime,
} from "../core/blitzkit/skinAnimations/runtime";
import { Tankopedia } from "../stores/tankopedia";
import type { Skin } from "./useSkin";
// demand rendering can leave long gaps between frames
const MAX_DELTA = 0.1;
export const skinAnimationEvent = new Quicklime<string>();
export function useSkinAnimation(skin?: Skin) {
const runtime = useRef<SkinRuntime>(undefined);
const active = useRef(false);
useEffect(() => {
if (!skin) return;
let created: SkinRuntime;
try {
created = createSkinRuntime(
[...skin.parts.values()].flat(),
skin.animations,
);
} catch (error) {
// the camo still shows, just without animations
console.warn("Skin animations failed to start", error);
return;
}
function handleSkinAnimation(event: QuicklimeEvent<string>) {
if (event.data === GARAGE_EVENT) {
created.replay();
} else {
created.trigger(event.data);
}
active.current = true;
invalidate();
}
runtime.current = created;
active.current = true;
skinAnimationEvent.on(handleSkinAnimation);
Tankopedia.mutate((draft) => {
draft.skinEvents = created.hasGarageAnimation
? [GARAGE_EVENT, ...created.events]
: created.events;
});
invalidate();
return () => {
skinAnimationEvent.off(handleSkinAnimation);
created.dispose();
runtime.current = undefined;
Tankopedia.mutate((draft) => {
draft.skinEvents = [];
draft.skinAnimating = false;
});
};
}, [skin]);
useFrame((_, delta) => {
if (!runtime.current || !active.current) return;
active.current = runtime.current.update(Math.min(delta, MAX_DELTA));
const busy = runtime.current.busy();
// only on change so the store doesn't update every frame
if (busy !== Tankopedia.state.skinAnimating) {
Tankopedia.mutate((draft) => {
draft.skinAnimating = busy;
});
}
if (active.current) invalidate();
});
}