diff --git a/app/src/modules/builder/floor/Instances/Instance/floor2DInstance.tsx b/app/src/modules/builder/floor/Instances/Instance/floor2DInstance.tsx new file mode 100644 index 0000000..166b1de --- /dev/null +++ b/app/src/modules/builder/floor/Instances/Instance/floor2DInstance.tsx @@ -0,0 +1,51 @@ +import { useMemo } from 'react'; +import { DoubleSide, Shape, Vector2 } from 'three'; +import { Extrude } from '@react-three/drei'; +import * as Constants from '../../../../../types/world/worldConstants'; + +function Floor2DInstance({ floor }: { floor: Floor }) { + const savedTheme: string | null = localStorage.getItem("theme"); + + const shape = useMemo(() => { + const shape = new Shape(); + const points = floor.points.map(p => new Vector2(p.position[0], p.position[2])); + if (points.length < 3) return null; + shape.moveTo(points[0].x, points[0].y); + for (let i = 1; i < points.length; i++) { + shape.lineTo(points[i].x, points[i].y); + } + return shape; + }, [floor]); + + if (!shape) return null; + + return ( + + + + + + ); +} + +export default Floor2DInstance; \ No newline at end of file diff --git a/app/src/modules/builder/floor/Instances/floorInstances.tsx b/app/src/modules/builder/floor/Instances/floorInstances.tsx index a5969eb..a578800 100644 --- a/app/src/modules/builder/floor/Instances/floorInstances.tsx +++ b/app/src/modules/builder/floor/Instances/floorInstances.tsx @@ -6,6 +6,7 @@ import { useToggleView } from '../../../../store/builder/store'; import Line from '../../line/line'; import Point from '../../point/point'; import FloorInstance from './Instance/floorInstance'; +import Floor2DInstance from './Instance/floor2DInstance'; function FloorInstances() { const { floorStore } = useSceneContext(); @@ -69,6 +70,14 @@ function FloorInstances() { )} + {toggleView && floors.length > 0 && ( + + {floors.map((floor) => ( + + ))} + + )} + {toggleView && ( <>