feat: ancre les réparations sur la map chargée

This commit is contained in:
tom-boullay
2026-05-28 15:47:53 +02:00
parent ba50224e6e
commit 9bbed06ddc
10 changed files with 150 additions and 19 deletions
+36
View File
@@ -0,0 +1,36 @@
import type { RepairMissionId } from "@/types/gameplay/repairMission";
import type { MapNode } from "@/types/map/mapScene";
import type { Vector3Tuple } from "@/types/three/three";
const REPAIR_MISSION_MAP_NODE_NAMES = {
ebike: "ebike",
pylon: "pylone",
farm: "fermeverticale",
} as const satisfies Record<RepairMissionId, string>;
function isOriginPosition(position: Vector3Tuple): boolean {
return position.every((value) => Math.abs(value) < 0.0001);
}
export function getRepairMissionMapAnchors(
mapNodes: readonly MapNode[],
): Partial<Record<RepairMissionId, Vector3Tuple>> {
const anchors: Partial<Record<RepairMissionId, Vector3Tuple>> = {};
for (const [mission, mapName] of Object.entries(
REPAIR_MISSION_MAP_NODE_NAMES,
) as [RepairMissionId, string][]) {
const node = mapNodes.find(
(candidate) =>
candidate.name === mapName &&
candidate.type === "Object3D" &&
!isOriginPosition(candidate.position),
);
if (node) {
anchors[mission] = node.position;
}
}
return anchors;
}