Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-07-22 10:22:29 +05:30
parent 8a6312322c
commit 60e43f9619
11 changed files with 18 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -6,6 +6,7 @@ import defaultTexture from '../../../../assets/textures/floor/white.png';
import flootTexture1 from '../../../../assets/textures/floor/factory wall texture.jpg'; import flootTexture1 from '../../../../assets/textures/floor/factory wall texture.jpg';
import flootTexture2 from '../../../../assets/textures/floor/tex1/MI_FactoryConcreteFloor01_BaseColor.001.jpg'; import flootTexture2 from '../../../../assets/textures/floor/tex1/MI_FactoryConcreteFloor01_BaseColor.001.jpg';
import flootTexture3 from '../../../../assets/textures/floor/tex2/MI_FloorMats01_baseColor.png'; import flootTexture3 from '../../../../assets/textures/floor/tex2/MI_FloorMats01_baseColor.png';
import flootTexture4 from '../../../../assets/textures/floor/tex3/metal_plate_diff_1k.jpg';
import { useBuilderStore } from "../../../../store/builder/useBuilderStore"; import { useBuilderStore } from "../../../../store/builder/useBuilderStore";
@@ -20,6 +21,7 @@ export const materials = [
{ texture: flootTexture1, textureId: "Material 1", textureName: "Grunge Concrete Wall" }, { texture: flootTexture1, textureId: "Material 1", textureName: "Grunge Concrete Wall" },
{ texture: flootTexture2, textureId: "Material 2", textureName: "Tiled Floor" }, { texture: flootTexture2, textureId: "Material 2", textureName: "Tiled Floor" },
{ texture: flootTexture3, textureId: "Material 3", textureName: "Metal Floor" }, { texture: flootTexture3, textureId: "Material 3", textureName: "Metal Floor" },
{ texture: flootTexture4, textureId: "Material 4", textureName: "Metal Floor 2" },
]; ];
const FloorProperties = () => { const FloorProperties = () => {

View File

@@ -29,6 +29,12 @@ import material3Map from "../../../../../assets/textures/floor/tex2/MI_FloorMats
import material3NormalMap from "../../../../../assets/textures/floor/tex2/MI_FloorMats01_Normal.png"; import material3NormalMap from "../../../../../assets/textures/floor/tex2/MI_FloorMats01_Normal.png";
import material3MetalicRoughnessMap from "../../../../../assets/textures/floor/tex2/MI_FloorMats01_occlusionRoughnessMetallic.png"; import material3MetalicRoughnessMap from "../../../../../assets/textures/floor/tex2/MI_FloorMats01_occlusionRoughnessMetallic.png";
// floor-mat3
import material4Map from "../../../../../assets/textures/floor/tex3/metal_plate_diff_1k.jpg";
import material4RoughnessMap from "../../../../../assets/textures/floor/tex3/metal_plate_rough_1k.png";
import material4MetalicMap from "../../../../../assets/textures/floor/tex3/metal_plate_metal_1k.png";
import material4NormalMap from "../../../../../assets/textures/floor/tex3/metal_plate_nor_gl_1k.png";
function FloorInstance({ floor }: { floor: Floor }) { function FloorInstance({ floor }: { floor: Floor }) {
const { togglView } = useToggleView(); const { togglView } = useToggleView();
const { activeModule } = useModuleStore(); const { activeModule } = useModuleStore();
@@ -65,6 +71,12 @@ function FloorInstance({ floor }: { floor: Floor }) {
metalnessMap: material3MetalicRoughnessMap, metalnessMap: material3MetalicRoughnessMap,
normalMap: material3NormalMap, normalMap: material3NormalMap,
}, },
"Material 4": {
map: material4Map,
roughnessMap: material4RoughnessMap,
metalnessMap: material4MetalicMap,
normalMap: material4NormalMap,
},
}; };
const shape = useMemo(() => { const shape = useMemo(() => {
@@ -131,6 +143,7 @@ function FloorInstance({ floor }: { floor: Floor }) {
if (!tex) return; if (!tex) return;
tex.wrapS = tex.wrapT = RepeatWrapping; tex.wrapS = tex.wrapT = RepeatWrapping;
tex.repeat.set(tileScale, tileScale); tex.repeat.set(tileScale, tileScale);
tex.anisotropy = 16;
// First texture is always the color map (use SRGB), others should be linear // First texture is always the color map (use SRGB), others should be linear
tex.colorSpace = idx < 1 ? SRGBColorSpace : NoColorSpace; tex.colorSpace = idx < 1 ? SRGBColorSpace : NoColorSpace;
}); });
@@ -184,14 +197,14 @@ function FloorInstance({ floor }: { floor: Floor }) {
]} ]}
userData={floor} userData={floor}
> >
<meshStandardMaterial <meshPhysicalMaterial
attach="material-0" attach="material-0"
color={Constants.floorConfig.defaultColor} color={Constants.floorConfig.defaultColor}
map={topTexture} map={topTexture}
roughnessMap={topRoughnessTexture} roughnessMap={topRoughnessTexture}
metalnessMap={topMetalicTexture} metalnessMap={topMetalicTexture}
normalMap={topNormalTexture} normalMap={topNormalTexture}
roughness={1.0} roughness={1.5}
metalness={1.0} metalness={1.0}
side={DoubleSide} side={DoubleSide}
/> />

View File

@@ -52,6 +52,7 @@ export default function Scene({ layout }: { readonly layout: 'Main Layout' | 'Co
}).catch((err) => { }).catch((err) => {
console.error(err); console.error(err);
}); });
// eslint-disable-next-line
}, [activeModule, assets, loadingProgress]) }, [activeModule, assets, loadingProgress])
return ( return (