Files
blitzkit/packages/website/src/pages/[...locale]/mixer/_index.tsx
T

67 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-09-01 19:19:44 -05:00
import { Box } from "@radix-ui/themes";
import { useRef } from "react";
import { MixerScene } from "../../../components/MixerScene";
2025-09-13 23:42:26 -05:00
import { awaitableModelDefinitions } from "../../../core/awaitables/modelDefinitions";
2025-09-01 19:19:44 -05:00
import { awaitableTankDefinitions } from "../../../core/awaitables/tankDefinitions";
2025-08-28 16:12:40 -05:00
import {
LocaleProvider,
type LocaleAcceptorProps,
2025-09-01 19:19:44 -05:00
} from "../../../hooks/useLocale";
import { Mixer } from "../../../stores/mixer";
2025-08-28 16:12:40 -05:00
const tankDefinitions = await awaitableTankDefinitions;
2025-09-13 23:42:26 -05:00
const modelDefinitions = await awaitableModelDefinitions;
const tanks = Object.values(tankDefinitions.tanks).filter((tank) => {
const tankModel = modelDefinitions.models[tank.id];
const turret = tank.turrets.at(-1)!;
const turretModel = tankModel.turrets[turret.id];
return tank.tier >= 10 && !turretModel.yaw;
});
2025-08-28 16:12:40 -05:00
export function Page({ locale }: LocaleAcceptorProps) {
const hull = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
const turretTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
const turret = useRef(
turretTank.current.turrets[
Math.floor(Math.random() * turretTank.current.turrets.length)
2025-09-01 19:19:44 -05:00
]
2025-08-28 16:12:40 -05:00
);
const gunTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]);
const gunTurret = useRef(
gunTank.current.turrets[
Math.floor(Math.random() * gunTank.current.turrets.length)
2025-09-01 19:19:44 -05:00
]
2025-08-28 16:12:40 -05:00
);
const gun = useRef(
gunTurret.current.guns[
Math.floor(Math.random() * gunTurret.current.guns.length)
2025-09-01 19:19:44 -05:00
]
2025-08-28 16:12:40 -05:00
);
2025-09-01 19:19:44 -05:00
Mixer.useInitialization({
hull: hull.current,
turret: { tank: turretTank.current, turret: turret.current },
gun: {
tank: gunTank.current,
turret: gunTurret.current,
gun: gun.current,
},
});
2025-08-28 16:12:40 -05:00
return (
<LocaleProvider locale={locale}>
2025-09-01 19:19:44 -05:00
<Content />
2025-08-28 16:12:40 -05:00
</LocaleProvider>
);
}
function Content() {
return (
2025-09-13 23:42:26 -05:00
<Box flexGrow="1" position="relative">
<Box position="absolute" width="100%" height="100%" top="0" left="0">
<MixerScene />
2025-08-28 16:12:40 -05:00
</Box>
2025-09-13 23:42:26 -05:00
</Box>
2025-08-28 16:12:40 -05:00
);
}