diff --git a/src/app/tools/tankopedia/[id]/components/Thicknesses.tsx b/src/app/tools/tankopedia/[id]/components/Thicknesses.tsx index 2c749dffc..f890da12e 100644 --- a/src/app/tools/tankopedia/[id]/components/Thicknesses.tsx +++ b/src/app/tools/tankopedia/[id]/components/Thicknesses.tsx @@ -15,8 +15,8 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) { const showSpacedArmor = TankopediaPersistent.use( (state) => state.model.visual.showSpacedArmor, ); - const showCoreArmor = TankopediaPersistent.use( - (state) => state.model.visual.showCoreArmor, + const showPrimaryArmor = TankopediaPersistent.use( + (state) => state.model.visual.showPrimaryArmor, ); const mutateTankopediaPersistent = TankopediaPersistent.useMutation(); const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation(); @@ -35,11 +35,11 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) { { mutateTankopediaPersistent((draft) => { - draft.model.visual.showCoreArmor = - !draft.model.visual.showCoreArmor; + draft.model.visual.showPrimaryArmor = + !draft.model.visual.showPrimaryArmor; }); mutateTankopediaEphemeral((draft) => { draft.highlightArmor = undefined; @@ -51,8 +51,8 @@ export function Thicknesses({ thicknessRange }: ThicknessesProps) { {thicknessRange.quartile.toFixed(0)} - {showCoreArmor ? : } - Core + {showPrimaryArmor ? : } + Primary 0 diff --git a/src/components/Armor/components/CoreArmorScene.tsx b/src/components/Armor/components/PrimaryArmorScene.tsx similarity index 92% rename from src/components/Armor/components/CoreArmorScene.tsx rename to src/components/Armor/components/PrimaryArmorScene.tsx index 377294a63..32c301359 100644 --- a/src/components/Armor/components/CoreArmorScene.tsx +++ b/src/components/Armor/components/PrimaryArmorScene.tsx @@ -8,10 +8,10 @@ import { useModelDefinitions } from '../../../hooks/useModelDefinitions'; import { useTankTransform } from '../../../hooks/useTankTransform'; import * as Duel from '../../../stores/duel'; import * as TankopediaPersistent from '../../../stores/tankopediaPersistent'; -import { CoreArmorSceneComponent } from './CoreArmorSceneComponent'; import { ModelTankWrapper } from './ModelTankWrapper'; +import { PrimaryArmorSceneComponent } from './PrimaryArmorSceneComponent'; -export const CoreArmorScene = memo(() => { +export const PrimaryArmorScene = memo(() => { const wrapper = useRef(null); const modelDefinitions = useModelDefinitions(); const turretContainer = useRef(null); @@ -49,7 +49,7 @@ export const CoreArmorScene = memo(() => { if (!isVisible || spaced || thickness === undefined) return null; return ( - { return ( - { key={node.uuid} position={turretOrigin.clone().add(gunOrigin)} > - + ); diff --git a/src/components/Armor/components/CoreArmorSceneComponent/index.tsx b/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx similarity index 97% rename from src/components/Armor/components/CoreArmorSceneComponent/index.tsx rename to src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx index c287c54ea..f33918b41 100644 --- a/src/components/Armor/components/CoreArmorSceneComponent/index.tsx +++ b/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx @@ -15,7 +15,7 @@ import fragmentShader from './shaders/fragment.glsl'; import vertexShader from './shaders/vertex.glsl'; import { spacedArmorRenderTarget } from './target'; -interface CoreArmorSceneComponentProps { +interface PrimaryArmorSceneComponentProps { thickness: number; node: Object3D; } @@ -24,10 +24,10 @@ const excludeMaterial = new MeshBasicMaterial({ colorWrite: false, }); -export function CoreArmorSceneComponent({ +export function PrimaryArmorSceneComponent({ node, thickness, -}: CoreArmorSceneComponentProps) { +}: PrimaryArmorSceneComponentProps) { const tankopediaPersistentStore = TankopediaPersistent.useStore(); const duelStore = Duel.useStore(); const material = new ShaderMaterial({ diff --git a/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl b/src/components/Armor/components/PrimaryArmorSceneComponent/shaders/fragment.glsl similarity index 95% rename from src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl rename to src/components/Armor/components/PrimaryArmorSceneComponent/shaders/fragment.glsl index e75e8eb65..045d49a80 100644 --- a/src/components/Armor/components/CoreArmorSceneComponent/shaders/fragment.glsl +++ b/src/components/Armor/components/PrimaryArmorSceneComponent/shaders/fragment.glsl @@ -45,8 +45,8 @@ void main() { // world space in meters vec4 spacedArmorDepthFragment = texture2D(spacedArmorDepth, screenCoordinates); float spacedArmorDistance = depthToDistance(spacedArmorDepthFragment.r); - float coreArmorDistance = depthToDistance(gl_FragCoord.z); - float distanceFromSpacedArmor = coreArmorDistance - spacedArmorDistance; + float primaryArmorDistance = depthToDistance(gl_FragCoord.z); + float distanceFromSpacedArmor = primaryArmorDistance - spacedArmorDistance; if (canSplash && isUnderSpacedArmor) { float spacedArmorThickness = spacedArmorBufferFragment.r * penetration; diff --git a/src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl b/src/components/Armor/components/PrimaryArmorSceneComponent/shaders/vertex.glsl similarity index 100% rename from src/components/Armor/components/CoreArmorSceneComponent/shaders/vertex.glsl rename to src/components/Armor/components/PrimaryArmorSceneComponent/shaders/vertex.glsl diff --git a/src/components/Armor/components/CoreArmorSceneComponent/target.tsx b/src/components/Armor/components/PrimaryArmorSceneComponent/target.tsx similarity index 100% rename from src/components/Armor/components/CoreArmorSceneComponent/target.tsx rename to src/components/Armor/components/PrimaryArmorSceneComponent/target.tsx diff --git a/src/components/Armor/components/ShotDisplayCard.tsx b/src/components/Armor/components/ShotDisplayCard.tsx index 55c8d85db..f36dec60b 100644 --- a/src/components/Armor/components/ShotDisplayCard.tsx +++ b/src/components/Armor/components/ShotDisplayCard.tsx @@ -14,7 +14,7 @@ import { ArmorType } from './SpacedArmorScene'; import { ExternalModuleVariant } from './SpacedArmorSceneComponent'; export const layerTypeNames: Record = { - [ArmorType.Core]: 'Core', + [ArmorType.Primary]: 'Primary', [ArmorType.Spaced]: 'Spaced', [ArmorType.External]: 'External', null: 'Gap', @@ -50,7 +50,7 @@ function LayerEntry({ {layerIndex} - + {layerName} @@ -74,7 +74,8 @@ function LayerEntry({ )} - {(layer.type === ArmorType.Core || layer.type === ArmorType.Spaced) && ( + {(layer.type === ArmorType.Primary || + layer.type === ArmorType.Spaced) && ( <> {Math.round(layer.thicknessAngled).toLocaleString()} @@ -140,7 +141,7 @@ export function ShotDisplayCard({ shot, ...props }: ShotDisplayCardProps) { layerName={layerName} shotStatusColor={shotStatusColor} angle={ - layer.type === ArmorType.Core || + layer.type === ArmorType.Primary || layer.type === ArmorType.Spaced ? layer.angle : undefined @@ -206,7 +207,7 @@ export function ShotDisplayCard({ shot, ...props }: ShotDisplayCardProps) { layerName={layerName} shotStatusColor={shotStatusColor} angle={ - layer.type === ArmorType.Core || + layer.type === ArmorType.Primary || layer.type === ArmorType.Spaced ? layer.angle : undefined diff --git a/src/components/Armor/components/SpacedArmorScene.tsx b/src/components/Armor/components/SpacedArmorScene.tsx index 7a6c99e9c..68baf3cf9 100644 --- a/src/components/Armor/components/SpacedArmorScene.tsx +++ b/src/components/Armor/components/SpacedArmorScene.tsx @@ -12,7 +12,7 @@ import { ModelTankWrapper } from './ModelTankWrapper'; import { SpacedArmorSceneComponent } from './SpacedArmorSceneComponent'; export enum ArmorType { - Core, + Primary, Spaced, External, } @@ -67,7 +67,7 @@ export const SpacedArmorScene = memo(({ scene }) => { @@ -114,7 +114,7 @@ export const SpacedArmorScene = memo(({ scene }) => { @@ -145,7 +145,7 @@ export const SpacedArmorScene = memo(({ scene }) => { > diff --git a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx index 5844763a4..ca0a372e7 100644 --- a/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx +++ b/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx @@ -105,7 +105,7 @@ export function SpacedArmorSceneComponent({ let depthWrite = true; switch (props.type) { - case ArmorType.Core: + case ArmorType.Primary: color = new Color(-((1 - x) ** 2) + 1, -(x ** 2) + 1, 0); opacity = 1; break; @@ -280,7 +280,7 @@ export function SpacedArmorSceneComponent({ } else { noDuplicateIntersections.push(intersection); - if (intersection.object.userData.type === ArmorType.Core) { + if (intersection.object.userData.type === ArmorType.Primary) { break; } } @@ -289,7 +289,7 @@ export function SpacedArmorSceneComponent({ if ( !allowRicochet && !noDuplicateIntersections.some((intersection) => { - intersection.object.userData.type === ArmorType.Core; + intersection.object.userData.type === ArmorType.Primary; }) ) { return null; @@ -386,7 +386,7 @@ export function SpacedArmorSceneComponent({ point: intersection.point, surfaceNormal: intersection.face!.normal, status: - shell.type === ShellType.HE && layer.type !== ArmorType.Core + shell.type === ShellType.HE && layer.type !== ArmorType.Primary ? 'blocked' : blocked ? 'blocked' @@ -416,7 +416,7 @@ export function SpacedArmorSceneComponent({ if (shell.type === ShellType.HE) { const totalSpacedArmorThickness = shot.in.layers.reduce( (acc, layer) => { - if (layer.type === null || layer.type === ArmorType.Core) { + if (layer.type === null || layer.type === ArmorType.Primary) { return acc; } @@ -515,14 +515,14 @@ export function SpacedArmorSceneComponent({ return ( <> - {props.type === ArmorType.Core && + {props.type === ArmorType.Primary && jsxTree( node, { renderOrder: 0, material: omitMaterial, userData: { - type: ArmorType.Core, + type: ArmorType.Primary, thickness, } satisfies ArmorUserData, async onClick(event) { diff --git a/src/components/Armor/index.tsx b/src/components/Armor/index.tsx index ed82f3a9f..fe1927fd5 100644 --- a/src/components/Armor/index.tsx +++ b/src/components/Armor/index.tsx @@ -1,18 +1,21 @@ import { createPortal, useFrame } from '@react-three/fiber'; import { memo, useState } from 'react'; import { DepthTexture, Scene, Vector2 } from 'three'; -import { CoreArmorScene } from './components/CoreArmorScene'; -import { spacedArmorRenderTarget } from './components/CoreArmorSceneComponent/target'; +import { PrimaryArmorScene } from './components/PrimaryArmorScene'; +import { spacedArmorRenderTarget } from './components/PrimaryArmorSceneComponent/target'; import { SpacedArmorScene } from './components/SpacedArmorScene'; export const Armor = memo(() => { const [spacedArmorScene] = useState(() => new Scene()); - const [coreArmorScene] = useState(() => new Scene()); + const [primaryArmorScene] = useState(() => new Scene()); const spacedArmorPortal = createPortal( , spacedArmorScene, ); - const coreArmorPortal = createPortal(, coreArmorScene); + const primaryArmorPortal = createPortal( + , + primaryArmorScene, + ); const renderSize = new Vector2(); const newRenderSize = new Vector2(); @@ -40,13 +43,13 @@ export const Armor = memo(() => { gl.render(scene, camera); gl.clearDepth(); - gl.render(coreArmorScene, camera); + gl.render(primaryArmorScene, camera); }, 1); return ( <> {spacedArmorPortal} - {coreArmorPortal} + {primaryArmorPortal} ); }); diff --git a/src/components/StaticArmor/components/StaticArmorScene.tsx b/src/components/StaticArmor/components/StaticArmorScene.tsx index 38c649565..be8ca9a0e 100644 --- a/src/components/StaticArmor/components/StaticArmorScene.tsx +++ b/src/components/StaticArmor/components/StaticArmorScene.tsx @@ -48,8 +48,8 @@ export const StaticArmorScene = memo( gunModelDefinition.mask === undefined ? undefined : gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y; - const showCoreArmor = TankopediaPersistent.use( - (state) => state.model.visual.showCoreArmor, + const showPrimaryArmor = TankopediaPersistent.use( + (state) => state.model.visual.showPrimaryArmor, ); const showSpacedArmor = TankopediaPersistent.use( (state) => state.model.visual.showSpacedArmor, @@ -75,7 +75,7 @@ export const StaticArmorScene = memo( if ( !isVisible || thickness === undefined || - (!showCoreArmor && !spaced) || + (!showPrimaryArmor && !spaced) || (!showSpacedArmor && spaced) ) return null; @@ -86,7 +86,7 @@ export const StaticArmorScene = memo( thicknessRange={thicknessRange} static key={node.uuid} - type={spaced ? ArmorType.Spaced : ArmorType.Core} + type={spaced ? ArmorType.Spaced : ArmorType.Primary} thickness={thickness} node={node} /> @@ -130,7 +130,7 @@ export const StaticArmorScene = memo( if ( !isVisible || thickness === undefined || - (!showCoreArmor && !spaced) || + (!showPrimaryArmor && !spaced) || (!showSpacedArmor && spaced) ) return null; @@ -143,7 +143,7 @@ export const StaticArmorScene = memo( thicknessRange={thicknessRange} static key={node.uuid} - type={spaced ? ArmorType.Spaced : ArmorType.Core} + type={spaced ? ArmorType.Spaced : ArmorType.Primary} thickness={thickness} node={node} /> @@ -167,7 +167,7 @@ export const StaticArmorScene = memo( if ( !isVisible || thickness === undefined || - (!showCoreArmor && !spaced) || + (!showPrimaryArmor && !spaced) || (!showSpacedArmor && spaced) ) return null; @@ -182,7 +182,7 @@ export const StaticArmorScene = memo( name={node.name} thicknessRange={thicknessRange} static - type={spaced ? ArmorType.Spaced : ArmorType.Core} + type={spaced ? ArmorType.Spaced : ArmorType.Primary} thickness={thickness} node={node} /> diff --git a/src/stores/tankopediaEphemeral.ts b/src/stores/tankopediaEphemeral.ts index 5960620ab..563eedc53 100644 --- a/src/stores/tankopediaEphemeral.ts +++ b/src/stores/tankopediaEphemeral.ts @@ -18,7 +18,7 @@ interface TankopediaEphemeral { color: string; } & ( | { - type: ArmorType.Core | ArmorType.Spaced; + type: ArmorType.Primary | ArmorType.Spaced; thicknessAngled: number; angle: number; } diff --git a/src/stores/tankopediaPersistent/index.ts b/src/stores/tankopediaPersistent/index.ts index 643e8a089..13c7a1aae 100644 --- a/src/stores/tankopediaPersistent/index.ts +++ b/src/stores/tankopediaPersistent/index.ts @@ -23,7 +23,7 @@ export interface TankopediaPersistent { showEnvironment: boolean; showSpacedArmor: boolean; showExternalModules: boolean; - showCoreArmor: boolean; + showPrimaryArmor: boolean; }; }; sort: { @@ -50,7 +50,7 @@ export const { Provider, use, useMutation, useStore } = createNextSafeStore( visual: { showSpacedArmor: true, showExternalModules: true, - showCoreArmor: true, + showPrimaryArmor: true, wireframe: false, opaque: false, environment: ENVIRONMENTS[0],