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 97cb6faec..03e958c82 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 @@ -27,27 +27,29 @@ export function QuickInputs() { const hasDownImprovedVerticalStabilizer = useEquipment(124); useEffect(() => { - function handleTransformEvent( - event: QuicklimeEvent - ) { + function syncInputValues(data: ModelTransformEventData) { if (!pitchInput.current || !yawInput.current) return; pitchInput.current.value = ( - radToDeg(event.data.pitch) + + radToDeg(data.pitch) + (tankModelDefinition.initial_turret_rotation?.pitch ?? 0) ).toFixed(1); + yawInput.current.value = radToDeg(data.yaw).toFixed(1); + } - if (event.data.yaw === undefined) return; - - yawInput.current.value = radToDeg(event.data.yaw).toFixed(1); + function handleTransformEvent( + event: QuicklimeEvent + ) { + syncInputValues(event.data); } modelTransformEvent.on(handleTransformEvent); + syncInputValues(modelTransformEvent.last!); return () => { modelTransformEvent.off(handleTransformEvent); }; - }, []); + }, [initialGunPitch]); return ( { const value = Number(yawInput.current!.value); @@ -113,7 +115,9 @@ export function QuickInputs() { size="1" radius="full" style={{ flex: 1, textAlign: "right" }} - defaultValue="0.0" + defaultValue={( + radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch + ).toFixed(1)} onBlur={() => { const value = Number(pitchInput.current!.value); if (isNaN(value)) {