feat: Implement selected animation handling and integrate with human mechanics

This commit is contained in:
2025-07-03 15:18:49 +05:30
parent eb5683eadc
commit 8dd853dd03
10 changed files with 351 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
import React, { useRef } from "react";
import { AddIcon, RemoveIcon, ResizeHeightIcon } from "../../../../../icons/ExportCommonIcons";
import { handleResize } from "../../../../../../functions/handleResizePannel";
import { useSelectedAction } from "../../../../../../store/simulation/useSimulationStore";
import { useSelectedAction, useSelectedAnimation } from "../../../../../../store/simulation/useSimulationStore";
import RenameInput from "../../../../../ui/inputs/RenameInput";
interface AnimationListProps {
@@ -17,13 +17,6 @@ interface AnimationListProps {
onRemoveAnimation: (animationUuid: string) => void;
handleAnimationSelect: (animationUuid: string) => void;
handleRenameAnimation: (animationUuid: string, newName: string) => void;
selectedAnimation: {
animationUuid: string;
animationName: string;
animationType: "behaviour" | "animatedTravel";
animation: string | null;
travelPoints?: { startPoint: [number, number, number] | null; endPoint: [number, number, number] | null };
} | undefined
}
const AnimationList: React.FC<AnimationListProps> = ({
@@ -32,10 +25,10 @@ const AnimationList: React.FC<AnimationListProps> = ({
onRemoveAnimation,
handleAnimationSelect,
handleRenameAnimation,
selectedAnimation
}) => {
const animationContainerRef = useRef<HTMLDivElement>(null);
const { selectedAction } = useSelectedAction();
const { selectedAnimation } = useSelectedAnimation();
return (
<div className="actions-list-container">

View File

@@ -7,7 +7,7 @@ import Trigger from "../trigger/Trigger";
import PickAndPlaceAction from "../actions/PickAndPlaceAction";
import ActionsList from "../components/ActionsList";
import AnimationList from "../components/AnimationList";
import { useSelectedEventData, useSelectedAction } from "../../../../../../store/simulation/useSimulationStore";
import { useSelectedEventData, useSelectedAction, useSelectedAnimation } from "../../../../../../store/simulation/useSimulationStore";
import { upsertProductOrEventApi } from "../../../../../../services/simulation/products/UpsertProductOrEventApi";
import { useProductContext } from "../../../../../../modules/simulation/products/productContext";
import { useVersionContext } from "../../../../../../modules/builder/version/versionContext";
@@ -26,14 +26,8 @@ function HumanMechanics() {
const { getPointByUuid, getEventByModelUuid, updateEvent, updateAction, addAction, removeAction } = productStore();
const { selectedProductStore } = useProductContext();
const { selectedProduct } = selectedProductStore();
const [selectedAnimation, setSelectedAnimation] = useState<{
animationUuid: string;
animationName: string;
animationType: "behaviour" | "animatedTravel";
animation: string | null;
travelPoints?: { startPoint: [number, number, number] | null; endPoint: [number, number, number] | null; }
}>();
const { selectedAction, setSelectedAction, clearSelectedAction } = useSelectedAction();
const { selectedAnimation, setSelectedAnimation } = useSelectedAnimation();
const { selectedVersionStore } = useVersionContext();
const { selectedVersion } = selectedVersionStore();
const { projectId } = useParams();
@@ -210,10 +204,8 @@ function HumanMechanics() {
if (!updatedAnimation) return;
updatedAnimation.travelPoints = {
startPoint: null,
endPoint: null
};
delete updatedAnimation.startPoint;
delete updatedAnimation.endPoint;
const updatedAction = {
...currentAction,
@@ -387,14 +379,8 @@ function HumanMechanics() {
animationType: newType
};
if (newType === 'animatedTravel') {
updatedAnim.travelPoints = {
startPoint: null,
endPoint: null
};
} else {
delete updatedAnim.travelPoints;
}
delete updatedAnim.startPoint;
delete updatedAnim.endPoint;
return updatedAnim;
}
@@ -546,7 +532,6 @@ function HumanMechanics() {
onRemoveAnimation={handleRemoveAnimation}
handleAnimationSelect={handleAnimationSelect}
handleRenameAnimation={handleRenameAnimation}
selectedAnimation={selectedAnimation}
/>
{selectedAnimation && (
<>