mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
fix: signs of tankiopedia transofmr controls
This commit is contained in:
1 parent
ab10343704
commit
e7fe3a4baf
1 file changed
+31
-31
+31
-31
@@ -1,17 +1,17 @@
|
|||||||
import { HeightIcon, WidthIcon } from '@radix-ui/react-icons';
|
import { HeightIcon, WidthIcon } from "@radix-ui/react-icons";
|
||||||
import { Flex, TextField } from '@radix-ui/themes';
|
import { Flex, TextField } from "@radix-ui/themes";
|
||||||
import type { QuicklimeEvent } from 'quicklime';
|
import type { QuicklimeEvent } from "quicklime";
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from "react";
|
||||||
import { degToRad, radToDeg } from 'three/src/math/MathUtils.js';
|
import { degToRad, radToDeg } from "three/src/math/MathUtils.js";
|
||||||
import { applyPitchYawLimits } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from "../../../../../../../core/blitz/applyPitchYawLimits";
|
||||||
import {
|
import {
|
||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
modelTransformEvent,
|
modelTransformEvent,
|
||||||
} from '../../../../../../../core/blitzkit/modelTransform';
|
} from "../../../../../../../core/blitzkit/modelTransform";
|
||||||
import { useEquipment } from '../../../../../../../hooks/useEquipment';
|
import { useEquipment } from "../../../../../../../hooks/useEquipment";
|
||||||
import { useTankModelDefinition } from '../../../../../../../hooks/useTankModelDefinition';
|
import { useTankModelDefinition } from "../../../../../../../hooks/useTankModelDefinition";
|
||||||
import { Duel } from '../../../../../../../stores/duel';
|
import { Duel } from "../../../../../../../stores/duel";
|
||||||
import './index.css';
|
import "./index.css";
|
||||||
|
|
||||||
export function QuickInputs() {
|
export function QuickInputs() {
|
||||||
const protagonist = Duel.use((state) => state.protagonist);
|
const protagonist = Duel.use((state) => state.protagonist);
|
||||||
@@ -28,12 +28,12 @@ export function QuickInputs() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleTransformEvent(
|
function handleTransformEvent(
|
||||||
event: QuicklimeEvent<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(event.data.pitch) +
|
||||||
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
|
|
||||||
@@ -56,11 +56,11 @@ export function QuickInputs() {
|
|||||||
width="4rem"
|
width="4rem"
|
||||||
direction="column"
|
direction="column"
|
||||||
style={{
|
style={{
|
||||||
pointerEvents: 'auto',
|
pointerEvents: "auto",
|
||||||
position: 'absolute',
|
position: "absolute",
|
||||||
top: '50%',
|
top: "50%",
|
||||||
transform: 'translateY(-50%)',
|
transform: "translateY(-50%)",
|
||||||
transitionDuration: '0.2s',
|
transitionDuration: "0.2s",
|
||||||
}}
|
}}
|
||||||
className="quick-inputs"
|
className="quick-inputs"
|
||||||
>
|
>
|
||||||
@@ -68,14 +68,14 @@ export function QuickInputs() {
|
|||||||
variant="classic"
|
variant="classic"
|
||||||
size="1"
|
size="1"
|
||||||
radius="full"
|
radius="full"
|
||||||
style={{ flex: 1, textAlign: 'right' }}
|
style={{ flex: 1, textAlign: "right" }}
|
||||||
defaultValue="0.0"
|
defaultValue="0.0"
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const value = Number(yawInput.current!.value);
|
const value = Number(yawInput.current!.value);
|
||||||
|
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
yawInput.current!.value = radToDeg(
|
yawInput.current!.value = radToDeg(
|
||||||
modelTransformEvent.last!.yaw,
|
modelTransformEvent.last!.yaw
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -86,23 +86,23 @@ export function QuickInputs() {
|
|||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer,
|
hasDownImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
yawInput.current!.value = radToDeg(
|
yawInput.current!.value = radToDeg(
|
||||||
modelTransformEvent.last!.yaw,
|
modelTransformEvent.last!.yaw
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === "Enter") {
|
||||||
yawInput.current?.blur();
|
yawInput.current?.blur();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onFocus={() => yawInput.current?.focus()}
|
onFocus={() => yawInput.current?.focus()}
|
||||||
ref={yawInput}
|
ref={yawInput}
|
||||||
>
|
>
|
||||||
<TextField.Slot style={{ userSelect: 'none' }}>
|
<TextField.Slot style={{ userSelect: "none" }}>
|
||||||
<WidthIcon />
|
<WidthIcon />
|
||||||
</TextField.Slot>
|
</TextField.Slot>
|
||||||
<TextField.Slot />
|
<TextField.Slot />
|
||||||
@@ -112,31 +112,31 @@ export function QuickInputs() {
|
|||||||
variant="classic"
|
variant="classic"
|
||||||
size="1"
|
size="1"
|
||||||
radius="full"
|
radius="full"
|
||||||
style={{ flex: 1, textAlign: 'right' }}
|
style={{ flex: 1, textAlign: "right" }}
|
||||||
defaultValue="0.0"
|
defaultValue="0.0"
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
const value = Number(pitchInput.current!.value);
|
const value = Number(pitchInput.current!.value);
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
pitchInput.current!.value = (
|
pitchInput.current!.value = (
|
||||||
-radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
|
radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [pitch, yaw] = applyPitchYawLimits(
|
const [pitch, yaw] = applyPitchYawLimits(
|
||||||
degToRad(-value + initialGunPitch),
|
degToRad(value + initialGunPitch),
|
||||||
modelTransformEvent.last!.yaw,
|
modelTransformEvent.last!.yaw,
|
||||||
gunModelDefinition.pitch,
|
gunModelDefinition.pitch,
|
||||||
turretModelDefinition.yaw,
|
turretModelDefinition.yaw,
|
||||||
hasImprovedVerticalStabilizer,
|
hasImprovedVerticalStabilizer,
|
||||||
hasDownImprovedVerticalStabilizer,
|
hasDownImprovedVerticalStabilizer
|
||||||
);
|
);
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
modelTransformEvent.dispatch({ pitch, yaw });
|
||||||
pitchInput.current!.value = (
|
pitchInput.current!.value = (
|
||||||
-radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
|
radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
|
||||||
).toFixed(1);
|
).toFixed(1);
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === "Enter") {
|
||||||
pitchInput.current?.blur();
|
pitchInput.current?.blur();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -145,7 +145,7 @@ export function QuickInputs() {
|
|||||||
>
|
>
|
||||||
<TextField.Slot
|
<TextField.Slot
|
||||||
style={{
|
style={{
|
||||||
userSelect: 'none',
|
userSelect: "none",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<HeightIcon />
|
<HeightIcon />
|
||||||
|
|||||||
Reference in new issue
Block a user