updated vehicle

This commit is contained in:
2025-08-29 10:27:44 +05:30
parent 6182862296
commit c9536a13e0
2 changed files with 16 additions and 9 deletions

View File

@@ -156,7 +156,6 @@ export default function VehicleInstance2({
const allPoints = useMemo(() => {
const points: PointData[] = [];
const seen = new Set<string>();
paths?.forEach((path: PathDataInterface) => {
path.pathPoints.forEach((p) => {
if (!seen.has(p.pointId)) {
@@ -197,9 +196,9 @@ export default function VehicleInstance2({
if (prev.length === 1) {
const prevPoint = allPoints[prev[0]];
console.log("prevPoint: ", prevPoint);
const newPoint = allPoints[pointIndex];
console.log("newPoint: ", newPoint);
//
//
if (prevPoint.pointId === newPoint.pointId) return prev;
@@ -215,18 +214,24 @@ export default function VehicleInstance2({
setTimeout(() => {
const modelUuid = selectedEventSphere?.userData?.modelUuid;
const index = vehiclesData.findIndex(
const index = vehiclesDataRef.current.findIndex(
(v) => v.vehicleId === modelUuid
);
console.log(
"vehiclesDataRef.current: ",
vehiclesDataRef.current,
modelUuid
);
if (index !== -1) {
const updatedVehicles = [...vehiclesData];
const updatedVehicles = [...vehiclesDataRef.current];
updatedVehicles[index] = {
...updatedVehicles[index],
...vehiclesDataRef.current[index],
startPoint: prevPoint.position,
endPoint: newPoint.position,
route: edges,
};
setVehiclesData(updatedVehicles);
}
}, 0);
@@ -247,7 +252,7 @@ export default function VehicleInstance2({
return () => {
canvasElement.removeEventListener("contextmenu", handleContextMenu);
};
}, [raycaster]);
}, [raycaster, setVehiclesData, vehiclesData]);
return null;
}

View File

@@ -20,10 +20,12 @@ function VehicleInstances() {
endPoint: null,
selectedPointId: val.point.uuid,
}));
console.log("updatedVehicles: ", updatedVehicles);
setVehiclesData(updatedVehicles);
}, [vehicles]);
useEffect(() => {
console.log("vehiclesData", vehiclesData);
}, [vehiclesData]);
return (
<>