Fix: Address karelpak1's review on animated legendary camouflages

- Sockets bound to a joint now sit right on the joint, as in game. Only the skeleton's own children are bound. This fixes the WZ-114 gun barrels collapsing.
- Clips keep their full duration when it runs past their last key.
- Part states are kept per entity and exported on each part's own switchers, so parts with matching names can't overwrite each other.
- A finished one-shot animation now stops on whatever it switched to, as in game. It only keeps looping if it changes nothing.
- Delayed actions run in delay order.
This commit is contained in:
Mark Greene committed 2026-11-07 15:35:12 +13:00
1 parent 99373872ed
commit 232b3e7770
5 files changed
+83 -72

No files matched your search

@@ -20,10 +20,7 @@ import type { Vector3Tuple, Vector4Tuple } from "three";
import { SKIN_NUMBER } from "../../../../constants/skinNumber";
import { api } from "../../../../core/blitzkit/api";
import { mixStaticPaths } from "../../../../core/blitzkit/mixStaticPaths";
import {
partGarage,
switcherStates,
} from "../../../../core/blitzkit/switcherStates";
import { switcherStates } from "../../../../core/blitzkit/switcherStates";
import { vfs } from "../../../../core/blitzkit/vfs";
import {
extractMaterials,
@@ -176,12 +173,6 @@ export async function GET({ props }: APIContext<{ skin: number }>) {
}
const part = await extractModel(vfs, path, true, preset);
const partSc2 = new Sc2ReadStream(
(await vfs.file(`Data/3d/${path}.sc2`)).buffer as ArrayBuffer,
).sc2();
Object.assign(states, partGarage(partSc2, preset).states);
const map = mergeDocuments(document, part);
const partScene = map.get(part.getRoot().listScenes()[0]) as Scene;
const node = document
@@ -118,7 +118,7 @@ export async function extractModel(
skin: Skin,
][] = [];
const motions = new Map<Hierarchy, Motion>();
const garageMotions = isPart ? partGarage(sc2, preset).motions : new Set();
const garage = isPart ? partGarage(sc2, preset) : undefined;
if (isPart) {
const loading: Promise<void>[] = [];
@@ -173,7 +173,7 @@ export async function extractModel(
skeletons.set(hierarchy, created);
// only what loops in the garage is exported
if (motion && motionComponent && garageMotions.has(hierarchy)) {
if (motion && motionComponent && garage?.motions.has(hierarchy)) {
createMotionClip(
document,
buffer,
@@ -210,9 +210,9 @@ export async function extractModel(
case "StateSwitcherComponent":
node.setExtras({
// a part's scenarios can pick its state as it loads
state:
component[`ssc.state${component["ssc.activeState"]}`] ??
(isPart ? null : undefined),
state: garage
? (garage.states.get(hierarchy) ?? null)
: component[`ssc.state${component["ssc.activeState"]}`],
});
break;
@@ -348,7 +348,13 @@ export async function extractModel(
);
for (const [owner, entity, joint, skin] of jointBindings) {
const socket = findNode(owner, entity);
// the game only binds the skeleton entity's own children
const socket = owner
.listChildren()
.find(
(child) =>
child.getName() === entity && !skin.listJoints().includes(child),
);
if (!socket) throw new Error(`Missing socket ${entity}`);
@@ -362,16 +368,6 @@ export async function extractModel(
return document;
}
function findNode(node: Node, name: string): Node | undefined {
for (const child of node.listChildren()) {
if (child.getName() === name) return child;
const found = findNode(child, name);
if (found) return found;
}
}
export async function extractMaterials(
document: Document,
sc2: ReturnType<Sc2ReadStream["sc2"]>,