schema changes
This commit is contained in:
@@ -10,6 +10,9 @@ interface VehiclesStore {
|
||||
modelUuid: string,
|
||||
updates: Partial<Omit<VehicleStatus, "modelUuid" | "productUuid">>
|
||||
) => void;
|
||||
addPathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], point: VehicleAction["paths"]["initPickup"][number]) => VehicleAction["paths"];
|
||||
updatePathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], pointId: string, updates: Partial<VehicleAction["paths"]["initPickup"][number]>) => VehicleAction["paths"];
|
||||
deletePathPoint: (modelUuid: string, pathKey: keyof VehicleAction["paths"], pointId: string) => VehicleAction["paths"];
|
||||
clearVehicles: () => void;
|
||||
|
||||
setVehicleActive: (modelUuid: string, isActive: boolean) => void;
|
||||
@@ -79,6 +82,48 @@ export const createVehicleStore = () => {
|
||||
});
|
||||
},
|
||||
|
||||
addPathPoint: (modelUuid, pathKey, point) => {
|
||||
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||
set((state) => {
|
||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||
if (vehicle) {
|
||||
const path = vehicle.point.action.paths[pathKey];
|
||||
path.push(point);
|
||||
updatedPaths = vehicle.point.action.paths;
|
||||
}
|
||||
});
|
||||
return updatedPaths;
|
||||
},
|
||||
|
||||
updatePathPoint: (modelUuid, pathKey, pointId, updates) => {
|
||||
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||
set((state) => {
|
||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||
if (vehicle) {
|
||||
const path = vehicle.point.action.paths[pathKey];
|
||||
const index = path.findIndex(p => p.pointId === pointId);
|
||||
if (index !== -1) {
|
||||
Object.assign(path[index], updates);
|
||||
updatedPaths = vehicle.point.action.paths;
|
||||
}
|
||||
}
|
||||
});
|
||||
return updatedPaths;
|
||||
},
|
||||
|
||||
deletePathPoint: (modelUuid, pathKey, pointId) => {
|
||||
let updatedPaths: VehicleAction["paths"] = { initPickup: [], pickupDrop: [], dropPickup: [] };
|
||||
set((state) => {
|
||||
const vehicle = state.vehicles.find(v => v.modelUuid === modelUuid);
|
||||
if (vehicle) {
|
||||
const path = vehicle.point.action.paths[pathKey];
|
||||
vehicle.point.action.paths[pathKey] = path.filter(p => p.pointId !== pointId);
|
||||
updatedPaths = vehicle.point.action.paths;
|
||||
}
|
||||
});
|
||||
return updatedPaths;
|
||||
},
|
||||
|
||||
clearVehicles: () => {
|
||||
set((state) => {
|
||||
state.vehicles = [];
|
||||
|
||||
24
app/src/types/simulationTypes.d.ts
vendored
24
app/src/types/simulationTypes.d.ts
vendored
@@ -41,9 +41,27 @@ interface VehicleAction {
|
||||
pickUpPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||
unLoadPoint: { position: { x: number; y: number, z: number }, rotation: { x: number; y: number, z: number } } | null;
|
||||
paths: {
|
||||
initPickup: [number, number, number][],
|
||||
pickupDrop: [number, number, number][],
|
||||
dropPickup: [number, number, number][],
|
||||
initPickup: {
|
||||
pointId: string;
|
||||
position: [number, number, number];
|
||||
isCurved: boolean;
|
||||
handleA: [number, number, number] | null;
|
||||
handleB: [number, number, number] | null;
|
||||
}[],
|
||||
pickupDrop: {
|
||||
pointId: string;
|
||||
position: [number, number, number];
|
||||
isCurved: boolean;
|
||||
handleA: [number, number, number] | null;
|
||||
handleB: [number, number, number] | null;
|
||||
}[],
|
||||
dropPickup: {
|
||||
pointId: string;
|
||||
position: [number, number, number];
|
||||
isCurved: boolean;
|
||||
handleA: [number, number, number] | null;
|
||||
handleB: [number, number, number] | null;
|
||||
}[],
|
||||
}
|
||||
triggers: TriggerSchema[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user