2025-09-27 16:07:45 -05:00
|
|
|
import { memo, useRef } from "react";
|
|
|
|
|
import { Group } from "three";
|
2026-11-30 23:08:43 -06:00
|
|
|
import { useArmorPlates } from "../hooks/useArmorPlates";
|
2026-09-30 17:56:31 -05:00
|
|
|
import { useConsumable } from "../hooks/useConsumable";
|
2026-11-14 01:17:38 -06:00
|
|
|
import { useDuelModels } from "../hooks/useDuelModels";
|
|
|
|
|
import { useDuelModules } from "../hooks/useDuelModules";
|
2026-09-30 17:56:31 -05:00
|
|
|
import { useTankTransform } from "../hooks/useTankTransform";
|
2026-09-30 20:59:18 -05:00
|
|
|
import { toThreeVector } from "../three/toThreeVector";
|
2025-09-27 16:07:45 -05:00
|
|
|
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
|
2024-01-15 21:55:09 -06:00
|
|
|
|
2024-07-29 20:46:57 -05:00
|
|
|
export const PrimaryArmorScene = memo(() => {
|
2025-09-27 16:07:45 -05:00
|
|
|
const turretContainer = useRef<Group>(null!);
|
|
|
|
|
const gunContainer = useRef<Group>(null!);
|
2026-11-14 01:17:38 -06:00
|
|
|
const protagonist = useDuelModules("protagonist");
|
|
|
|
|
const models = useDuelModels("protagonist");
|
|
|
|
|
const hullOrigin = toThreeVector(models.track.origin);
|
|
|
|
|
const turretOrigin = toThreeVector(models.tank.turret_origin);
|
|
|
|
|
const gunOrigin = toThreeVector(models.turret.gun_origin);
|
2026-09-30 17:56:31 -05:00
|
|
|
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
2024-07-30 13:24:55 -05:00
|
|
|
|
2026-11-30 23:08:43 -06:00
|
|
|
const hiddenState = isDynamicArmorActive ? "state_01" : "state_00";
|
|
|
|
|
const plates = useArmorPlates(hiddenState);
|
|
|
|
|
|
2026-11-14 01:17:38 -06:00
|
|
|
useTankTransform(
|
|
|
|
|
protagonist.track,
|
|
|
|
|
protagonist.turret,
|
|
|
|
|
turretContainer,
|
|
|
|
|
gunContainer,
|
|
|
|
|
);
|
2024-02-28 17:41:59 -06:00
|
|
|
|
|
|
|
|
return (
|
2026-09-30 17:56:31 -05:00
|
|
|
<>
|
2024-07-13 19:49:00 -05:00
|
|
|
<group position={hullOrigin}>
|
2026-11-30 23:08:43 -06:00
|
|
|
<PrimaryArmorSceneComponent plates={plates.hull.primary} />
|
2024-07-13 19:49:00 -05:00
|
|
|
</group>
|
|
|
|
|
|
|
|
|
|
<group ref={turretContainer}>
|
2026-11-30 23:08:43 -06:00
|
|
|
<group position={hullOrigin}>
|
|
|
|
|
<group position={turretOrigin}>
|
|
|
|
|
<PrimaryArmorSceneComponent plates={plates.turret.primary} />
|
|
|
|
|
</group>
|
|
|
|
|
</group>
|
2024-07-24 20:46:42 -05:00
|
|
|
|
|
|
|
|
<group ref={gunContainer}>
|
2026-11-30 23:08:43 -06:00
|
|
|
<group position={hullOrigin}>
|
|
|
|
|
<group position={turretOrigin.clone().add(gunOrigin)}>
|
|
|
|
|
<PrimaryArmorSceneComponent plates={plates.gun.primary} />
|
|
|
|
|
</group>
|
|
|
|
|
</group>
|
2024-01-22 16:54:07 -06:00
|
|
|
</group>
|
2024-01-15 21:55:09 -06:00
|
|
|
</group>
|
2026-09-30 17:56:31 -05:00
|
|
|
</>
|
2024-02-28 17:41:59 -06:00
|
|
|
);
|
|
|
|
|
});
|