feat: Implement ArmBot simulation with IK animation and event handling
- Added ArmBot component to manage ArmBot instances in the simulation. - Created ArmBotInstances component to render individual ArmBot models. - Developed IKAnimationController for handling inverse kinematics during animations. - Introduced IkInstances component to load and manage IK-enabled arm models. - Defined simulation types for ArmBot events and connections in TypeScript. - Enhanced type definitions for better clarity and maintainability.
This commit is contained in:
@@ -133,7 +133,6 @@ const Assets: React.FC = () => {
|
||||
} else {
|
||||
try {
|
||||
const res = await getCategoryAsset(asset);
|
||||
console.log('res: ', res);
|
||||
setCategoryAssets(res);
|
||||
setFiltereredAssets(res);
|
||||
} catch (error) {}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useRef, useMemo, useCallback, useState } from "react";
|
||||
import { InfoIcon, AddIcon, RemoveIcon, ResizeHeightIcon } from "../../../icons/ExportCommonIcons";
|
||||
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
||||
import { useSelectedActionSphere, useSimulationStates, useSocketStore } from "../../../../store/store";
|
||||
import * as Types from '../../../../types/world/worldTypes';
|
||||
import * as SimulationTypes from '../../../../types/simulation';
|
||||
import LabledDropdown from "../../../ui/inputs/LabledDropdown";
|
||||
import { handleResize } from "../../../../functions/handleResizePannel";
|
||||
|
||||
@@ -34,7 +34,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
if (!selectedActionSphere?.points?.uuid) return [];
|
||||
|
||||
const armBotPaths = simulationStates.filter(
|
||||
(path): path is Types.ArmBotEventsSchema => path.type === "ArmBot"
|
||||
(path): path is SimulationTypes.ArmBotEventsSchema => path.type === "ArmBot"
|
||||
);
|
||||
|
||||
const currentPoint = armBotPaths.find(
|
||||
@@ -54,7 +54,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
let points: { uuid: string; position: [number, number, number] }[] = [];
|
||||
|
||||
if (connectedModel.type === "Conveyor") {
|
||||
const conveyor = connectedModel as Types.ConveyorEventsSchema;
|
||||
const conveyor = connectedModel as SimulationTypes.ConveyorEventsSchema;
|
||||
|
||||
const connectedPointUUIDs = currentPoint?.connections?.targets
|
||||
.filter(t => t.modelUUID === connectedModel.modeluuid)
|
||||
@@ -72,7 +72,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
triggers = conveyor.points.flatMap(p => p.triggers?.filter(t => t.isUsed) || []);
|
||||
}
|
||||
else if (connectedModel.type === "StaticMachine") {
|
||||
const staticMachine = connectedModel as Types.StaticMachineEventsSchema;
|
||||
const staticMachine = connectedModel as SimulationTypes.StaticMachineEventsSchema;
|
||||
|
||||
points = [{
|
||||
uuid: staticMachine.points.uuid,
|
||||
@@ -128,7 +128,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null };
|
||||
|
||||
const armBotPaths = simulationStates.filter(
|
||||
(path): path is Types.ArmBotEventsSchema => path.type === "ArmBot"
|
||||
(path): path is SimulationTypes.ArmBotEventsSchema => path.type === "ArmBot"
|
||||
);
|
||||
|
||||
const points = armBotPaths.find(
|
||||
@@ -140,7 +140,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
};
|
||||
}, [selectedActionSphere, simulationStates]);
|
||||
|
||||
const updateBackend = async (updatedPath: Types.ArmBotEventsSchema | undefined) => {
|
||||
const updateBackend = async (updatedPath: SimulationTypes.ArmBotEventsSchema | undefined) => {
|
||||
if (!updatedPath) return;
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
||||
@@ -150,12 +150,11 @@ const ArmBotMechanics: React.FC = () => {
|
||||
modeluuid: updatedPath.modeluuid,
|
||||
eventData: { type: "ArmBot", points: updatedPath.points }
|
||||
}
|
||||
console.log('data: ', data);
|
||||
|
||||
socket.emit('v2:model-asset:updateEventData', data);
|
||||
}
|
||||
|
||||
const handleActionUpdate = useCallback((updatedAction: Partial<Types.ArmBotEventsSchema['points']['actions']>) => {
|
||||
const handleActionUpdate = useCallback((updatedAction: Partial<SimulationTypes.ArmBotEventsSchema['points']['actions']>) => {
|
||||
if (!selectedActionSphere?.points?.uuid || !selectedPoint) return;
|
||||
|
||||
const updatedPaths = simulationStates.map((path) => {
|
||||
@@ -175,7 +174,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ArmBotEventsSchema =>
|
||||
(path): path is SimulationTypes.ArmBotEventsSchema =>
|
||||
path.type === "ArmBot" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
@@ -188,7 +187,7 @@ const ArmBotMechanics: React.FC = () => {
|
||||
handleActionUpdate({ speed });
|
||||
}, [handleActionUpdate]);
|
||||
|
||||
const handleProcessChange = useCallback((processes: Types.ArmBotEventsSchema['points']['actions']['processes']) => {
|
||||
const handleProcessChange = useCallback((processes: SimulationTypes.ArmBotEventsSchema['points']['actions']['processes']) => {
|
||||
handleActionUpdate({ processes });
|
||||
}, [handleActionUpdate]);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useSocketStore,
|
||||
} from "../../../../store/store";
|
||||
import * as THREE from "three";
|
||||
import * as Types from "../../../../types/world/worldTypes";
|
||||
import * as SimulationTypes from "../../../../types/simulation";
|
||||
import InputToggle from "../../../ui/inputs/InputToggle";
|
||||
import { setFloorItemApi } from "../../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
|
||||
import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
||||
@@ -36,13 +36,13 @@ const ConveyorMechanics: React.FC = () => {
|
||||
if (!selectedActionSphere) return null;
|
||||
return simulationStates
|
||||
.filter(
|
||||
(path): path is Types.ConveyorEventsSchema => path.type === "Conveyor"
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema => path.type === "Conveyor"
|
||||
)
|
||||
.flatMap((path) => path.points)
|
||||
.find((point) => point.uuid === selectedActionSphere.points.uuid);
|
||||
}, [selectedActionSphere, simulationStates]);
|
||||
|
||||
const updateBackend = async (updatedPath: Types.ConveyorEventsSchema | undefined) => {
|
||||
const updateBackend = async (updatedPath: SimulationTypes.ConveyorEventsSchema | undefined) => {
|
||||
if (!updatedPath) return;
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
||||
@@ -93,7 +93,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -126,7 +126,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -174,7 +174,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -188,7 +188,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
if (selectedItem?.type === "action" && selectedItem.item.uuid === uuid) {
|
||||
const updatedAction = updatedPaths
|
||||
.filter(
|
||||
(path): path is Types.ConveyorEventsSchema => path.type === "Conveyor"
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema => path.type === "Conveyor"
|
||||
)
|
||||
.flatMap((path) => path.points)
|
||||
.find((p) => p.uuid === selectedActionSphere.points.uuid)
|
||||
@@ -229,7 +229,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -273,7 +273,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -311,7 +311,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -330,7 +330,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.modeluuid === selectedPath.path.modeluuid
|
||||
);
|
||||
@@ -367,7 +367,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -400,7 +400,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -435,7 +435,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -479,7 +479,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -525,7 +525,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
@@ -571,7 +571,7 @@ const ConveyorMechanics: React.FC = () => {
|
||||
);
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.ConveyorEventsSchema =>
|
||||
(path): path is SimulationTypes.ConveyorEventsSchema =>
|
||||
path.type === "Conveyor" &&
|
||||
path.points.some(
|
||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useRef, useMemo, useCallback } from "react";
|
||||
import { InfoIcon } from "../../../icons/ExportCommonIcons";
|
||||
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
||||
import { useSelectedActionSphere, useSimulationStates, useSocketStore } from "../../../../store/store";
|
||||
import * as Types from '../../../../types/world/worldTypes';
|
||||
import * as SimulationTypes from '../../../../types/simulation';
|
||||
import LabledDropdown from "../../../ui/inputs/LabledDropdown";
|
||||
import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
||||
|
||||
@@ -17,7 +17,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null, connectedPointUuids: [] };
|
||||
|
||||
const staticMachinePaths = simulationStates.filter(
|
||||
(path): path is Types.StaticMachineEventsSchema => path.type === "StaticMachine"
|
||||
(path): path is SimulationTypes.StaticMachineEventsSchema => path.type === "StaticMachine"
|
||||
);
|
||||
|
||||
const points = staticMachinePaths.find(
|
||||
@@ -39,7 +39,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
};
|
||||
}, [selectedActionSphere, simulationStates]);
|
||||
|
||||
const updateBackend = async (updatedPath: Types.StaticMachineEventsSchema | undefined) => {
|
||||
const updateBackend = async (updatedPath: SimulationTypes.StaticMachineEventsSchema | undefined) => {
|
||||
if (!updatedPath) return;
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
||||
@@ -59,7 +59,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
socket.emit('v2:model-asset:updateEventData', data);
|
||||
}
|
||||
|
||||
const handleActionUpdate = useCallback((updatedAction: Partial<Types.StaticMachineEventsSchema['points']['actions']>) => {
|
||||
const handleActionUpdate = useCallback((updatedAction: Partial<SimulationTypes.StaticMachineEventsSchema['points']['actions']>) => {
|
||||
if (!selectedActionSphere?.points?.uuid) return;
|
||||
|
||||
const updatedPaths = simulationStates.map((path) => {
|
||||
@@ -79,7 +79,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.StaticMachineEventsSchema =>
|
||||
(path): path is SimulationTypes.StaticMachineEventsSchema =>
|
||||
path.type === "StaticMachine" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
@@ -96,7 +96,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
handleActionUpdate({ material });
|
||||
}, [handleActionUpdate]);
|
||||
|
||||
const handleTriggerChange = useCallback((updatedTrigger: Partial<Types.StaticMachineEventsSchema['points']['triggers']>) => {
|
||||
const handleTriggerChange = useCallback((updatedTrigger: Partial<SimulationTypes.StaticMachineEventsSchema['points']['triggers']>) => {
|
||||
if (!selectedActionSphere?.points?.uuid) return;
|
||||
|
||||
const updatedPaths = simulationStates.map((path) => {
|
||||
@@ -116,7 +116,7 @@ const StaticMachineMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.StaticMachineEventsSchema =>
|
||||
(path): path is SimulationTypes.StaticMachineEventsSchema =>
|
||||
path.type === "StaticMachine" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useRef, useMemo } from "react";
|
||||
import { InfoIcon } from "../../../icons/ExportCommonIcons";
|
||||
import InputWithDropDown from "../../../ui/inputs/InputWithDropDown";
|
||||
import { useEditingPoint, useEyeDropMode, usePreviewPosition, useSelectedActionSphere, useSimulationStates, useSocketStore } from "../../../../store/store";
|
||||
import * as Types from '../../../../types/world/worldTypes';
|
||||
import * as SimulationTypes from '../../../../types/simulation';
|
||||
import PositionInput from "../customInput/PositionInputs";
|
||||
import { setEventApi } from "../../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
||||
import LabeledButton from "../../../ui/inputs/LabledButton";
|
||||
@@ -21,7 +21,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
if (!selectedActionSphere?.points?.uuid) return { selectedPoint: null, connectedPointUuids: [] };
|
||||
|
||||
const vehiclePaths = simulationStates.filter(
|
||||
(path): path is Types.VehicleEventsSchema => path.type === "Vehicle"
|
||||
(path): path is SimulationTypes.VehicleEventsSchema => path.type === "Vehicle"
|
||||
);
|
||||
|
||||
const points = vehiclePaths.find(
|
||||
@@ -43,7 +43,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
};
|
||||
}, [selectedActionSphere, simulationStates]);
|
||||
|
||||
const updateBackend = async (updatedPath: Types.VehicleEventsSchema | undefined) => {
|
||||
const updateBackend = async (updatedPath: SimulationTypes.VehicleEventsSchema | undefined) => {
|
||||
if (!updatedPath) return;
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
||||
@@ -64,7 +64,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
|
||||
}
|
||||
|
||||
const handleActionUpdate = React.useCallback((updatedAction: Partial<Types.VehicleEventsSchema['points']['actions']>) => {
|
||||
const handleActionUpdate = React.useCallback((updatedAction: Partial<SimulationTypes.VehicleEventsSchema['points']['actions']>) => {
|
||||
if (!selectedActionSphere?.points?.uuid) return;
|
||||
|
||||
const updatedPaths = simulationStates.map((path) => {
|
||||
@@ -84,7 +84,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.VehicleEventsSchema =>
|
||||
(path): path is SimulationTypes.VehicleEventsSchema =>
|
||||
path.type === "Vehicle" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
@@ -118,7 +118,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.VehicleEventsSchema =>
|
||||
(path): path is SimulationTypes.VehicleEventsSchema =>
|
||||
path.type === "Vehicle" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
@@ -145,7 +145,7 @@ const VehicleMechanics: React.FC = () => {
|
||||
});
|
||||
|
||||
const updatedPath = updatedPaths.find(
|
||||
(path): path is Types.VehicleEventsSchema =>
|
||||
(path): path is SimulationTypes.VehicleEventsSchema =>
|
||||
path.type === "Vehicle" &&
|
||||
path.points.uuid === selectedActionSphere.points.uuid
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user