added backend connection for conveyor and vehicle mechanics

This commit is contained in:
Jerald-Golden-B 2025-04-04 16:57:18 +05:30
parent e1892b0b00
commit cf6946750b
24 changed files with 595 additions and 280 deletions

View File

@ -11,7 +11,7 @@ REACT_APP_SERVER_REST_API_BASE_URL=185.100.212.76:5000
REACT_APP_SERVER_MARKETPLACE_URL=185.100.212.76:50011 REACT_APP_SERVER_MARKETPLACE_URL=185.100.212.76:50011
# Base URL for the asset library server, used for asset library images and model blob id. # Base URL for the asset library server, used for asset library images and model blob id.
REACT_APP_SERVER_ASSET_LIBRARY_URL=192.168.0.111:3501 REACT_APP_SERVER_ASSET_LIBRARY_URL=185.100.212.76:50011
# base url for IoT socket server # base url for IoT socket server
REACT_APP_IOT_SOCKET_SERVER_URL =185.100.212.76:5010 REACT_APP_IOT_SOCKET_SERVER_URL =185.100.212.76:5010

View File

@ -37,20 +37,18 @@ const ConveyorMechanics: React.FC = () => {
(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.point.uuid); .find((point) => point.uuid === selectedActionSphere.points.uuid);
}, [selectedActionSphere, simulationPaths]); }, [selectedActionSphere, simulationPaths]);
const updateBackend = async (updatedPath: Types.ConveyorEventsSchema | undefined) => { const updateBackend = async (updatedPath: Types.ConveyorEventsSchema | undefined) => {
if (!updatedPath) return; if (!updatedPath) return;
// const email = localStorage.getItem("email"); const email = localStorage.getItem("email");
// const organization = email ? email.split("@")[1].split(".")[0] : ""; const organization = email ? email.split("@")[1].split(".")[0] : "";
// console.log('updatedPath: ', updatedPath); await setEventApi(
// const a = await setEventApi( organization,
// organization, updatedPath.modeluuid,
// updatedPath.modeluuid, { type: "Conveyor", points: updatedPath.points, speed: updatedPath.speed }
// updatedPath.points );
// );
// console.log('a: ', a);
} }
const handleAddAction = () => { const handleAddAction = () => {
@ -61,7 +59,7 @@ const ConveyorMechanics: React.FC = () => {
return { return {
...path, ...path,
points: path.points.map((point) => { points: path.points.map((point) => {
if (point.uuid === selectedActionSphere.point.uuid) { if (point.uuid === selectedActionSphere.points.uuid) {
const actionIndex = point.actions.length; const actionIndex = point.actions.length;
const newAction = { const newAction = {
uuid: THREE.MathUtils.generateUUID(), uuid: THREE.MathUtils.generateUUID(),
@ -86,7 +84,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -102,7 +100,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.filter( actions: point.actions.filter(
@ -119,7 +117,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -135,7 +133,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.map((action) => actions: point.actions.map((action) =>
@ -167,7 +165,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -181,7 +179,7 @@ const ConveyorMechanics: React.FC = () => {
(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((p) => p.uuid === selectedActionSphere.point.uuid) .find((p) => p.uuid === selectedActionSphere.points.uuid)
?.actions.find((a) => a.uuid === uuid); ?.actions.find((a) => a.uuid === uuid);
if (updatedAction) { if (updatedAction) {
@ -202,7 +200,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.map((action) => actions: point.actions.map((action) =>
@ -222,7 +220,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -249,7 +247,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.map((action) => actions: point.actions.map((action) =>
@ -266,7 +264,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -285,7 +283,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.map((action) => actions: point.actions.map((action) =>
@ -304,7 +302,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -323,7 +321,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -340,7 +338,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => { points: path.points.map((point) => {
if (point.uuid === selectedActionSphere.point.uuid) { if (point.uuid === selectedActionSphere.points.uuid) {
const triggerIndex = point.triggers.length; const triggerIndex = point.triggers.length;
const newTrigger = { const newTrigger = {
uuid: THREE.MathUtils.generateUUID(), uuid: THREE.MathUtils.generateUUID(),
@ -362,7 +360,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -378,7 +376,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
triggers: point.triggers.filter( triggers: point.triggers.filter(
@ -395,7 +393,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -411,7 +409,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
triggers: point.triggers.map((trigger) => triggers: point.triggers.map((trigger) =>
@ -430,7 +428,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -456,7 +454,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
actions: point.actions.map((action) => ({ actions: point.actions.map((action) => ({
@ -474,7 +472,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -502,7 +500,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
triggers: point.triggers.map((trigger) => ({ triggers: point.triggers.map((trigger) => ({
@ -520,7 +518,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);
@ -547,7 +545,7 @@ const ConveyorMechanics: React.FC = () => {
? { ? {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
triggers: point.triggers.map((trigger) => triggers: point.triggers.map((trigger) =>
@ -566,7 +564,7 @@ const ConveyorMechanics: React.FC = () => {
(path): path is Types.ConveyorEventsSchema => (path): path is Types.ConveyorEventsSchema =>
path.type === "Conveyor" && path.type === "Conveyor" &&
path.points.some( path.points.some(
(point) => point.uuid === selectedActionSphere.point.uuid (point) => point.uuid === selectedActionSphere.points.uuid
) )
); );
updateBackend(updatedPath); updateBackend(updatedPath);

View File

@ -4,6 +4,7 @@ import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
import { useEditingPoint, useEyeDropMode, usePreviewPosition, useSelectedActionSphere, useSimulationPaths } from "../../../../store/store"; import { useEditingPoint, useEyeDropMode, usePreviewPosition, useSelectedActionSphere, useSimulationPaths } 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";
const VehicleMechanics: React.FC = () => { const VehicleMechanics: React.FC = () => {
const { selectedActionSphere } = useSelectedActionSphere(); const { selectedActionSphere } = useSelectedActionSphere();
@ -15,42 +16,53 @@ const VehicleMechanics: React.FC = () => {
const propertiesContainerRef = useRef<HTMLDivElement>(null); const propertiesContainerRef = useRef<HTMLDivElement>(null);
const { selectedPoint, connectedPointUuids } = useMemo(() => { const { selectedPoint, connectedPointUuids } = useMemo(() => {
if (!selectedActionSphere?.point?.uuid) return { selectedPoint: null, connectedPointUuids: [] }; if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null, connectedPointUuids: [] };
const vehiclePaths = simulationPaths.filter( const vehiclePaths = simulationPaths.filter(
(path): path is Types.VehicleEventsSchema => path.type === "Vehicle" (path): path is Types.VehicleEventsSchema => path.type === "Vehicle"
); );
const point = vehiclePaths.find( const points = vehiclePaths.find(
(path) => path.point.uuid === selectedActionSphere.point.uuid (path) => path.points.uuid === selectedActionSphere.points.uuid
)?.point; )?.points;
if (!point) return { selectedPoint: null, connectedPointUuids: [] }; if (!points) return { selectedPoint: null, connectedPointUuids: [] };
const connectedUuids: string[] = []; const connectedUuids: string[] = [];
if (point.connections?.targets) { if (points.connections?.targets) {
point.connections.targets.forEach(target => { points.connections.targets.forEach(target => {
connectedUuids.push(target.pointUUID); connectedUuids.push(target.pointUUID);
}); });
} }
return { return {
selectedPoint: point, selectedPoint: points,
connectedPointUuids: connectedUuids connectedPointUuids: connectedUuids
}; };
}, [selectedActionSphere, simulationPaths]); }, [selectedActionSphere, simulationPaths]);
const handleActionUpdate = React.useCallback((updatedAction: Partial<Types.VehicleEventsSchema['point']['actions']>) => { const updateBackend = async (updatedPath: Types.VehicleEventsSchema | undefined) => {
if (!selectedActionSphere?.point?.uuid) return; if (!updatedPath) return;
const email = localStorage.getItem("email");
const organization = email ? email.split("@")[1].split(".")[0] : "";
await setEventApi(
organization,
updatedPath.modeluuid,
{ type: "Vehicle", points: updatedPath.points }
);
}
const handleActionUpdate = React.useCallback((updatedAction: Partial<Types.VehicleEventsSchema['points']['actions']>) => {
if (!selectedActionSphere?.points?.uuid) return;
const updatedPaths = simulationPaths.map((path) => { const updatedPaths = simulationPaths.map((path) => {
if (path.type === "Vehicle" && path.point.uuid === selectedActionSphere.point.uuid) { if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
return { return {
...path, ...path,
point: { points: {
...path.point, ...path.points,
actions: { actions: {
...path.point.actions, ...path.points.actions,
...updatedAction ...updatedAction
} }
} }
@ -59,14 +71,15 @@ const VehicleMechanics: React.FC = () => {
return path; return path;
}); });
const updatedPath = updatedPaths.find(
(path): path is Types.VehicleEventsSchema =>
path.type === "Vehicle" &&
path.points.uuid === selectedActionSphere.points.uuid
);
updateBackend(updatedPath);
setSimulationPaths(updatedPaths); setSimulationPaths(updatedPaths);
}, [selectedActionSphere?.point?.uuid, simulationPaths, setSimulationPaths]); }, [selectedActionSphere?.points?.uuid, simulationPaths, setSimulationPaths]);
const handleStartPointChange = React.useCallback((position: { x: number, y: number }) => {
}, [handleActionUpdate]);
const handleEndPointChange = React.useCallback((position: { x: number, y: number }) => {
}, [handleActionUpdate]);
const handleHitCountChange = React.useCallback((hitCount: number) => { const handleHitCountChange = React.useCallback((hitCount: number) => {
handleActionUpdate({ hitCount }); handleActionUpdate({ hitCount });
@ -77,14 +90,14 @@ const VehicleMechanics: React.FC = () => {
}, [handleActionUpdate]); }, [handleActionUpdate]);
const handleSpeedChange = React.useCallback((speed: number) => { const handleSpeedChange = React.useCallback((speed: number) => {
if (!selectedActionSphere?.point?.uuid) return; if (!selectedActionSphere?.points?.uuid) return;
const updatedPaths = simulationPaths.map((path) => { const updatedPaths = simulationPaths.map((path) => {
if (path.type === "Vehicle" && path.point.uuid === selectedActionSphere.point.uuid) { if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
return { return {
...path, ...path,
point: { points: {
...path.point, ...path.points,
speed: speed speed: speed
} }
}; };
@ -92,8 +105,15 @@ const VehicleMechanics: React.FC = () => {
return path; return path;
}); });
const updatedPath = updatedPaths.find(
(path): path is Types.VehicleEventsSchema =>
path.type === "Vehicle" &&
path.points.uuid === selectedActionSphere.points.uuid
);
updateBackend(updatedPath);
setSimulationPaths(updatedPaths); setSimulationPaths(updatedPaths);
}, [selectedActionSphere?.point?.uuid, simulationPaths, setSimulationPaths]); }, [selectedActionSphere?.points?.uuid, simulationPaths, setSimulationPaths]);
const handleStartEyeDropClick = () => { const handleStartEyeDropClick = () => {
setEditingPoint('start'); setEditingPoint('start');

View File

@ -9,13 +9,12 @@ import {
useSelectedActionSphere, useSelectedActionSphere,
useSimulationPaths, useSimulationPaths,
} from "../../../store/store"; } from "../../../store/store";
import * as CONSTANTS from "../../../types/world/worldConstants";
const Agv = ({ const Agv = ({
lines, lines,
plane,
}: { }: {
lines: Types.RefLines; lines: Types.RefLines;
plane: Types.RefMesh;
}) => { }) => {
const [pathPoints, setPathPoints] = useState< const [pathPoints, setPathPoints] = useState<
{ {
@ -34,7 +33,6 @@ const Agv = ({
(val: any) => val.modelName === "agv" (val: any) => val.modelName === "agv"
); );
console.log("agvModels: ", agvModels);
let findMesh = agvModels.filter( let findMesh = agvModels.filter(
(val: any) => (val: any) =>
val.modeluuid === selectedActionSphere?.path?.modeluuid && val.modeluuid === selectedActionSphere?.path?.modeluuid &&
@ -43,37 +41,37 @@ const Agv = ({
const result = const result =
findMesh.length > 0 && findMesh.length > 0 &&
findMesh[0].type === "Vehicle" && findMesh[0].type === "Vehicle" &&
typeof findMesh[0].point?.actions.start === "object" && typeof findMesh[0].points?.actions.start === "object" &&
typeof findMesh[0].point?.actions.end === "object" && typeof findMesh[0].points?.actions.end === "object" &&
"x" in findMesh[0].point.actions.start && "x" in findMesh[0].points.actions.start &&
"y" in findMesh[0].point.actions.start && "y" in findMesh[0].points.actions.start &&
"x" in findMesh[0].point.actions.end && "x" in findMesh[0].points.actions.end &&
"y" in findMesh[0].point.actions.end "y" in findMesh[0].points.actions.end
? [ ? [
{ {
modelUuid: findMesh[0].modeluuid, // Ensure it's a number modelUuid: findMesh[0].modeluuid, // Ensure it's a number
modelSpeed: findMesh[0].point.speed, modelSpeed: findMesh[0].points.speed,
bufferTime: findMesh[0].point.actions.buffer, bufferTime: findMesh[0].points.actions.buffer,
points: [ points: [
{ {
x: findMesh[0].position[0], x: findMesh[0].position[0],
y: findMesh[0].position[1], y: findMesh[0].position[1],
z: findMesh[0].position[2], z: findMesh[0].position[2],
}, },
{ {
x: findMesh[0].point.actions.start.x, x: findMesh[0].points.actions.start.x,
y: 0, y: 0,
z: findMesh[0].point.actions.start.y, z: findMesh[0].points.actions.start.y,
}, },
{ {
x: findMesh[0].point.actions.end.x, x: findMesh[0].points.actions.end.x,
y: 0, y: 0,
z: findMesh[0].point.actions.end.y, z: findMesh[0].points.actions.end.y,
}, },
], ],
}, },
] ]
: []; : [];
if (result.length > 0) { if (result.length > 0) {
// setPathPoints((prev) => [...prev, ...result]); // setPathPoints((prev) => [...prev, ...result]);
@ -106,12 +104,11 @@ const Agv = ({
return ( return (
<> <>
<PolygonGenerator groupRef={groupRef} lines={lines} plane={plane} /> <PolygonGenerator groupRef={groupRef} lines={lines} />
<NavMeshDetails <NavMeshDetails
lines={lines} lines={lines}
setNavMesh={setNavMesh} setNavMesh={setNavMesh}
groupRef={groupRef} groupRef={groupRef}
plane={plane}
/> />
{pathPoints.map((pair, i) => ( {pathPoints.map((pair, i) => (
<> <>
@ -149,7 +146,12 @@ const Agv = ({
)} */} )} */}
</> </>
))} ))}
<group ref={groupRef} visible={false} name="Meshes"></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>
</> </>
); );
}; };

View File

@ -10,14 +10,12 @@ interface NavMeshDetailsProps {
setNavMesh: (navMesh: any) => void; setNavMesh: (navMesh: any) => void;
groupRef: React.MutableRefObject<THREE.Group | null>; groupRef: React.MutableRefObject<THREE.Group | null>;
lines: Types.RefLines; lines: Types.RefLines;
plane: Types.RefMesh;
} }
export default function NavMeshDetails({ export default function NavMeshDetails({
lines, lines,
setNavMesh, setNavMesh,
groupRef, groupRef,
plane,
}: NavMeshDetailsProps) { }: NavMeshDetailsProps) {
const { scene } = useThree(); const { scene } = useThree();
@ -34,14 +32,14 @@ export default function NavMeshDetails({
const [positions, indices] = getPositionsAndIndices(meshes); const [positions, indices] = getPositionsAndIndices(meshes);
const cs = 0.25; const cellSize = 0.35;
const ch = 0.69; const cellHeight = 0.7;
const walkableRadius = 0.5; const walkableRadius = 0.5;
const { success, navMesh } = generateSoloNavMesh(positions, indices, { const { success, navMesh } = generateSoloNavMesh(positions, indices, {
cs, cs: cellSize,
ch, ch: cellHeight,
walkableRadius: Math.round(walkableRadius / ch), walkableRadius: Math.round(walkableRadius / cellHeight),
}); });
if (!success || !navMesh) { if (!success || !navMesh) {
@ -50,10 +48,14 @@ export default function NavMeshDetails({
setNavMesh(navMesh); setNavMesh(navMesh);
scene.children
.filter((child) => child instanceof DebugDrawer)
.forEach((child) => scene.remove(child));
const debugDrawer = new DebugDrawer(); const debugDrawer = new DebugDrawer();
debugDrawer.drawNavMesh(navMesh); debugDrawer.drawNavMesh(navMesh);
// scene.add(debugDrawer); scene.add(debugDrawer);
} catch (error) {} } catch (error) { }
}; };
initializeNavigation(); initializeNavigation();

View File

@ -6,21 +6,12 @@ import arrayLinesToObject from "../geomentries/lines/lineConvertions/arrayLinesT
interface PolygonGeneratorProps { interface PolygonGeneratorProps {
groupRef: React.MutableRefObject<THREE.Group | null>; groupRef: React.MutableRefObject<THREE.Group | null>;
lines: Types.RefLines; lines: Types.RefLines;
plane: Types.RefMesh;
} }
export default function PolygonGenerator({ export default function PolygonGenerator({
groupRef, groupRef,
lines, lines,
plane,
}: PolygonGeneratorProps) { }: PolygonGeneratorProps) {
// const [rooms, setRooms] = useState<THREE.Vector3[][]>([]);
useEffect(() => {
if (groupRef.current && plane.current) {
groupRef.current.add(plane.current.clone());
}
}, [groupRef, plane]);
useEffect(() => { useEffect(() => {
let allLines = arrayLinesToObject(lines.current); let allLines = arrayLinesToObject(lines.current);
@ -37,13 +28,14 @@ export default function PolygonGenerator({
uuid: point.uuid, uuid: point.uuid,
})) }))
); );
if (!result || result.some((line) => !line)) { if (!result || result.some((line) => !line)) {
return; return;
} }
const lineFeatures = result?.map((line: any) => const lineFeatures = result?.map((line: any) =>
turf.lineString(line.map((p: any) => p?.position)) turf.lineString(line.map((p: any) => p?.position))
); );
const polygons = turf.polygonize(turf.featureCollection(lineFeatures)); const polygons = turf.polygonize(turf.featureCollection(lineFeatures));
renderWallGeometry(wallPoints); renderWallGeometry(wallPoints);
@ -79,8 +71,8 @@ export default function PolygonGenerator({
groupRef.current?.add(mesh); groupRef.current?.add(mesh);
} }
}); });
} }
}, [lines.current]); }, [lines.current]);
const renderWallGeometry = (walls: THREE.Vector3[][]) => { const renderWallGeometry = (walls: THREE.Vector3[][]) => {

View File

@ -136,7 +136,7 @@ async function handleModelLoad(
tempLoader.current = undefined; tempLoader.current = undefined;
} }
const newFloorItem: Types.FloorItemType = { const newFloorItem: Types.EventData = {
modeluuid: model.uuid, modeluuid: model.uuid,
modelname: selectedItem.name, modelname: selectedItem.name,
modelfileID: selectedItem.id, modelfileID: selectedItem.id,
@ -154,7 +154,7 @@ async function handleModelLoad(
if (res.type === "Conveyor") { if (res.type === "Conveyor") {
const pointUUIDs = res.points.map(() => THREE.MathUtils.generateUUID()); const pointUUIDs = res.points.map(() => THREE.MathUtils.generateUUID());
const backendEventData: Extract<Types.FloorItemType['eventData'], { type: 'Conveyor' }> = { const backendEventData: Extract<Types.EventData['eventData'], { type: 'Conveyor' }> = {
type: 'Conveyor', type: 'Conveyor',
points: res.points.map((point: any, index: number) => ({ points: res.points.map((point: any, index: number) => ({
uuid: pointUUIDs[index], uuid: pointUUIDs[index],
@ -167,7 +167,7 @@ async function handleModelLoad(
material: 'Inherit', material: 'Inherit',
delay: 'Inherit', delay: 'Inherit',
spawnInterval: 'Inherit', spawnInterval: 'Inherit',
isUsed: false isUsed: true
}], }],
triggers: [], triggers: [],
connections: { connections: {
@ -189,7 +189,7 @@ async function handleModelLoad(
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z }, // { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
// false, // false,
// true, // true,
// newFloorItem.eventData // { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed }
// ); // );
// SOCKET // SOCKET
@ -207,7 +207,6 @@ async function handleModelLoad(
socketId: socket.id socketId: socket.id
}; };
console.log('data: ', data);
setFloorItems((prevItems) => { setFloorItems((prevItems) => {
const updatedItems = [...(prevItems || []), newFloorItem]; const updatedItems = [...(prevItems || []), newFloorItem];
localStorage.setItem("FloorItems", JSON.stringify(updatedItems)); localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
@ -222,12 +221,25 @@ async function handleModelLoad(
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [ setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []), ...(prevEvents || []),
eventData as Types.ConveyorEventsSchema | Types.VehicleEventsSchema eventData as Types.ConveyorEventsSchema
]); ]);
socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} else { } else if (res.type === "Vehicle") {
const pointUUID = THREE.MathUtils.generateUUID();
const backendEventData: Extract<Types.EventData['eventData'], { type: 'Vehicle' }> = {
type: "Vehicle",
points: {
uuid: pointUUID,
position: res.points.position as [number, number, number],
actions: { uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Start', start: {}, hitCount: 1, end: {}, buffer: 0 },
connections: { source: { modelUUID: model.uuid, pointUUID: pointUUID }, targets: [] },
speed: 2,
}
}
// API // API
@ -239,7 +251,8 @@ async function handleModelLoad(
// newFloorItem.position, // newFloorItem.position,
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z }, // { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
// false, // false,
// true // true,
// { type: backendEventData.type, points: backendEventData.points }
// ); // );
// SOCKET // SOCKET
@ -253,15 +266,26 @@ async function handleModelLoad(
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z }, rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
isLocked: false, isLocked: false,
isVisible: true, isVisible: true,
eventData: { type: backendEventData.type, points: backendEventData.points },
socketId: socket.id socketId: socket.id
}; };
const eventData: any = backendEventData;
eventData.modeluuid = newFloorItem.modeluuid;
eventData.modelName = newFloorItem.modelname;
eventData.position = newFloorItem.position;
setFloorItems((prevItems) => { setFloorItems((prevItems) => {
const updatedItems = [...(prevItems || []), newFloorItem]; const updatedItems = [...(prevItems || []), newFloorItem];
localStorage.setItem("FloorItems", JSON.stringify(updatedItems)); localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
return updatedItems; return updatedItems;
}); });
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []),
eventData as Types.VehicleEventsSchema
]);
socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} }

View File

@ -111,7 +111,7 @@ const CamModelsGroup = () => {
socket.off("userDisConnectRespones"); socket.off("userDisConnectRespones");
socket.off("cameraUpdateResponse"); socket.off("cameraUpdateResponse");
}; };
}, [socket, activeUsers]); }, [socket]);
// useEffect(() => { // useEffect(() => {

View File

@ -143,10 +143,6 @@ export default function SocketResponses({
isVisible: data.data.isVisible, isVisible: data.data.isVisible,
}; };
if (data.data.eventData) {
newFloorItem.eventData = data.data.eventData;
}
setFloorItems((prevItems: any) => { setFloorItems((prevItems: any) => {
const updatedItems = [...(prevItems || []), newFloorItem]; const updatedItems = [...(prevItems || []), newFloorItem];
localStorage.setItem("FloorItems", JSON.stringify(updatedItems)); localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
@ -221,10 +217,6 @@ export default function SocketResponses({
isVisible: data.data.isVisible, isVisible: data.data.isVisible,
}; };
if (data.data.eventData) {
newFloorItem.eventData = data.data.eventData;
}
setFloorItems((prevItems: any) => { setFloorItems((prevItems: any) => {
const updatedItems = [...(prevItems || []), newFloorItem]; const updatedItems = [...(prevItems || []), newFloorItem];
localStorage.setItem("FloorItems", JSON.stringify(updatedItems)); localStorage.setItem("FloorItems", JSON.stringify(updatedItems));

View File

@ -26,7 +26,7 @@ async function loadInitialFloorItems(
if (items.message === "floorItems not found") return; if (items.message === "floorItems not found") return;
if (items) { if (items) {
const storedFloorItems: Types.FloorItems = items; const storedFloorItems: Types.EventData[] = items;
const loader = new GLTFLoader(); const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader(); const dracoLoader = new DRACOLoader();
@ -53,7 +53,6 @@ async function loadInitialFloorItems(
}); });
for (const item of storedFloorItems) { for (const item of storedFloorItems) {
console.log('item: ', item);
if (!item.modelfileID) return; if (!item.modelfileID) return;
const itemPosition = new THREE.Vector3(item.position[0], item.position[1], item.position[2]); const itemPosition = new THREE.Vector3(item.position[0], item.position[1], item.position[2]);
let storedPosition; let storedPosition;
@ -155,7 +154,7 @@ async function loadInitialFloorItems(
function processLoadedModel( function processLoadedModel(
gltf: any, gltf: any,
item: Types.FloorItemType, item: Types.EventData,
itemsGroup: Types.RefGroup, itemsGroup: Types.RefGroup,
setFloorItems: Types.setFloorItemSetState, setFloorItems: Types.setFloorItemSetState,
setSimulationPaths: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void setSimulationPaths: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
@ -193,7 +192,7 @@ function processLoadedModel(
}, },
]); ]);
if (item.eventData || item.modelfileID === '67e3da19c2e8f37134526e6a') { if (item.eventData) {
processEventData(item, setSimulationPaths); processEventData(item, setSimulationPaths);
} }
@ -201,7 +200,7 @@ function processLoadedModel(
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.FloorItemType, setSimulationPaths: any) { function processEventData(item: Types.EventData, setSimulationPaths: any) {
if (item.eventData?.type === 'Conveyor') { if (item.eventData?.type === 'Conveyor') {
@ -215,29 +214,19 @@ function processEventData(item: Types.FloorItemType, setSimulationPaths: any) {
...(prevEvents || []), ...(prevEvents || []),
data as Types.ConveyorEventsSchema data as Types.ConveyorEventsSchema
]); ]);
} else { } else {
const pointUUID = THREE.MathUtils.generateUUID(); const data: any = item.eventData;
const pointPosition = new THREE.Vector3(0, 1.3, 0); data.modeluuid = item.modeluuid;
data.modelName = item.modelname;
data.position = item.position;
const newVehiclePath: Types.VehicleEventsSchema = { setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
modeluuid: item.modeluuid,
modelName: item.modelname,
type: 'Vehicle',
point: {
uuid: pointUUID,
position: [pointPosition.x, pointPosition.y, pointPosition.z],
actions: { uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Start', start: {}, hitCount: 1, end: {}, buffer: 0 },
connections: { source: { pathUUID: item.modeluuid, pointUUID: pointUUID }, targets: [] },
speed: 2,
},
position: [...item.position],
};
setSimulationPaths((prevEvents: (Types.VehicleEventsSchema)[]) => [
...(prevEvents || []), ...(prevEvents || []),
newVehiclePath as Types.VehicleEventsSchema data as Types.VehicleEventsSchema
]); ]);
} }
} }

View File

@ -236,10 +236,91 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [ setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []), ...(prevEvents || []),
newEventData as Types.ConveyorEventsSchema | Types.VehicleEventsSchema newEventData as Types.ConveyorEventsSchema
]); ]);
socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} else if (eventData.type === 'Vehicle' && eventData) {
const createVehiclePoint = () => {
const pointUUID = THREE.MathUtils.generateUUID();
const vehiclePoint = (eventData as Types.VehicleEventsSchema)?.points;
const hasActions = vehiclePoint?.actions !== undefined;
const defaultAction = {
uuid: THREE.MathUtils.generateUUID(),
name: 'Action 1',
type: 'Inherit',
start: {},
hitCount: 0,
end: {},
buffer: 0
};
return {
uuid: pointUUID,
position: vehiclePoint?.position,
actions: hasActions
? {
...vehiclePoint.actions,
uuid: THREE.MathUtils.generateUUID()
}
: defaultAction,
connections: {
source: { modelUUID: obj.uuid, pointUUID },
targets: []
},
speed: vehiclePoint?.speed || 1
};
};
const backendEventData = {
type: 'Vehicle',
points: createVehiclePoint(),
speed: (eventData as Types.VehicleEventsSchema)?.points.speed
};
// API
// setFloorItemApi(
// organization,
// obj.uuid,
// obj.userData.name,
// obj.userData.modelId,
// [worldPosition.x, worldPosition.y, worldPosition.z],
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
// false,
// true,
// { type: backendEventData.type, points: backendEventData.points }
// );
// SOCKET
const data = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
isLocked: false,
isVisible: true,
eventData: backendEventData,
socketId: socket.id,
};
const newEventData: any = backendEventData;
newEventData.modeluuid = newFloorItem.modeluuid;
newEventData.modelName = newFloorItem.modelname;
newEventData.position = newFloorItem.position;
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []),
newEventData as Types.VehicleEventsSchema
]);
socket.emit("v2:model-asset:add", data);
} }
} else { } else {

View File

@ -5,6 +5,7 @@ import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, u
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";
import { setFloorItemApi } from "../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedObjects, setpastedObjects, selectionGroup, movedObjects, setMovedObjects, rotatedObjects, setRotatedObjects, boundingBoxRef }: any) => { const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedObjects, setpastedObjects, selectionGroup, movedObjects, setMovedObjects, rotatedObjects, setRotatedObjects, boundingBoxRef }: any) => {
const { camera, controls, gl, scene, pointer, raycaster } = useThree(); const { camera, controls, gl, scene, pointer, raycaster } = useThree();
@ -182,16 +183,16 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
//REST //REST
// await setFloorItemApi( // setFloorItemApi(
// organization, // organization,
// obj.uuid, // obj.uuid,
// obj.userData.name, // obj.userData.name,
// obj.userData.modelId,
// [worldPosition.x, worldPosition.y, worldPosition.z], // [worldPosition.x, worldPosition.y, worldPosition.z],
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z }, // { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
// obj.userData.modelId,
// false, // false,
// true, // true,
// backendEventData // { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed }
// ); // );
//SOCKET //SOCKET
@ -217,10 +218,90 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [ setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []), ...(prevEvents || []),
newEventData as Types.ConveyorEventsSchema | Types.VehicleEventsSchema newEventData as Types.ConveyorEventsSchema
]); ]);
socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} else if (eventData.type === 'Vehicle' && eventData) {
const createVehiclePoint = () => {
const pointUUID = THREE.MathUtils.generateUUID();
const vehiclePoint = (eventData as Types.VehicleEventsSchema)?.points;
const hasActions = vehiclePoint?.actions !== undefined;
const defaultAction = {
uuid: THREE.MathUtils.generateUUID(),
name: 'Action 1',
type: 'Inherit',
start: {},
hitCount: 0,
end: {},
buffer: 0
};
return {
uuid: pointUUID,
position: vehiclePoint?.position,
actions: hasActions
? {
...vehiclePoint.actions,
uuid: THREE.MathUtils.generateUUID()
}
: defaultAction,
connections: {
source: { modelUUID: obj.uuid, pointUUID },
targets: []
},
speed: vehiclePoint?.speed || 2
};
};
const backendEventData = {
type: 'Vehicle',
points: createVehiclePoint()
};
// API
setFloorItemApi(
organization,
obj.uuid,
obj.userData.name,
obj.userData.modelId,
[worldPosition.x, worldPosition.y, worldPosition.z],
{ "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
false,
true,
{ type: backendEventData.type, points: backendEventData.points }
);
// SOCKET
const data = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
isLocked: false,
isVisible: true,
eventData: backendEventData,
socketId: socket.id,
};
const newEventData: any = backendEventData;
newEventData.modeluuid = newFloorItem.modeluuid;
newEventData.modelName = newFloorItem.modelname;
newEventData.position = newFloorItem.position;
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
...(prevEvents || []),
newEventData as Types.VehicleEventsSchema
]);
// socket.emit("v2:model-asset:add", data);
} }
} else { } else {

View File

@ -238,7 +238,59 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
return updatedEvents; return updatedEvents;
}); });
// socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} else if (eventData.type === 'Vehicle' && eventData) {
const backendEventData = {
type: 'Vehicle',
points: eventData.points
};
// REST
// await setFloorItemApi(
// organization,
// obj.uuid,
// obj.userData.name,
// obj.userData.modelId,
// [worldPosition.x, worldPosition.y, worldPosition.z],
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
// false,
// true,
// backendEventData
// );
//SOCKET
const data = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
isLocked: false,
isVisible: true,
eventData: backendEventData,
socketId: socket.id,
};
const newEventData: any = backendEventData;
newEventData.modeluuid = newFloorItem.modeluuid;
newEventData.modelName = newFloorItem.modelname;
newEventData.position = newFloorItem.position;
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
const updatedEvents = (prevEvents || []).map(event =>
event.modeluuid === newFloorItem.modeluuid
? { ...event, ...newEventData }
: event
);
return updatedEvents;
});
socket.emit("v2:model-asset:add", data);
} }
} else { } else {

View File

@ -5,6 +5,7 @@ import { useFloorItems, useSelectedAssets, useSimulationPaths, useSocketStore, u
// 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";
import { setFloorItemApi } from "../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMovedObjects, itemsGroupRef, copiedObjects, setCopiedObjects, pastedObjects, setpastedObjects, duplicatedObjects, setDuplicatedObjects, selectionGroup, boundingBoxRef }: any) { function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMovedObjects, itemsGroupRef, copiedObjects, setCopiedObjects, pastedObjects, setpastedObjects, duplicatedObjects, setDuplicatedObjects, selectionGroup, boundingBoxRef }: any) {
const { camera, controls, gl, scene, pointer, raycaster } = useThree(); const { camera, controls, gl, scene, pointer, raycaster } = useThree();
@ -197,15 +198,15 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
speed: (eventData as Types.ConveyorEventsSchema)?.speed speed: (eventData as Types.ConveyorEventsSchema)?.speed
}; };
//REST // REST
// await setFloorItemApi( // await setFloorItemApi(
// organization, // organization,
// obj.uuid, // obj.uuid,
// obj.userData.name, // obj.userData.name,
// obj.userData.modelId,
// [worldPosition.x, worldPosition.y, worldPosition.z], // [worldPosition.x, worldPosition.y, worldPosition.z],
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z }, // { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
// obj.userData.modelId,
// false, // false,
// true, // true,
// backendEventData // backendEventData
@ -241,7 +242,60 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
return updatedEvents; return updatedEvents;
}); });
// socket.emit("v2:model-asset:add", data); socket.emit("v2:model-asset:add", data);
} else if (eventData.type === 'Vehicle' && eventData) {
const backendEventData = {
type: 'Vehicle',
points: eventData.points
};
// REST
// await setFloorItemApi(
// organization,
// obj.uuid,
// obj.userData.name,
// obj.userData.modelId,
// [worldPosition.x, worldPosition.y, worldPosition.z],
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
// false,
// true,
// backendEventData
// );
//SOCKET
const data = {
organization,
modeluuid: newFloorItem.modeluuid,
modelname: newFloorItem.modelname,
modelfileID: newFloorItem.modelfileID,
position: newFloorItem.position,
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
isLocked: false,
isVisible: true,
eventData: backendEventData,
socketId: socket.id,
};
const newEventData: any = backendEventData;
newEventData.modeluuid = newFloorItem.modeluuid;
newEventData.modelName = newFloorItem.modelname;
newEventData.position = newFloorItem.position;
setSimulationPaths((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
const updatedEvents = (prevEvents || []).map(event =>
event.modeluuid === newFloorItem.modeluuid
? { ...event, ...newEventData }
: event
);
return updatedEvents;
});
socket.emit("v2:model-asset:add", data);
} }
} else { } else {

View File

@ -91,7 +91,7 @@ export default function PostProcessing() {
)} )}
{selectedActionSphere && ( {selectedActionSphere && (
<Outline <Outline
selection={[selectedActionSphere.point]} selection={[selectedActionSphere.points]}
selectionLayer={10} selectionLayer={10}
width={1000} width={1000}
blendFunction={BlendFunction.ALPHA} blendFunction={BlendFunction.ALPHA}

View File

@ -367,7 +367,9 @@ export default function World() {
/> />
{/* <DrieHtmlTemp itemsGroup={itemsGroup} /> */} {/* <DrieHtmlTemp itemsGroup={itemsGroup} /> */}
{activeModule === "simulation" && <Agv lines={lines} plane={plane} />}
{activeModule === "simulation" && <Agv lines={lines} />}
</> </>
); );
} }

View File

@ -5,12 +5,14 @@ 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, useSimulationPaths } from '../../../store/store';
import useModuleStore from '../../../store/useModuleStore'; import useModuleStore from '../../../store/useModuleStore';
import { usePlayButtonStore } from '../../../store/usePlayButtonStore';
function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObject<THREE.Group> }) { function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObject<THREE.Group> }) {
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 { simulationPaths, setSimulationPaths } = useSimulationPaths();
const { isPlaying } = usePlayButtonStore();
const [firstSelected, setFirstSelected] = useState<{ const [firstSelected, setFirstSelected] = useState<{
pathUUID: string; pathUUID: string;
@ -89,12 +91,12 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
// In the updatePathConnections function, modify the Vehicle handling section: // In the updatePathConnections function, modify the Vehicle handling section:
else if (path.type === 'Vehicle') { else if (path.type === 'Vehicle') {
// Handle outgoing connections from Vehicle // Handle outgoing connections from Vehicle
if (path.modeluuid === fromPathUUID && path.point.uuid === fromPointUUID) { if (path.modeluuid === fromPathUUID && path.points.uuid === fromPointUUID) {
const newTarget = { const newTarget = {
pathUUID: toPathUUID, pathUUID: toPathUUID,
pointUUID: toPointUUID pointUUID: toPointUUID
}; };
const existingTargets = path.point.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 = simulationPaths.find(p => p.modeluuid === toPathUUID);
@ -115,10 +117,10 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
)) { )) {
return { return {
...path, ...path,
point: { points: {
...path.point, ...path.points,
connections: { connections: {
...path.point.connections, ...path.points.connections,
targets: [...existingTargets, newTarget] targets: [...existingTargets, newTarget]
} }
} }
@ -126,12 +128,12 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
} }
// Handle incoming connections to Vehicle // Handle incoming connections to Vehicle
else if (path.modeluuid === toPathUUID && path.point.uuid === toPointUUID) { else if (path.modeluuid === toPathUUID && path.points.uuid === toPointUUID) {
const reverseTarget = { const reverseTarget = {
pathUUID: fromPathUUID, pathUUID: fromPathUUID,
pointUUID: fromPointUUID pointUUID: fromPointUUID
}; };
const existingTargets = path.point.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 = simulationPaths.find(p => p.modeluuid === fromPathUUID);
@ -152,10 +154,10 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
)) { )) {
return { return {
...path, ...path,
point: { points: {
...path.point, ...path.points,
connections: { connections: {
...path.point.connections, ...path.points.connections,
targets: [...existingTargets, reverseTarget] targets: [...existingTargets, reverseTarget]
} }
} }
@ -215,13 +217,13 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
let isStartOrEnd = false; let isStartOrEnd = false;
if (intersected.userData.path.points) { if (intersected.userData.path.points && intersected.userData.path.points.length > 1) {
isStartOrEnd = intersected.userData.path.points.length > 0 && ( isStartOrEnd = intersected.userData.path.points.length > 0 && (
sphereUUID === intersected.userData.path.points[0].uuid || sphereUUID === intersected.userData.path.points[0].uuid ||
sphereUUID === intersected.userData.path.points[intersected.userData.path.points.length - 1].uuid sphereUUID === intersected.userData.path.points[intersected.userData.path.points.length - 1].uuid
); );
} else if (intersected.userData.path.point) { } else if (intersected.userData.path.points) {
isStartOrEnd = sphereUUID === intersected.userData.path.point.uuid; isStartOrEnd = sphereUUID === intersected.userData.path.points.uuid;
} }
if (pathUUID) { if (pathUUID) {
@ -253,7 +255,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.pathUUID === pathUUID && t.pointUUID === sphereUUID
); );
} else if (path.type === 'Vehicle') { } else if (path.type === 'Vehicle') {
return path.point.connections.targets.some(t => return path.points.connections.targets.some(t =>
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.pathUUID === pathUUID && t.pointUUID === sphereUUID
); );
} }
@ -269,7 +271,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
// For Vehicles, check if they're already connected to anything // For Vehicles, check if they're already connected to anything
if (intersected.userData.path.type === 'Vehicle') { if (intersected.userData.path.type === 'Vehicle') {
const vehicleConnections = intersected.userData.path.point.connections.targets.length; console.log('intersected: ', intersected);
const vehicleConnections = intersected.userData.path.points.connections.targets.length;
if (vehicleConnections >= 1) { if (vehicleConnections >= 1) {
console.log("Vehicle can only have one connection"); console.log("Vehicle can only have one connection");
return; return;
@ -418,7 +421,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.pathUUID === pathUUID && t.pointUUID === sphereUUID
); );
} else if (path.type === 'Vehicle') { } else if (path.type === 'Vehicle') {
return path.point.connections.targets.some(t => return path.points.connections.targets.some(t =>
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.pathUUID === pathUUID && t.pointUUID === sphereUUID
); );
} }
@ -440,7 +443,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
// Check vehicle connection rules // Check vehicle connection rules
const isVehicleAtMaxConnections = pathData.type === 'Vehicle' && const isVehicleAtMaxConnections = pathData.type === 'Vehicle' &&
pathData.point.connections.targets.length >= 1; pathData.points.connections.targets.length >= 1;
const isVehicleConnectingToNonConveyor = const isVehicleConnectingToNonConveyor =
(firstPath?.type === 'Vehicle' && secondPath?.type !== 'Conveyor') || (firstPath?.type === 'Vehicle' && secondPath?.type !== 'Conveyor') ||
(secondPath?.type === 'Vehicle' && firstPath?.type !== 'Conveyor'); (secondPath?.type === 'Vehicle' && firstPath?.type !== 'Conveyor');
@ -501,7 +504,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
}); });
return ( return (
<> <group name='simulationConnectionGroup' visible={!isPlaying} >
{simulationPaths.flatMap(path => { {simulationPaths.flatMap(path => {
if (path.type === 'Conveyor') { if (path.type === 'Conveyor') {
return path.points.flatMap(point => return path.points.flatMap(point =>
@ -545,8 +548,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
}) })
); );
} else if (path.type === 'Vehicle') { } else if (path.type === 'Vehicle') {
return path.point.connections.targets.map((target, index) => { return path.points.connections.targets.map((target, index) => {
const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', path.point.uuid); const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', path.points.uuid);
const toSphere = pathsGroupRef.current?.getObjectByProperty('uuid', target.pointUUID); const toSphere = pathsGroupRef.current?.getObjectByProperty('uuid', target.pointUUID);
if (fromSphere && toSphere) { if (fromSphere && toSphere) {
@ -566,7 +569,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
return ( return (
<QuadraticBezierLine <QuadraticBezierLine
key={`${path.point.uuid}-${target.pointUUID}-${index}`} key={`${path.points.uuid}-${target.pointUUID}-${index}`}
start={fromWorldPosition.toArray()} start={fromWorldPosition.toArray()}
end={toWorldPosition.toArray()} end={toWorldPosition.toArray()}
mid={midPoint.toArray()} mid={midPoint.toArray()}
@ -596,7 +599,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
dashScale={20} dashScale={20}
/> />
)} )}
</> </group>
); );
} }

View File

@ -15,6 +15,7 @@ import {
import { useFrame, useThree } from "@react-three/fiber"; import { useFrame, useThree } from "@react-three/fiber";
import { useSubModuleStore } from "../../../store/useModuleStore"; import { useSubModuleStore } from "../../../store/useModuleStore";
import { usePlayButtonStore } from "../../../store/usePlayButtonStore"; import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
import { setEventApi } from "../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
function PathCreation({ function PathCreation({
pathsGroupRef, pathsGroupRef,
@ -24,16 +25,12 @@ function PathCreation({
const { isPlaying } = usePlayButtonStore(); const { isPlaying } = usePlayButtonStore();
const { renderDistance } = useRenderDistance(); const { renderDistance } = useRenderDistance();
const { setSubModule } = useSubModuleStore(); const { setSubModule } = useSubModuleStore();
const { setSelectedActionSphere, selectedActionSphere } = const { setSelectedActionSphere, selectedActionSphere } = useSelectedActionSphere();
useSelectedActionSphere();
const { eyeDropMode, setEyeDropMode } = useEyeDropMode(); const { eyeDropMode, setEyeDropMode } = useEyeDropMode();
const { editingPoint, setEditingPoint } = useEditingPoint(); const { editingPoint, setEditingPoint } = useEditingPoint();
const { previewPosition, setPreviewPosition } = usePreviewPosition(); const { previewPosition, setPreviewPosition } = usePreviewPosition();
const { raycaster, camera, pointer, gl } = useThree(); const { raycaster, camera, pointer, gl } = useThree();
const plane = useMemo( const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0),
[]
);
const { setSelectedPath } = useSelectedPath(); const { setSelectedPath } = useSelectedPath();
const { simulationPaths, setSimulationPaths } = useSimulationPaths(); const { simulationPaths, setSimulationPaths } = useSimulationPaths();
const { isConnecting } = useIsConnecting(); const { isConnecting } = useIsConnecting();
@ -42,9 +39,7 @@ function PathCreation({
const sphereRefs = useRef<{ [key: string]: THREE.Mesh }>({}); const sphereRefs = useRef<{ [key: string]: THREE.Mesh }>({});
const isMovingRef = useRef(false); const isMovingRef = useRef(false);
const transformRef = useRef<any>(null); const transformRef = useRef<any>(null);
const [transformMode, setTransformMode] = useState< const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null);
"translate" | "rotate" | null
>(null);
useEffect(() => { useEffect(() => {
setTransformMode(null); setTransformMode(null);
@ -81,20 +76,20 @@ function PathCreation({
return { return {
...path, ...path,
points: path.points.map((point) => points: path.points.map((point) =>
point.uuid === selectedActionSphere.point.uuid point.uuid === selectedActionSphere.points.uuid
? { ? {
...point, ...point,
position: [ position: [
selectedActionSphere.point.position.x, selectedActionSphere.points.position.x,
selectedActionSphere.point.position.y, selectedActionSphere.points.position.y,
selectedActionSphere.point.position.z, selectedActionSphere.points.position.z,
], ],
rotation: [ rotation: [
selectedActionSphere.point.rotation.x, selectedActionSphere.points.rotation.x,
selectedActionSphere.point.rotation.y, selectedActionSphere.points.rotation.y,
selectedActionSphere.point.rotation.z, selectedActionSphere.points.rotation.z,
], ],
} }
: point : point
), ),
}; };
@ -161,26 +156,37 @@ function PathCreation({
}; };
}, [eyeDropMode, editingPoint, previewPosition]); }, [eyeDropMode, editingPoint, previewPosition]);
const updateBackend = async (updatedPath: Types.VehicleEventsSchema | undefined) => {
if (!updatedPath) return;
const email = localStorage.getItem("email");
const organization = email ? email.split("@")[1].split(".")[0] : "";
await setEventApi(
organization,
updatedPath.modeluuid,
{ type: "Vehicle", points: updatedPath.points }
);
}
const handlePointUpdate = ( const handlePointUpdate = (
pointType: "start" | "end", pointType: "start" | "end",
x: number, x: number,
z: number z: number
) => { ) => {
if (!selectedActionSphere?.point?.uuid) return; if (!selectedActionSphere?.points?.uuid) return;
const updatedPaths = simulationPaths.map((path) => { const updatedPaths = simulationPaths.map((path) => {
if ( if (
path.type === "Vehicle" && path.type === "Vehicle" &&
path.point.uuid === selectedActionSphere.point.uuid path.points.uuid === selectedActionSphere.points.uuid
) { ) {
return { return {
...path, ...path,
point: { points: {
...path.point, ...path.points,
actions: { actions: {
...path.point.actions, ...path.points.actions,
[pointType]: { [pointType]: {
...path.point.actions[pointType], ...path.points.actions[pointType],
x: x, x: x,
y: z, y: z,
}, },
@ -191,6 +197,13 @@ function PathCreation({
return path; return path;
}); });
const updatedPath = updatedPaths.find(
(path): path is Types.VehicleEventsSchema =>
path.type === "Vehicle" &&
path.points.uuid === selectedActionSphere.points.uuid
);
updateBackend(updatedPath);
setSimulationPaths(updatedPaths); setSimulationPaths(updatedPaths);
}; };
@ -239,12 +252,12 @@ function PathCreation({
e.stopPropagation(); e.stopPropagation();
setSelectedActionSphere({ setSelectedActionSphere({
path, path,
point: sphereRefs.current[point.uuid], points: sphereRefs.current[point.uuid],
}); });
setSubModule("mechanics"); setSubModule("mechanics");
setSelectedPath(null); setSelectedPath(null);
}} }}
userData={{ point, path }} userData={{ points, path }}
onPointerMissed={() => { onPointerMissed={() => {
if (eyeDropMode) return; if (eyeDropMode) return;
setSubModule("properties"); setSubModule("properties");
@ -256,8 +269,8 @@ function PathCreation({
index === 0 index === 0
? "orange" ? "orange"
: index === path.points.length - 1 : index === path.points.length - 1
? "blue" ? "blue"
: "green" : "green"
} }
/> />
</Sphere> </Sphere>
@ -318,23 +331,23 @@ function PathCreation({
}} }}
> >
<Sphere <Sphere
key={path.point.uuid} key={path.points.uuid}
uuid={path.point.uuid} uuid={path.points.uuid}
position={path.point.position} position={path.points.position}
args={[0.15, 32, 32]} args={[0.15, 32, 32]}
name="events-sphere" name="events-sphere"
ref={(el) => (sphereRefs.current[path.point.uuid] = el!)} ref={(el) => (sphereRefs.current[path.points.uuid] = el!)}
onClick={(e) => { onClick={(e) => {
if (isConnecting || eyeDropMode) return; if (isConnecting || eyeDropMode) return;
e.stopPropagation(); e.stopPropagation();
setSelectedActionSphere({ setSelectedActionSphere({
path, path,
point: sphereRefs.current[path.point.uuid], points: sphereRefs.current[path.points.uuid],
}); });
setSubModule("mechanics"); setSubModule("mechanics");
setSelectedPath(null); setSelectedPath(null);
}} }}
userData={{ point: path.point, path }} userData={{ points: path.points, path }}
onPointerMissed={() => { onPointerMissed={() => {
if (eyeDropMode) return; if (eyeDropMode) return;
setSubModule("properties"); setSubModule("properties");
@ -352,7 +365,7 @@ function PathCreation({
{selectedActionSphere && transformMode && ( {selectedActionSphere && transformMode && (
<TransformControls <TransformControls
ref={transformRef} ref={transformRef}
object={selectedActionSphere.point} object={selectedActionSphere.points}
mode={transformMode} mode={transformMode}
onMouseUp={updateSimulationPaths} onMouseUp={updateSimulationPaths}
/> />

View File

@ -486,20 +486,20 @@ function convertToSimulationPath(
modeluuid, modeluuid,
points: [ points: [
{ {
uuid: path.point.uuid, uuid: path.points.uuid,
position: path.point.position, position: path.points.position,
actions: Array.isArray(path.point.actions) actions: Array.isArray(path.points.actions)
? path.point.actions.map(normalizeAction) ? path.points.actions.map(normalizeAction)
: [normalizeAction(path.point.actions)], : [normalizeAction(path.points.actions)],
connections: { connections: {
targets: path.point.connections.targets.map((target) => ({ targets: path.points.connections.targets.map((target) => ({
pathUUID: target.pathUUID, pathUUID: target.pathUUID,
})), })),
}, },
}, },
], ],
pathPosition: path.position, pathPosition: path.position,
speed: path.point.speed || 1, speed: path.points.speed || 1,
}; };
} }
} }

View File

@ -19,7 +19,7 @@ function Simulation() {
const [processes, setProcesses] = useState([]); const [processes, setProcesses] = useState([]);
useEffect(() => { useEffect(() => {
console.log('simulationPaths: ', simulationPaths); // console.log('simulationPaths: ', simulationPaths);
}, [simulationPaths]); }, [simulationPaths]);
// useEffect(() => { // useEffect(() => {

View File

@ -19,7 +19,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => { // points: path.points.map((point) => {
// if (point.uuid === selectedActionSphere.point.uuid) { // if (point.uuid === selectedActionSphere.points.uuid) {
// const actionIndex = point.actions.length; // const actionIndex = point.actions.length;
// const newAction = { // const newAction = {
// uuid: THREE.MathUtils.generateUUID(), // uuid: THREE.MathUtils.generateUUID(),
@ -46,7 +46,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { ...point, actions: point.actions.filter(action => action.uuid !== uuid) } // ? { ...point, actions: point.actions.filter(action => action.uuid !== uuid) }
// : point // : point
// ), // ),
@ -61,7 +61,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// actions: point.actions.map((action) => // actions: point.actions.map((action) =>
@ -81,7 +81,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// actions: point.actions.map((action) => // actions: point.actions.map((action) =>
@ -101,7 +101,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// actions: point.actions.map((action) => // actions: point.actions.map((action) =>
@ -121,7 +121,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// actions: point.actions.map((action) => // actions: point.actions.map((action) =>
@ -152,7 +152,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => { // points: path.points.map((point) => {
// if (point.uuid === selectedActionSphere.point.uuid) { // if (point.uuid === selectedActionSphere.points.uuid) {
// const triggerIndex = point.triggers.length; // const triggerIndex = point.triggers.length;
// const newTrigger = { // const newTrigger = {
// uuid: THREE.MathUtils.generateUUID(), // uuid: THREE.MathUtils.generateUUID(),
@ -176,7 +176,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { ...point, triggers: point.triggers.filter(trigger => trigger.uuid !== uuid) } // ? { ...point, triggers: point.triggers.filter(trigger => trigger.uuid !== uuid) }
// : point // : point
// ), // ),
@ -191,7 +191,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// triggers: point.triggers.map((trigger) => // triggers: point.triggers.map((trigger) =>
@ -217,7 +217,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// actions: point.actions.map((action) => ({ // actions: point.actions.map((action) => ({
@ -238,7 +238,7 @@
// const updatedPaths = simulationPaths.map((path) => ({ // const updatedPaths = simulationPaths.map((path) => ({
// ...path, // ...path,
// points: path.points.map((point) => // points: path.points.map((point) =>
// point.uuid === selectedActionSphere.point.uuid // point.uuid === selectedActionSphere.points.uuid
// ? { // ? {
// ...point, // ...point,
// triggers: point.triggers.map((trigger) => ({ // triggers: point.triggers.map((trigger) => ({
@ -255,7 +255,7 @@
// 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.point.uuid); // return simulationPaths.flatMap((path) => path.points).find((point) => point.uuid === selectedActionSphere.points.uuid);
// }, [selectedActionSphere, simulationPaths]); // }, [selectedActionSphere, simulationPaths]);
// const createPath = () => { // const createPath = () => {

View File

@ -2,7 +2,7 @@ let BackEnd_url = `http://${process.env.REACT_APP_SERVER_ASSET_LIBRARY_URL}`;
export const getCategoryAsset = async (categoryName: any) => { export const getCategoryAsset = async (categoryName: any) => {
try { try {
const response = await fetch( const response = await fetch(
`${BackEnd_url}/api/v2/getCatagoryAssets/${categoryName}`, `${BackEnd_url}/api/v2/getCategoryAssets/${categoryName}`,
{ {
method: "GET", method: "GET",
headers: { headers: {

View File

@ -17,7 +17,7 @@ export const setEventApi = async (
}); });
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to set or update Floor Item"); throw new Error("Failed to set or Update Event Data");
} }
const result = await response.json(); const result = await response.json();

View File

@ -201,27 +201,6 @@ export type FloorItemType = {
modelfileID: string; modelfileID: string;
isLocked: boolean; isLocked: boolean;
isVisible: boolean; isVisible: boolean;
eventData?: {
type: 'Conveyor';
points: {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | [];
triggers: { uuid: string; name: string; type: string; isUsed: boolean; bufferTime: number }[] | [];
connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
}[];
speed: number | string;
} | {
type: 'Vehicle';
point: {
uuid: string;
position: [number, number, number];
actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number };
connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
speed: number;
};
};
}; };
// Array of floor items for managing multiple objects on the floor // Array of floor items for managing multiple objects on the floor
@ -328,12 +307,43 @@ interface VehicleEventsSchema {
modeluuid: string; modeluuid: string;
modelName: string; modelName: string;
type: 'Vehicle'; type: 'Vehicle';
point: { points: {
uuid: string; uuid: string;
position: [number, number, number]; position: [number, number, number];
actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number }; actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number };
connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; connections: { source: { modelUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
speed: number; speed: number;
}; };
position: [number, number, number]; position: [number, number, number];
} }
export type EventData = {
modeluuid: string;
modelname: string;
position: [number, number, number];
rotation: { x: number; y: number; z: number };
modelfileID: string;
isLocked: boolean;
isVisible: boolean;
eventData?: {
type: 'Conveyor';
points: {
uuid: string;
position: [number, number, number];
rotation: [number, number, number];
actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | [];
triggers: { uuid: string; name: string; type: string; isUsed: boolean; bufferTime: number }[] | [];
connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
}[];
speed: number | string;
} | {
type: 'Vehicle';
points: {
uuid: string;
position: [number, number, number];
actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number };
connections: { source: { modelUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] };
speed: number;
};
};
}