diff --git a/src/components/Armor/components/ShotDisplay.tsx b/src/components/Armor/components/ShotDisplay.tsx index 2009a7288..172279a7e 100644 --- a/src/components/Armor/components/ShotDisplay.tsx +++ b/src/components/Armor/components/ShotDisplay.tsx @@ -1,4 +1,4 @@ -import { Text } from '@radix-ui/themes'; +import { Card, Inset, Text } from '@radix-ui/themes'; import { Html } from '@react-three/drei'; import { Euler, Quaternion, Vector3 } from 'three'; import { J_HAT } from '../../../constants/axis'; @@ -22,9 +22,13 @@ import { // const THICKNESS = 0.05; // const LENGTH = 4; +const LENGTH_INFINITY = 4; + export function ShotDisplay() { const shot = useTankopediaTemporary((state) => state.shot); + console.log(shot); + return ( <> {shot?.map((layer, index) => { @@ -44,39 +48,36 @@ export function ShotDisplay() { position={layer.point} rotation={shellRotation} > - {shot.length > 1 && ( - -
- - {layer.index + 1} - -
- - )} + + + + {shot.length > 1 && ( + + {layer.index + 1} + + )} + + + {(() => { - let length = 4; + let length = LENGTH_INFINITY; if (layer.index !== 0) { const gap = shot[index - 1] as ShotLayerGap; @@ -91,6 +92,34 @@ export function ShotDisplay() { ); })()} + + {(() => { + if (layer.status !== 'ricochet' || index !== shot.length - 1) + return null; + const ricochetShellNormal = layer.shellNormal + .clone() + .reflect(layer.surfaceNormal) + .multiplyScalar(-1); + const ricochetShellRotation = new Euler().setFromQuaternion( + new Quaternion().setFromAxisAngle( + new Vector3() + .crossVectors(J_HAT, ricochetShellNormal) + .normalize(), + J_HAT.angleTo(ricochetShellNormal), + ), + ); + + return ( + + + + + + + ); + })()} ); })} diff --git a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx index 5ac920e80..a5d036cc3 100644 --- a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx +++ b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx @@ -170,14 +170,6 @@ export function SpacedArmorSceneComponent({ }); } - console.log( - JSON.stringify( - intersections.map((i) => i.object.userData), - null, - 2, - ), - ); - return intersections; } @@ -190,7 +182,7 @@ export function SpacedArmorSceneComponent({ let layerIndex = startingIndex; let loopIndex = 0; - if (layerIndex !== 0) { + if (layerIndex !== 0 && intersections.length > 0) { shot.push({ type: null, distance: (shot.at(-1) as ShotLayerBase).point.distanceTo( @@ -260,6 +252,8 @@ export function SpacedArmorSceneComponent({ status: 'ricochet', }); + remainingPenetration *= 0.75; + const raycaster = new Raycaster(); const newShellNormal = shellNormal .clone() @@ -300,6 +294,8 @@ export function SpacedArmorSceneComponent({ } } + console.log('setting', shot); + useTankopediaTemporary.setState({ shot }); }, })}