import React, { useEffect, useState } from "react"; import VehicleInstances from "./instances/vehicleInstances"; import { useVehicleStore } from "../../../store/simulation/useVehicleStore"; import { useFloorItems } from "../../../store/store"; import { useSelectedEventData, useSelectedEventSphere } from "../../../store/simulation/useSimulationStore"; import VehicleUI from "../ui/vehicle/vehicleUI"; import { usePlayButtonStore } from "../../../store/usePlayButtonStore"; function Vehicles() { const { vehicles, addVehicle } = useVehicleStore(); const { selectedEventSphere } = useSelectedEventSphere(); const { selectedEventData } = useSelectedEventData(); const { floorItems } = useFloorItems(); const { isPlaying } = usePlayButtonStore(); const [vehicleStatusSample, setVehicleStatusSample] = useState< VehicleEventSchema[] >([ { modelUuid: "9356f710-4727-4b50-bdb2-9c1e747ecc74", modelName: "AGV", position: [97.9252965204558, 0, 37.96138815638661], rotation: [0, 0, 0], state: "idle", type: "vehicle", speed: 2.5, point: { uuid: "point-789", position: [0, 1, 0], rotation: [0, 0, 0], action: { actionUuid: "action-456", actionName: "Deliver to Zone A", actionType: "travel", unLoadDuration: 10, loadCapacity: 2, steeringAngle:0, pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } }, unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } }, triggers: [ { triggerUuid: "trig-001", triggerName: "Start Travel", triggerType: "onComplete", delay: 0, triggeredAsset: { triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" }, triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" }, triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" } } }, { triggerUuid: "trig-002", triggerName: "Complete Travel", triggerType: "onComplete", delay: 2, triggeredAsset: null } ] } } }, { modelUuid: "b06960bb-3d2e-41f7-a646-335f389c68b4", modelName: "AGV", position: [89.61609306554463, 0, 33.634136622267356], rotation: [0, 0, 0], state: "idle", type: "vehicle", speed: 2.5, point: { uuid: "point-789", position: [0, 1, 0], rotation: [0, 0, 0], action: { actionUuid: "action-456", actionName: "Deliver to Zone A", actionType: "travel", unLoadDuration: 10, loadCapacity: 2, steeringAngle:0, pickUpPoint: null, unLoadPoint: null, triggers: [ { triggerUuid: "trig-001", triggerName: "Start Travel", triggerType: "onStart", delay: 0, triggeredAsset: { triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" }, triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" }, triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" } } }, { triggerUuid: "trig-002", triggerName: "Complete Travel", triggerType: "onComplete", delay: 2, triggeredAsset: null } ] } } }, // { // modelUuid: "cd7d0584-0684-42b4-b051-9e882c1914aa", // modelName: "AGV", // position: [105.90938758014703, 0, 31.584209911095215], // rotation: [0, 0, 0], // state: "idle", // type: "vehicle", // speed: 2.5, // point: { // uuid: "point-789", // position: [0, 1, 0], // rotation: [0, 0, 0], // action: { // actionUuid: "action-456", // actionName: "Deliver to Zone A", // actionType: "travel", // unLoadDuration: 10, // loadCapacity: 2, // steeringAngle:0, // pickUpPoint: null, // unLoadPoint: null, // triggers: [ // { // triggerUuid: "trig-001", // triggerName: "Start Travel", // triggerType: "onStart", // delay: 0, // triggeredAsset: { // triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" }, // triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" }, // triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" } // } // }, // { // triggerUuid: "trig-002", // triggerName: "Complete Travel", // triggerType: "onComplete", // delay: 2, // triggeredAsset: null // } // ] // } // } // }, // { // modelUuid: "e729a4f1-11d2-4778-8d6a-468f1b4f6b79", // modelName: "forklift", // position: [98.85729337188162, 0, 38.36616546567653], // rotation: [0, 0, 0], // state: "idle", // type: "vehicle", // speed: 2.5, // point: { // uuid: "point-789", // position: [0, 1, 0], // rotation: [0, 0, 0], // action: { // actionUuid: "action-456", // actionName: "Deliver to Zone A", // actionType: "travel", // unLoadDuration: 15, // loadCapacity: 5, // steeringAngle:0, // pickUpPoint: null, // unLoadPoint: null, // triggers: [ // { // triggerUuid: "trig-001", // triggerName: "Start Travel", // triggerType: "onStart", // delay: 0, // triggeredAsset: { // triggeredModel: { modelName: "ArmBot-X", modelUuid: "arm-001" }, // triggeredPoint: { pointName: "Pickup Arm Point", pointUuid: "arm-point-01" }, // triggeredAction: { actionName: "Grab Widget", actionUuid: "grab-001" } // } // }, // { // triggerUuid: "trig-002", // triggerName: "Complete Travel", // triggerType: "onComplete", // delay: 2, // triggeredAsset: null // } // ] // } // } // } ]); useEffect(() => { // console.log('vehicles: ', vehicles); }, [vehicles]) useEffect(() => { addVehicle("123", vehicleStatusSample[0]); addVehicle('123', vehicleStatusSample[1]); // addVehicle('123', vehicleStatusSample[2]); }, []); return ( <> {selectedEventSphere && selectedEventData?.data.type === "vehicle" && !isPlaying && < VehicleUI /> } ); } export default Vehicles;