mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-26 12:09:50 +01:00
fix: green penetration reactivity
This commit is contained in:
1 parent
b47e6436e7
commit
7db02aa579
1 file changed
+16
-12
@@ -22,12 +22,9 @@ export function ArmorMesh({
|
|||||||
maxThickness,
|
maxThickness,
|
||||||
...props
|
...props
|
||||||
}: ArmorMeshProps) {
|
}: ArmorMeshProps) {
|
||||||
const initialEquipment = useTankopediaPersistent.getState().model.equipment;
|
|
||||||
const camera = useThree((state) => state.camera);
|
const camera = useThree((state) => state.camera);
|
||||||
const initialShell = useDuel.getState().antagonist!.shell;
|
const initialShell = useDuel.getState().antagonist!.shell;
|
||||||
const greenPenetration = useTankopediaPersistent(
|
const initialTankopedia = useTankopediaPersistent.getState();
|
||||||
(state) => state.model.visual.greenPenetration,
|
|
||||||
);
|
|
||||||
const material = useRef<ShaderMaterial>(null);
|
const material = useRef<ShaderMaterial>(null);
|
||||||
const resolution = new Vector2();
|
const resolution = new Vector2();
|
||||||
const explosionCapable = isExplosive(initialShell.type);
|
const explosionCapable = isExplosive(initialShell.type);
|
||||||
@@ -73,6 +70,14 @@ export function ArmorMesh({
|
|||||||
(state) => state.antagonist!.shell,
|
(state) => state.antagonist!.shell,
|
||||||
updateShellProperties,
|
updateShellProperties,
|
||||||
),
|
),
|
||||||
|
useTankopediaPersistent.subscribe(
|
||||||
|
(state) => state.model.visual.greenPenetration,
|
||||||
|
(greenPenetration) => {
|
||||||
|
if (material.current) {
|
||||||
|
material.current.uniforms.greenPenetration.value = greenPenetration;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -118,17 +123,21 @@ export function ArmorMesh({
|
|||||||
projectionMatrixInverse: { value: null },
|
projectionMatrixInverse: { value: null },
|
||||||
zNear: { value: camera.near },
|
zNear: { value: camera.near },
|
||||||
zFar: { value: camera.far },
|
zFar: { value: camera.far },
|
||||||
greenPenetration: { value: greenPenetration },
|
greenPenetration: {
|
||||||
|
value: initialTankopedia.model.visual.greenPenetration,
|
||||||
|
},
|
||||||
maxThickness: { value: maxThickness },
|
maxThickness: { value: maxThickness },
|
||||||
isExplosive: { value: explosionCapable },
|
isExplosive: { value: explosionCapable },
|
||||||
canSplash: { value: canSplash(initialShell.type) },
|
canSplash: { value: canSplash(initialShell.type) },
|
||||||
thickness: {
|
thickness: {
|
||||||
value: thickness * (initialEquipment.enhancedArmor ? 1.04 : 1),
|
value:
|
||||||
|
thickness *
|
||||||
|
(initialTankopedia.model.equipment.enhancedArmor ? 1.04 : 1),
|
||||||
},
|
},
|
||||||
penetration: {
|
penetration: {
|
||||||
value:
|
value:
|
||||||
resolveNearPenetration(initialShell.penetration) *
|
resolveNearPenetration(initialShell.penetration) *
|
||||||
(initialEquipment.calibratedShells
|
(initialTankopedia.model.equipment.calibratedShells
|
||||||
? explosionCapable
|
? explosionCapable
|
||||||
? 1.1
|
? 1.1
|
||||||
: 1.05
|
: 1.05
|
||||||
@@ -143,11 +152,6 @@ export function ArmorMesh({
|
|||||||
explosionRadius: { value: initialShell.explosionRadius ?? 0 },
|
explosionRadius: { value: initialShell.explosionRadius ?? 0 },
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/* <meshBasicMaterial
|
|
||||||
transparent
|
|
||||||
color="#ff0000"
|
|
||||||
opacity={Math.random()}
|
|
||||||
/> */}
|
|
||||||
</mesh>
|
</mesh>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user