mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: spaced armor
This commit is contained in:
1 parent
cae4836e17
commit
9218eb09d6
4 files changed
+34
-9
No files matched your search
@@ -12,25 +12,31 @@ interface ArmorMeshProps extends MeshProps {
|
||||
ricochet: number;
|
||||
caliber: number;
|
||||
normalization: number;
|
||||
spaced?: boolean;
|
||||
}
|
||||
|
||||
// shader split: https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/issues/48
|
||||
|
||||
export function ArmorMesh({
|
||||
thickness,
|
||||
penetration,
|
||||
caliber,
|
||||
ricochet,
|
||||
normalization,
|
||||
spaced = false,
|
||||
...props
|
||||
}: ArmorMeshProps) {
|
||||
const opaqueArmor = useTankopedia((state) => state.model.opaqueArmor);
|
||||
|
||||
return (
|
||||
<>
|
||||
<mesh {...props}>
|
||||
<meshBasicMaterial colorWrite={false} />
|
||||
</mesh>
|
||||
{!spaced && (
|
||||
<mesh {...props}>
|
||||
<meshBasicMaterial colorWrite={false} />
|
||||
</mesh>
|
||||
)}
|
||||
|
||||
<mesh {...props} renderOrder={1}>
|
||||
<mesh {...props} renderOrder={spaced ? 3 : 1}>
|
||||
<CustomShaderMaterial
|
||||
baseMaterial={MeshStandardMaterial}
|
||||
transparent
|
||||
@@ -42,10 +48,10 @@ export function ArmorMesh({
|
||||
ricochet: { value: ricochet * (Math.PI / 180) },
|
||||
caliber: { value: caliber },
|
||||
normalization: { value: normalization * (Math.PI / 180) },
|
||||
spaced: { value: spaced },
|
||||
}}
|
||||
vertexShader={vertex}
|
||||
// split shaders due to https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/issues/48
|
||||
fragmentShader={opaqueArmor ? fragmentOpaque : fragment}
|
||||
fragmentShader={opaqueArmor && !spaced ? fragmentOpaque : fragment}
|
||||
/>
|
||||
</mesh>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user