Add navmesh support to the new map.

https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
Dan Albert
2022-03-06 23:07:24 -08:00
parent b08b91ca2e
commit 15176223fa
11 changed files with 181 additions and 33 deletions

View File

@@ -0,0 +1,33 @@
import { selectNavMeshes } from "../../api/navMeshSlice";
import { useAppSelector } from "../../app/hooks";
import { LatLng } from "leaflet";
import { LayerGroup, Polygon } from "react-leaflet";
interface NavMeshLayerProps {
blue: boolean;
}
export default function NavMeshLayer(props: NavMeshLayerProps) {
const meshes = useAppSelector(selectNavMeshes);
const mesh = props.blue ? meshes.blue : meshes.red;
return (
<LayerGroup>
{mesh.map((zone, idx) => {
const positions = zone.poly.map(([lat, lng]) => new LatLng(lat, lng));
return (
<Polygon
key={idx}
positions={positions}
color="#000000"
weight={1}
fill
fillColor={zone.threatened ? "#ff0000" : "#00ff00"}
fillOpacity={0.1}
noClip
interactive={false}
/>
);
})}
</LayerGroup>
);
}

View File

@@ -0,0 +1 @@
export { default } from "./NavMeshLayer";