mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
fix: contextual shot display card
This commit is contained in:
1 parent
7e22f4596d
commit
447b4629ce
4 files changed
+57
-62
No files matched your search
@@ -2,6 +2,7 @@ import { PerspectiveCamera } from '@react-three/drei';
|
|||||||
import { Canvas } from '@react-three/fiber';
|
import { Canvas } from '@react-three/fiber';
|
||||||
import { use, useEffect, useRef } from 'react';
|
import { use, useEffect, useRef } from 'react';
|
||||||
import { Armor } from '../../../../../../components/Armor';
|
import { Armor } from '../../../../../../components/Armor';
|
||||||
|
import { ShotDisplay } from '../../../../../../components/Armor/components/ShotDisplay';
|
||||||
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { modelDefinitions } from '../../../../../../core/blitzkit/modelDefinitions';
|
import { modelDefinitions } from '../../../../../../core/blitzkit/modelDefinitions';
|
||||||
import { modelTransformEvent } from '../../../../../../core/blitzkit/modelTransform';
|
import { modelTransformEvent } from '../../../../../../core/blitzkit/modelTransform';
|
||||||
@@ -142,6 +143,7 @@ export function TankSandbox() {
|
|||||||
<Lighting />
|
<Lighting />
|
||||||
<TankModel />
|
<TankModel />
|
||||||
<Armor />
|
<Armor />
|
||||||
|
<ShotDisplay />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ import { useModelDefinitions } from '../../../hooks/useModelDefinitions';
|
|||||||
import * as Duel from '../../../stores/duel';
|
import * as Duel from '../../../stores/duel';
|
||||||
import * as TankopediaPersistent from '../../../stores/tankopediaPersistent';
|
import * as TankopediaPersistent from '../../../stores/tankopediaPersistent';
|
||||||
import { CoreArmorSceneComponent } from './CoreArmorSceneComponent';
|
import { CoreArmorSceneComponent } from './CoreArmorSceneComponent';
|
||||||
import { ShotDisplay } from './ShotDisplay';
|
|
||||||
|
|
||||||
export const CoreArmorScene = memo(() => {
|
export const CoreArmorScene = memo(() => {
|
||||||
const wrapper = useRef<Group>(null);
|
const wrapper = useRef<Group>(null);
|
||||||
@@ -137,94 +136,86 @@ export const CoreArmorScene = memo(() => {
|
|||||||
).applyAxisAngle(I_HAT, Math.PI / 2);
|
).applyAxisAngle(I_HAT, Math.PI / 2);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<group
|
||||||
<ShotDisplay />
|
ref={wrapper}
|
||||||
|
rotation={[-Math.PI / 2, 0, 0]}
|
||||||
|
visible={initialTankopediaState.mode === 'armor'}
|
||||||
|
>
|
||||||
|
<group position={hullOrigin}>
|
||||||
|
{armorNodes.map((node) => {
|
||||||
|
const isHull = node.name.startsWith('hull_');
|
||||||
|
const isVisible = isHull;
|
||||||
|
const armorId = nameToArmorId(node.name);
|
||||||
|
const { spaced, thickness } = resolveArmor(
|
||||||
|
tankModelDefinition.armor,
|
||||||
|
armorId,
|
||||||
|
);
|
||||||
|
|
||||||
<group
|
if (!isVisible || spaced || thickness === undefined) return null;
|
||||||
ref={wrapper}
|
|
||||||
rotation={[-Math.PI / 2, 0, 0]}
|
return (
|
||||||
visible={initialTankopediaState.mode === 'armor'}
|
<CoreArmorSceneComponent
|
||||||
>
|
key={node.uuid}
|
||||||
|
thickness={thickness}
|
||||||
|
node={node}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group ref={turretContainer}>
|
||||||
<group position={hullOrigin}>
|
<group position={hullOrigin}>
|
||||||
{armorNodes.map((node) => {
|
{armorNodes.map((node) => {
|
||||||
const isHull = node.name.startsWith('hull_');
|
const isCurrentTurret = node.name.startsWith(
|
||||||
const isVisible = isHull;
|
`turret_${turretModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
|
);
|
||||||
|
const isVisible = isCurrentTurret;
|
||||||
const armorId = nameToArmorId(node.name);
|
const armorId = nameToArmorId(node.name);
|
||||||
const { spaced, thickness } = resolveArmor(
|
const { spaced, thickness } = resolveArmor(
|
||||||
tankModelDefinition.armor,
|
turretModelDefinition.armor,
|
||||||
armorId,
|
armorId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isVisible || spaced || thickness === undefined) return null;
|
if (!isVisible || spaced || thickness === undefined) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CoreArmorSceneComponent
|
<group key={node.uuid} position={turretOrigin}>
|
||||||
key={node.uuid}
|
<CoreArmorSceneComponent
|
||||||
thickness={thickness}
|
key={node.uuid}
|
||||||
node={node}
|
thickness={thickness}
|
||||||
/>
|
node={node}
|
||||||
|
/>
|
||||||
|
</group>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</group>
|
</group>
|
||||||
|
<group ref={gunContainer}>
|
||||||
<group ref={turretContainer}>
|
|
||||||
<group position={hullOrigin}>
|
<group position={hullOrigin}>
|
||||||
{armorNodes.map((node) => {
|
{armorNodes.map((node) => {
|
||||||
const isCurrentTurret = node.name.startsWith(
|
const isCurrentGun = node.name.startsWith(
|
||||||
`turret_${turretModelDefinition.model.toString().padStart(2, '0')}`,
|
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
);
|
);
|
||||||
const isVisible = isCurrentTurret;
|
const isVisible = isCurrentGun;
|
||||||
const armorId = nameToArmorId(node.name);
|
const armorId = nameToArmorId(node.name);
|
||||||
const { spaced, thickness } = resolveArmor(
|
const { spaced, thickness } = resolveArmor(
|
||||||
turretModelDefinition.armor,
|
gunModelDefinition.armor,
|
||||||
armorId,
|
armorId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isVisible || spaced || thickness === undefined) return null;
|
if (!isVisible || spaced || thickness === undefined) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group key={node.uuid} position={turretOrigin}>
|
<group
|
||||||
<CoreArmorSceneComponent
|
key={node.uuid}
|
||||||
key={node.uuid}
|
position={turretOrigin.clone().add(gunOrigin)}
|
||||||
thickness={thickness}
|
>
|
||||||
node={node}
|
<CoreArmorSceneComponent thickness={thickness} node={node} />
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</group>
|
</group>
|
||||||
<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 || spaced || thickness === undefined)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group
|
|
||||||
key={node.uuid}
|
|
||||||
position={turretOrigin.clone().add(gunOrigin)}
|
|
||||||
>
|
|
||||||
<CoreArmorSceneComponent
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
</group>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</>
|
</group>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -82,7 +82,7 @@ export function ShotDisplay() {
|
|||||||
sm: 'block',
|
sm: 'block',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ShotDisplayCard />
|
<ShotDisplayCard shot={shot} />
|
||||||
</Box>
|
</Box>
|
||||||
</Html>
|
</Html>
|
||||||
|
|
||||||
|
|||||||
@@ -108,9 +108,11 @@ function LayerEntry({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ShotDisplayCard() {
|
interface ShotDisplayCardProps {
|
||||||
const shot = TankopediaEphemeral.use((state) => state.shot);
|
shot: TankopediaEphemeral.Shot;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ShotDisplayCard({ shot }: ShotDisplayCardProps) {
|
||||||
if (!shot) return null;
|
if (!shot) return null;
|
||||||
|
|
||||||
const outTitleColor = shot.out
|
const outTitleColor = shot.out
|
||||||
|
|||||||
Reference in new issue
Block a user