import React from "react";
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 PathNavigator from "./pathNavigator";
interface RawNavMesh {
  ptr: number; // Replace `number` with the actual type if known
}
interface NavMesh {
  raw: RawNavMesh;
}
// interface LineProps{
//     lines
//     planes:
// } 
export default function Agv({  }) {
  const { scene } = useThree();
  const groupRef = useRef<THREE.Group | null>(null);
  const [navMesh, setNavMesh] = useState<RecastNavMesh | null>(null);
  let pathPoints = [
    [
      { x: 8.477161935339709, y: 0, z: 17.41343083550102 },
      { x: 9.175416491482693, y: 0, z: -12.361001232663693 },
    ],
    [
      { 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]);

  return (
    <>
      <PolygonGenerator groupRef={groupRef} processPoint={processPoint} />
      <NavMeshDetails setNavMesh={setNavMesh} />
      {pathPoints.map((pair, i) => (
        <PathNavigator navMesh={navMesh} pathPoints={pair} key={i} />
      ))}
    </>
  );
}
