fix: add separate rust texture for walls to stop stretching
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user