Refactor: Integrate activeLayer and builder store into SelectFloorPlan and LoadBlueprint components; enhance getWallPointsFromBlueprint function with additional parameters for wall creation; update wall handling in WallCreator and PolygonGenerator components.
This commit is contained in:
@@ -12,13 +12,12 @@ interface PolygonGeneratorProps {
|
||||
export default function PolygonGenerator({
|
||||
groupRef,
|
||||
}: PolygonGeneratorProps) {
|
||||
const { aisleStore } = useSceneContext();
|
||||
const { aisleStore, wallStore } = useSceneContext();
|
||||
const { aisles } = aisleStore();
|
||||
const { scene } = useThree();
|
||||
const { walls } = wallStore();
|
||||
|
||||
useEffect(() => {
|
||||
// let allLines = arrayLinesToObject(lines.current);
|
||||
// const wallLines = allLines?.filter((line) => line?.type === "WallLine");
|
||||
const result = aisles
|
||||
.filter(
|
||||
(aisle) =>
|
||||
@@ -61,9 +60,12 @@ export default function PolygonGenerator({
|
||||
});
|
||||
});
|
||||
|
||||
// const wallPoints = wallLines
|
||||
// .map((pair) => pair?.line.map((vals) => vals.position))
|
||||
// .filter((wall): wall is THREE.Vector3[] => !!wall);
|
||||
|
||||
const wallPoints: THREE.Vector3[][] = walls
|
||||
.map((wall) =>
|
||||
wall.points.map((pt) => new THREE.Vector3(pt.position[0], pt.position[1], pt.position[2]))
|
||||
)
|
||||
.filter(points => points.length === 2);
|
||||
|
||||
|
||||
if (!result || result.some((line) => !line)) {
|
||||
@@ -81,7 +83,7 @@ export default function PolygonGenerator({
|
||||
|
||||
const polygons = turf.polygonize(turf.featureCollection(validLineFeatures));
|
||||
|
||||
// renderWallGeometry(wallPoints);
|
||||
renderWallGeometry(wallPoints);
|
||||
|
||||
if (polygons.features.length > 0) {
|
||||
polygons.features.forEach((feature) => {
|
||||
@@ -116,7 +118,7 @@ export default function PolygonGenerator({
|
||||
});
|
||||
}
|
||||
|
||||
}, [ aisles, scene]);
|
||||
}, [aisles, scene, walls]);
|
||||
|
||||
const renderWallGeometry = (walls: THREE.Vector3[][]) => {
|
||||
walls.forEach((wall) => {
|
||||
|
||||
Reference in New Issue
Block a user