Feature: Looping garage animations for legendary camouflages

Legendary camo add-ons now loop their garage animation in the Tankopedia viewer. It's always on, with no settings.

- The garage replay now also works out which motions end up looping, and the export writes only those clips
- Customization parts export skeletons, skin weights and sockets
- Parts render as primitives so their bones can animate, with attachments layered on top
- Base tank models are unchanged
This commit is contained in:
Mark Greene committed 2026-10-31 22:15:57 +13:00
commit 8566b2cc2f
94 files changed
+2037 -1861

No files matched your search

+5 -77
View File
@@ -1,85 +1,13 @@
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 function useSkinAnimation(skins: Skin[]) {
useFrame((_, delta) => {
for (const { mixer } of skins) {
if (!mixer) continue;
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;
mixer.update(delta);
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();
});
}