From 7d9d322405c8fab93377c4c2a51981c3dee2db9c Mon Sep 17 00:00:00 2001 From: GonnaHetzMe Date: Wed, 8 Apr 2026 14:04:06 +0200 Subject: [PATCH] fix: correct input pitch offset for initial turret rotation --- .../Options/components/QuickInputs/index.tsx | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/QuickInputs/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/QuickInputs/index.tsx index 27881773b..d4fd3d5b6 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/QuickInputs/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/QuickInputs/index.tsx @@ -21,19 +21,20 @@ export function QuickInputs() { const turretModelDefinition = tankModelDefinition.turrets[protagonist.turret.id]; const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id]; - const initialGunPitch = + const initialTurretPitch = tankModelDefinition.initial_turret_rotation?.pitch ?? 0; const hasImprovedVerticalStabilizer = useEquipment(122); const hasDownImprovedVerticalStabilizer = useEquipment(124); + function displayPitch(pitch: number) { + return radToDeg(pitch) - initialTurretPitch; + } + useEffect(() => { function syncInputValues(data: ModelTransformEventData) { if (!pitchInput.current || !yawInput.current) return; - pitchInput.current.value = ( - radToDeg(data.pitch) + - (tankModelDefinition.initial_turret_rotation?.pitch ?? 0) - ).toFixed(1); + pitchInput.current.value = displayPitch(data.pitch).toFixed(1); yawInput.current.value = radToDeg(data.yaw).toFixed(1); } @@ -49,7 +50,7 @@ export function QuickInputs() { return () => { modelTransformEvent.off(handleTransformEvent); }; - }, [initialGunPitch]); + }, [initialTurretPitch]); return ( { const value = Number(pitchInput.current!.value); if (isNaN(value)) { - pitchInput.current!.value = ( - radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch + pitchInput.current!.value = displayPitch( + modelTransformEvent.last!.pitch, ).toFixed(1); return; } const [pitch, yaw] = applyPitchYawLimits( - degToRad(value + initialGunPitch), + degToRad(value + initialTurretPitch), modelTransformEvent.last!.yaw, gunModelDefinition.pitch!, turretModelDefinition.yaw, @@ -135,8 +134,8 @@ export function QuickInputs() { hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); - pitchInput.current!.value = ( - radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch + pitchInput.current!.value = displayPitch( + modelTransformEvent.last!.pitch, ).toFixed(1); }} onKeyDown={(event) => {