Add layout management with Zustand and integrate LayoutImage component

This commit is contained in:
2025-05-13 18:20:25 +05:30
parent b7f74c975c
commit ba4fdfc314
3 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { useMemo } from 'react';
import layout1 from '../../../assets/gltf-glb/layouts/floorplane_1.glb';
import layout2 from '../../../assets/gltf-glb/layouts/floorplane_2.glb';
import useLayoutStore from '../../../store/builder/uselayoutStore';
import { useGLTF } from '@react-three/drei';
import { useToggleView } from '../../../store/builder/store';
const modelPaths: Record<string, string> = {
'layout1': layout1,
'layout2': layout2
};
function LayoutModel() {
const { toggleView } = useToggleView();
const { currentLayout } = useLayoutStore();
if (!currentLayout) return null;
const path = modelPaths[currentLayout];
const gltf = useGLTF(path);
const cloned = useMemo(() => gltf?.scene?.clone(), [gltf]);
return (
<>
{toggleView &&
<group position={[0,0,0]} scale={[0,0,0]} dispose={null}>
<primitive
object={cloned}
/>
</group>
}
</>
);
}
export default LayoutModel;