Compare commits

...
5 Commits
Author SHA1 Message Date
TrèsAbhi 0aa6e1e79a Update deployment condition for GitHub Pages 2025-12-20 20:03:27 -06:00
TrèsAbhi d2a6379131 feat: abstracted meta 2025-12-20 19:10:11 -06:00
TrèsAbhi 07ce61d19f fix: depression 2025-12-20 19:05:42 -06:00
TrèsAbhi ad9f2d8609 feat: start of pitch yaw limits 2025-12-20 19:03:57 -06:00
TrèsAbhi 57702d8a43 fix: repo 2025-12-20 18:10:24 -06:00
9 changed files with 237 additions and 111 deletions

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ jobs:
path: dist/website
deploy-github-pages:
if: ${{ github.ref == 'refs/heads/ue' }}
if: ${{ github.ref == 'refs/heads/ue' && github.repository == 'blitzkit/host-beta' }}
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: build
+1
View File
@@ -3,6 +3,7 @@ export * from "./fisherYates";
export * from "./formatCompact";
export * from "./isNumber";
export * from "./NaNFallback";
export * from "./normalizeAngleDeg";
export * from "./normalizeAngleRad";
export * from "./normalToEuler";
export * from "./numberToRomanNumeral";
@@ -0,0 +1,6 @@
export function normalizeAngleDeg(angle: number) {
const newAngle = angle % 360;
if (newAngle > 360) return newAngle - 360;
if (newAngle < -360) return newAngle + 360;
return newAngle;
}
@@ -0,0 +1,3 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="sitemap" href="/sitemap-index.xml" />
@@ -0,0 +1,104 @@
---
import type { Color } from "../pages/styles/colors/[accent].css";
interface Props {
accent: Color;
}
const { accent } = Astro.props;
const accentVariables = {
"accent-1": `var(--${accent}-1)`,
"accent-2": `var(--${accent}-2)`,
"accent-3": `var(--${accent}-3)`,
"accent-4": `var(--${accent}-4)`,
"accent-5": `var(--${accent}-5)`,
"accent-6": `var(--${accent}-6)`,
"accent-7": `var(--${accent}-7)`,
"accent-8": `var(--${accent}-8)`,
"accent-9": `var(--${accent}-9)`,
"accent-10": `var(--${accent}-10)`,
"accent-11": `var(--${accent}-11)`,
"accent-12": `var(--${accent}-12)`,
};
---
<style is:global define:vars={accentVariables}>
@import "@radix-ui/colors/mauve-dark.css";
@import "@radix-ui/colors/mauve-alpha.css";
:root {
--accent-1: var(--amber-1);
--accent-2: var(--amber-2);
--accent-3: var(--amber-3);
--accent-4: var(--amber-4);
--accent-5: var(--amber-5);
--accent-6: var(--amber-6);
--accent-7: var(--amber-7);
--accent-8: var(--amber-8);
--accent-9: var(--amber-9);
--accent-10: var(--amber-10);
--accent-11: var(--amber-11);
--accent-12: var(--amber-12);
}
body {
--gray-1: var(--mauve-1);
--gray-2: var(--mauve-2);
--gray-3: var(--mauve-3);
--gray-4: var(--mauve-4);
--gray-5: var(--mauve-5);
--gray-6: var(--mauve-6);
--gray-7: var(--mauve-7);
--gray-8: var(--mauve-8);
--gray-9: var(--mauve-9);
--gray-10: var(--mauve-10);
--gray-11: var(--mauve-11);
--gray-12: var(--mauve-12);
--gray-a1: var(--mauve-a1);
--gray-a2: var(--mauve-a2);
--gray-a3: var(--mauve-a3);
--gray-a4: var(--mauve-a4);
--gray-a5: var(--mauve-a5);
--gray-a6: var(--mauve-a6);
--gray-a7: var(--mauve-a7);
--gray-a8: var(--mauve-a8);
--gray-a9: var(--mauve-a9);
--gray-a10: var(--mauve-a10);
--gray-a11: var(--mauve-a11);
--gray-a12: var(--mauve-a12);
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-5: 1.5rem;
--space-6: 2rem;
--space-7: 2.5rem;
--space-8: 3rem;
--space-9: 4rem;
background-color: var(--gray-1);
color: var(--gray-12);
font-family: "Inter Variable", sans-serif;
display: flex;
flex-direction: column;
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin: 0;
}
a {
color: var(--accent-11);
}
</style>
@@ -0,0 +1,100 @@
import { normalizeAngleDeg } from "@blitzkit/core";
import type { PitchLimit } from "@protos/blitz_static_tank_upgrade_single_stage";
import { clamp, degToRad, lerp, radToDeg } from "three/src/math/MathUtils.js";
export function applyPitchYawLimits(
givenPitch: number,
givenYaw: number,
pitchLimitsUp: PitchLimit[],
pitchLimitsDown: PitchLimit[]
) {
const givenYawDeg = normalizeAngleDeg(radToDeg(givenYaw));
const givenPitchDeg = normalizeAngleDeg(radToDeg(givenPitch));
const yawDeg = givenYawDeg;
const yaw = degToRad(givenYawDeg);
let leftLimitUp: PitchLimit | undefined;
let rightLimitUp: PitchLimit | undefined;
let leftLimitDown: PitchLimit | undefined;
let rightLimitDown: PitchLimit | undefined;
for (const limit of pitchLimitsUp) {
const normalizedAngle = normalizeAngleDeg(limit.angle);
if (normalizedAngle <= yawDeg) {
if (
!leftLimitUp ||
normalizeAngleDeg(yawDeg - normalizedAngle) <
normalizeAngleDeg(yawDeg - leftLimitUp.angle)
) {
leftLimitUp = limit;
}
}
if (normalizedAngle >= yawDeg) {
if (
!rightLimitUp ||
normalizeAngleDeg(normalizedAngle - yawDeg) <
normalizeAngleDeg(rightLimitUp.angle - yawDeg)
) {
rightLimitUp = limit;
}
}
}
for (const limit of pitchLimitsDown) {
const normalizedAngle = normalizeAngleDeg(limit.angle);
if (normalizedAngle <= yawDeg) {
if (
!leftLimitDown ||
normalizeAngleDeg(yawDeg - normalizedAngle) <
normalizeAngleDeg(yawDeg - leftLimitDown.angle)
) {
leftLimitDown = limit;
}
}
if (normalizedAngle >= yawDeg) {
if (
!rightLimitDown ||
normalizeAngleDeg(normalizedAngle - yawDeg) <
normalizeAngleDeg(rightLimitDown.angle - yawDeg)
) {
rightLimitDown = limit;
}
}
}
if (!leftLimitUp || !rightLimitUp || !leftLimitDown || !rightLimitDown) {
throw new Error("Pitch limits not found");
}
const spanUp = rightLimitUp.angle - leftLimitUp.angle;
const spanDown = rightLimitDown.angle - leftLimitDown.angle;
let limitUp: number;
let limitDown: number;
if (spanUp === 0) {
limitUp = leftLimitUp.limit;
} else {
const delta = givenYawDeg - leftLimitUp.angle;
const t = delta / spanUp;
limitUp = lerp(leftLimitUp.limit, rightLimitUp.limit, t);
}
if (spanDown === 0) {
limitDown = leftLimitDown.limit;
} else {
const delta = givenYawDeg - leftLimitDown.angle;
const t = delta / spanDown;
limitDown = lerp(leftLimitDown.limit, rightLimitDown.limit, t);
}
const pitchDeg = clamp(givenPitchDeg, -limitDown, limitUp);
const pitch = degToRad(pitchDeg);
return { pitch, yaw };
}
@@ -4,6 +4,8 @@ import {
StageParameters,
TankAttributeChange_AttributeName,
} from "@protos/blitz_static_tank_upgrade_single_stage";
import { radToDeg } from "three/src/math/MathUtils.js";
import { applyPitchYawLimits } from "./applyPitchYawLimits";
import type { TankState } from "./tankState";
export type CharacteristicOutput = number | null;
@@ -213,23 +215,25 @@ export const characteristics = {
},
gun_depression({ parameters }) {
const pitchLimit = parameters.pitch_limits_down.find(
(pitchLimit) => pitchLimit.angle === 0
return -radToDeg(
applyPitchYawLimits(
-Math.PI / 2,
0,
parameters.pitch_limits_up,
parameters.pitch_limits_down
).pitch
);
if (!pitchLimit) throw new Error("No angle 0 depression pitch limit found");
return pitchLimit.limit;
},
gun_elevation({ parameters }) {
const pitchLimit = parameters.pitch_limits_up.find(
(pitchLimit) => pitchLimit.angle === 0
return radToDeg(
applyPitchYawLimits(
Math.PI / 2,
0,
parameters.pitch_limits_up,
parameters.pitch_limits_down
).pitch
);
if (!pitchLimit) throw new Error("No angle 0 elevation pitch limit found");
return pitchLimit.limit;
},
engine_power({ attribute }) {
@@ -50,8 +50,8 @@ export const characteristicsOrder: CharacteristicsOrder = [
{ name: "dispersion", decimals: 3, units: "m" },
{ name: "gun_depression", units: "deg" },
{ name: "gun_elevation", units: "deg" },
{ name: "gun_depression", decimals: 0, units: "deg" },
{ name: "gun_elevation", decimals: 0, units: "deg" },
{ toy: "flexibility" },
],
@@ -1,5 +1,7 @@
---
import "@fontsource-variable/inter";
import BaseMeta from "../components/BaseMeta.astro";
import BaseStyles from "../components/BaseStyles.astro";
import type { Color } from "../pages/styles/colors/[accent].css";
interface Props {
@@ -7,106 +9,12 @@ interface Props {
}
const { accent } = Astro.props;
const accentVariables = {
"accent-1": `var(--${accent}-1)`,
"accent-2": `var(--${accent}-2)`,
"accent-3": `var(--${accent}-3)`,
"accent-4": `var(--${accent}-4)`,
"accent-5": `var(--${accent}-5)`,
"accent-6": `var(--${accent}-6)`,
"accent-7": `var(--${accent}-7)`,
"accent-8": `var(--${accent}-8)`,
"accent-9": `var(--${accent}-9)`,
"accent-10": `var(--${accent}-10)`,
"accent-11": `var(--${accent}-11)`,
"accent-12": `var(--${accent}-12)`,
};
---
<html>
<head>
<meta charset="utf-8" />
<style is:global define:vars={accentVariables}>
@import "@radix-ui/colors/mauve-dark.css";
@import "@radix-ui/colors/mauve-alpha.css";
:root {
--accent-1: var(--amber-1);
--accent-2: var(--amber-2);
--accent-3: var(--amber-3);
--accent-4: var(--amber-4);
--accent-5: var(--amber-5);
--accent-6: var(--amber-6);
--accent-7: var(--amber-7);
--accent-8: var(--amber-8);
--accent-9: var(--amber-9);
--accent-10: var(--amber-10);
--accent-11: var(--amber-11);
--accent-12: var(--amber-12);
}
body {
--gray-1: var(--mauve-1);
--gray-2: var(--mauve-2);
--gray-3: var(--mauve-3);
--gray-4: var(--mauve-4);
--gray-5: var(--mauve-5);
--gray-6: var(--mauve-6);
--gray-7: var(--mauve-7);
--gray-8: var(--mauve-8);
--gray-9: var(--mauve-9);
--gray-10: var(--mauve-10);
--gray-11: var(--mauve-11);
--gray-12: var(--mauve-12);
--gray-a1: var(--mauve-a1);
--gray-a2: var(--mauve-a2);
--gray-a3: var(--mauve-a3);
--gray-a4: var(--mauve-a4);
--gray-a5: var(--mauve-a5);
--gray-a6: var(--mauve-a6);
--gray-a7: var(--mauve-a7);
--gray-a8: var(--mauve-a8);
--gray-a9: var(--mauve-a9);
--gray-a10: var(--mauve-a10);
--gray-a11: var(--mauve-a11);
--gray-a12: var(--mauve-a12);
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-5: 1.5rem;
--space-6: 2rem;
--space-7: 2.5rem;
--space-8: 3rem;
--space-9: 4rem;
background-color: var(--gray-1);
color: var(--gray-12);
font-family: "Inter Variable", sans-serif;
display: flex;
flex-direction: column;
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin: 0;
}
a {
color: var(--accent-11);
}
</style>
<BaseMeta />
<BaseStyles {accent} />
</head>
<body class="dark">