diff --git a/app/src/components/ui/list/DropDownList.tsx b/app/src/components/ui/list/DropDownList.tsx
index a61054b..d31ef96 100644
--- a/app/src/components/ui/list/DropDownList.tsx
+++ b/app/src/components/ui/list/DropDownList.tsx
@@ -39,7 +39,7 @@ const DropDownList: React.FC<DropDownListProps> = ({
   useEffect(() => {
     async function GetZoneData() {
       const response = await getZonesApi("hexrfactory")
-      console.log('response: ', response.data);
+      // console.log('response: ', response.data);
       setZoneDataList([{ id: "1", name: "zone1" },
       { id: "2", name: "Zone 2" },])
     }
diff --git a/app/src/modules/builder/agv/agv.tsx b/app/src/modules/builder/agv/agv.tsx
index b2e78c0..749e39f 100644
--- a/app/src/modules/builder/agv/agv.tsx
+++ b/app/src/modules/builder/agv/agv.tsx
@@ -1,1580 +1,51 @@
-import React from "react";
+import PolygonGenerator from "./polygonGenerator";
 import { useThree } from "@react-three/fiber";
 import { useEffect, useRef, useState } from "react";
 import * as THREE from "three";
-import PolygonGenerator from "./polygonGenerator";
-import NavMeshDetails from "./navMeshDetails";
-import { NavMesh as RecastNavMesh } from "@recast-navigation/core";
+import * as Types from "../../../types/world/worldTypes";
 import PathNavigator from "./pathNavigator";
-interface RawNavMesh {
-  ptr: number; // Replace `number` with the actual type if known
-}
-interface NavMesh {
-  raw: RawNavMesh;
-}
-export default function Agv({ lines, plane }: any) {
-  
-  
-  const { scene } = useThree();
-  const groupRef = useRef<THREE.Group | null>(null);
-  const [navMesh, setNavMesh] = useState<RecastNavMesh | null>(null);
+import NavMeshDetails from "./navMeshDetails";
+
+const Agv = ({
+  lines,
+  plane,
+}: {
+  lines: Types.RefLines;
+  plane: Types.RefMesh;
+}) => {
   let pathPoints = [
     [
       { x: 8.477161935339709, y: 0, z: 17.41343083550102 },
       { x: 9.175416491482693, y: 0, z: -12.361001232663693 },
     ],
+    ,
+    // [
+    //   { x: 13.508213355232144, y: 0, z: -15.456970649652018 },
+    //   { x: -30.464866520869617, y: 0, z: 9.779806557688929 },
+    // ],
     [
       { x: 16.792040856420844, y: 0, z: 15.86281907549489 },
       { x: -42.77173264503395, y: 0, z: -15.821322764400804 },
     ],
   ];
-  let processPoint = [
-    {
-      _id: {
-        $oid: "67da9121029b39637717b7b1",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -32.49832772097252,
-            y: 0.01,
-            z: -14.687753872309017,
-            _id: {
-              $oid: "67da9121029b39637717b7b3",
-            },
-          },
-          uuid: "9ba396ee-8ef5-4996-84a9-6fdac915eea8",
-          _id: {
-            $oid: "67da9121029b39637717b7b2",
-          },
-        },
-        {
-          position: {
-            x: -26.13448312795506,
-            y: 0.01,
-            z: -14.687753872309019,
-            _id: {
-              $oid: "67da9121029b39637717b7b5",
-            },
-          },
-          uuid: "b51d6a49-8d6a-4889-8b51-6b45353ee4d7",
-          _id: {
-            $oid: "67da9121029b39637717b7b4",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9122029b39637717b7b7",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.13448312795506,
-            y: 0.01,
-            z: -14.687753872309019,
-            _id: {
-              $oid: "67da9122029b39637717b7b9",
-            },
-          },
-          uuid: "b51d6a49-8d6a-4889-8b51-6b45353ee4d7",
-          _id: {
-            $oid: "67da9122029b39637717b7b8",
-          },
-        },
-        {
-          position: {
-            x: -26.13448312795506,
-            y: 0.01,
-            z: -7.782512568268439,
-            _id: {
-              $oid: "67da9122029b39637717b7bb",
-            },
-          },
-          uuid: "b5ace9cb-7795-47bd-a813-7ae29a713692",
-          _id: {
-            $oid: "67da9122029b39637717b7ba",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9126029b39637717b7bd",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.13448312795506,
-            y: 0.01,
-            z: -7.782512568268439,
-            _id: {
-              $oid: "67da9126029b39637717b7bf",
-            },
-          },
-          uuid: "b5ace9cb-7795-47bd-a813-7ae29a713692",
-          _id: {
-            $oid: "67da9126029b39637717b7be",
-          },
-        },
-        {
-          position: {
-            x: -32.639282521592044,
-            y: 0.01,
-            z: -7.782512568268438,
-            _id: {
-              $oid: "67da9126029b39637717b7c1",
-            },
-          },
-          uuid: "08df978b-ce38-4a0d-a89c-9992f0c470e7",
-          _id: {
-            $oid: "67da9126029b39637717b7c0",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9127029b39637717b7c3",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -32.639282521592044,
-            y: 0.01,
-            z: -7.782512568268438,
-            _id: {
-              $oid: "67da9127029b39637717b7c5",
-            },
-          },
-          uuid: "08df978b-ce38-4a0d-a89c-9992f0c470e7",
-          _id: {
-            $oid: "67da9127029b39637717b7c4",
-          },
-        },
-        {
-          position: {
-            x: -32.49832772097252,
-            y: 0.01,
-            z: -14.687753872309017,
-            _id: {
-              $oid: "67da9127029b39637717b7c7",
-            },
-          },
-          uuid: "9ba396ee-8ef5-4996-84a9-6fdac915eea8",
-          _id: {
-            $oid: "67da9127029b39637717b7c6",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9131029b39637717b7c9",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -18.900000000000002,
-            y: 0.01,
-            z: -14.65000050000732,
-            _id: {
-              $oid: "67da9131029b39637717b7cb",
-            },
-          },
-          uuid: "d066f4bd-3df9-4824-9e66-b5b67263152b",
-          _id: {
-            $oid: "67da9131029b39637717b7ca",
-          },
-        },
-        {
-          position: {
-            x: -11.499324355168639,
-            y: 0.01,
-            z: -14.650000500007321,
-            _id: {
-              $oid: "67da9131029b39637717b7cd",
-            },
-          },
-          uuid: "ddea6247-d96d-42b6-b9cf-ef2da7d12848",
-          _id: {
-            $oid: "67da9131029b39637717b7cc",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9132029b39637717b7cf",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -11.499324355168639,
-            y: 0.01,
-            z: -14.650000500007321,
-            _id: {
-              $oid: "67da9132029b39637717b7d1",
-            },
-          },
-          uuid: "ddea6247-d96d-42b6-b9cf-ef2da7d12848",
-          _id: {
-            $oid: "67da9132029b39637717b7d0",
-          },
-        },
-        {
-          position: {
-            x: -11.499324355168639,
-            y: 0.01,
-            z: -7.946995896512458,
-            _id: {
-              $oid: "67da9132029b39637717b7d3",
-            },
-          },
-          uuid: "1b3d365d-e15a-4690-ab1f-097bc43a7206",
-          _id: {
-            $oid: "67da9132029b39637717b7d2",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9135029b39637717b7d5",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -11.499324355168639,
-            y: 0.01,
-            z: -7.946995896512458,
-            _id: {
-              $oid: "67da9135029b39637717b7d7",
-            },
-          },
-          uuid: "1b3d365d-e15a-4690-ab1f-097bc43a7206",
-          _id: {
-            $oid: "67da9135029b39637717b7d6",
-          },
-        },
-        {
-          position: {
-            x: -19.2026753309413,
-            y: 0.01,
-            z: -7.946995896512457,
-            _id: {
-              $oid: "67da9135029b39637717b7d9",
-            },
-          },
-          uuid: "1e0576fb-c048-483c-acf9-1431e7c108f9",
-          _id: {
-            $oid: "67da9135029b39637717b7d8",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9136029b39637717b7db",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -19.2026753309413,
-            y: 0.01,
-            z: -7.946995896512457,
-            _id: {
-              $oid: "67da9136029b39637717b7dd",
-            },
-          },
-          uuid: "1e0576fb-c048-483c-acf9-1431e7c108f9",
-          _id: {
-            $oid: "67da9136029b39637717b7dc",
-          },
-        },
-        {
-          position: {
-            x: -18.900000000000002,
-            y: 0.01,
-            z: -14.65000050000732,
-            _id: {
-              $oid: "67da9136029b39637717b7df",
-            },
-          },
-          uuid: "d066f4bd-3df9-4824-9e66-b5b67263152b",
-          _id: {
-            $oid: "67da9136029b39637717b7de",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da913a029b39637717b7e1",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -2.8000000000000007,
-            y: 0.01,
-            z: -14.350000500007173,
-            _id: {
-              $oid: "67da913a029b39637717b7e3",
-            },
-          },
-          uuid: "589c4a82-c0a3-4fe3-85b2-92436d874016",
-          _id: {
-            $oid: "67da913a029b39637717b7e2",
-          },
-        },
-        {
-          position: {
-            x: 3.3000000000000043,
-            y: 0.01,
-            z: -14.350000500007173,
-            _id: {
-              $oid: "67da913a029b39637717b7e5",
-            },
-          },
-          uuid: "5808bc4e-be8b-467a-851e-23571fb4883d",
-          _id: {
-            $oid: "67da913a029b39637717b7e4",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da913b029b39637717b7e7",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 3.3000000000000043,
-            y: 0.01,
-            z: -14.350000500007173,
-            _id: {
-              $oid: "67da913b029b39637717b7e9",
-            },
-          },
-          uuid: "5808bc4e-be8b-467a-851e-23571fb4883d",
-          _id: {
-            $oid: "67da913b029b39637717b7e8",
-          },
-        },
-        {
-          position: {
-            x: 3.3000000000000047,
-            y: 0.01,
-            z: -7.749242967720177,
-            _id: {
-              $oid: "67da913b029b39637717b7eb",
-            },
-          },
-          uuid: "5531d693-96a5-4317-9d54-64aaee0c4aca",
-          _id: {
-            $oid: "67da913b029b39637717b7ea",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da913d029b39637717b7ed",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 3.3000000000000047,
-            y: 0.01,
-            z: -7.749242967720177,
-            _id: {
-              $oid: "67da913d029b39637717b7ef",
-            },
-          },
-          uuid: "5531d693-96a5-4317-9d54-64aaee0c4aca",
-          _id: {
-            $oid: "67da913d029b39637717b7ee",
-          },
-        },
-        {
-          position: {
-            x: -3.5007464355254387,
-            y: 0.01,
-            z: -7.749242967720176,
-            _id: {
-              $oid: "67da913d029b39637717b7f1",
-            },
-          },
-          uuid: "42877408-00e9-45b7-825e-ab9ec32bbbcb",
-          _id: {
-            $oid: "67da913d029b39637717b7f0",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da913e029b39637717b7f3",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -3.5007464355254387,
-            y: 0.01,
-            z: -7.749242967720176,
-            _id: {
-              $oid: "67da913e029b39637717b7f5",
-            },
-          },
-          uuid: "42877408-00e9-45b7-825e-ab9ec32bbbcb",
-          _id: {
-            $oid: "67da913e029b39637717b7f4",
-          },
-        },
-        {
-          position: {
-            x: -2.8000000000000007,
-            y: 0.01,
-            z: -14.350000500007173,
-            _id: {
-              $oid: "67da913e029b39637717b7f7",
-            },
-          },
-          uuid: "589c4a82-c0a3-4fe3-85b2-92436d874016",
-          _id: {
-            $oid: "67da913e029b39637717b7f6",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9143029b39637717b7f9",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -32.3,
-            y: 0.01,
-            z: -1.0500005000005297,
-            _id: {
-              $oid: "67da9143029b39637717b7fb",
-            },
-          },
-          uuid: "ac46f914-ad0c-47f6-a1e9-8b73d0f359ef",
-          _id: {
-            $oid: "67da9143029b39637717b7fa",
-          },
-        },
-        {
-          position: {
-            x: -26.099193600828997,
-            y: 0.01,
-            z: -1.0500005000005297,
-            _id: {
-              $oid: "67da9143029b39637717b7fd",
-            },
-          },
-          uuid: "9ace6852-938b-48e8-b6b6-fc81d0140301",
-          _id: {
-            $oid: "67da9143029b39637717b7fc",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9144029b39637717b7ff",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.099193600828997,
-            y: 0.01,
-            z: -1.0500005000005297,
-            _id: {
-              $oid: "67da9144029b39637717b801",
-            },
-          },
-          uuid: "9ace6852-938b-48e8-b6b6-fc81d0140301",
-          _id: {
-            $oid: "67da9144029b39637717b800",
-          },
-        },
-        {
-          position: {
-            x: -26.099193600828997,
-            y: 0.01,
-            z: 5.353098600486059,
-            _id: {
-              $oid: "67da9144029b39637717b803",
-            },
-          },
-          uuid: "e74176ae-eb71-484e-aada-c0f54c67b81d",
-          _id: {
-            $oid: "67da9144029b39637717b802",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9147029b39637717b805",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.099193600828997,
-            y: 0.01,
-            z: 5.353098600486059,
-            _id: {
-              $oid: "67da9147029b39637717b807",
-            },
-          },
-          uuid: "e74176ae-eb71-484e-aada-c0f54c67b81d",
-          _id: {
-            $oid: "67da9147029b39637717b806",
-          },
-        },
-        {
-          position: {
-            x: -32.60000073871014,
-            y: 0.01,
-            z: 5.35309860048606,
-            _id: {
-              $oid: "67da9147029b39637717b809",
-            },
-          },
-          uuid: "84072a23-945a-4270-a63e-3940e081dfc0",
-          _id: {
-            $oid: "67da9147029b39637717b808",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9148029b39637717b80b",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -32.60000073871014,
-            y: 0.01,
-            z: 5.35309860048606,
-            _id: {
-              $oid: "67da9148029b39637717b80d",
-            },
-          },
-          uuid: "84072a23-945a-4270-a63e-3940e081dfc0",
-          _id: {
-            $oid: "67da9148029b39637717b80c",
-          },
-        },
-        {
-          position: {
-            x: -32.3,
-            y: 0.01,
-            z: -1.0500005000005297,
-            _id: {
-              $oid: "67da9148029b39637717b80f",
-            },
-          },
-          uuid: "ac46f914-ad0c-47f6-a1e9-8b73d0f359ef",
-          _id: {
-            $oid: "67da9148029b39637717b80e",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da914c029b39637717b811",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -17.699999999999996,
-            y: 0.01,
-            z: -0.6500005000003296,
-            _id: {
-              $oid: "67da914c029b39637717b813",
-            },
-          },
-          uuid: "c92f88d8-c05e-4736-9b05-dc03c45b5cd7",
-          _id: {
-            $oid: "67da914c029b39637717b812",
-          },
-        },
-        {
-          position: {
-            x: -11.499999999999996,
-            y: 0.01,
-            z: -0.6500005000003296,
-            _id: {
-              $oid: "67da914c029b39637717b815",
-            },
-          },
-          uuid: "9eba6103-dfff-4282-8872-848584d26d45",
-          _id: {
-            $oid: "67da914c029b39637717b814",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da914e029b39637717b817",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -11.499999999999996,
-            y: 0.01,
-            z: -0.6500005000003296,
-            _id: {
-              $oid: "67da914e029b39637717b819",
-            },
-          },
-          uuid: "9eba6103-dfff-4282-8872-848584d26d45",
-          _id: {
-            $oid: "67da914e029b39637717b818",
-          },
-        },
-        {
-          position: {
-            x: -11.499999999999996,
-            y: 0.01,
-            z: 5.950757032286672,
-            _id: {
-              $oid: "67da914e029b39637717b81b",
-            },
-          },
-          uuid: "c176bd60-1bfe-496b-a030-1a1b17fada7c",
-          _id: {
-            $oid: "67da914e029b39637717b81a",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da914f029b39637717b81d",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -11.499999999999996,
-            y: 0.01,
-            z: 5.950757032286672,
-            _id: {
-              $oid: "67da914f029b39637717b81f",
-            },
-          },
-          uuid: "c176bd60-1bfe-496b-a030-1a1b17fada7c",
-          _id: {
-            $oid: "67da914f029b39637717b81e",
-          },
-        },
-        {
-          position: {
-            x: -17.90079308213536,
-            y: 0.01,
-            z: 5.950757032286673,
-            _id: {
-              $oid: "67da914f029b39637717b821",
-            },
-          },
-          uuid: "d99e9ed6-81b5-4a13-82db-e144b84d558b",
-          _id: {
-            $oid: "67da914f029b39637717b820",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9150029b39637717b823",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -17.90079308213536,
-            y: 0.01,
-            z: 5.950757032286673,
-            _id: {
-              $oid: "67da9150029b39637717b825",
-            },
-          },
-          uuid: "d99e9ed6-81b5-4a13-82db-e144b84d558b",
-          _id: {
-            $oid: "67da9150029b39637717b824",
-          },
-        },
-        {
-          position: {
-            x: -17.699999999999996,
-            y: 0.01,
-            z: -0.6500005000003296,
-            _id: {
-              $oid: "67da9150029b39637717b827",
-            },
-          },
-          uuid: "c92f88d8-c05e-4736-9b05-dc03c45b5cd7",
-          _id: {
-            $oid: "67da9150029b39637717b826",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9155029b39637717b829",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -2.400000000000002,
-            y: 0.01,
-            z: -0.8500005000004297,
-            _id: {
-              $oid: "67da9155029b39637717b82b",
-            },
-          },
-          uuid: "67580953-4b53-4d70-8e25-ed840c6f2d72",
-          _id: {
-            $oid: "67da9155029b39637717b82a",
-          },
-        },
-        {
-          position: {
-            x: 2.8009614495783284,
-            y: 0.01,
-            z: -0.8500005000004297,
-            _id: {
-              $oid: "67da9155029b39637717b82d",
-            },
-          },
-          uuid: "a4121a99-ff0a-4b9f-b6ea-545de9049ea6",
-          _id: {
-            $oid: "67da9155029b39637717b82c",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9155029b39637717b82f",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 2.8009614495783284,
-            y: 0.01,
-            z: -0.8500005000004297,
-            _id: {
-              $oid: "67da9155029b39637717b831",
-            },
-          },
-          uuid: "a4121a99-ff0a-4b9f-b6ea-545de9049ea6",
-          _id: {
-            $oid: "67da9155029b39637717b830",
-          },
-        },
-        {
-          position: {
-            x: 2.800961449578329,
-            y: 0.01,
-            z: 7.352461661099969,
-            _id: {
-              $oid: "67da9155029b39637717b833",
-            },
-          },
-          uuid: "3f4a3ee0-f8ba-4bd3-9f5b-008330bdcdc8",
-          _id: {
-            $oid: "67da9155029b39637717b832",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9156029b39637717b835",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 2.800961449578329,
-            y: 0.01,
-            z: 7.352461661099969,
-            _id: {
-              $oid: "67da9156029b39637717b837",
-            },
-          },
-          uuid: "3f4a3ee0-f8ba-4bd3-9f5b-008330bdcdc8",
-          _id: {
-            $oid: "67da9156029b39637717b836",
-          },
-        },
-        {
-          position: {
-            x: -3.500000000000003,
-            y: 0.01,
-            z: 6.049999500003015,
-            _id: {
-              $oid: "67da9156029b39637717b839",
-            },
-          },
-          uuid: "bd269764-9ece-4803-8581-ede457df054c",
-          _id: {
-            $oid: "67da9156029b39637717b838",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9157029b39637717b83b",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -3.500000000000003,
-            y: 0.01,
-            z: 6.049999500003015,
-            _id: {
-              $oid: "67da9157029b39637717b83d",
-            },
-          },
-          uuid: "bd269764-9ece-4803-8581-ede457df054c",
-          _id: {
-            $oid: "67da9157029b39637717b83c",
-          },
-        },
-        {
-          position: {
-            x: -2.400000000000002,
-            y: 0.01,
-            z: -0.8500005000004297,
-            _id: {
-              $oid: "67da9157029b39637717b83f",
-            },
-          },
-          uuid: "67580953-4b53-4d70-8e25-ed840c6f2d72",
-          _id: {
-            $oid: "67da9157029b39637717b83e",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da915a029b39637717b841",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -31.899999999999995,
-            y: 0.01,
-            z: 12.44999950000622,
-            _id: {
-              $oid: "67da915a029b39637717b843",
-            },
-          },
-          uuid: "32f006c1-4038-4159-9ca5-f51677a904f3",
-          _id: {
-            $oid: "67da915a029b39637717b842",
-          },
-        },
-        {
-          position: {
-            x: -26.499999999999993,
-            y: 0.01,
-            z: 12.849999500006419,
-            _id: {
-              $oid: "67da915a029b39637717b845",
-            },
-          },
-          uuid: "bca361f3-66a7-4137-a1a2-7194925224ea",
-          _id: {
-            $oid: "67da915a029b39637717b844",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da915b029b39637717b847",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.499999999999993,
-            y: 0.01,
-            z: 12.849999500006419,
-            _id: {
-              $oid: "67da915b029b39637717b849",
-            },
-          },
-          uuid: "bca361f3-66a7-4137-a1a2-7194925224ea",
-          _id: {
-            $oid: "67da915b029b39637717b848",
-          },
-        },
-        {
-          position: {
-            x: -26.499999999999993,
-            y: 0.01,
-            z: 19.150793100818913,
-            _id: {
-              $oid: "67da915b029b39637717b84b",
-            },
-          },
-          uuid: "a92a1504-6628-4e02-bc5e-da38256dbaa8",
-          _id: {
-            $oid: "67da915b029b39637717b84a",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da915c029b39637717b84d",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -26.499999999999993,
-            y: 0.01,
-            z: 19.150793100818913,
-            _id: {
-              $oid: "67da915c029b39637717b84f",
-            },
-          },
-          uuid: "a92a1504-6628-4e02-bc5e-da38256dbaa8",
-          _id: {
-            $oid: "67da915c029b39637717b84e",
-          },
-        },
-        {
-          position: {
-            x: -32.6,
-            y: 0.01,
-            z: 18.649999500009315,
-            _id: {
-              $oid: "67da915c029b39637717b851",
-            },
-          },
-          uuid: "577a0d87-ba44-41ce-b526-4352790e12a1",
-          _id: {
-            $oid: "67da915c029b39637717b850",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da915d029b39637717b853",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -32.6,
-            y: 0.01,
-            z: 18.649999500009315,
-            _id: {
-              $oid: "67da915d029b39637717b855",
-            },
-          },
-          uuid: "577a0d87-ba44-41ce-b526-4352790e12a1",
-          _id: {
-            $oid: "67da915d029b39637717b854",
-          },
-        },
-        {
-          position: {
-            x: -31.899999999999995,
-            y: 0.01,
-            z: 12.44999950000622,
-            _id: {
-              $oid: "67da915d029b39637717b857",
-            },
-          },
-          uuid: "32f006c1-4038-4159-9ca5-f51677a904f3",
-          _id: {
-            $oid: "67da915d029b39637717b856",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9160029b39637717b859",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -16.7,
-            y: 0.01,
-            z: 12.649999500006311,
-            _id: {
-              $oid: "67da9160029b39637717b85b",
-            },
-          },
-          uuid: "dfee795e-6446-40b7-892b-a94da5056328",
-          _id: {
-            $oid: "67da9160029b39637717b85a",
-          },
-        },
-        {
-          position: {
-            x: -10.199230814741991,
-            y: 0.01,
-            z: 12.649999500006311,
-            _id: {
-              $oid: "67da9160029b39637717b85d",
-            },
-          },
-          uuid: "ed10ad9b-b461-4c9c-a397-1bd5e05df3b9",
-          _id: {
-            $oid: "67da9160029b39637717b85c",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9160029b39637717b85f",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -10.199230814741991,
-            y: 0.01,
-            z: 12.649999500006311,
-            _id: {
-              $oid: "67da9160029b39637717b861",
-            },
-          },
-          uuid: "ed10ad9b-b461-4c9c-a397-1bd5e05df3b9",
-          _id: {
-            $oid: "67da9160029b39637717b860",
-          },
-        },
-        {
-          position: {
-            x: -9.811292099159576,
-            y: 0.01,
-            z: 18.601665294824446,
-            _id: {
-              $oid: "67da9178029b39637717b88f",
-            },
-          },
-          uuid: "695d5859-3c42-45d5-8843-326833dc0802",
-          _id: {
-            $oid: "67da9160029b39637717b862",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9161029b39637717b865",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -9.811292099159576,
-            y: 0.01,
-            z: 18.601665294824446,
-            _id: {
-              $oid: "67da9178029b39637717b88f",
-            },
-          },
-          uuid: "695d5859-3c42-45d5-8843-326833dc0802",
-          _id: {
-            $oid: "67da9161029b39637717b866",
-          },
-        },
-        {
-          position: {
-            x: -17.667236770650547,
-            y: 0.01,
-            z: 18.729297555078116,
-            _id: {
-              $oid: "67da917b029b39637717b891",
-            },
-          },
-          uuid: "4fc8bc1a-1cca-4a3f-8645-4ea608e9571d",
-          _id: {
-            $oid: "67da9161029b39637717b868",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9162029b39637717b86b",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -17.667236770650547,
-            y: 0.01,
-            z: 18.729297555078116,
-            _id: {
-              $oid: "67da917b029b39637717b891",
-            },
-          },
-          uuid: "4fc8bc1a-1cca-4a3f-8645-4ea608e9571d",
-          _id: {
-            $oid: "67da9162029b39637717b86c",
-          },
-        },
-        {
-          position: {
-            x: -16.7,
-            y: 0.01,
-            z: 12.649999500006311,
-            _id: {
-              $oid: "67da9162029b39637717b86f",
-            },
-          },
-          uuid: "dfee795e-6446-40b7-892b-a94da5056328",
-          _id: {
-            $oid: "67da9162029b39637717b86e",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9165029b39637717b871",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -2.4999999999999964,
-            y: 0.01,
-            z: 12.949999500006472,
-            _id: {
-              $oid: "67da9165029b39637717b873",
-            },
-          },
-          uuid: "357eb663-01e5-4dab-b961-bb14416a289e",
-          _id: {
-            $oid: "67da9165029b39637717b872",
-          },
-        },
-        {
-          position: {
-            x: 2.6009802979427414,
-            y: 0.01,
-            z: 12.949999500006472,
-            _id: {
-              $oid: "67da9165029b39637717b875",
-            },
-          },
-          uuid: "0e9f216f-77bd-442f-bd6f-c8ff04ae24f3",
-          _id: {
-            $oid: "67da9165029b39637717b874",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9166029b39637717b877",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 2.6009802979427414,
-            y: 0.01,
-            z: 12.949999500006472,
-            _id: {
-              $oid: "67da9166029b39637717b879",
-            },
-          },
-          uuid: "0e9f216f-77bd-442f-bd6f-c8ff04ae24f3",
-          _id: {
-            $oid: "67da9166029b39637717b878",
-          },
-        },
-        {
-          position: {
-            x: 2.600980297942742,
-            y: 0.01,
-            z: 20.352675289331685,
-            _id: {
-              $oid: "67da9166029b39637717b87b",
-            },
-          },
-          uuid: "88d9dc8d-b7e5-488e-ac1a-7455885bea1f",
-          _id: {
-            $oid: "67da9166029b39637717b87a",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9166029b39637717b87d",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 2.600980297942742,
-            y: 0.01,
-            z: 20.352675289331685,
-            _id: {
-              $oid: "67da9166029b39637717b87f",
-            },
-          },
-          uuid: "88d9dc8d-b7e5-488e-ac1a-7455885bea1f",
-          _id: {
-            $oid: "67da9166029b39637717b87e",
-          },
-        },
-        {
-          position: {
-            x: -3.300000000000004,
-            y: 0.01,
-            z: 19.949999500009966,
-            _id: {
-              $oid: "67da9166029b39637717b881",
-            },
-          },
-          uuid: "d36f39b8-c4b1-4859-8b86-f4c4693efda8",
-          _id: {
-            $oid: "67da9166029b39637717b880",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9168029b39637717b883",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -3.300000000000004,
-            y: 0.01,
-            z: 19.949999500009966,
-            _id: {
-              $oid: "67da9168029b39637717b885",
-            },
-          },
-          uuid: "d36f39b8-c4b1-4859-8b86-f4c4693efda8",
-          _id: {
-            $oid: "67da9168029b39637717b884",
-          },
-        },
-        {
-          position: {
-            x: -2.4999999999999964,
-            y: 0.01,
-            z: 12.949999500006472,
-            _id: {
-              $oid: "67da9168029b39637717b887",
-            },
-          },
-          uuid: "357eb663-01e5-4dab-b961-bb14416a289e",
-          _id: {
-            $oid: "67da9168029b39637717b886",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da916d029b39637717b889",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: 6.899999999999991,
-            y: 0.01,
-            z: -15.150000500007573,
-            _id: {
-              $oid: "67da916d029b39637717b88b",
-            },
-          },
-          uuid: "909123d8-0364-4b08-9c6e-c0fedab2ea9b",
-          _id: {
-            $oid: "67da916d029b39637717b88a",
-          },
-        },
-        {
-          position: {
-            x: 6.899999999999993,
-            y: 0.01,
-            z: 22.050537130534586,
-            _id: {
-              $oid: "67da916d029b39637717b88d",
-            },
-          },
-          uuid: "cae9c80c-13f9-4681-b638-2df63ed21a68",
-          _id: {
-            $oid: "67da916d029b39637717b88c",
-          },
-        },
-      ],
-      type: "AisleLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da9239029b39637717b8a6",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -39.01181407607426,
-            y: 0.01,
-            z: -15.164269566681014,
-            _id: {
-              $oid: "67da9239029b39637717b8a8",
-            },
-          },
-          uuid: "597dae26-e0e4-40ab-a7cd-885e99e3b639",
-          _id: {
-            $oid: "67da9239029b39637717b8a7",
-          },
-        },
-        {
-          position: {
-            x: -39.01181407607426,
-            y: 0.01,
-            z: 2.4462151192550863,
-            _id: {
-              $oid: "67da9239029b39637717b8aa",
-            },
-          },
-          uuid: "36b6a74c-8eb8-4d1d-93a5-11bb0f692e21",
-          _id: {
-            $oid: "67da9239029b39637717b8a9",
-          },
-        },
-      ],
-      type: "WallLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da923b029b39637717b8ac",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -39.01181407607426,
-            y: 0.01,
-            z: 2.4462151192550863,
-            _id: {
-              $oid: "67da923b029b39637717b8ae",
-            },
-          },
-          uuid: "36b6a74c-8eb8-4d1d-93a5-11bb0f692e21",
-          _id: {
-            $oid: "67da923b029b39637717b8ad",
-          },
-        },
-        {
-          position: {
-            x: -39.01181407607426,
-            y: 0.01,
-            z: 18.116739329146327,
-            _id: {
-              $oid: "67da923b029b39637717b8b0",
-            },
-          },
-          uuid: "7fb2c837-9599-4481-9b90-6598c12873ed",
-          _id: {
-            $oid: "67da923b029b39637717b8af",
-          },
-        },
-      ],
-      type: "WallLine",
-      __v: 0,
-    },
-    {
-      _id: {
-        $oid: "67da929f029b39637717b8c1",
-      },
-      layer: 1,
-      line: [
-        {
-          position: {
-            x: -36.42107219144319,
-            y: 0.01,
-            z: -18.72939338741006,
-            _id: {
-              $oid: "67da929f029b39637717b8c3",
-            },
-          },
-          uuid: "1c6a6439-e096-4f0f-a88e-9e221733e9a1",
-          _id: {
-            $oid: "67da929f029b39637717b8c2",
-          },
-        },
-        {
-          position: {
-            x: 4.466350487599726,
-            y: 0.01,
-            z: -18.72939338741006,
-            _id: {
-              $oid: "67da929f029b39637717b8c5",
-            },
-          },
-          uuid: "a8e4ec42-f05b-47ed-9cf4-3bc1461f178f",
-          _id: {
-            $oid: "67da929f029b39637717b8c4",
-          },
-        },
-      ],
-      type: "FloorLine",
-      __v: 0,
-    },
-  ];
-  React.useEffect(() => {
-    const groups = new THREE.Group();
-    groups.name = "Meshes";
-    groupRef.current = groups;
-    scene.add(groups);
-
-    return () => {
-      if (groupRef.current) {
-        scene.remove(groupRef.current);
-      }
-    };
-  }, [scene]);
+  let groupRef = useRef() as Types.RefGroup;
+  const [navMesh, setNavMesh] = useState();
 
   return (
     <>
-      <PolygonGenerator
-        groupRef={groupRef}
-        processPoint={processPoint}
+      <PolygonGenerator groupRef={groupRef} lines={lines} plane={plane} />
+      <NavMeshDetails
         lines={lines}
+        setNavMesh={setNavMesh}
+        groupRef={groupRef}
         plane={plane}
       />
-      <NavMeshDetails setNavMesh={setNavMesh} />
       {pathPoints.map((pair, i) => (
-        <PathNavigator navMesh={navMesh} pathPoints={pair} key={i} />
+        <PathNavigator navMesh={navMesh} selectedPoints={pair} key={i} />
       ))}
+      <group ref={groupRef} visible={false} name="Meshes"></group>
     </>
   );
