From 20b6a559fd56355d14d142f4782076f1186af87d Mon Sep 17 00:00:00 2001 From: neru Date: Mon, 1 Jun 2026 15:07:01 -0300 Subject: [PATCH] fix: add separate rust texture for walls to stop stretching --- src/app/fear/scene-components/hallway.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/app/fear/scene-components/hallway.tsx b/src/app/fear/scene-components/hallway.tsx index d5cc430..d52b226 100644 --- a/src/app/fear/scene-components/hallway.tsx +++ b/src/app/fear/scene-components/hallway.tsx @@ -32,19 +32,21 @@ function Door({ position, rotation }: DoorProps) { export default function Hallway() { const [width, setWidth] = useState(fearState.currentWidth); - const [floorTex, wallTex, rustTex] = useTexture([ + const [floorTex, wallTex, rustWallTex, rustFloorTex] = useTexture([ 'fear/img/concrete-floor.png', 'fear/img/concrete-wall.png', + 'fear/img/rust.png', 'fear/img/rust.png' ]); useEffect(() => { - [floorTex, wallTex, rustTex].forEach((tex) => { + [floorTex, wallTex, rustWallTex, rustFloorTex].forEach((tex) => { tex.wrapS = tex.wrapT = THREE.RepeatWrapping; tex.minFilter = tex.magFilter = THREE.NearestFilter; tex.colorSpace = THREE.SRGBColorSpace; }); - }, [floorTex, wallTex, rustTex]); + }, [floorTex, wallTex, rustWallTex, rustFloorTex]); + const segmentPool = [0, 1, 2, 3, 4]; const segmentCount = segmentPool.length; @@ -125,11 +127,13 @@ export default function Hallway() { const horizontalTexRepeat = width / FEAR_SETTINGS.HALLWAY_WIDTH; floorTex.repeat.set(horizontalTexRepeat, 10); wallTex.repeat.set(10, 1); - rustTex.repeat.set(horizontalTexRepeat, 10); + rustWallTex.repeat.set(10, 1); + rustFloorTex.repeat.set(horizontalTexRepeat, 10); floorTex.needsUpdate = true; wallTex.needsUpdate = true; - rustTex.needsUpdate = true; + rustWallTex.needsUpdate = true; + rustFloorTex.needsUpdate = true; let closestPoolIndex = 0; let minDistance = Infinity; @@ -140,7 +144,6 @@ export default function Hallway() { let segmentZIndex = poolIndex - Math.floor(segmentCount / 2) + playerSegmentZ; segGroup.position.z = segmentZIndex * length; - // Track which pool index is currently physically closest to the player's camera position const distance = Math.abs(segGroup.position.z - state.camera.position.z); if (distance < minDistance) { minDistance = distance; @@ -197,10 +200,10 @@ export default function Hallway() { /* materials */ - const updateMaterials = (materials: THREE.MeshStandardMaterial[], defaultTex: THREE.Texture, activeColor: string, defaultColor: string, activeRough: number, defaultRough: number, activeMetal: number, defaultMetal: number) => { + const updateMaterials = (materials: THREE.MeshStandardMaterial[], defaultTex: THREE.Texture, targetRustTex: THREE.Texture, activeColor: string, defaultColor: string, activeRough: number, defaultRough: number, activeMetal: number, defaultMetal: number) => { materials.forEach(mat => { if (!mat) return; - const targetTex = isRustActive ? rustTex : defaultTex; + const targetTex = isRustActive ? targetRustTex : defaultTex; if (mat.map !== targetTex) { mat.map = targetTex; mat.needsUpdate = true; @@ -211,8 +214,8 @@ export default function Hallway() { }); }; - updateMaterials(wallMaterialsRef.current, wallTex, "#918a87", "#ffffff", 0.95, 0.7, 0.05, 0.1); - updateMaterials(floorMaterialsRef.current, floorTex, "#8b827f", "#ffffff", 0.95, 0.8, 0.05, 0.2); + updateMaterials(wallMaterialsRef.current, wallTex, rustWallTex, "#c5c0be", "#ffffff", 0.95, 0.7, 0.05, 0.1); + updateMaterials(floorMaterialsRef.current, floorTex, rustFloorTex, "#cabdb9", "#ffffff", 0.95, 0.8, 0.05, 0.2); pipeMaterialsRef.current.forEach(mat => { if (!mat) return;