Files
blitzkit/packages/website/src/components/InitialCameraAligner.tsx
T

31 lines
977 B
TypeScript
Raw Normal View History

2026-03-31 14:11:45 -05:00
import { useEffect } from "react";
import { degToRad } from "three/src/math/MathUtils.js";
2026-09-23 17:25:51 -05:00
import { api } from "../api/dynamic";
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
2026-09-30 17:56:31 -05:00
import { DuelModule, useDuel } from "../hooks/useDuel";
2025-08-12 13:43:11 -05:00
2026-08-30 14:26:08 -05:00
const modelDefinitions = await api.models();
2025-08-12 13:43:11 -05:00
2026-09-23 17:25:51 -05:00
export function InitialCameraAligner() {
2026-09-30 17:56:31 -05:00
const tank = useDuel("protagonist", DuelModule.Tank);
const turret = useDuel("protagonist", DuelModule.Turret);
const gun = useDuel("protagonist", DuelModule.Gun);
2025-08-12 13:43:11 -05:00
const tankModel = modelDefinitions.models[tank.id];
const turretModel = tankModel.turrets[turret.id];
2025-08-18 12:06:14 -05:00
const gunModel = turretModel.guns[gun.id];
2025-08-12 13:43:11 -05:00
useEffect(() => {
const [pitch, yaw] = applyPitchYawLimits(
degToRad(8),
degToRad(25),
2026-03-31 14:11:45 -05:00
gunModel.pitch!,
2025-08-12 13:43:11 -05:00
turretModel.yaw,
);
modelTransformEvent.dispatch({ pitch, yaw });
}, []);
return null;
}