2025-06-10 05:48:39 +00:00
|
|
|
import React, { useEffect, useMemo, useRef } from 'react';
|
2025-06-04 04:53:22 +00:00
|
|
|
import { useWallStore } from '../../../../store/builder/useWallStore'
|
|
|
|
import WallInstance from './instance/wallInstance';
|
2025-06-04 09:49:37 +00:00
|
|
|
import Line from '../../line/line';
|
|
|
|
import Point from '../../point/point';
|
|
|
|
import { useToggleView } from '../../../../store/builder/store';
|
2025-06-18 06:08:35 +00:00
|
|
|
import { Geometry } from '@react-three/csg';
|
2025-06-04 04:53:22 +00:00
|
|
|
|
|
|
|
function WallInstances() {
|
|
|
|
const { walls } = useWallStore();
|
2025-06-04 09:49:37 +00:00
|
|
|
const { toggleView } = useToggleView();
|
2025-06-04 04:53:22 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
// console.log('walls: ', walls);
|
|
|
|
}, [walls])
|
|
|
|
|
2025-06-05 06:25:46 +00:00
|
|
|
const allPoints = useMemo(() => {
|
|
|
|
const points: Point[] = [];
|
|
|
|
const seenUuids = new Set<string>();
|
2025-06-04 09:49:37 +00:00
|
|
|
|
2025-06-05 06:25:46 +00:00
|
|
|
walls.forEach(aisle => {
|
|
|
|
aisle.points.forEach(point => {
|
|
|
|
if (!seenUuids.has(point.pointUuid)) {
|
|
|
|
seenUuids.add(point.pointUuid);
|
|
|
|
points.push(point);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2025-06-04 09:49:37 +00:00
|
|
|
|
2025-06-05 06:25:46 +00:00
|
|
|
return points;
|
|
|
|
}, [walls]);
|
2025-06-04 09:49:37 +00:00
|
|
|
|
2025-06-05 06:25:46 +00:00
|
|
|
return (
|
|
|
|
<>
|
2025-06-10 05:48:39 +00:00
|
|
|
|
2025-06-18 06:08:35 +00:00
|
|
|
{!toggleView && (
|
2025-06-10 05:48:39 +00:00
|
|
|
|
2025-06-18 06:08:35 +00:00
|
|
|
<mesh name='Walls-Group'>
|
|
|
|
{/* <Base name="base" geometry={box} scale={[3, 3, 3]} /> */}
|
2025-06-10 05:48:39 +00:00
|
|
|
|
2025-06-18 06:08:35 +00:00
|
|
|
<Geometry useGroups>
|
2025-06-18 04:45:17 +00:00
|
|
|
{walls.map((wall) => (
|
|
|
|
<WallInstance key={wall.wallUuid} wall={wall} />
|
|
|
|
))}
|
|
|
|
</Geometry>
|
|
|
|
|
2025-06-18 06:08:35 +00:00
|
|
|
{/* <Subtraction rotation={[0, Math.PI / 2, 0]} position={[-1.425, -0.45, 0]} scale={[1, 3, 1]}>
|
|
|
|
<Geometry>
|
|
|
|
<Base geometry={box} />
|
|
|
|
</Geometry>
|
|
|
|
</Subtraction> */}
|
|
|
|
</mesh>
|
|
|
|
)}
|
2025-06-05 06:25:46 +00:00
|
|
|
|
|
|
|
{toggleView && (
|
|
|
|
<>
|
|
|
|
<group name='Wall-Points-Group'>
|
|
|
|
{allPoints.map((point) => (
|
|
|
|
<Point key={point.pointUuid} point={point} />
|
|
|
|
))}
|
|
|
|
</group>
|
|
|
|
|
|
|
|
<group name='Wall-Lines-Group'>
|
|
|
|
{walls.map((wall) => (
|
|
|
|
<React.Fragment key={wall.wallUuid}>
|
|
|
|
<Line points={wall.points} />
|
|
|
|
</React.Fragment>
|
|
|
|
))}
|
|
|
|
</group>
|
2025-06-04 09:49:37 +00:00
|
|
|
</>
|
|
|
|
)}
|
2025-06-04 04:53:22 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2025-06-18 04:45:17 +00:00
|
|
|
export default WallInstances
|