Add layout management with Zustand and integrate LayoutImage component
This commit is contained in:
35
app/src/modules/builder/layout/layoutImage.tsx
Normal file
35
app/src/modules/builder/layout/layoutImage.tsx
Normal 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;
|
||||
Reference in New Issue
Block a user