mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: post mid point tracer
This commit is contained in:
1 parent
7af1fdcf6b
commit
d496b46b6f
3 files changed
+25
-7
No files matched your search
@@ -63,6 +63,8 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
};
|
};
|
||||||
}, [initialId, assigned]);
|
}, [initialId, assigned]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageWrapper color="purple" size="double">
|
<PageWrapper color="purple" size="double">
|
||||||
{assigned && (
|
{assigned && (
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const layerTypeNames: Record<ArmorType | 'null', string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const LENGTH_INFINITY = 4;
|
const LENGTH_INFINITY = 4;
|
||||||
const TRACER_THIN = 1 / 128;
|
|
||||||
const TRACER_THICK = 1 / 64;
|
const TRACER_THICK = 1 / 64;
|
||||||
|
const TRACER_THIN = TRACER_THICK / 2;
|
||||||
|
|
||||||
export function ShotDisplay() {
|
export function ShotDisplay() {
|
||||||
const shot = useTankopediaTemporary((state) => state.shot);
|
const shot = useTankopediaTemporary((state) => state.shot);
|
||||||
@@ -53,12 +53,22 @@ export function ShotDisplay() {
|
|||||||
0,
|
0,
|
||||||
shot.layers.indexOf(midPointLayer as ShotLayer),
|
shot.layers.indexOf(midPointLayer as ShotLayer),
|
||||||
);
|
);
|
||||||
|
const postMidPointLayers = shot?.layers.slice(
|
||||||
|
shot.layers.indexOf(midPointLayer as ShotLayer),
|
||||||
|
shot.layers.length,
|
||||||
|
);
|
||||||
const preMidPointGap = shot
|
const preMidPointGap = shot
|
||||||
? preMidPointLayers!.reduce((accumulator, layer) => {
|
? preMidPointLayers!.reduce((accumulator, layer) => {
|
||||||
if (layer.type === null) return accumulator + layer.distance;
|
if (layer.type === null) return accumulator + layer.distance;
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}, 0) + LENGTH_INFINITY
|
}, 0) + LENGTH_INFINITY
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const postMidPointGap = shot
|
||||||
|
? postMidPointLayers!.reduce((accumulator, layer) => {
|
||||||
|
if (layer.type === null) return accumulator + layer.distance;
|
||||||
|
return accumulator;
|
||||||
|
}, 0) || LENGTH_INFINITY
|
||||||
|
: undefined;
|
||||||
|
|
||||||
useFrame(({ clock }) => {
|
useFrame(({ clock }) => {
|
||||||
if (!shot || !preMidPointTracer.current) return;
|
if (!shot || !preMidPointTracer.current) return;
|
||||||
@@ -71,7 +81,7 @@ export function ShotDisplay() {
|
|||||||
|
|
||||||
if (!postMidPointTracer.current) return;
|
if (!postMidPointTracer.current) return;
|
||||||
|
|
||||||
postMidPointTracer.current.position.set(0, t2 * preMidPointGap!, 0);
|
postMidPointTracer.current.position.set(0, t2 * postMidPointGap!, 0);
|
||||||
postMidPointTracer.current.scale.set(1, 1 - 2 * Math.abs(t2 - 0.5), 1);
|
postMidPointTracer.current.scale.set(1, 1 - 2 * Math.abs(t2 - 0.5), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,15 +124,18 @@ export function ShotDisplay() {
|
|||||||
.multiplyScalar(-1),
|
.multiplyScalar(-1),
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<mesh position={[0, preMidPointGap! / 2, 0]}>
|
<mesh position={[0, postMidPointGap! / 2, 0]}>
|
||||||
<cylinderGeometry
|
<cylinderGeometry
|
||||||
args={[TRACER_THIN, TRACER_THIN, preMidPointGap]}
|
args={[TRACER_THIN, TRACER_THIN, postMidPointGap]}
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
<mesh position={[0, preMidPointGap! / 2, 0]} ref={postMidPointTracer}>
|
<mesh
|
||||||
|
position={[0, postMidPointGap! / 2, 0]}
|
||||||
|
ref={postMidPointTracer}
|
||||||
|
>
|
||||||
<cylinderGeometry
|
<cylinderGeometry
|
||||||
args={[TRACER_THICK, TRACER_THICK, preMidPointGap]}
|
args={[TRACER_THICK, TRACER_THICK, postMidPointGap]}
|
||||||
/>
|
/>
|
||||||
<meshBasicMaterial color={0xffff00} />
|
<meshBasicMaterial color={0xffff00} />
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|||||||
@@ -243,7 +243,6 @@ export function SpacedArmorSceneComponent({
|
|||||||
thickness === 0
|
thickness === 0
|
||||||
? 0
|
? 0
|
||||||
: thickness / Math.cos(angle - finalNormalization);
|
: thickness / Math.cos(angle - finalNormalization);
|
||||||
remainingPenetration -= finalThickness;
|
|
||||||
|
|
||||||
if (!threeCalibersRule && angle >= ricochet) {
|
if (!threeCalibersRule && angle >= ricochet) {
|
||||||
shot.layers.push({
|
shot.layers.push({
|
||||||
@@ -279,7 +278,9 @@ export function SpacedArmorSceneComponent({
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
remainingPenetration -= finalThickness;
|
||||||
const blocked = remainingPenetration < 0;
|
const blocked = remainingPenetration < 0;
|
||||||
|
|
||||||
shot.layers.push({
|
shot.layers.push({
|
||||||
type,
|
type,
|
||||||
index: layerIndex,
|
index: layerIndex,
|
||||||
@@ -299,6 +300,8 @@ export function SpacedArmorSceneComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(shot);
|
||||||
|
|
||||||
useTankopediaTemporary.setState({ shot });
|
useTankopediaTemporary.setState({ shot });
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in new issue
Block a user