2025-07-03 15:18:49 +05:30
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
import { useSelectedAnimation, useSelectedEventSphere } from '../../../store/simulation/useSimulationStore';
|
|
|
|
|
import { usePlayButtonStore } from '../../../store/usePlayButtonStore';
|
|
|
|
|
import { useSceneContext } from '../../scene/sceneContext';
|
2025-07-02 15:07:31 +05:30
|
|
|
import HumanInstances from './instances/humanInstances'
|
2025-07-03 15:18:49 +05:30
|
|
|
import HumanUi from './instances/instance/humanUi';
|
2025-07-02 15:07:31 +05:30
|
|
|
|
|
|
|
|
function Human() {
|
2025-07-03 12:09:31 +05:30
|
|
|
const { humanStore } = useSceneContext();
|
|
|
|
|
const { getHumanById } = humanStore();
|
2025-07-03 15:18:49 +05:30
|
|
|
const { selectedAnimation } = useSelectedAnimation();
|
2025-07-03 12:09:31 +05:30
|
|
|
const { selectedEventSphere } = useSelectedEventSphere();
|
|
|
|
|
const { isPlaying } = usePlayButtonStore();
|
2025-07-03 15:18:49 +05:30
|
|
|
const [isVehicleSelected, setIsHumanSelected] = useState(false);
|
2025-07-03 12:09:31 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selectedEventSphere) {
|
2025-07-03 15:18:49 +05:30
|
|
|
const selectedHuman = getHumanById(selectedEventSphere.userData.modelUuid);
|
|
|
|
|
if (selectedHuman &&
|
|
|
|
|
selectedHuman.point.actions.some((action) =>
|
|
|
|
|
action.animationSequences.some((animation) =>
|
|
|
|
|
animation.animationUuid === selectedAnimation?.animationUuid && animation.animationType === 'animatedTravel'
|
|
|
|
|
)
|
|
|
|
|
)) {
|
2025-07-03 12:09:31 +05:30
|
|
|
setIsHumanSelected(true);
|
|
|
|
|
} else {
|
|
|
|
|
setIsHumanSelected(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-03 15:18:49 +05:30
|
|
|
}, [getHumanById, selectedEventSphere, selectedAnimation])
|
2025-07-03 12:09:31 +05:30
|
|
|
|
2025-07-02 15:07:31 +05:30
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
|
|
<HumanInstances />
|
|
|
|
|
|
2025-07-03 15:18:49 +05:30
|
|
|
{isVehicleSelected && selectedEventSphere && !isPlaying &&
|
|
|
|
|
<HumanUi />
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 15:07:31 +05:30
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Human
|