mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: missing turrets
This commit is contained in:
1 parent
7db02aa579
commit
002d0d4bc0
3 files changed
+108
-1
No files matched your search
+47
-1
@@ -18,6 +18,7 @@ export function ArmorHighlighting() {
|
|||||||
const protagonist = useDuel((state) => state.protagonist!);
|
const protagonist = useDuel((state) => state.protagonist!);
|
||||||
const wrapper = useRef<Group>(null);
|
const wrapper = useRef<Group>(null);
|
||||||
const modelDefinitions = useModelDefinitions();
|
const modelDefinitions = useModelDefinitions();
|
||||||
|
const gunContainer = useRef<Group>(null);
|
||||||
const turretContainer = useRef<Group>(null);
|
const turretContainer = useRef<Group>(null);
|
||||||
const initialTankopediaState = useTankopediaTemporary.getState();
|
const initialTankopediaState = useTankopediaTemporary.getState();
|
||||||
|
|
||||||
@@ -34,10 +35,24 @@ export function ArmorHighlighting() {
|
|||||||
).applyAxisAngle(I_HAT, Math.PI / 2);
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
const turretPosition = new Vector3();
|
const turretPosition = new Vector3();
|
||||||
const turretRotation = new Euler();
|
const turretRotation = new Euler();
|
||||||
|
const gunPosition = new Vector3();
|
||||||
|
const gunRotation = new Euler();
|
||||||
|
|
||||||
function handleModelTransform({ yaw }: ModelTransformEventData) {
|
function handleModelTransform({ pitch, yaw }: ModelTransformEventData) {
|
||||||
if (yaw === undefined) return;
|
if (yaw === undefined) return;
|
||||||
|
|
||||||
|
gunPosition
|
||||||
|
.set(0, 0, 0)
|
||||||
|
.sub(hullOrigin)
|
||||||
|
.sub(turretOrigin)
|
||||||
|
.sub(gunOrigin)
|
||||||
|
.applyAxisAngle(I_HAT, pitch)
|
||||||
|
.add(gunOrigin)
|
||||||
|
.add(turretOrigin)
|
||||||
|
.add(hullOrigin);
|
||||||
|
gunRotation.set(pitch, 0, 0);
|
||||||
|
gunContainer.current?.position.copy(gunPosition);
|
||||||
|
gunContainer.current?.rotation.copy(gunRotation);
|
||||||
turretPosition
|
turretPosition
|
||||||
.set(0, 0, 0)
|
.set(0, 0, 0)
|
||||||
.sub(hullOrigin)
|
.sub(hullOrigin)
|
||||||
@@ -101,6 +116,11 @@ export function ArmorHighlighting() {
|
|||||||
tankModelDefinition.turretOrigin[1],
|
tankModelDefinition.turretOrigin[1],
|
||||||
-tankModelDefinition.turretOrigin[2],
|
-tankModelDefinition.turretOrigin[2],
|
||||||
).applyAxisAngle(I_HAT, Math.PI / 2);
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
const gunOrigin = new Vector3(
|
||||||
|
turretModelDefinition.gunOrigin[0],
|
||||||
|
turretModelDefinition.gunOrigin[1],
|
||||||
|
-turretModelDefinition.gunOrigin[2],
|
||||||
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
const maxThickness = Math.max(
|
const maxThickness = Math.max(
|
||||||
tankModelDefinition.trackThickness,
|
tankModelDefinition.trackThickness,
|
||||||
gunModelDefinition.barrelThickness,
|
gunModelDefinition.barrelThickness,
|
||||||
@@ -164,6 +184,32 @@ export function ArmorHighlighting() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
<group ref={gunContainer}>
|
||||||
|
{armorNodes.map((node) => {
|
||||||
|
const isCurrentGun = node.name.startsWith(
|
||||||
|
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
|
);
|
||||||
|
const isVisible = isCurrentGun;
|
||||||
|
const armorId = nameToArmorId(node.name);
|
||||||
|
const { spaced, thickness } = resolveArmor(
|
||||||
|
gunModelDefinition.armor,
|
||||||
|
armorId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isVisible || thickness === undefined || spaced) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ArmorMesh
|
||||||
|
maxThickness={maxThickness}
|
||||||
|
key={node.uuid}
|
||||||
|
geometry={(node as Mesh).geometry}
|
||||||
|
position={turretOrigin.clone().add(gunOrigin)}
|
||||||
|
thickness={thickness}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
|
|||||||
+28
@@ -143,6 +143,11 @@ export const ExternalModuleMask = memo(() => {
|
|||||||
tankModelDefinition.turretOrigin[1],
|
tankModelDefinition.turretOrigin[1],
|
||||||
-tankModelDefinition.turretOrigin[2],
|
-tankModelDefinition.turretOrigin[2],
|
||||||
).applyAxisAngle(I_HAT, Math.PI / 2);
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
const gunOrigin = new Vector3(
|
||||||
|
turretModelDefinition.gunOrigin[0],
|
||||||
|
turretModelDefinition.gunOrigin[1],
|
||||||
|
-turretModelDefinition.gunOrigin[2],
|
||||||
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
@@ -216,6 +221,29 @@ export const ExternalModuleMask = memo(() => {
|
|||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
<group ref={gunContainer}>
|
||||||
|
{armorNodes.map((node) => {
|
||||||
|
const isCurrentGun = node.name.startsWith(
|
||||||
|
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
|
);
|
||||||
|
const isVisible = isCurrentGun;
|
||||||
|
const armorId = nameToArmorId(node.name);
|
||||||
|
const { thickness } = resolveArmor(
|
||||||
|
gunModelDefinition.armor,
|
||||||
|
armorId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isVisible || thickness === undefined) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ArmorMeshExternalModuleMask
|
||||||
|
exclude
|
||||||
|
key={node.uuid}
|
||||||
|
geometry={(node as Mesh).geometry}
|
||||||
|
position={turretOrigin.clone().add(gunOrigin)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
{modelNodes.map((node) => {
|
||||||
const isCurrentGun =
|
const isCurrentGun =
|
||||||
node.name ===
|
node.name ===
|
||||||
|
|||||||
+33
@@ -149,6 +149,11 @@ export const SpacedArmorDepth = memo(() => {
|
|||||||
tankModelDefinition.turretOrigin[1],
|
tankModelDefinition.turretOrigin[1],
|
||||||
-tankModelDefinition.turretOrigin[2],
|
-tankModelDefinition.turretOrigin[2],
|
||||||
).applyAxisAngle(I_HAT, Math.PI / 2);
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
const gunOrigin = new Vector3(
|
||||||
|
turretModelDefinition.gunOrigin[0],
|
||||||
|
turretModelDefinition.gunOrigin[1],
|
||||||
|
-turretModelDefinition.gunOrigin[2],
|
||||||
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
@@ -225,6 +230,34 @@ export const SpacedArmorDepth = memo(() => {
|
|||||||
})}
|
})}
|
||||||
</group>
|
</group>
|
||||||
<group ref={gunContainer}>
|
<group ref={gunContainer}>
|
||||||
|
<group position={hullOrigin}>
|
||||||
|
{armorNodes.map((node) => {
|
||||||
|
const isCurrentGun = node.name.startsWith(
|
||||||
|
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
|
);
|
||||||
|
const isVisible = isCurrentGun;
|
||||||
|
const armorId = nameToArmorId(node.name);
|
||||||
|
const { spaced, thickness } = resolveArmor(
|
||||||
|
gunModelDefinition.armor,
|
||||||
|
armorId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isVisible || thickness === undefined) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ArmorMeshSpacedArmorDepth
|
||||||
|
include={spaced}
|
||||||
|
isExternalModule={false}
|
||||||
|
thickness={thickness}
|
||||||
|
maxThickness={maxThickness}
|
||||||
|
key={node.uuid}
|
||||||
|
geometry={(node as Mesh).geometry}
|
||||||
|
position={turretOrigin.clone().add(gunOrigin)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</group>
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
{modelNodes.map((node) => {
|
||||||
const isCurrentGun =
|
const isCurrentGun =
|
||||||
node.name ===
|
node.name ===
|
||||||
|
|||||||
Reference in new issue
Block a user