import React, { useEffect, useMemo, useRef } from 'react'; import { useWallStore } from '../../../../store/builder/useWallStore' import WallInstance from './instance/wallInstance'; import Line from '../../line/line'; import Point from '../../point/point'; import { useToggleView } from '../../../../store/builder/store'; import { Geometry } from '@react-three/csg'; function WallInstances() { const { walls } = useWallStore(); const { toggleView } = useToggleView(); useEffect(() => { // console.log('walls: ', walls); }, [walls]) const allPoints = useMemo(() => { const points: Point[] = []; const seenUuids = new Set(); walls.forEach(aisle => { aisle.points.forEach(point => { if (!seenUuids.has(point.pointUuid)) { seenUuids.add(point.pointUuid); points.push(point); } }); }); return points; }, [walls]); return ( <> {!toggleView && ( {/* */} {walls.map((wall) => ( ))} {/* */} )} {toggleView && ( <> {allPoints.map((point) => ( ))} {walls.map((wall) => ( ))} )} ) } export default WallInstances