mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
Merge pull request #254 from Hitjack007/he-crash-fix
This commit is contained in:
1 file changed
+24
-18
@@ -42,10 +42,10 @@ const TRACER_THIN = TRACER_THICK / 2;
|
|||||||
|
|
||||||
export function ShotDisplay() {
|
export function ShotDisplay() {
|
||||||
const shot = Tankopedia.use((state) => state.shot);
|
const shot = Tankopedia.use((state) => state.shot);
|
||||||
const inTracer = useRef<Mesh>(null!);
|
const inTracer = useRef<Mesh>(null);
|
||||||
const outTracer = useRef<Mesh>(null!);
|
const outTracer = useRef<Mesh>(null);
|
||||||
const splashRadiusWrapper = useRef<Group>(null!);
|
const splashRadiusWrapper = useRef<Group>(null);
|
||||||
const splashRadiusMaterial = useRef<MeshBasicMaterial>(null!);
|
const splashRadiusMaterial = useRef<MeshBasicMaterial>(null);
|
||||||
const { locale } = useLocale();
|
const { locale } = useLocale();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -63,10 +63,10 @@ export function ShotDisplay() {
|
|||||||
outlineMaterial,
|
outlineMaterial,
|
||||||
).computeLineDistances();
|
).computeLineDistances();
|
||||||
|
|
||||||
splashRadiusWrapper.current.add(outline);
|
splashRadiusWrapper.current?.add(outline);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
splashRadiusWrapper.current.remove(outline);
|
splashRadiusWrapper.current?.remove(outline);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -255,11 +255,11 @@ export function ShotDisplay() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AnimatorProps {
|
interface AnimatorProps {
|
||||||
inTracer: RefObject<Mesh>;
|
inTracer: RefObject<Mesh | null>;
|
||||||
outTracer: RefObject<Mesh>;
|
outTracer: RefObject<Mesh | null>;
|
||||||
|
|
||||||
splashRadiusWrapper: RefObject<Group>;
|
splashRadiusWrapper: RefObject<Group | null>;
|
||||||
splashRadiusMaterial: RefObject<MeshBasicMaterial>;
|
splashRadiusMaterial: RefObject<MeshBasicMaterial | null>;
|
||||||
|
|
||||||
inLength: number;
|
inLength: number;
|
||||||
outLength: number;
|
outLength: number;
|
||||||
@@ -283,17 +283,23 @@ function Animator({
|
|||||||
const tracerT1 = t % 1;
|
const tracerT1 = t % 1;
|
||||||
const tracerT2 = (t + 0.5) % 1;
|
const tracerT2 = (t + 0.5) % 1;
|
||||||
|
|
||||||
inTracer.current.scale.set(1, 1 - 2 * Math.abs(tracerT1 - 0.5), 1);
|
if (inTracer.current) {
|
||||||
inTracer.current.position.set(0, (1 - tracerT1) * inLength, 0);
|
inTracer.current.scale.set(1, 1 - 2 * Math.abs(tracerT1 - 0.5), 1);
|
||||||
|
inTracer.current.position.set(0, (1 - tracerT1) * inLength, 0);
|
||||||
|
|
||||||
if (outTracer.current) {
|
if (outTracer.current) {
|
||||||
outTracer.current.scale.set(1, 1 - 2 * Math.abs(tracerT2 - 0.5), 1);
|
outTracer.current.scale.set(1, 1 - 2 * Math.abs(tracerT2 - 0.5), 1);
|
||||||
outTracer.current.position.set(0, tracerT2 * outLength, 0);
|
outTracer.current.position.set(0, tracerT2 * outLength, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate();
|
if (
|
||||||
|
shot.splashRadius !== undefined &&
|
||||||
if (shot.splashRadius !== undefined) {
|
splashRadiusWrapper.current &&
|
||||||
|
splashRadiusMaterial.current
|
||||||
|
) {
|
||||||
if (animationStartTime === null) animationStartTime = t;
|
if (animationStartTime === null) animationStartTime = t;
|
||||||
|
|
||||||
const scale =
|
const scale =
|
||||||
|
|||||||
Reference in new issue
Block a user