import { useEffect, useState } from "react"; import InputWithDropDown from "../../../ui/inputs/InputWithDropDown"; // Texture Imports import defaultTexture from '../../../../assets/textures/floor/wall-tex.png'; import wallTexture1 from '../../../../assets/textures/floor/factory wall texture.jpg'; import { useBuilderStore } from "../../../../store/builder/useBuilderStore"; // Define Material type type Material = { texture: string; textureName: string; }; // Default and initial materials const defaultMaterial: Material = { texture: defaultTexture, textureName: "Default Material", }; const initialMaterial: Material = { texture: wallTexture1, textureName: "Grunge Concrete Wall", }; const WallProperties = () => { const { wallHeight, wallThickness, setWallHeight, setWallThickness } = useBuilderStore(); const [activeSide, setActiveSide] = useState<"side1" | "side2">("side1"); const [materials, setMaterials] = useState([ defaultMaterial, initialMaterial, ]); const [selectedMaterials, setSelectedMaterials] = useState<{ side1: Material | null; side2: Material | null; }>({ side1: null, side2: null, }); // Set default material initially for both sides useEffect(() => { setSelectedMaterials({ side1: defaultMaterial, side2: defaultMaterial, }); }, []); const handleHeightChange = (newValue: string) => { setWallHeight(parseFloat(newValue)); }; const handleThicknessChange = (newValue: string) => { setWallThickness(parseFloat(newValue)); }; const handleSelectMaterial = (material: Material) => { setSelectedMaterials((prev) => ({ ...prev, [activeSide]: material, })); }; return (
Wall
handleHeightChange(val)} /> handleThicknessChange(val)} />
Materials
{selectedMaterials[activeSide] && ( {selectedMaterials[activeSide]!.textureName} )}
{materials.length === 0 ? (
No materials added yet.
) : (
{materials.map((material, index) => { const isSelected = selectedMaterials[activeSide]?.texture === material.texture; return ( ); })}
)}
); }; export default WallProperties;