mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: he start
This commit is contained in:
1 parent
9ed2b79a4b
commit
9dc4483d70
5 files changed
+28
-4
No files matched your search
@@ -6,6 +6,7 @@ import { ArmorMesh } from '../../../../../../../components/ArmorMesh';
|
||||
import { HeadsUpDisplay } from '../../../../../../../components/HeadsUpDisplay';
|
||||
import { X_AXIS } from '../../../../../../../constants/axis';
|
||||
import { canRicochet } from '../../../../../../../core/blitz/canRicochet';
|
||||
import { canSplash } from '../../../../../../../core/blitz/canSplash';
|
||||
import { numericPenetration } from '../../../../../../../core/blitz/numericPenetration';
|
||||
import { asset } from '../../../../../../../core/blitzkrieg/asset';
|
||||
import {
|
||||
@@ -69,6 +70,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
||||
.applyAxisAngle(new Vector3(0, 0, 1), model.turretYaw);
|
||||
const turretRotation = new Euler(0, 0, model.turretYaw);
|
||||
const ricochetCapable = canRicochet(antagonist.shell.type);
|
||||
const splashCapable = canSplash(antagonist.shell.type);
|
||||
|
||||
if (tankModelDefinition.turretRotation) {
|
||||
const pitch = -tankModelDefinition.turretRotation.pitch * (Math.PI / 180);
|
||||
@@ -111,6 +113,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
||||
|
||||
return (
|
||||
<ArmorMesh
|
||||
canSplash={splashCapable}
|
||||
spaced={isSpaced}
|
||||
key={node.uuid}
|
||||
geometry={(node as Mesh).geometry}
|
||||
@@ -154,6 +157,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
||||
|
||||
return (
|
||||
<ArmorMesh
|
||||
canSplash={splashCapable}
|
||||
spaced={isSpaced}
|
||||
key={node.uuid}
|
||||
position={turretOrigin}
|
||||
@@ -203,6 +207,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
||||
return null;
|
||||
return (
|
||||
<ArmorMesh
|
||||
canSplash={splashCapable}
|
||||
spaced={isSpaced}
|
||||
key={node.uuid}
|
||||
position={turretOrigin.clone().add(gunOrigin)}
|
||||
|
||||
@@ -12,6 +12,7 @@ interface ArmorMeshProps extends MeshProps {
|
||||
caliber: number;
|
||||
spaced?: boolean;
|
||||
canRicochet: boolean;
|
||||
canSplash: boolean;
|
||||
ricochet?: number;
|
||||
normalization?: number;
|
||||
}
|
||||
@@ -24,6 +25,7 @@ export function ArmorMesh({
|
||||
caliber,
|
||||
canRicochet,
|
||||
ricochet,
|
||||
canSplash,
|
||||
normalization,
|
||||
spaced = false,
|
||||
...props
|
||||
@@ -59,6 +61,7 @@ export function ArmorMesh({
|
||||
caliber: { value: caliber },
|
||||
spaced: { value: spaced ?? false },
|
||||
canRicochet: { value: canRicochet },
|
||||
canSplash: { value: canSplash },
|
||||
}}
|
||||
vertexShader={vertex}
|
||||
fragmentShader={opaqueArmor && !spaced ? fragmentOpaque : fragment}
|
||||
|
||||
@@ -8,6 +8,7 @@ uniform float caliber;
|
||||
uniform float normalization;
|
||||
uniform bool spaced;
|
||||
uniform bool canRichochet;
|
||||
uniform bool canSplash;
|
||||
|
||||
void main() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
@@ -42,9 +43,18 @@ void main() {
|
||||
|
||||
float alpha = (1.0 - penetrationChance) * 0.5;
|
||||
|
||||
if (spaced) {
|
||||
csm_FragColor = vec4(0.0, 0.0, 1.0, alpha);
|
||||
if (canSplash) {
|
||||
if (spaced) {
|
||||
csm_FragColor = vec4(1.0, 0.0, 0.0, alpha);
|
||||
} else {
|
||||
// color taken directly from the game
|
||||
csm_FragColor = vec4(1.0, 0.392, 0.0, alpha);
|
||||
}
|
||||
} else {
|
||||
csm_FragColor = vec4(1.0, 0.0, 0.0, alpha);
|
||||
if (spaced) {
|
||||
csm_FragColor = vec4(0.0, 0.0, 1.0, alpha);
|
||||
} else {
|
||||
csm_FragColor = vec4(1.0, 0.0, 0.0, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ uniform float penetration;
|
||||
uniform float ricochet;
|
||||
uniform float caliber;
|
||||
uniform float normalization;
|
||||
uniform bool canRichochet;
|
||||
|
||||
void main() {
|
||||
vec3 normalizedNormal = normalize(vNormal);
|
||||
@@ -16,7 +17,7 @@ void main() {
|
||||
float penetrationChance = -1.0;
|
||||
bool threeCaliberRule = caliber > 3.0 * thickness;
|
||||
|
||||
if (!threeCaliberRule && angle >= ricochet) {
|
||||
if (canRichochet && !threeCaliberRule && angle >= ricochet) {
|
||||
// auto ricochet angle and three caliber rule not met
|
||||
penetrationChance = 0.0;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ShellDefinition } from '../blitzkrieg/tankDefinitions';
|
||||
|
||||
export function canSplash(type: ShellDefinition['type']): type is 'he' {
|
||||
return type === 'he';
|
||||
}
|
||||
Reference in new issue
Block a user