Refactor simulation paths to simulation states
- Updated all instances of `simulationPaths` to `simulationStates` across multiple components including copyPasteControls, duplicationControls, moveControls, rotateControls, selectionControls, and others. - Adjusted related state management hooks in the store to reflect the change from `simulationPaths` to `simulationStates`. - Ensured that all references to simulation paths in the simulation logic and UI components are consistent with the new naming convention.
This commit is contained in:
parent
42f0ae5317
commit
e92345d820
|
@ -13,7 +13,7 @@ import {
|
||||||
useFloorItems,
|
useFloorItems,
|
||||||
useSelectedActionSphere,
|
useSelectedActionSphere,
|
||||||
useSelectedPath,
|
useSelectedPath,
|
||||||
useSimulationPaths,
|
useSimulationStates,
|
||||||
useSocketStore,
|
useSocketStore,
|
||||||
} from "../../../../store/store";
|
} from "../../../../store/store";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
|
@ -25,7 +25,7 @@ import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAss
|
||||||
const ConveyorMechanics: React.FC = () => {
|
const ConveyorMechanics: React.FC = () => {
|
||||||
const { selectedActionSphere } = useSelectedActionSphere();
|
const { selectedActionSphere } = useSelectedActionSphere();
|
||||||
const { selectedPath, setSelectedPath } = useSelectedPath();
|
const { selectedPath, setSelectedPath } = useSelectedPath();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { floorItems, setFloorItems } = useFloorItems();
|
const { floorItems, setFloorItems } = useFloorItems();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
|
|
||||||
const selectedPoint = useMemo(() => {
|
const selectedPoint = useMemo(() => {
|
||||||
if (!selectedActionSphere) return null;
|
if (!selectedActionSphere) return null;
|
||||||
return simulationPaths
|
return simulationStates
|
||||||
.filter(
|
.filter(
|
||||||
(path): path is Types.ConveyorEventsSchema => path.type === "Conveyor"
|
(path): path is Types.ConveyorEventsSchema => path.type === "Conveyor"
|
||||||
)
|
)
|
||||||
.flatMap((path) => path.points)
|
.flatMap((path) => path.points)
|
||||||
.find((point) => point.uuid === selectedActionSphere.points.uuid);
|
.find((point) => point.uuid === selectedActionSphere.points.uuid);
|
||||||
}, [selectedActionSphere, simulationPaths]);
|
}, [selectedActionSphere, simulationStates]);
|
||||||
|
|
||||||
const updateBackend = async (updatedPath: Types.ConveyorEventsSchema | undefined) => {
|
const updateBackend = async (updatedPath: Types.ConveyorEventsSchema | undefined) => {
|
||||||
if (!updatedPath) return;
|
if (!updatedPath) return;
|
||||||
|
@ -66,7 +66,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
const handleAddAction = () => {
|
const handleAddAction = () => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
if (path.type === "Conveyor") {
|
if (path.type === "Conveyor") {
|
||||||
return {
|
return {
|
||||||
...path,
|
...path,
|
||||||
|
@ -101,13 +101,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteAction = (uuid: string) => {
|
const handleDeleteAction = (uuid: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -134,13 +134,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleActionSelect = (uuid: string, actionType: string) => {
|
const handleActionSelect = (uuid: string, actionType: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -182,7 +182,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Update the selected item to reflect changes
|
// Update the selected item to reflect changes
|
||||||
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
||||||
|
@ -207,7 +207,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
const handleMaterialSelect = (uuid: string, material: string) => {
|
const handleMaterialSelect = (uuid: string, material: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -237,7 +237,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Update selected item if it's the current action
|
// Update selected item if it's the current action
|
||||||
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
||||||
|
@ -254,7 +254,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
const handleDelayChange = (uuid: string, delay: number | string) => {
|
const handleDelayChange = (uuid: string, delay: number | string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -281,7 +281,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSpawnIntervalChange = (
|
const handleSpawnIntervalChange = (
|
||||||
|
@ -290,7 +290,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
) => {
|
) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -319,13 +319,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSpeedChange = (speed: number | string) => {
|
const handleSpeedChange = (speed: number | string) => {
|
||||||
if (!selectedPath) return;
|
if (!selectedPath) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path
|
path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -338,14 +338,14 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } });
|
setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddTrigger = () => {
|
const handleAddTrigger = () => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -377,13 +377,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteTrigger = (uuid: string) => {
|
const handleDeleteTrigger = (uuid: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -410,13 +410,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTriggerSelect = (uuid: string, triggerType: string) => {
|
const handleTriggerSelect = (uuid: string, triggerType: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -445,7 +445,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Ensure the selectedItem is updated immediately
|
// Ensure the selectedItem is updated immediately
|
||||||
const updatedTrigger = updatedPaths
|
const updatedTrigger = updatedPaths
|
||||||
|
@ -461,7 +461,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
// Update the toggle handlers to immediately update the selected item
|
// Update the toggle handlers to immediately update the selected item
|
||||||
const handleActionToggle = (uuid: string) => {
|
const handleActionToggle = (uuid: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -489,7 +489,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Immediately update the selected item if it's the one being toggled
|
// Immediately update the selected item if it's the one being toggled
|
||||||
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
||||||
|
@ -507,7 +507,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
const handleTriggerToggle = (uuid: string) => {
|
const handleTriggerToggle = (uuid: string) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -535,7 +535,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Immediately update the selected item if it's the one being toggled
|
// Immediately update the selected item if it's the one being toggled
|
||||||
if (selectedItem?.type === "trigger" && selectedItem.item.uuid === uuid) {
|
if (selectedItem?.type === "trigger" && selectedItem.item.uuid === uuid) {
|
||||||
|
@ -552,7 +552,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
const handleTriggerBufferTimeChange = (uuid: string, bufferTime: number) => {
|
const handleTriggerBufferTimeChange = (uuid: string, bufferTime: number) => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.type === "Conveyor"
|
path.type === "Conveyor"
|
||||||
? {
|
? {
|
||||||
...path,
|
...path,
|
||||||
|
@ -581,7 +581,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
|
|
||||||
// Immediately update selectedItem if it's the currently selected trigger
|
// Immediately update selectedItem if it's the currently selected trigger
|
||||||
if (selectedItem?.type === "trigger" && selectedItem.item.uuid === uuid) {
|
if (selectedItem?.type === "trigger" && selectedItem.item.uuid === uuid) {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import React, { useRef, useMemo } from "react";
|
import React, { useRef, useMemo } from "react";
|
||||||
import { InfoIcon } from "../../../icons/ExportCommonIcons";
|
import { InfoIcon } from "../../../icons/ExportCommonIcons";
|
||||||
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
||||||
import { useEditingPoint, useEyeDropMode, usePreviewPosition, useSelectedActionSphere, useSimulationPaths, useSocketStore } from "../../../../store/store";
|
import { useEditingPoint, useEyeDropMode, usePreviewPosition, useSelectedActionSphere, useSimulationStates, useSocketStore } from "../../../../store/store";
|
||||||
import * as Types from '../../../../types/world/worldTypes';
|
import * as Types from '../../../../types/world/worldTypes';
|
||||||
import PositionInput from "../customInput/PositionInputs";
|
import PositionInput from "../customInput/PositionInputs";
|
||||||
import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
||||||
|
|
||||||
const VehicleMechanics: React.FC = () => {
|
const VehicleMechanics: React.FC = () => {
|
||||||
const { selectedActionSphere } = useSelectedActionSphere();
|
const { selectedActionSphere } = useSelectedActionSphere();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { eyeDropMode, setEyeDropMode } = useEyeDropMode();
|
const { eyeDropMode, setEyeDropMode } = useEyeDropMode();
|
||||||
const { editingPoint, setEditingPoint } = useEditingPoint();
|
const { editingPoint, setEditingPoint } = useEditingPoint();
|
||||||
const { previewPosition, setPreviewPosition } = usePreviewPosition();
|
const { previewPosition, setPreviewPosition } = usePreviewPosition();
|
||||||
|
@ -19,7 +19,7 @@ const VehicleMechanics: React.FC = () => {
|
||||||
const { selectedPoint, connectedPointUuids } = useMemo(() => {
|
const { selectedPoint, connectedPointUuids } = useMemo(() => {
|
||||||
if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null, connectedPointUuids: [] };
|
if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null, connectedPointUuids: [] };
|
||||||
|
|
||||||
const vehiclePaths = simulationPaths.filter(
|
const vehiclePaths = simulationStates.filter(
|
||||||
(path): path is Types.VehicleEventsSchema => path.type === "Vehicle"
|
(path): path is Types.VehicleEventsSchema => path.type === "Vehicle"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ const VehicleMechanics: React.FC = () => {
|
||||||
selectedPoint: points,
|
selectedPoint: points,
|
||||||
connectedPointUuids: connectedUuids
|
connectedPointUuids: connectedUuids
|
||||||
};
|
};
|
||||||
}, [selectedActionSphere, simulationPaths]);
|
}, [selectedActionSphere, simulationStates]);
|
||||||
|
|
||||||
const updateBackend = async (updatedPath: Types.VehicleEventsSchema | undefined) => {
|
const updateBackend = async (updatedPath: Types.VehicleEventsSchema | undefined) => {
|
||||||
if (!updatedPath) return;
|
if (!updatedPath) return;
|
||||||
|
@ -66,7 +66,7 @@ const VehicleMechanics: React.FC = () => {
|
||||||
const handleActionUpdate = React.useCallback((updatedAction: Partial<Types.VehicleEventsSchema['points']['actions']>) => {
|
const handleActionUpdate = React.useCallback((updatedAction: Partial<Types.VehicleEventsSchema['points']['actions']>) => {
|
||||||
if (!selectedActionSphere?.points?.uuid) return;
|
if (!selectedActionSphere?.points?.uuid) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
|
if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
|
||||||
return {
|
return {
|
||||||
...path,
|
...path,
|
||||||
|
@ -89,8 +89,8 @@ const VehicleMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
}, [selectedActionSphere?.points?.uuid, simulationPaths, setSimulationPaths]);
|
}, [selectedActionSphere?.points?.uuid, simulationStates, setSimulationStates]);
|
||||||
|
|
||||||
const handleHitCountChange = React.useCallback((hitCount: number) => {
|
const handleHitCountChange = React.useCallback((hitCount: number) => {
|
||||||
handleActionUpdate({ hitCount });
|
handleActionUpdate({ hitCount });
|
||||||
|
@ -103,7 +103,7 @@ const VehicleMechanics: React.FC = () => {
|
||||||
const handleSpeedChange = React.useCallback((speed: number) => {
|
const handleSpeedChange = React.useCallback((speed: number) => {
|
||||||
if (!selectedActionSphere?.points?.uuid) return;
|
if (!selectedActionSphere?.points?.uuid) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
|
if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
|
||||||
return {
|
return {
|
||||||
...path,
|
...path,
|
||||||
|
@ -123,8 +123,8 @@ const VehicleMechanics: React.FC = () => {
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
}, [selectedActionSphere?.points?.uuid, simulationPaths, setSimulationPaths]);
|
}, [selectedActionSphere?.points?.uuid, simulationStates, setSimulationStates]);
|
||||||
|
|
||||||
const handleStartEyeDropClick = () => {
|
const handleStartEyeDropClick = () => {
|
||||||
setEditingPoint('start');
|
setEditingPoint('start');
|
||||||
|
|
|
@ -31,7 +31,6 @@ interface ListProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
const List: React.FC<ListProps> = ({ items = [], remove }) => {
|
||||||
console.log("items: ", items);
|
|
||||||
const { activeModule, setActiveModule } = useModuleStore();
|
const { activeModule, setActiveModule } = useModuleStore();
|
||||||
const { selectedZone, setSelectedZone } = useSelectedZoneStore();
|
const { selectedZone, setSelectedZone } = useSelectedZoneStore();
|
||||||
const { setSubModule } = useSubModuleStore();
|
const { setSubModule } = useSubModuleStore();
|
||||||
|
|
|
@ -1,163 +1,91 @@
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { useSimulationStates } from "../../../store/store";
|
||||||
import PolygonGenerator from "./polygonGenerator";
|
import PolygonGenerator from "./polygonGenerator";
|
||||||
import { useThree } from "@react-three/fiber";
|
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
|
||||||
import * as THREE from "three";
|
|
||||||
import * as Types from "../../../types/world/worldTypes";
|
|
||||||
import PathNavigator from "./pathNavigator";
|
import PathNavigator from "./pathNavigator";
|
||||||
import NavMeshDetails from "./navMeshDetails";
|
import NavMeshDetails from "./navMeshDetails";
|
||||||
import {
|
|
||||||
useSelectedActionSphere,
|
|
||||||
useSimulationPaths,
|
|
||||||
} from "../../../store/store";
|
|
||||||
import * as CONSTANTS from "../../../types/world/worldConstants";
|
import * as CONSTANTS from "../../../types/world/worldConstants";
|
||||||
|
import * as Types from "../../../types/world/worldTypes";
|
||||||
|
|
||||||
const Agv = ({
|
type AgvProps = {
|
||||||
lines,
|
lines: Types.RefLines
|
||||||
}: {
|
};
|
||||||
lines: Types.RefLines;
|
|
||||||
}) => {
|
|
||||||
const [pathPoints, setPathPoints] = useState<
|
|
||||||
{
|
|
||||||
modelUuid: string;
|
|
||||||
modelSpeed: number;
|
|
||||||
bufferTime: number;
|
|
||||||
points: { x: number; y: number; z: number }[];
|
|
||||||
hitCount: number;
|
|
||||||
}[]
|
|
||||||
>([]);
|
|
||||||
const { simulationPaths } = useSimulationPaths();
|
|
||||||
const { selectedActionSphere } = useSelectedActionSphere();
|
|
||||||
useEffect(() => {
|
|
||||||
if (!Array.isArray(simulationPaths)) {
|
|
||||||
} else {
|
|
||||||
let agvModels = simulationPaths.filter(
|
|
||||||
(val: any) => val.modelName === "agv"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
type PathPoints = {
|
||||||
let findMesh = agvModels.filter(
|
modelUuid: string;
|
||||||
(val: any) =>
|
modelSpeed: number;
|
||||||
val.modeluuid === selectedActionSphere?.path?.modeluuid &&
|
bufferTime: number;
|
||||||
val.type === "Vehicle"
|
points: { x: number; y: number; z: number }[];
|
||||||
);
|
hitCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
const result =
|
const Agv = ({ lines }: AgvProps) => {
|
||||||
findMesh.length > 0 &&
|
|
||||||
findMesh[0].type === "Vehicle" &&
|
|
||||||
typeof findMesh[0].points?.actions.start === "object" &&
|
|
||||||
typeof findMesh[0].points?.actions.end === "object" &&
|
|
||||||
"x" in findMesh[0].points.actions.start &&
|
|
||||||
"y" in findMesh[0].points.actions.start &&
|
|
||||||
"x" in findMesh[0].points.actions.end &&
|
|
||||||
"y" in findMesh[0].points.actions.end
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
modelUuid: findMesh[0].modeluuid, // Ensure it's a number
|
|
||||||
modelSpeed: findMesh[0].points.speed,
|
|
||||||
bufferTime: findMesh[0].points.actions.buffer,
|
|
||||||
hitCount: findMesh[0].points.actions.hitCount,
|
|
||||||
points: [
|
|
||||||
{
|
|
||||||
x: findMesh[0].position[0],
|
|
||||||
y: findMesh[0].position[1],
|
|
||||||
z: findMesh[0].position[2],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: findMesh[0].points.actions.start.x,
|
|
||||||
y: 0,
|
|
||||||
z: findMesh[0].points.actions.start.y,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
x: findMesh[0].points.actions.end.x,
|
|
||||||
y: 0,
|
|
||||||
z: findMesh[0].points.actions.end.y,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [];
|
|
||||||
if (result.length > 0) {
|
|
||||||
// setPathPoints((prev) => [...prev, ...result]);
|
|
||||||
setPathPoints((prev) => {
|
|
||||||
const existingIndex = prev.findIndex(
|
|
||||||
(item) => item.modelUuid === result[0].modelUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
if (existingIndex !== -1) {
|
let groupRef = useRef() as Types.RefGroup;
|
||||||
const updatedPathPoints = [...prev];
|
const [pathPoints, setPathPoints] = useState<PathPoints[]>([]);
|
||||||
updatedPathPoints[existingIndex] = result[0];
|
const { simulationStates } = useSimulationStates();
|
||||||
return updatedPathPoints;
|
const [navMesh, setNavMesh] = useState();
|
||||||
} else {
|
|
||||||
return [...prev, ...result];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// setPathPoints((prev) => {
|
|
||||||
// const existingUUIDs = new Set(prev.map((item) => item.uuid));
|
|
||||||
// const newItems = result.filter(
|
|
||||||
// (item) => !existingUUIDs.has(item.uuid)
|
|
||||||
// );
|
|
||||||
// return [...prev, ...newItems];
|
|
||||||
// });
|
|
||||||
}, [simulationPaths, selectedActionSphere]);
|
|
||||||
|
|
||||||
let groupRef = useRef() as Types.RefGroup;
|
useEffect(() => {
|
||||||
const [navMesh, setNavMesh] = useState();
|
if (simulationStates.length > 0) {
|
||||||
|
|
||||||
return (
|
const agvModels = simulationStates.filter((val) => val.modelName === "agv" && val.type === "Vehicle");
|
||||||
<>
|
|
||||||
<PolygonGenerator groupRef={groupRef} lines={lines} />
|
const newPathPoints = agvModels.filter((model: any) => model.points && model.points.actions && typeof model.points.actions.start === "object" && typeof model.points.actions.end === "object" && "x" in model.points.actions.start && "y" in model.points.actions.start && "x" in model.points.actions.end && "y" in model.points.actions.end)
|
||||||
<NavMeshDetails
|
.map((model: any) => ({
|
||||||
lines={lines}
|
modelUuid: model.modeluuid,
|
||||||
setNavMesh={setNavMesh}
|
modelSpeed: model.points.speed,
|
||||||
groupRef={groupRef}
|
bufferTime: model.points.actions.buffer,
|
||||||
/>
|
hitCount: model.points.actions.hitCount,
|
||||||
{pathPoints.map((pair, i) => (
|
points: [
|
||||||
<>
|
{ x: model.position[0], y: model.position[1], z: model.position[2], },
|
||||||
<PathNavigator
|
{ x: model.points.actions.start.x, y: 0, z: model.points.actions.start.y, },
|
||||||
navMesh={navMesh}
|
{ x: model.points.actions.end.x, y: 0, z: model.points.actions.end.y, },
|
||||||
selectedPoints={pair.points}
|
],
|
||||||
id={pair.modelUuid}
|
}));
|
||||||
key={i}
|
|
||||||
speed={pair.modelSpeed}
|
setPathPoints(newPathPoints);
|
||||||
bufferTime={pair.bufferTime}
|
}
|
||||||
hitCount={pair.hitCount}
|
}, [simulationStates]);
|
||||||
/>
|
|
||||||
{/* {pair.points.length > 2 && (
|
return (
|
||||||
<>
|
<>
|
||||||
<mesh
|
|
||||||
position={[
|
<PolygonGenerator groupRef={groupRef} lines={lines} />
|
||||||
pair.points[1].x,
|
<NavMeshDetails lines={lines} setNavMesh={setNavMesh} groupRef={groupRef} />
|
||||||
pair.points[1].y,
|
|
||||||
pair.points[1].z,
|
{pathPoints.map((pair, i) => (
|
||||||
]}
|
<PathNavigator
|
||||||
>
|
navMesh={navMesh}
|
||||||
<sphereGeometry args={[0.3, 15, 15]} />
|
selectedPoints={pair.points}
|
||||||
<meshStandardMaterial color="red" />
|
id={pair.modelUuid}
|
||||||
</mesh>
|
key={i}
|
||||||
<mesh
|
speed={pair.modelSpeed}
|
||||||
position={[
|
bufferTime={pair.bufferTime}
|
||||||
pair.points[2].x,
|
hitCount={pair.hitCount}
|
||||||
pair.points[2].y,
|
/>
|
||||||
pair.points[2].z,
|
))}
|
||||||
]}
|
|
||||||
>
|
{pathPoints.map((pair, i) => (
|
||||||
<sphereGeometry args={[0.3, 15, 15]} />
|
<group key={i}>
|
||||||
<meshStandardMaterial color="red" />
|
<mesh position={[pair.points[1].x, pair.points[1].y, pair.points[1].z,]} >
|
||||||
</mesh>
|
<sphereGeometry args={[0.3, 15, 15]} />
|
||||||
</>
|
<meshStandardMaterial color="red" />
|
||||||
)} */}
|
</mesh>
|
||||||
</>
|
<mesh position={[pair.points[2].x, pair.points[2].y, pair.points[2].z,]} >
|
||||||
))}
|
<sphereGeometry args={[0.3, 15, 15]} />
|
||||||
<group ref={groupRef} visible={false} name="Meshes">
|
<meshStandardMaterial color="red" />
|
||||||
<mesh rotation-x={CONSTANTS.planeConfig.rotation} position={CONSTANTS.planeConfig.position3D} name="Plane" receiveShadow>
|
</mesh>
|
||||||
<planeGeometry args={[300, 300]} />
|
</group>
|
||||||
<meshBasicMaterial color={CONSTANTS.planeConfig.color} />
|
))}
|
||||||
</mesh>
|
|
||||||
</group>
|
<group ref={groupRef} visible={false} name="Meshes">
|
||||||
</>
|
<mesh rotation-x={CONSTANTS.planeConfig.rotation} position={CONSTANTS.planeConfig.position3D} name="Plane" receiveShadow>
|
||||||
);
|
<planeGeometry args={[300, 300]} />
|
||||||
|
<meshBasicMaterial color={CONSTANTS.planeConfig.color} />
|
||||||
|
</mesh>
|
||||||
|
</group>
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Agv;
|
export default Agv;
|
||||||
|
|
|
@ -24,7 +24,7 @@ async function addAssetModel(
|
||||||
socket: Socket<any>,
|
socket: Socket<any>,
|
||||||
selectedItem: any,
|
selectedItem: any,
|
||||||
setSelectedItem: any,
|
setSelectedItem: any,
|
||||||
setSimulationPaths: any,
|
setSimulationStates: any,
|
||||||
plane: Types.RefMesh,
|
plane: Types.RefMesh,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ async function addAssetModel(
|
||||||
const cachedModel = THREE.Cache.get(selectedItem.id);
|
const cachedModel = THREE.Cache.get(selectedItem.id);
|
||||||
if (cachedModel) {
|
if (cachedModel) {
|
||||||
// console.log(`[Cache] Fetching ${selectedItem.name}`);
|
// console.log(`[Cache] Fetching ${selectedItem.name}`);
|
||||||
handleModelLoad(cachedModel, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationPaths, socket);
|
handleModelLoad(cachedModel, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationStates, socket);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const cachedModelBlob = await retrieveGLTF(selectedItem.id);
|
const cachedModelBlob = await retrieveGLTF(selectedItem.id);
|
||||||
|
@ -78,7 +78,7 @@ async function addAssetModel(
|
||||||
URL.revokeObjectURL(blobUrl);
|
URL.revokeObjectURL(blobUrl);
|
||||||
THREE.Cache.remove(blobUrl);
|
THREE.Cache.remove(blobUrl);
|
||||||
THREE.Cache.add(selectedItem.id, gltf);
|
THREE.Cache.add(selectedItem.id, gltf);
|
||||||
handleModelLoad(gltf, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationPaths, socket);
|
handleModelLoad(gltf, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationStates, socket);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
TempLoader(intersectPoint!, isTempLoader, tempLoader, itemsGroup);
|
TempLoader(intersectPoint!, isTempLoader, tempLoader, itemsGroup);
|
||||||
|
@ -90,7 +90,7 @@ async function addAssetModel(
|
||||||
const modelBlob = await fetch(`${url_Backend_dwinzo}/api/v1/AssetFile/${selectedItem.id}`).then((res) => res.blob());
|
const modelBlob = await fetch(`${url_Backend_dwinzo}/api/v1/AssetFile/${selectedItem.id}`).then((res) => res.blob());
|
||||||
await storeGLTF(selectedItem.id, modelBlob);
|
await storeGLTF(selectedItem.id, modelBlob);
|
||||||
THREE.Cache.add(selectedItem.id, gltf);
|
THREE.Cache.add(selectedItem.id, gltf);
|
||||||
await handleModelLoad(gltf, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationPaths, socket);
|
await handleModelLoad(gltf, intersectPoint!, selectedItem, itemsGroup, tempLoader, isTempLoader, setFloorItems, setSimulationStates, socket);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
TempLoader(intersectPoint!, isTempLoader, tempLoader, itemsGroup);
|
TempLoader(intersectPoint!, isTempLoader, tempLoader, itemsGroup);
|
||||||
|
@ -113,7 +113,7 @@ async function handleModelLoad(
|
||||||
tempLoader: Types.RefMesh,
|
tempLoader: Types.RefMesh,
|
||||||
isTempLoader: Types.RefBoolean,
|
isTempLoader: Types.RefBoolean,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationPaths: any,
|
setSimulationStates: any,
|
||||||
socket: Socket<any>
|
socket: Socket<any>
|
||||||
) {
|
) {
|
||||||
const model = gltf.scene.clone();
|
const model = gltf.scene.clone();
|
||||||
|
@ -219,7 +219,7 @@ async function handleModelLoad(
|
||||||
eventData.position = newFloorItem.position;
|
eventData.position = newFloorItem.position;
|
||||||
eventData.rotation = [model.rotation.x, model.rotation.y, model.rotation.z];
|
eventData.rotation = [model.rotation.x, model.rotation.y, model.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
eventData as Types.ConveyorEventsSchema
|
eventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
|
@ -281,7 +281,7 @@ async function handleModelLoad(
|
||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
eventData as Types.VehicleEventsSchema
|
eventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -10,7 +10,7 @@ async function DeleteFloorItems(
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
hoveredDeletableFloorItem: Types.RefMesh,
|
hoveredDeletableFloorItem: Types.RefMesh,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationPaths: any,
|
setSimulationStates: any,
|
||||||
socket: Socket<any>
|
socket: Socket<any>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ async function DeleteFloorItems(
|
||||||
}
|
}
|
||||||
setFloorItems(updatedItems);
|
setFloorItems(updatedItems);
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== removedItem.modeluuid);
|
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== removedItem.modeluuid);
|
||||||
return updatedEvents;
|
return updatedEvents;
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
useRenderDistance,
|
useRenderDistance,
|
||||||
useselectedFloorItem,
|
useselectedFloorItem,
|
||||||
useSelectedItem,
|
useSelectedItem,
|
||||||
useSimulationPaths,
|
useSimulationStates,
|
||||||
useSocketStore,
|
useSocketStore,
|
||||||
useToggleView,
|
useToggleView,
|
||||||
useTransformMode,
|
useTransformMode,
|
||||||
|
@ -65,7 +65,7 @@ const FloorItemsGroup = ({
|
||||||
const { setselectedFloorItem } = useselectedFloorItem();
|
const { setselectedFloorItem } = useselectedFloorItem();
|
||||||
const { activeTool } = useActiveTool();
|
const { activeTool } = useActiveTool();
|
||||||
const { selectedItem, setSelectedItem } = useSelectedItem();
|
const { selectedItem, setSelectedItem } = useSelectedItem();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { setLoadingProgress } = useLoadingProgress();
|
const { setLoadingProgress } = useLoadingProgress();
|
||||||
const { activeModule } = useModuleStore();
|
const { activeModule } = useModuleStore();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
@ -111,7 +111,7 @@ const FloorItemsGroup = ({
|
||||||
gltfLoaderWorker.postMessage({ floorItems: data });
|
gltfLoaderWorker.postMessage({ floorItems: data });
|
||||||
} else {
|
} else {
|
||||||
gltfLoaderWorker.postMessage({ floorItems: [] });
|
gltfLoaderWorker.postMessage({ floorItems: [] });
|
||||||
loadInitialFloorItems(itemsGroup, setFloorItems, setSimulationPaths);
|
loadInitialFloorItems(itemsGroup, setFloorItems, setSimulationStates);
|
||||||
updateLoadingProgress(100);
|
updateLoadingProgress(100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -130,7 +130,7 @@ const FloorItemsGroup = ({
|
||||||
updateLoadingProgress(progress);
|
updateLoadingProgress(progress);
|
||||||
|
|
||||||
if (loadedAssets === totalAssets) {
|
if (loadedAssets === totalAssets) {
|
||||||
loadInitialFloorItems(itemsGroup, setFloorItems, setSimulationPaths);
|
loadInitialFloorItems(itemsGroup, setFloorItems, setSimulationStates);
|
||||||
updateLoadingProgress(100);
|
updateLoadingProgress(100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -248,7 +248,7 @@ const FloorItemsGroup = ({
|
||||||
itemsGroup,
|
itemsGroup,
|
||||||
hoveredDeletableFloorItem,
|
hoveredDeletableFloorItem,
|
||||||
setFloorItems,
|
setFloorItems,
|
||||||
setSimulationPaths,
|
setSimulationStates,
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ const FloorItemsGroup = ({
|
||||||
socket,
|
socket,
|
||||||
selectedItem,
|
selectedItem,
|
||||||
setSelectedItem,
|
setSelectedItem,
|
||||||
setSimulationPaths,
|
setSimulationStates,
|
||||||
plane
|
plane
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { getFloorAssets } from '../../../services/factoryBuilder/assest/floorAss
|
||||||
async function loadInitialFloorItems(
|
async function loadInitialFloorItems(
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationPaths: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!itemsGroup.current) return;
|
if (!itemsGroup.current) return;
|
||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||||
|
@ -71,7 +71,7 @@ async function loadInitialFloorItems(
|
||||||
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
const cachedModel = THREE.Cache.get(item.modelfileID!);
|
||||||
if (cachedModel) {
|
if (cachedModel) {
|
||||||
// console.log(`[Cache] Fetching ${item.modelname}`);
|
// console.log(`[Cache] Fetching ${item.modelname}`);
|
||||||
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, setFloorItems, setSimulationPaths);
|
processLoadedModel(cachedModel.scene.clone(), item, itemsGroup, setFloorItems, setSimulationStates);
|
||||||
modelsLoaded++;
|
modelsLoaded++;
|
||||||
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
||||||
return;
|
return;
|
||||||
|
@ -88,7 +88,7 @@ async function loadInitialFloorItems(
|
||||||
URL.revokeObjectURL(blobUrl);
|
URL.revokeObjectURL(blobUrl);
|
||||||
THREE.Cache.remove(blobUrl);
|
THREE.Cache.remove(blobUrl);
|
||||||
THREE.Cache.add(item.modelfileID!, gltf);
|
THREE.Cache.add(item.modelfileID!, gltf);
|
||||||
processLoadedModel(gltf.scene.clone(), item, itemsGroup, setFloorItems, setSimulationPaths);
|
processLoadedModel(gltf.scene.clone(), item, itemsGroup, setFloorItems, setSimulationStates);
|
||||||
modelsLoaded++;
|
modelsLoaded++;
|
||||||
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
||||||
},
|
},
|
||||||
|
@ -111,7 +111,7 @@ async function loadInitialFloorItems(
|
||||||
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
|
const modelBlob = await fetch(modelUrl).then((res) => res.blob());
|
||||||
await storeGLTF(item.modelfileID!, modelBlob);
|
await storeGLTF(item.modelfileID!, modelBlob);
|
||||||
THREE.Cache.add(item.modelfileID!, gltf);
|
THREE.Cache.add(item.modelfileID!, gltf);
|
||||||
processLoadedModel(gltf.scene.clone(), item, itemsGroup, setFloorItems, setSimulationPaths);
|
processLoadedModel(gltf.scene.clone(), item, itemsGroup, setFloorItems, setSimulationStates);
|
||||||
modelsLoaded++;
|
modelsLoaded++;
|
||||||
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
checkLoadingCompletion(modelsLoaded, modelsToLoad, dracoLoader, resolve);
|
||||||
},
|
},
|
||||||
|
@ -138,7 +138,7 @@ async function loadInitialFloorItems(
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (item.eventData) {
|
if (item.eventData) {
|
||||||
processEventData(item, setSimulationPaths);
|
processEventData(item, setSimulationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelsLoaded++;
|
modelsLoaded++;
|
||||||
|
@ -157,7 +157,7 @@ function processLoadedModel(
|
||||||
item: Types.EventData,
|
item: Types.EventData,
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationPaths: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
||||||
) {
|
) {
|
||||||
const model = gltf;
|
const model = gltf;
|
||||||
model.uuid = item.modeluuid;
|
model.uuid = item.modeluuid;
|
||||||
|
@ -193,14 +193,14 @@ function processLoadedModel(
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (item.eventData) {
|
if (item.eventData) {
|
||||||
processEventData(item, setSimulationPaths);
|
processEventData(item, setSimulationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
gsap.to(model.position, { y: item.position[1], duration: 1.5, ease: 'power2.out' });
|
gsap.to(model.position, { y: item.position[1], duration: 1.5, ease: 'power2.out' });
|
||||||
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out' });
|
gsap.to(model.scale, { x: 1, y: 1, z: 1, duration: 1.5, ease: 'power2.out' });
|
||||||
}
|
}
|
||||||
|
|
||||||
function processEventData(item: Types.EventData, setSimulationPaths: any) {
|
function processEventData(item: Types.EventData, setSimulationStates: any) {
|
||||||
|
|
||||||
if (item.eventData?.type === 'Conveyor') {
|
if (item.eventData?.type === 'Conveyor') {
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ function processEventData(item: Types.EventData, setSimulationPaths: any) {
|
||||||
data.position = item.position;
|
data.position = item.position;
|
||||||
data.rotation = [item.rotation.x, item.rotation.y, item.rotation.z];
|
data.rotation = [item.rotation.x, item.rotation.y, item.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
data as Types.ConveyorEventsSchema
|
data as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
|
@ -222,7 +222,7 @@ function processEventData(item: Types.EventData, setSimulationPaths: any) {
|
||||||
data.modelName = item.modelname;
|
data.modelName = item.modelname;
|
||||||
data.position = item.position;
|
data.position = item.position;
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
data as Types.VehicleEventsSchema
|
data as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, useToggleView } from "../../../../store/store";
|
import { useFloorItems, useSelectedAssets, useSimulationStates, useSocketStore, useToggleView } from "../../../../store/store";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||||
import * as Types from "../../../../types/world/worldTypes";
|
import * as Types from "../../../../types/world/worldTypes";
|
||||||
|
@ -10,7 +10,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||||
const { floorItems, setFloorItems } = useFloorItems();
|
const { floorItems, setFloorItems } = useFloorItems();
|
||||||
const { socket } = useSocketStore()
|
const { socket } = useSocketStore()
|
||||||
|
@ -151,7 +151,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationPaths.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
||||||
|
@ -234,7 +234,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.ConveyorEventsSchema
|
newEventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
|
@ -314,7 +314,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.VehicleEventsSchema
|
newEventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, useToggleView } from "../../../../store/store";
|
import { useFloorItems, useSelectedAssets, useSimulationStates, useSocketStore, useToggleView } from "../../../../store/store";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||||
import * as Types from "../../../../types/world/worldTypes";
|
import * as Types from "../../../../types/world/worldTypes";
|
||||||
|
@ -11,7 +11,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||||
const { floorItems, setFloorItems } = useFloorItems();
|
const { floorItems, setFloorItems } = useFloorItems();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
|
@ -132,7 +132,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationPaths.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
||||||
|
@ -216,7 +216,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.ConveyorEventsSchema
|
newEventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
|
@ -295,7 +295,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.VehicleEventsSchema
|
newEventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, useToggleView } from "../../../../store/store";
|
import { useFloorItems, useSelectedAssets, useSimulationStates, useSocketStore, useToggleView } from "../../../../store/store";
|
||||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import * as Types from "../../../../types/world/worldTypes";
|
import * as Types from "../../../../types/world/worldTypes";
|
||||||
|
@ -12,7 +12,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
||||||
|
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { floorItems, setFloorItems } = useFloorItems();
|
const { floorItems, setFloorItems } = useFloorItems();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const itemsData = useRef<Types.FloorItems>([]);
|
const itemsData = useRef<Types.FloorItems>([]);
|
||||||
|
@ -180,7 +180,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationPaths.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
||||||
|
@ -229,7 +229,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
@ -280,7 +280,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, useToggleView } from "../../../../store/store";
|
import { useFloorItems, useSelectedAssets, useSimulationStates, useSocketStore, useToggleView } from "../../../../store/store";
|
||||||
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
// import { setFloorItemApi } from '../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi';
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import * as Types from "../../../../types/world/worldTypes";
|
import * as Types from "../../../../types/world/worldTypes";
|
||||||
|
@ -13,7 +13,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
||||||
|
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { floorItems, setFloorItems } = useFloorItems();
|
const { floorItems, setFloorItems } = useFloorItems();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const itemsData = useRef<Types.FloorItems>([]);
|
const itemsData = useRef<Types.FloorItems>([]);
|
||||||
|
@ -184,7 +184,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationPaths.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
const organization = email ? email.split("@")[1].split(".")[0] : "default";
|
||||||
|
@ -233,7 +233,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
@ -285,7 +285,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { SelectionBox } from "three/examples/jsm/interactive/SelectionBox";
|
import { SelectionBox } from "three/examples/jsm/interactive/SelectionBox";
|
||||||
import { SelectionHelper } from "./selectionHelper";
|
import { SelectionHelper } from "./selectionHelper";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, useToggleView } from "../../../../store/store";
|
import { useFloorItems, useSelectedAssets, useSimulationStates, useSocketStore, useToggleView } from "../../../../store/store";
|
||||||
import BoundingBox from "./boundingBoxHelper";
|
import BoundingBox from "./boundingBoxHelper";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
// import { deleteFloorItem } from '../../../../services/factoryBuilder/assest/floorAsset/deleteFloorItemApi';
|
// import { deleteFloorItem } from '../../../../services/factoryBuilder/assest/floorAsset/deleteFloorItemApi';
|
||||||
|
@ -20,7 +20,7 @@ const SelectionControls: React.FC = () => {
|
||||||
const itemsGroupRef = useRef<THREE.Group | undefined>(undefined);
|
const itemsGroupRef = useRef<THREE.Group | undefined>(undefined);
|
||||||
const selectionGroup = useRef() as Types.RefGroup;
|
const selectionGroup = useRef() as Types.RefGroup;
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { setSimulationPaths } = useSimulationPaths();
|
const { setSimulationStates } = useSimulationStates();
|
||||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||||
const [movedObjects, setMovedObjects] = useState<THREE.Object3D[]>([]);
|
const [movedObjects, setMovedObjects] = useState<THREE.Object3D[]>([]);
|
||||||
const [rotatedObjects, setRotatedObjects] = useState<THREE.Object3D[]>([]);
|
const [rotatedObjects, setRotatedObjects] = useState<THREE.Object3D[]>([]);
|
||||||
|
@ -240,7 +240,7 @@ const SelectionControls: React.FC = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== selectedMesh.uuid);
|
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== selectedMesh.uuid);
|
||||||
return updatedEvents;
|
return updatedEvents;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { useFloorItems, useSimulationPaths } from '../../../store/store';
|
import { useFloorItems, useSimulationStates } from '../../../store/store';
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import * as Types from '../../../types/world/worldTypes';
|
import * as Types from '../../../types/world/worldTypes';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
function Behaviour() {
|
function Behaviour() {
|
||||||
const { setSimulationPaths } = useSimulationPaths();
|
const { setSimulationStates } = useSimulationStates();
|
||||||
const { floorItems } = useFloorItems();
|
const { floorItems } = useFloorItems();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -78,7 +78,7 @@ function Behaviour() {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// setSimulationPaths(newPaths);
|
// setSimulationStates(newPaths);
|
||||||
// console.log('floorItems: ', floorItems);
|
// console.log('floorItems: ', floorItems);
|
||||||
}, [floorItems]);
|
}, [floorItems]);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import * as Types from '../../../types/world/worldTypes';
|
import * as Types from '../../../types/world/worldTypes';
|
||||||
import { QuadraticBezierLine } from '@react-three/drei';
|
import { QuadraticBezierLine } from '@react-three/drei';
|
||||||
import { useIsConnecting, useSimulationPaths } from '../../../store/store';
|
import { useIsConnecting, useSimulationStates } from '../../../store/store';
|
||||||
import useModuleStore from '../../../store/useModuleStore';
|
import useModuleStore from '../../../store/useModuleStore';
|
||||||
import { usePlayButtonStore } from '../../../store/usePlayButtonStore';
|
import { usePlayButtonStore } from '../../../store/usePlayButtonStore';
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
const { activeModule } = useModuleStore();
|
const { activeModule } = useModuleStore();
|
||||||
const { gl, raycaster, scene, pointer, camera } = useThree();
|
const { gl, raycaster, scene, pointer, camera } = useThree();
|
||||||
const { setIsConnecting } = useIsConnecting();
|
const { setIsConnecting } = useIsConnecting();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { isPlaying } = usePlayButtonStore();
|
const { isPlaying } = usePlayButtonStore();
|
||||||
|
|
||||||
const [firstSelected, setFirstSelected] = useState<{
|
const [firstSelected, setFirstSelected] = useState<{
|
||||||
|
@ -29,7 +29,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
toPathUUID: string,
|
toPathUUID: string,
|
||||||
toPointUUID: string
|
toPointUUID: string
|
||||||
) => {
|
) => {
|
||||||
const updatedPaths = simulationPaths.map(path => {
|
const updatedPaths = simulationStates.map(path => {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
if (path.modeluuid === fromPathUUID) {
|
if (path.modeluuid === fromPathUUID) {
|
||||||
return {
|
return {
|
||||||
|
@ -99,7 +99,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
const existingTargets = path.points.connections.targets || [];
|
const existingTargets = path.points.connections.targets || [];
|
||||||
|
|
||||||
// Check if target is a Conveyor
|
// Check if target is a Conveyor
|
||||||
const toPath = simulationPaths.find(p => p.modeluuid === toPathUUID);
|
const toPath = simulationStates.find(p => p.modeluuid === toPathUUID);
|
||||||
if (toPath?.type !== 'Conveyor') {
|
if (toPath?.type !== 'Conveyor') {
|
||||||
console.log("Vehicle can only connect to Conveyors");
|
console.log("Vehicle can only connect to Conveyors");
|
||||||
return path;
|
return path;
|
||||||
|
@ -136,7 +136,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
const existingTargets = path.points.connections.targets || [];
|
const existingTargets = path.points.connections.targets || [];
|
||||||
|
|
||||||
// Check if source is a Conveyor
|
// Check if source is a Conveyor
|
||||||
const fromPath = simulationPaths.find(p => p.modeluuid === fromPathUUID);
|
const fromPath = simulationStates.find(p => p.modeluuid === fromPathUUID);
|
||||||
if (fromPath?.type !== 'Conveyor') {
|
if (fromPath?.type !== 'Conveyor') {
|
||||||
console.log("Vehicle can only connect to Conveyors");
|
console.log("Vehicle can only connect to Conveyors");
|
||||||
return path;
|
return path;
|
||||||
|
@ -169,7 +169,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
return path;
|
return path;
|
||||||
});
|
});
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddConnection = (fromPathUUID: string, fromUUID: string, toPathUUID: string, toUUID: string) => {
|
const handleAddConnection = (fromPathUUID: string, fromUUID: string, toPathUUID: string, toUUID: string) => {
|
||||||
|
@ -227,8 +227,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pathUUID) {
|
if (pathUUID) {
|
||||||
const firstPath = simulationPaths.find(p => p.modeluuid === firstSelected?.pathUUID);
|
const firstPath = simulationStates.find(p => p.modeluuid === firstSelected?.pathUUID);
|
||||||
const secondPath = simulationPaths.find(p => p.modeluuid === pathUUID);
|
const secondPath = simulationStates.find(p => p.modeluuid === pathUUID);
|
||||||
|
|
||||||
// Prevent vehicle-to-vehicle connections
|
// Prevent vehicle-to-vehicle connections
|
||||||
if (firstPath && secondPath && firstPath.type === 'Vehicle' && secondPath.type === 'Vehicle') {
|
if (firstPath && secondPath && firstPath.type === 'Vehicle' && secondPath.type === 'Vehicle') {
|
||||||
|
@ -247,7 +247,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
|
|
||||||
// Check if this specific connection already exists
|
// Check if this specific connection already exists
|
||||||
const isDuplicateConnection = firstSelected
|
const isDuplicateConnection = firstSelected
|
||||||
? simulationPaths.some(path => {
|
? simulationStates.some(path => {
|
||||||
if (path.modeluuid === firstSelected.pathUUID) {
|
if (path.modeluuid === firstSelected.pathUUID) {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
|
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
|
||||||
|
@ -281,7 +281,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
|
|
||||||
// For non-Vehicle paths, check if already connected
|
// For non-Vehicle paths, check if already connected
|
||||||
if (intersected.userData.path.type !== 'Vehicle') {
|
if (intersected.userData.path.type !== 'Vehicle') {
|
||||||
const isAlreadyConnected = simulationPaths.some(path => {
|
const isAlreadyConnected = simulationStates.some(path => {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
return path.points.some(point =>
|
return path.points.some(point =>
|
||||||
point.uuid === sphereUUID &&
|
point.uuid === sphereUUID &&
|
||||||
|
@ -361,7 +361,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
canvasElement.removeEventListener("mousemove", onMouseMove);
|
canvasElement.removeEventListener("mousemove", onMouseMove);
|
||||||
canvasElement.removeEventListener("contextmenu", onContextMenu);
|
canvasElement.removeEventListener("contextmenu", onContextMenu);
|
||||||
};
|
};
|
||||||
}, [camera, scene, raycaster, firstSelected, simulationPaths]);
|
}, [camera, scene, raycaster, firstSelected, simulationStates]);
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
if (firstSelected) {
|
if (firstSelected) {
|
||||||
|
@ -397,8 +397,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
const pathData = sphere.userData.path;
|
const pathData = sphere.userData.path;
|
||||||
const pathUUID = pathData.modeluuid;
|
const pathUUID = pathData.modeluuid;
|
||||||
|
|
||||||
const firstPath = simulationPaths.find(p => p.modeluuid === firstSelected.pathUUID);
|
const firstPath = simulationStates.find(p => p.modeluuid === firstSelected.pathUUID);
|
||||||
const secondPath = simulationPaths.find(p => p.modeluuid === pathUUID);
|
const secondPath = simulationStates.find(p => p.modeluuid === pathUUID);
|
||||||
const isVehicleToVehicle = firstPath?.type === 'Vehicle' && secondPath?.type === 'Vehicle';
|
const isVehicleToVehicle = firstPath?.type === 'Vehicle' && secondPath?.type === 'Vehicle';
|
||||||
|
|
||||||
// Inside the useFrame hook, where we check for snapped spheres:
|
// Inside the useFrame hook, where we check for snapped spheres:
|
||||||
|
@ -413,7 +413,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
!firstSelected.isCorner);
|
!firstSelected.isCorner);
|
||||||
|
|
||||||
// Check for duplicate connection (regardless of path type)
|
// Check for duplicate connection (regardless of path type)
|
||||||
const isDuplicateConnection = simulationPaths.some(path => {
|
const isDuplicateConnection = simulationStates.some(path => {
|
||||||
if (path.modeluuid === firstSelected.pathUUID) {
|
if (path.modeluuid === firstSelected.pathUUID) {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
|
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
|
||||||
|
@ -431,7 +431,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
|
|
||||||
// For non-Vehicle paths, check if already connected
|
// For non-Vehicle paths, check if already connected
|
||||||
const isNonVehicleAlreadyConnected = pathData.type !== 'Vehicle' &&
|
const isNonVehicleAlreadyConnected = pathData.type !== 'Vehicle' &&
|
||||||
simulationPaths.some(path => {
|
simulationStates.some(path => {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
return path.points.some(point =>
|
return path.points.some(point =>
|
||||||
point.uuid === sphereUUID &&
|
point.uuid === sphereUUID &&
|
||||||
|
@ -505,11 +505,11 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group name='simulationConnectionGroup' visible={!isPlaying} >
|
<group name='simulationConnectionGroup' visible={!isPlaying} >
|
||||||
{simulationPaths.flatMap(path => {
|
{simulationStates.flatMap(path => {
|
||||||
if (path.type === 'Conveyor') {
|
if (path.type === 'Conveyor') {
|
||||||
return path.points.flatMap(point =>
|
return path.points.flatMap(point =>
|
||||||
point.connections.targets.map((target, index) => {
|
point.connections.targets.map((target, index) => {
|
||||||
const targetPath = simulationPaths.find(p => p.modeluuid === target.pathUUID);
|
const targetPath = simulationStates.find(p => p.modeluuid === target.pathUUID);
|
||||||
if (targetPath?.type === 'Vehicle') return null;
|
if (targetPath?.type === 'Vehicle') return null;
|
||||||
|
|
||||||
const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', point.uuid);
|
const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', point.uuid);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
useRenderDistance,
|
useRenderDistance,
|
||||||
useSelectedActionSphere,
|
useSelectedActionSphere,
|
||||||
useSelectedPath,
|
useSelectedPath,
|
||||||
useSimulationPaths,
|
useSimulationStates,
|
||||||
} from "../../../store/store";
|
} from "../../../store/store";
|
||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { useSubModuleStore } from "../../../store/useModuleStore";
|
import { useSubModuleStore } from "../../../store/useModuleStore";
|
||||||
|
@ -32,7 +32,7 @@ function PathCreation({
|
||||||
const { raycaster, camera, pointer, gl } = useThree();
|
const { raycaster, camera, pointer, gl } = useThree();
|
||||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||||
const { setSelectedPath } = useSelectedPath();
|
const { setSelectedPath } = useSelectedPath();
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { isConnecting } = useIsConnecting();
|
const { isConnecting } = useIsConnecting();
|
||||||
|
|
||||||
const groupRefs = useRef<{ [key: string]: THREE.Group }>({});
|
const groupRefs = useRef<{ [key: string]: THREE.Group }>({});
|
||||||
|
@ -71,7 +71,7 @@ function PathCreation({
|
||||||
const updateSimulationPaths = () => {
|
const updateSimulationPaths = () => {
|
||||||
if (!selectedActionSphere) return;
|
if (!selectedActionSphere) return;
|
||||||
|
|
||||||
const updatedPaths = simulationPaths.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
if (path.type === "Conveyor") {
|
if (path.type === "Conveyor") {
|
||||||
return {
|
return {
|
||||||
...path,
|
...path,
|
||||||
|
@ -97,7 +97,7 @@ function PathCreation({
|
||||||
return path;
|
return path;
|
||||||
}) as Types.ConveyorEventsSchema[];
|
}) as Types.ConveyorEventsSchema[];
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
|
@ -173,7 +173,7 @@ function PathCreation({
|
||||||
z: number
|
z: number
|
||||||
) => {
|
) => {
|
||||||
if (!selectedActionSphere?.points?.uuid) return;
|
if (!selectedActionSphere?.points?.uuid) return;
|
||||||
const updatedPaths = simulationPaths.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
path.type === "Vehicle" &&
|
path.type === "Vehicle" &&
|
||||||
|
@ -204,12 +204,12 @@ function PathCreation({
|
||||||
);
|
);
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group visible={!isPlaying} name="simulation-simulationPaths-group" ref={pathsGroupRef}>
|
<group visible={!isPlaying} name="simulation-simulationStates-group" ref={pathsGroupRef}>
|
||||||
{simulationPaths.map((path) => {
|
{simulationStates.map((path) => {
|
||||||
if (path.type === "Conveyor") {
|
if (path.type === "Conveyor") {
|
||||||
const points = path.points.map(
|
const points = path.points.map(
|
||||||
(point) => new THREE.Vector3(...point.position)
|
(point) => new THREE.Vector3(...point.position)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// useCallback,
|
// useCallback,
|
||||||
// useRef,
|
// useRef,
|
||||||
// } from "react";
|
// } from "react";
|
||||||
// import { useSimulationPaths } from "../../../store/store";
|
// import { useSimulationStates } from "../../../store/store";
|
||||||
// import * as THREE from "three";
|
// import * as THREE from "three";
|
||||||
// import { useThree } from "@react-three/fiber";
|
// import { useThree } from "@react-three/fiber";
|
||||||
// import {
|
// import {
|
||||||
|
@ -312,19 +312,19 @@
|
||||||
|
|
||||||
// const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
// const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
||||||
// ({ onProcessesCreated }) => {
|
// ({ onProcessesCreated }) => {
|
||||||
// const { simulationPaths } = useSimulationPaths();
|
// const { simulationStates } = useSimulationStates();
|
||||||
// const { createProcessesFromPaths } = useProcessCreation();
|
// const { createProcessesFromPaths } = useProcessCreation();
|
||||||
// const prevPathsRef = useRef<SimulationPath[]>([]);
|
// const prevPathsRef = useRef<SimulationPath[]>([]);
|
||||||
// const prevProcessesRef = useRef<Process[]>([]);
|
// const prevProcessesRef = useRef<Process[]>([]);
|
||||||
|
|
||||||
// const convertedPaths = useMemo((): SimulationPath[] => {
|
// const convertedPaths = useMemo((): SimulationPath[] => {
|
||||||
// if (!simulationPaths) return [];
|
// if (!simulationStates) return [];
|
||||||
// return simulationPaths.map((path) =>
|
// return simulationStates.map((path) =>
|
||||||
// convertToSimulationPath(
|
// convertToSimulationPath(
|
||||||
// path as ConveyorEventsSchema | VehicleEventsSchema
|
// path as ConveyorEventsSchema | VehicleEventsSchema
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
// }, [simulationPaths]);
|
// }, [simulationStates]);
|
||||||
|
|
||||||
// const pathsDependency = useMemo(() => {
|
// const pathsDependency = useMemo(() => {
|
||||||
// if (!convertedPaths) return null;
|
// if (!convertedPaths) return null;
|
||||||
|
@ -404,7 +404,7 @@ import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useRef,
|
useRef,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useSimulationPaths } from "../../../store/store";
|
import { useSimulationStates } from "../../../store/store";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useThree } from "@react-three/fiber";
|
import { useThree } from "@react-three/fiber";
|
||||||
import {
|
import {
|
||||||
|
@ -737,19 +737,19 @@ export function useProcessCreation() {
|
||||||
|
|
||||||
const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
|
||||||
({ onProcessesCreated }) => {
|
({ onProcessesCreated }) => {
|
||||||
const { simulationPaths } = useSimulationPaths();
|
const { simulationStates } = useSimulationStates();
|
||||||
const { createProcessesFromPaths } = useProcessCreation();
|
const { createProcessesFromPaths } = useProcessCreation();
|
||||||
const prevPathsRef = useRef<SimulationPath[]>([]);
|
const prevPathsRef = useRef<SimulationPath[]>([]);
|
||||||
const prevProcessesRef = useRef<Process[]>([]);
|
const prevProcessesRef = useRef<Process[]>([]);
|
||||||
|
|
||||||
const convertedPaths = useMemo((): SimulationPath[] => {
|
const convertedPaths = useMemo((): SimulationPath[] => {
|
||||||
if (!simulationPaths) return [];
|
if (!simulationStates) return [];
|
||||||
return simulationPaths.map((path) =>
|
return simulationStates.map((path) =>
|
||||||
convertToSimulationPath(
|
convertToSimulationPath(
|
||||||
path as ConveyorEventsSchema | VehicleEventsSchema
|
path as ConveyorEventsSchema | VehicleEventsSchema
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}, [simulationPaths]);
|
}, [simulationStates]);
|
||||||
|
|
||||||
// Enhanced dependency tracking that includes action types
|
// Enhanced dependency tracking that includes action types
|
||||||
const pathsDependency = useMemo(() => {
|
const pathsDependency = useMemo(() => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { useState, useEffect, useRef, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
useSelectedActionSphere,
|
useSelectedActionSphere,
|
||||||
useSelectedPath,
|
useSelectedPath,
|
||||||
useSimulationPaths,
|
useSimulationStates,
|
||||||
} from "../../store/store";
|
} from "../../store/store";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import Behaviour from "./behaviour/behaviour";
|
import Behaviour from "./behaviour/behaviour";
|
||||||
|
@ -15,12 +15,12 @@ import Agv from "../builder/agv/agv";
|
||||||
function Simulation() {
|
function Simulation() {
|
||||||
const { activeModule } = useModuleStore();
|
const { activeModule } = useModuleStore();
|
||||||
const pathsGroupRef = useRef() as React.MutableRefObject<THREE.Group>;
|
const pathsGroupRef = useRef() as React.MutableRefObject<THREE.Group>;
|
||||||
const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const [processes, setProcesses] = useState([]);
|
const [processes, setProcesses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// console.log('simulationPaths: ', simulationPaths);
|
// console.log('simulationStates: ', simulationStates);
|
||||||
}, [simulationPaths]);
|
}, [simulationStates]);
|
||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// if (selectedActionSphere) {
|
// if (selectedActionSphere) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// import { useMemo, useState } from 'react';
|
// import { useMemo, useState } from 'react';
|
||||||
// import { useSelectedActionSphere, useToggleView, useSimulationPaths, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store';
|
// import { useSelectedActionSphere, useToggleView, useSimulationStates, useSelectedPath, useStartSimulation, useDrawMaterialPath } from '../../store/store';
|
||||||
// import * as THREE from 'three';
|
// import * as THREE from 'three';
|
||||||
// import useModuleStore from '../../store/useModuleStore';
|
// import useModuleStore from '../../store/useModuleStore';
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@
|
||||||
// const { startSimulation, setStartSimulation } = useStartSimulation();
|
// const { startSimulation, setStartSimulation } = useStartSimulation();
|
||||||
// const { selectedActionSphere } = useSelectedActionSphere();
|
// const { selectedActionSphere } = useSelectedActionSphere();
|
||||||
// const { selectedPath, setSelectedPath } = useSelectedPath();
|
// const { selectedPath, setSelectedPath } = useSelectedPath();
|
||||||
// const { simulationPaths, setSimulationPaths } = useSimulationPaths();
|
// const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
// const { drawMaterialPath, setDrawMaterialPath } = useDrawMaterialPath();
|
// const { drawMaterialPath, setDrawMaterialPath } = useDrawMaterialPath();
|
||||||
// const [activeButton, setActiveButton] = useState<string | null>(null);
|
// const [activeButton, setActiveButton] = useState<string | null>(null);
|
||||||
|
|
||||||
// const handleAddAction = () => {
|
// const handleAddAction = () => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) => {
|
// points: path.points.map((point) => {
|
||||||
// if (point.uuid === selectedActionSphere.points.uuid) {
|
// if (point.uuid === selectedActionSphere.points.uuid) {
|
||||||
|
@ -37,13 +37,13 @@
|
||||||
// }),
|
// }),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleDeleteAction = (uuid: string) => {
|
// const handleDeleteAction = (uuid: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -52,13 +52,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleActionSelect = (uuid: string, actionType: string) => {
|
// const handleActionSelect = (uuid: string, actionType: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -72,13 +72,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleMaterialSelect = (uuid: string, material: string) => {
|
// const handleMaterialSelect = (uuid: string, material: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -92,13 +92,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleDelayChange = (uuid: string, delay: number | string) => {
|
// const handleDelayChange = (uuid: string, delay: number | string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -112,13 +112,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleSpawnIntervalChange = (uuid: string, spawnInterval: number | string) => {
|
// const handleSpawnIntervalChange = (uuid: string, spawnInterval: number | string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -132,24 +132,24 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleSpeedChange = (speed: number) => {
|
// const handleSpeedChange = (speed: number) => {
|
||||||
// if (!selectedPath) return;
|
// if (!selectedPath) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) =>
|
// const updatedPaths = simulationStates.map((path) =>
|
||||||
// path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path
|
// path.modeluuid === selectedPath.path.modeluuid ? { ...path, speed } : path
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } });
|
// setSelectedPath({ ...selectedPath, path: { ...selectedPath.path, speed } });
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleAddTrigger = () => {
|
// const handleAddTrigger = () => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) => {
|
// points: path.points.map((point) => {
|
||||||
// if (point.uuid === selectedActionSphere.points.uuid) {
|
// if (point.uuid === selectedActionSphere.points.uuid) {
|
||||||
|
@ -167,13 +167,13 @@
|
||||||
// }),
|
// }),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleDeleteTrigger = (uuid: string) => {
|
// const handleDeleteTrigger = (uuid: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -182,13 +182,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleTriggerSelect = (uuid: string, triggerType: string) => {
|
// const handleTriggerSelect = (uuid: string, triggerType: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleResetPath = () => {
|
// const handleResetPath = () => {
|
||||||
|
@ -214,7 +214,7 @@
|
||||||
// const handleActionToggle = (uuid: string) => {
|
// const handleActionToggle = (uuid: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -229,13 +229,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const handleTriggerToggle = (uuid: string) => {
|
// const handleTriggerToggle = (uuid: string) => {
|
||||||
// if (!selectedActionSphere) return;
|
// if (!selectedActionSphere) return;
|
||||||
|
|
||||||
// const updatedPaths = simulationPaths.map((path) => ({
|
// const updatedPaths = simulationStates.map((path) => ({
|
||||||
// ...path,
|
// ...path,
|
||||||
// points: path.points.map((point) =>
|
// points: path.points.map((point) =>
|
||||||
// point.uuid === selectedActionSphere.points.uuid
|
// point.uuid === selectedActionSphere.points.uuid
|
||||||
|
@ -250,13 +250,13 @@
|
||||||
// ),
|
// ),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// setSimulationPaths(updatedPaths);
|
// setSimulationStates(updatedPaths);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// const selectedPoint = useMemo(() => {
|
// const selectedPoint = useMemo(() => {
|
||||||
// if (!selectedActionSphere) return null;
|
// if (!selectedActionSphere) return null;
|
||||||
// return simulationPaths.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.points.uuid);
|
// return simulationStates.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.points.uuid);
|
||||||
// }, [selectedActionSphere, simulationPaths]);
|
// }, [selectedActionSphere, simulationStates]);
|
||||||
|
|
||||||
// const createPath = () => {
|
// const createPath = () => {
|
||||||
// setActiveButton(activeButton !== 'addMaterialPath' ? 'addMaterialPath' : null);
|
// setActiveButton(activeButton !== 'addMaterialPath' ? 'addMaterialPath' : null);
|
||||||
|
|
|
@ -11,13 +11,13 @@ type PathPoint = {
|
||||||
};
|
};
|
||||||
|
|
||||||
type PathCreatorProps = {
|
type PathCreatorProps = {
|
||||||
simulationPaths: PathPoint[][];
|
simulationStates: PathPoint[][];
|
||||||
setSimulationPaths: React.Dispatch<React.SetStateAction<PathPoint[][]>>;
|
setSimulationStates: React.Dispatch<React.SetStateAction<PathPoint[][]>>;
|
||||||
connections: { start: PathPoint; end: PathPoint }[];
|
connections: { start: PathPoint; end: PathPoint }[];
|
||||||
setConnections: React.Dispatch<React.SetStateAction<{ start: PathPoint; end: PathPoint }[]>>
|
setConnections: React.Dispatch<React.SetStateAction<{ start: PathPoint; end: PathPoint }[]>>
|
||||||
};
|
};
|
||||||
|
|
||||||
const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConnections }: PathCreatorProps) => {
|
const PathCreator = ({ simulationStates, setSimulationStates, connections, setConnections }: PathCreatorProps) => {
|
||||||
const { camera, scene, raycaster, pointer, gl } = useThree();
|
const { camera, scene, raycaster, pointer, gl } = useThree();
|
||||||
const { drawMaterialPath } = useDrawMaterialPath();
|
const { drawMaterialPath } = useDrawMaterialPath();
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConn
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (drag || e.button === 0) return;
|
if (drag || e.button === 0) return;
|
||||||
if (currentPath.length > 1) {
|
if (currentPath.length > 1) {
|
||||||
setSimulationPaths((prevPaths) => [...prevPaths, currentPath]);
|
setSimulationStates((prevPaths) => [...prevPaths, currentPath]);
|
||||||
}
|
}
|
||||||
setCurrentPath([]);
|
setCurrentPath([]);
|
||||||
setTemporaryPoint(null);
|
setTemporaryPoint(null);
|
||||||
|
@ -125,7 +125,7 @@ const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConn
|
||||||
canvasElement.addEventListener("contextmenu", onContextMenu);
|
canvasElement.addEventListener("contextmenu", onContextMenu);
|
||||||
} else {
|
} else {
|
||||||
if (currentPath.length > 1) {
|
if (currentPath.length > 1) {
|
||||||
setSimulationPaths((prevPaths) => [...prevPaths, currentPath]);
|
setSimulationStates((prevPaths) => [...prevPaths, currentPath]);
|
||||||
}
|
}
|
||||||
setCurrentPath([]);
|
setCurrentPath([]);
|
||||||
setTemporaryPoint(null);
|
setTemporaryPoint(null);
|
||||||
|
@ -179,25 +179,25 @@ const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConn
|
||||||
if (selectedPoint) {
|
if (selectedPoint) {
|
||||||
const updatedPosition = e.target.object.position.clone();
|
const updatedPosition = e.target.object.position.clone();
|
||||||
const updatedRotation = e.target.object.quaternion.clone();
|
const updatedRotation = e.target.object.quaternion.clone();
|
||||||
const updatedPaths = simulationPaths.map((path) =>
|
const updatedPaths = simulationStates.map((path) =>
|
||||||
path.map((p) =>
|
path.map((p) =>
|
||||||
p.uuid === selectedPoint.uuid ? { ...p, position: updatedPosition, rotation: updatedRotation } : p
|
p.uuid === selectedPoint.uuid ? { ...p, position: updatedPosition, rotation: updatedRotation } : p
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
setSimulationPaths(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const meshContext = (uuid: string) => {
|
const meshContext = (uuid: string) => {
|
||||||
const pathIndex = simulationPaths.findIndex(path => path.some(point => point.uuid === uuid));
|
const pathIndex = simulationStates.findIndex(path => path.some(point => point.uuid === uuid));
|
||||||
if (pathIndex === -1) return;
|
if (pathIndex === -1) return;
|
||||||
|
|
||||||
const clickedPoint = simulationPaths[pathIndex].find(point => point.uuid === uuid);
|
const clickedPoint = simulationStates[pathIndex].find(point => point.uuid === uuid);
|
||||||
if (!clickedPoint) return;
|
if (!clickedPoint) return;
|
||||||
|
|
||||||
const isStart = simulationPaths[pathIndex][0].uuid === uuid;
|
const isStart = simulationStates[pathIndex][0].uuid === uuid;
|
||||||
const isEnd = simulationPaths[pathIndex][simulationPaths[pathIndex].length - 1].uuid === uuid;
|
const isEnd = simulationStates[pathIndex][simulationStates[pathIndex].length - 1].uuid === uuid;
|
||||||
|
|
||||||
if (pathIndex === 0 && isStart) {
|
if (pathIndex === 0 && isStart) {
|
||||||
console.log("The first-ever point is not connectable.");
|
console.log("The first-ever point is not connectable.");
|
||||||
|
@ -285,8 +285,8 @@ const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConn
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<group name='pathObjects'>
|
<group name='pathObjects'>
|
||||||
{/* Render finalized simulationPaths */}
|
{/* Render finalized simulationStates */}
|
||||||
{simulationPaths.map((path, pathIndex) => (
|
{simulationStates.map((path, pathIndex) => (
|
||||||
<group key={`path-line-${pathIndex}`}>
|
<group key={`path-line-${pathIndex}`}>
|
||||||
<Line
|
<Line
|
||||||
name={`path-line-${pathIndex}`}
|
name={`path-line-${pathIndex}`}
|
||||||
|
@ -299,7 +299,7 @@ const PathCreator = ({ simulationPaths, setSimulationPaths, connections, setConn
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Render finalized points */}
|
{/* Render finalized points */}
|
||||||
{simulationPaths.map((path) =>
|
{simulationStates.map((path) =>
|
||||||
path.map((point) => (
|
path.map((point) => (
|
||||||
<mesh
|
<mesh
|
||||||
key={`path-point-${point.uuid}`}
|
key={`path-point-${point.uuid}`}
|
||||||
|
|
|
@ -10,13 +10,13 @@ type PathPoint = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function Simulation() {
|
function Simulation() {
|
||||||
const [simulationPaths, setSimulationPaths] = useState<{ position: THREE.Vector3; rotation: THREE.Quaternion; uuid: string }[][]>([]);
|
const [simulationStates, setSimulationStates] = useState<{ position: THREE.Vector3; rotation: THREE.Quaternion; uuid: string }[][]>([]);
|
||||||
const [connections, setConnections] = useState<{ start: PathPoint; end: PathPoint }[]>([]);
|
const [connections, setConnections] = useState<{ start: PathPoint; end: PathPoint }[]>([]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PathCreator simulationPaths={simulationPaths} setSimulationPaths={setSimulationPaths} connections={connections} setConnections={setConnections} />
|
<PathCreator simulationStates={simulationStates} setSimulationStates={setSimulationStates} connections={connections} setConnections={setConnections} />
|
||||||
{simulationPaths.map((path, index) => (
|
{simulationStates.map((path, index) => (
|
||||||
<PathFlow key={index} path={path} connections={connections} />
|
<PathFlow key={index} path={path} connections={connections} />
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -341,8 +341,8 @@ export const useSelectedPath = create<any>((set: any) => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
interface SimulationPathsStore {
|
interface SimulationPathsStore {
|
||||||
simulationPaths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[];
|
simulationStates: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[];
|
||||||
setSimulationPaths: (
|
setSimulationStates: (
|
||||||
paths:
|
paths:
|
||||||
| (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
| (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
||||||
| ((prev: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
| ((prev: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
||||||
|
@ -350,12 +350,12 @@ interface SimulationPathsStore {
|
||||||
) => void;
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSimulationPaths = create<SimulationPathsStore>((set) => ({
|
export const useSimulationStates = create<SimulationPathsStore>((set) => ({
|
||||||
simulationPaths: [],
|
simulationStates: [],
|
||||||
setSimulationPaths: (paths) =>
|
setSimulationStates: (paths) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
simulationPaths:
|
simulationStates:
|
||||||
typeof paths === "function" ? paths(state.simulationPaths) : paths,
|
typeof paths === "function" ? paths(state.simulationStates) : paths,
|
||||||
})),
|
})),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue