mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
32 lines
987 B
TypeScript
32 lines
987 B
TypeScript
import { useEffect } from "react";
|
|
import { degToRad } from "three/src/math/MathUtils.js";
|
|
import { Duel } from "../../../../../../stores/duel";
|
|
import { api } from "../api/dynamic";
|
|
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
|
|
|
const modelDefinitions = await api.models();
|
|
|
|
export function InitialCameraAligner() {
|
|
const tank = Duel.use((state) => state.protagonist.tank);
|
|
const turret = Duel.use((state) => state.protagonist.turret);
|
|
const gun = Duel.use((state) => state.protagonist.gun);
|
|
|
|
const tankModel = modelDefinitions.models[tank.id];
|
|
const turretModel = tankModel.turrets[turret.id];
|
|
const gunModel = turretModel.guns[gun.id];
|
|
|
|
useEffect(() => {
|
|
const [pitch, yaw] = applyPitchYawLimits(
|
|
degToRad(8),
|
|
degToRad(25),
|
|
gunModel.pitch!,
|
|
turretModel.yaw,
|
|
);
|
|
|
|
modelTransformEvent.dispatch({ pitch, yaw });
|
|
}, []);
|
|
|
|
return null;
|
|
}
|