mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: initialize tank quick inputs from current model transform
This commit is contained in:
1 parent
191843f972
commit
41882ddf23
1 file changed
+14
-10
+14
-10
@@ -27,27 +27,29 @@ export function QuickInputs() {
|
||||
const hasDownImprovedVerticalStabilizer = useEquipment(124);
|
||||
|
||||
useEffect(() => {
|
||||
function handleTransformEvent(
|
||||
event: QuicklimeEvent<ModelTransformEventData>
|
||||
) {
|
||||
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<ModelTransformEventData>
|
||||
) {
|
||||
syncInputValues(event.data);
|
||||
}
|
||||
|
||||
modelTransformEvent.on(handleTransformEvent);
|
||||
syncInputValues(modelTransformEvent.last!);
|
||||
|
||||
return () => {
|
||||
modelTransformEvent.off(handleTransformEvent);
|
||||
};
|
||||
}, []);
|
||||
}, [initialGunPitch]);
|
||||
|
||||
return (
|
||||
<Flex
|
||||
@@ -69,7 +71,7 @@ export function QuickInputs() {
|
||||
size="1"
|
||||
radius="full"
|
||||
style={{ flex: 1, textAlign: "right" }}
|
||||
defaultValue="0.0"
|
||||
defaultValue={radToDeg(modelTransformEvent.last!.yaw).toFixed(1)}
|
||||
onBlur={() => {
|
||||
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)) {
|
||||
|
||||
Reference in new issue
Block a user