-}
+};
+
+export default Agv;
diff --git a/app/src/modules/builder/agv/navMeshDetails.tsx b/app/src/modules/builder/agv/navMeshDetails.tsx
index 0f4852e..c941011 100644
--- a/app/src/modules/builder/agv/navMeshDetails.tsx
+++ b/app/src/modules/builder/agv/navMeshDetails.tsx
@@ -1,146 +1,43 @@
-// import React, { useEffect, useState } from "react";
-// import { init as initRecastNavigation } from "@recast-navigation/core";
-// import { generateSoloNavMesh } from "@recast-navigation/generators";
-// import { DebugDrawer, getPositionsAndIndices } from "@recast-navigation/three";
-// import { useThree } from "@react-three/fiber";
-// import * as THREE from "three";
-// interface RawNavMesh {
-//   ptr: number; // Replace `number` with the actual type if known
-// }
-
-// interface NavMesh {
-//   raw: RawNavMesh;
-// }
-
-// // Update the MeshState interface to use the correct type
-// interface MeshState {
-//   setNavMesh: React.Dispatch<React.SetStateAction<NavMesh | null>>;
-// }
-// export default function NavMeshDetails({ setNavMesh }: MeshState) {
-//   const { scene } = useThree();
-//   useEffect(() => {
-//     const initializeNavMesh = async () => {
-//       try {
-//         // Initialize Recast Navigation
-//         await initRecastNavigation();
-
-//         // Extract meshes from the scene
-//         // Extract meshes from the scene
-//         const meshes = scene?.children
-//           .filter((child) => child.name === "Meshes")
-//           .flatMap((mesh) => mesh.children);
-
-//         if (!meshes || meshes.length === 0) {
-
-//           return;
-//         }
-
-//         // Filter and process only Mesh objects
-//         const meshObjects = meshes.filter(
-//           (
-//             child
-//           ): child is THREE.Mesh<
-//             THREE.BufferGeometry,
-//             THREE.Material | THREE.Material[]
-//           > => child instanceof THREE.Mesh
-//         );
-
-//         if (meshObjects.length === 0) {
-
-//           return;
-//         }
-
-//         // Get positions and indices from the meshes
-//         const [positions, indices] = getPositionsAndIndices(meshObjects);
-
-//         // Generate navigation mesh
-//         const cs = 0.05;
-//         const ch = 0.05;
-//         const walkableRadius = 0.87;
-//         const { success, navMesh } = generateSoloNavMesh(positions, indices, {
-//           cs,
-//           ch,
-//           walkableRadius: Math.round(walkableRadius / ch),
-//         });
-
-//         if (!success || !navMesh) {
-
-//           return;
-//         }
-
-//         // Log and update the navigation mesh
-
-//
-//         setNavMesh(navMesh);
-
-//         // Draw the debug visualization
-//         const debugDrawer = new DebugDrawer();
-//         debugDrawer.drawNavMesh(navMesh);
-//         // scene.add(debugDrawer); // Uncomment if you want to add the debug drawer to the scene
-//       } catch (error) {
-
-//       }
-//     };
-
-//     initializeNavMesh();
-//   }, [setNavMesh, scene]);
-
-//   return null;
-// }
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
 import { init as initRecastNavigation } from "@recast-navigation/core";
 import { generateSoloNavMesh } from "@recast-navigation/generators";
 import { DebugDrawer, getPositionsAndIndices } from "@recast-navigation/three";
 import { useThree } from "@react-three/fiber";
 import * as THREE from "three";
