Compare commits

...
4 Commits
Author SHA1 Message Date
TrèsAbhi 3e37368038 Merge pull request #236 from karelpak1/fix-pitch-quickinput
fix: correct input pitch offset for initial turret rotation
2026-04-08 08:39:25 -05:00
TrèsAbhi d9a14924eb Merge pull request #235 from karelpak1/fix-child-node-position
fix: position of child nodes
2026-04-08 08:38:07 -05:00
GonnaHetzMe 7d9d322405 fix: correct input pitch offset for initial turret rotation 2026-04-08 14:04:06 +02:00
GonnaHetzMe 5365044017 fix: position of child nodes 2026-04-08 08:48:53 +02:00
2 changed files with 19 additions and 16 deletions

No files matched your search

@@ -170,8 +170,12 @@ export async function extractModel(vfs: AbstractVFS, path: string) {
break;
case "TransformComponent": {
component["tc.localTranslation"] = [0, 0, 0]; // Game when is loading model resets position to [0, 0, 0], so any set value is ignored.
node.setTranslation(component["tc.localTranslation"]);
const localTranslation = component["tc.localTranslation"];
// The game resets top-level node translation to [0, 0, 0] on load.
// Child nodes must keep their authored local offsets.
node.setTranslation(
parent instanceof Scene ? [0, 0, 0] : localTranslation,
);
node.setRotation(component["tc.localRotation"]);
node.setScale(component["tc.localScale"]);
@@ -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 (
<Flex
@@ -115,19 +116,17 @@ export function QuickInputs() {
size="1"
radius="full"
style={{ flex: 1, textAlign: "right" }}
defaultValue={(
radToDeg(modelTransformEvent.last!.pitch) + initialGunPitch
).toFixed(1)}
defaultValue={displayPitch(modelTransformEvent.last!.pitch).toFixed(1)}
onBlur={() => {
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) => {