feat: Implement selected animation handling and integrate with human mechanics
This commit is contained in:
@@ -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 />
|
||||
}
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user