+import * as Types from "../../../types/world/worldTypes";
 
-// Import the NavMesh type from the library
-import { NavMesh as RecastNavMesh } from "@recast-navigation/core";
-
-// Define the state type based on the library's NavMesh type
-interface MeshState {
-  setNavMesh: React.Dispatch<React.SetStateAction<RecastNavMesh | null>>;
+interface NavMeshDetailsProps {
+  setNavMesh: (navMesh: any) => void;
+  groupRef: React.MutableRefObject<THREE.Group | null>;
+  lines: Types.RefLines;
+  plane: Types.RefMesh;
 }
 
-export default function NavMeshDetails({ setNavMesh }: MeshState) {
+export default function NavMeshDetails({
+  lines,
+  setNavMesh,
+  groupRef,
+  plane,
+}: NavMeshDetailsProps) {
   const { scene } = useThree();
 
   useEffect(() => {
-    const initializeNavMesh = async () => {
+    const initializeNavigation = async () => {
       try {
-        // Initialize Recast Navigation
         await initRecastNavigation();
 
-        // Extract meshes from the scene
-        const meshes = scene?.children
-          .filter((child) => child.name === "Meshes")
-          .flatMap((mesh) => mesh.children);
-
-        if (!meshes || meshes.length === 0) {
+        if (!groupRef.current || groupRef.current.children.length === 0) {
           return;
         }
 
-        // Filter and process only Mesh objects
-        const meshObjects = meshes.filter(
-          (
-            child
-          ): child is THREE.Mesh<
-            THREE.BufferGeometry,
-            THREE.Material | THREE.Material[]
-          > => child instanceof THREE.Mesh
-        );
+        const meshes = groupRef?.current?.children as THREE.Mesh[];
 
-        if (meshObjects.length === 0) {
-          return;
-        }
+        const [positions, indices] = getPositionsAndIndices(meshes);
 
-        // Get positions and indices from the meshes
-        const [positions, indices] = getPositionsAndIndices(meshObjects);
+        const cs = 0.5;
+        const ch = 0.5;
+        const walkableRadius = 0.89;
 
-        // Generate navigation mesh
-        const cs = 0.05;
-        const ch = 0.05;
-        const walkableRadius = 0.95;
         const { success, navMesh } = generateSoloNavMesh(positions, indices, {
           cs,
           ch,
@@ -150,17 +47,17 @@ export default function NavMeshDetails({ setNavMesh }: MeshState) {
         if (!success || !navMesh) {
           return;
         }
-        // Log and update the navigation mesh
-        setNavMesh(navMesh); // Now compatible with the library's NavMesh type
-        // Draw the debug visualization
+
+        setNavMesh(navMesh);
+
         const debugDrawer = new DebugDrawer();
         debugDrawer.drawNavMesh(navMesh);
-        // scene.add(debugDrawer); // Uncomment if you want to add the debug drawer to the scene
+        // scene.add(debugDrawer);
       } catch (error) {}
     };
 
-    initializeNavMesh();
-  }, [setNavMesh, scene]);
+    initializeNavigation();
+  }, [scene, groupRef, lines.current]);
 
   return null;
 }
diff --git a/app/src/modules/builder/agv/pathNavigator.tsx b/app/src/modules/builder/agv/pathNavigator.tsx
index 257e3e4..4193fb7 100644
--- a/app/src/modules/builder/agv/pathNavigator.tsx
+++ b/app/src/modules/builder/agv/pathNavigator.tsx
@@ -1,76 +1,46 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
+import React, { useEffect, useState, useRef } from "react";
 import * as THREE from "three";
+import { useFrame } from "@react-three/fiber";
 import { NavMeshQuery } from "@recast-navigation/core";
-import { NavMesh as RecastNavMesh } from "@recast-navigation/core";
-import { useFrame, useThree } from "@react-three/fiber";
 import { Line } from "@react-three/drei";
-interface Pair {
-  x: number;
-  y: number;
-  z: number;
+
+// Define interface for props
+interface PathNavigatorProps {
+  navMesh: any;
+  selectedPoints: any;
 }
-interface PathProps {
-  navMesh: RecastNavMesh | null; // The navigation mesh
-  pathPoints: Pair[] | undefined; // Array of points (or undefined)
-}
-const PathNavigator = ({ navMesh, pathPoints }: PathProps) => {
-  const { scene, raycaster, gl } = useThree();
 
-  const [path, setPath] = useState<THREE.Vector3[]>([]); // Path is an array of THREE.Vector3
-  const [points, setSelectedPoints] = useState<THREE.Vector3[]>([]); // Path is an array of THREE.Vector3
-  const progressRef = useRef<number>(0);
-  const meshRef = useRef<THREE.Mesh>(null!);
-  const handleClick = useCallback(() => {
-    if (!navMesh) return;
+export default function PathNavigator({
+  navMesh,
+  selectedPoints,
+}: PathNavigatorProps) {
+  const [path, setPath] = useState<[number, number, number][]>([]);
+  const progressRef = useRef(0);
+  const meshRef = useRef<THREE.Mesh | null>(null);
 
-    const intersects = raycaster.intersectObjects(scene.children, true);
-    if (intersects.length > 0) {
-      const { point } = intersects[0];
-      const newPoint = { x: point.x, y: 0, z: point.z };
-
-      setSelectedPoints((prevPoints: THREE.Vector3[]) => {
-        if (prevPoints.length === 2) {
-          // If two points already exist, replace them with the new point
-          return [new THREE.Vector3(newPoint.x, newPoint.y, newPoint.z)];
-        }
-        // Otherwise, append the new point to the array
-        return [
-          ...prevPoints,
-          new THREE.Vector3(newPoint.x, newPoint.y, newPoint.z),
-        ];
-      });
-    }
-  }, [navMesh, scene]);
-  React.useEffect(() => {
-    if (points?.length === 2 && navMesh) {
-      const [start, end] = points;
-      console.log("start: ", start);
-      console.log("end: ", end);
+  useEffect(() => {
+    if (selectedPoints.length === 2 && navMesh) {
+      const [start, end] = selectedPoints;
+      if (!start || !end) return;
 
       const navMeshQuery = new NavMeshQuery(navMesh);
-      console.log("navMeshQuery: ", navMeshQuery);
 
-      const { path } = navMeshQuery.computePath(start, end);
-      console.log("paths: ", path);
+      const { path: computedPath } = navMeshQuery.computePath(start, end);
 
-      //   if (path.length > 0) {
-      //     setPath(
-      //       path.map((point) => {
-      //         const newY = point.y + 0.1; // Increment the y-coordinate
-      //         return new THREE.Vector3(point.x, newY, point.z); // Create a new Vector3
-      //       })
-      //     );
-      //     progressRef.current = 0;
-      //   }
+      if (computedPath.length > 0) {
+        setPath(computedPath.map(({ x, y, z }) => [x, y + 0.1, z]));
+        progressRef.current = 0;
+      }
     }
-  }, [points,]);
+  }, [selectedPoints, navMesh]);
 
   useFrame((_, delta) => {
     if (path.length > 1 && meshRef.current) {
       const speed = 3;
       progressRef.current += delta * speed;
+
       let totalDistance = 0;
-      const distances = [];
+      const distances: number[] = [];
       for (let i = 0; i < path.length - 1; i++) {
         const start = new THREE.Vector3(...path[i]);
         const end = new THREE.Vector3(...path[i + 1]);
@@ -97,7 +67,7 @@ const PathNavigator = ({ navMesh, pathPoints }: PathProps) => {
         const segmentDistance = distances[index];
 
         const t = (coveredDistance - accumulatedDistance) / segmentDistance;
-        const position = start.lerp(end, t);
+        const position = start.clone().lerp(end, t); // Use clone() to avoid mutating the original vector
         meshRef.current.position.copy(position);
 
         const direction = new THREE.Vector3()
@@ -114,20 +84,10 @@ const PathNavigator = ({ navMesh, pathPoints }: PathProps) => {
     }
   });
 
-  useEffect(() => {
-    gl.domElement.addEventListener("click", handleClick);
-    return () => gl.domElement.removeEventListener("click", handleClick);
-  }, [handleClick]);
   return (
     <>
       {path.length > 0 && <Line points={path} color="blue" lineWidth={3} />}
       {path.length > 0 && (
-        // <primitive
-        //   ref={gltfRef}
-        //   object={gltfClone}
-        //   position={path.length > 0 ? path[0] : [0, 0.1, 0]}
-        //   scale={[0.5, 0.5, 0.5]}
-        // />
         <mesh ref={meshRef} position={path.length > 0 ? path[0] : [0, 0.1, 0]}>
           <boxGeometry args={[1, 1, 1]} />
           <meshNormalMaterial />
@@ -135,6 +95,4 @@ const PathNavigator = ({ navMesh, pathPoints }: PathProps) => {
       )}
     </>
   );
-};
-
-export default PathNavigator;
+}
diff --git a/app/src/modules/builder/agv/polygonGenerator.tsx b/app/src/modules/builder/agv/polygonGenerator.tsx
index 75c0911..1eca588 100644
--- a/app/src/modules/builder/agv/polygonGenerator.tsx
+++ b/app/src/modules/builder/agv/polygonGenerator.tsx
@@ -1,86 +1,86 @@
 import * as THREE from "three";
-import { useEffect, useRef } from "react";
-import { useThree } from "@react-three/fiber";
+import { useEffect, useState } from "react";
 import * as turf from "@turf/turf";
 import * as Types from "../../../types/world/worldTypes";
-// import { Feature, Polygon, MultiPolygon } from "@turf/helpers";
-type Point = {
-  position: { x: number; y: number; z: number };
-  uuid: string;
-};
-
-type LineData = {
-  type: string;
-  line: Point[];
-  _id: {};
-  layer: number;
-  __v: number;
-};
-
-type PolygonGeneratorProps = {
-  processPoint: LineData[];
-  groupRef: React.RefObject<THREE.Group>;
-  lines: any;
-  plane: any;
-};
+import arrayLinesToObject from "../geomentries/lines/lineConvertions/arrayLinesToObject";
+interface PolygonGeneratorProps {
+  groupRef: React.MutableRefObject<THREE.Group | null>;
+  lines: Types.RefLines;
+  plane: Types.RefMesh;
+}
 
 export default function PolygonGenerator({
-  processPoint,
   groupRef,
   lines,
   plane,
 }: PolygonGeneratorProps) {
-  const { scene } = useThree();
-
-
+  // const [rooms, setRooms] = useState<THREE.Vector3[][]>([]);
 
   useEffect(() => {
-    if (!processPoint) return;
-    const wallInLayer = processPoint?.filter(
-      (line) => line.type === "WallLine"
-    );
-    const wallPoints = wallInLayer.map((pair) =>
-      pair?.line.map((vals) => vals.position)
-    );
-    renderWallGeometry(wallPoints);
+    if (groupRef.current && plane.current) {
+      groupRef.current.add(plane.current.clone());
+    }
+  }, [groupRef, plane]);
 
-    const linesInLayer = processPoint?.filter(
-      (line) => line.type === "AisleLine"
-    );
-    const result = linesInLayer.map((pair) =>
+  useEffect(() => {
+    let allLines = arrayLinesToObject(lines.current);
+    const wallLines = allLines?.filter((line) => line?.type === "WallLine");
+    const aisleLines = allLines?.filter((line) => line?.type === "AisleLine");
+
+    const wallPoints = wallLines
+      .map((pair) => pair?.line.map((vals) => vals.position))
+      .filter((wall): wall is THREE.Vector3[] => !!wall);
+
+    const result = aisleLines.map((pair) =>
       pair?.line.map((point) => ({
         position: [point.position.x, point.position.z],
         uuid: point.uuid,
       }))
     );
+    if (!result || result.some((line) => !line)) {
+      return;
+    }
 
-    const lineFeatures = result.map((line) =>
-      turf.lineString(line.map((p) => p.position))
+    const lineFeatures = result?.map((line: any) =>
+      turf.lineString(line.map((p: any) => p?.position))
     );
+
     const polygons = turf.polygonize(turf.featureCollection(lineFeatures));
-    let union: any[] = [];
+    renderWallGeometry(wallPoints);
+
+    let union: any = [];
 
     polygons.features.forEach((feature) => {
       union.push(feature);
     });
 
-    if (union.length > 0) {
+    if (union.length > 1) {
       const unionResult = turf.union(turf.featureCollection(union));
-      if (unionResult && unionResult.geometry.type === "MultiPolygon") {
+
+      if (unionResult?.geometry.type === "MultiPolygon") {
         unionResult.geometry.coordinates.forEach((poly) => {
-          const Coordinates = poly[0].map(
-            ([x, z]) => new THREE.Vector3(x, 0, z)
-          );
-          renderBoxGeometry(Coordinates);
+          const coordinates = poly[0].map(([x, z]) => {
+            return new THREE.Vector3(x, 0, z);
+          });
+          renderBoxGeometry(coordinates);
         });
-      } else if (unionResult && unionResult.geometry.type === "Polygon") {
-        const Coordinates = unionResult.geometry.coordinates[0].map(
-          ([x, z]) => new THREE.Vector3(x, 0, z)
+      } else if (unionResult?.geometry.type === "Polygon") {
+        const coordinates = unionResult.geometry.coordinates[0].map(
+          ([x, z]) => {
+            return new THREE.Vector3(x, 0, z);
+          }
         );
-        renderBoxGeometry(Coordinates);
+        renderBoxGeometry(coordinates);
       }
+    } else if (union.length === 1) {
+      const coordinates = union[0].geometry.coordinates[0].map(
+        ([x, z]: [number, number]) => {
+          return new THREE.Vector3(x, 0, z);
+        }
+      );
+      // setRooms((prevRooms) => [...prevRooms, coordinates]);
     }
-  }, [processPoint]);
+  }, [lines.current]);
 
   const renderBoxGeometry = (coordinates: THREE.Vector3[]) => {
     const minX = Math.min(...coordinates.map((p) => p.x));
@@ -97,16 +97,13 @@ export default function PolygonGenerator({
       color: "#ff66cc",
       visible: false,
     });
+
     const mesh = new THREE.Mesh(geometry, material);
     mesh.position.set((minX + maxX) / 2, height / 2, (minZ + maxZ) / 2);
-
-    groupRef?.current?.add(mesh);
-    // scene.add(groupRef.current!);
+    groupRef.current?.add(mesh);
   };
 
-  const renderWallGeometry = (
-    walls: { x: number; y: number; z: number }[][]
-  ) => {
+  const renderWallGeometry = (walls: THREE.Vector3[][]) => {
     walls.forEach((wall) => {
       if (wall.length < 2) return;
 
@@ -117,19 +114,20 @@ export default function PolygonGenerator({
           wall[i + 1].y,
           wall[i + 1].z
         );
+
         const wallHeight = 10;
         const direction = new THREE.Vector3().subVectors(end, start);
         const length = direction.length();
         direction.normalize();
 
-        const wallGeometry = new THREE.BoxGeometry(length, wallHeight, 0.5);
+        const wallGeometry = new THREE.BoxGeometry(length, wallHeight);
         const wallMaterial = new THREE.MeshBasicMaterial({
           color: "#aaa",
           transparent: true,
           opacity: 0.5,
         });
-        const wallMesh = new THREE.Mesh(wallGeometry, wallMaterial);
 
+        const wallMesh = new THREE.Mesh(wallGeometry, wallMaterial);
         const midPoint = new THREE.Vector3()
           .addVectors(start, end)
           .multiplyScalar(0.5);
@@ -139,17 +137,7 @@ export default function PolygonGenerator({
         quaternion.setFromUnitVectors(new THREE.Vector3(1, 0, 0), direction);
         wallMesh.quaternion.copy(quaternion);
 
-        groupRef?.current?.add(wallMesh);
-        // scene.add(groupRef.current!);
-
-        const lineGeometry = new THREE.BufferGeometry().setFromPoints([
-          start,
-          end,
-        ]);
-        const lineMaterial = new THREE.LineBasicMaterial({ color: "blue" });
-        const line = new THREE.Line(lineGeometry, lineMaterial);
-
-        groupRef?.current?.add(line);
+        groupRef.current?.add(wallMesh);
       }
     });
   };