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,32 +1,43 @@
import { useEffect, useState } from 'react'
import { useSelectedAnimation, useSelectedEventSphere } from '../../../store/simulation/useSimulationStore';
import { usePlayButtonStore } from '../../../store/usePlayButtonStore';
import { useSceneContext } from '../../scene/sceneContext';
import HumanInstances from './instances/humanInstances'
import { useEffect, useState } from "react";
import { useSelectedEventSphere } from "../../../store/simulation/useSimulationStore";
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
import { useSceneContext } from "../../scene/sceneContext";
import HumanUi from './instances/instance/humanUi';
function Human() {
const { humanStore } = useSceneContext();
const { getHumanById } = humanStore();
const { selectedAnimation } = useSelectedAnimation();
const { selectedEventSphere } = useSelectedEventSphere();
const { isPlaying } = usePlayButtonStore();
const [isHumanSelected, setIsHumanSelected] = useState(false);
const [isVehicleSelected, setIsHumanSelected] = useState(false);
useEffect(() => {
if (selectedEventSphere) {
const selectedVehicle = getHumanById(selectedEventSphere.userData.modelUuid);
if (selectedVehicle) {
const selectedHuman = getHumanById(selectedEventSphere.userData.modelUuid);
if (selectedHuman &&
selectedHuman.point.actions.some((action) =>
action.animationSequences.some((animation) =>
animation.animationUuid === selectedAnimation?.animationUuid && animation.animationType === 'animatedTravel'
)
)) {
setIsHumanSelected(true);
} else {
setIsHumanSelected(false);
}
}
}, [getHumanById, selectedEventSphere])
}, [getHumanById, selectedEventSphere, selectedAnimation])
return (
<>
<HumanInstances />
{isVehicleSelected && selectedEventSphere && !isPlaying &&
<HumanUi />
}
</>
)
}