updated vehicle
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@ function VehicleInstances() {
|
||||
endPoint: null,
|
||||
selectedPointId: val.point.uuid,
|
||||
}));
|
||||
|
||||
console.log("updatedVehicles: ", updatedVehicles);
|
||||
setVehiclesData(updatedVehicles);
|
||||
}, [vehicles]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("vehiclesData", vehiclesData);
|
||||
}, [vehiclesData]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* {vehicles.map((vehicle: VehicleStatus) => (
|
||||
|
||||
Reference in New Issue
Block a user