mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-26 20:19:50 +01: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);
|
const hasDownImprovedVerticalStabilizer = useEquipment(124);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleTransformEvent(
|
function syncInputValues(data: ModelTransformEventData) {
|
||||||
event: QuicklimeEvent<ModelTransformEventData>
|
|
||||||
) {
|
|
||||||
if (!pitchInput.current || !yawInput.current) return;
|
if (!pitchInput.current || !yawInput.current) return;
|
||||||
|
|
||||||
pitchInput.current.value = (
|
pitchInput.current.value = (
|
||||||
radToDeg(event.data.pitch) +
|
radToDeg(data.pitch) +
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
|
yawInput.current.value = radToDeg(data.yaw).toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (event.data.yaw === undefined) return;
|
function handleTransformEvent(
|
||||||
|
event: QuicklimeEvent<ModelTransformEventData>
|
||||||
yawInput.current.value = radToDeg(event.data.yaw).toFixed(1);
|
) {
|
||||||
|
syncInputValues(event.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelTransformEvent.on(handleTransformEvent);
|
modelTransformEvent.on(handleTransformEvent);
|
||||||
|
syncInputValues(modelTransformEvent.last!);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
modelTransformEvent.off(handleTransformEvent);
|
modelTransformEvent.off(handleTransformEvent);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [initialGunPitch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@@ -69,7 +71,7 @@ export function QuickInputs() {
|
|||||||
size="1"
|
size="1"
|
||||||
radius="full"
|
radius="full"
|
||||||
style={{ flex: 1, textAlign: "right" }}
|
style={{ flex: 1, textAlign: "right" }}
|
||||||
defaultValue="0.0"
|
defaultValue={radToDeg(modelTransformEvent.last!.yaw).toFixed(1)}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const value = Number(yawInput.current!.value);
|
const value = Number(yawInput.current!.value);
|
||||||
|
|
||||||
@@ -113,7 +115,9 @@ export function QuickInputs() {
|
|||||||
size="1"
|
size="1"
|
||||||
radius="full"
|
radius="full"
|
||||||
style={{ flex: 1, textAlign: "right" }}
|
style={{ flex: 1, textAlign: "right" }}
|
||||||
defaultValue="0.0"
|
defaultValue={(
|
||||||
|
radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
|
||||||
|
).toFixed(1)}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const value = Number(pitchInput.current!.value);
|
const value = Number(pitchInput.current!.value);
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
|
|||||||
Reference in new issue
Block a user