mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: static armor show on deselect
This commit is contained in:
1 parent
10d7fe1e75
commit
102072746a
1 file changed
+9
-8
@@ -1,5 +1,5 @@
|
||||
import { I_HAT, J_HAT } from "@blitzkit/core";
|
||||
import { useThree } from "@react-three/fiber";
|
||||
import { invalidate, useThree } from "@react-three/fiber";
|
||||
import { clamp } from "lodash-es";
|
||||
import type { QuicklimeEvent } from "quicklime";
|
||||
import { useEffect, useMemo, type ComponentProps } from "react";
|
||||
@@ -91,7 +91,7 @@ export function StaticArmorSceneComponent({
|
||||
color = new Color(
|
||||
clamp(1 - (7 / 8) * xClamped, 0, 1),
|
||||
0,
|
||||
clamp(1 - (1 / 8) * xClamped, 0, 1)
|
||||
clamp(1 - (1 / 8) * xClamped, 0, 1),
|
||||
);
|
||||
opacity = clamp(x + 1 / 2, 0, 1);
|
||||
break;
|
||||
@@ -115,7 +115,7 @@ export function StaticArmorSceneComponent({
|
||||
opacity: 0,
|
||||
userData: { opacity0: opacity },
|
||||
}),
|
||||
[thickness]
|
||||
[thickness],
|
||||
);
|
||||
const outlineMaterial = useMemo(
|
||||
() =>
|
||||
@@ -126,7 +126,7 @@ export function StaticArmorSceneComponent({
|
||||
opacity: 0,
|
||||
transparent: true,
|
||||
}),
|
||||
[thickness]
|
||||
[thickness],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -165,6 +165,7 @@ export function StaticArmorSceneComponent({
|
||||
}
|
||||
|
||||
surfaceMaterial.needsUpdate = true;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
function handleTransitionEvent(event: QuicklimeEvent<number>) {
|
||||
@@ -180,7 +181,7 @@ export function StaticArmorSceneComponent({
|
||||
const unsubscribes = [
|
||||
Tankopedia.on(
|
||||
(state) => state.highlightArmor?.name,
|
||||
handleHighlightArmor
|
||||
handleHighlightArmor,
|
||||
),
|
||||
() => transitionEvent.off(handleTransitionEvent),
|
||||
];
|
||||
@@ -194,14 +195,14 @@ export function StaticArmorSceneComponent({
|
||||
const { clip } = props;
|
||||
const gunOrigin = unrotateDavaVector(props.gunOrigin.clone());
|
||||
const neckOrigin = unrotateDavaVector(props.hullOrigin.clone()).add(
|
||||
unrotateDavaVector(props.turretOrigin.clone())
|
||||
unrotateDavaVector(props.turretOrigin.clone()),
|
||||
);
|
||||
const barrelOrigin = neckOrigin.clone().add(gunOrigin);
|
||||
const distanceToBarrel = clip.distanceToPoint(barrelOrigin);
|
||||
const point = new Vector3();
|
||||
|
||||
function handleModelTransform(
|
||||
event: QuicklimeEvent<ModelTransformEventData>
|
||||
event: QuicklimeEvent<ModelTransformEventData>,
|
||||
) {
|
||||
clip.normal
|
||||
.set(0, 0, -1)
|
||||
@@ -266,7 +267,7 @@ export function StaticArmorSceneComponent({
|
||||
const surfaceNormal = event
|
||||
.normal!.clone()
|
||||
.applyQuaternion(
|
||||
event.object.getWorldQuaternion(new Quaternion())
|
||||
event.object.getWorldQuaternion(new Quaternion()),
|
||||
);
|
||||
const angle = surfaceNormal.angleTo(cameraNormal);
|
||||
const thicknessAngled =
|
||||
|
||||
Reference in new issue
Block a user