completed init movement for human
This commit is contained in:
@@ -5,7 +5,6 @@ import { useSceneContext } from '../../../scene/sceneContext';
|
||||
|
||||
type HumanCallback = {
|
||||
humanId: string;
|
||||
actionId: string;
|
||||
callback: () => void;
|
||||
};
|
||||
|
||||
@@ -25,10 +24,10 @@ export function useHumanEventManager() {
|
||||
}, [isReset])
|
||||
|
||||
// Add a new human to monitor
|
||||
const addHumanToMonitor = (humanId: string, actionId: string, callback: () => void) => {
|
||||
const addHumanToMonitor = (humanId: string, callback: () => void) => {
|
||||
// Avoid duplicates
|
||||
if (!callbacksRef.current.some((entry) => entry.humanId === humanId)) {
|
||||
callbacksRef.current.push({ humanId, actionId, callback });
|
||||
callbacksRef.current.push({ humanId, callback });
|
||||
}
|
||||
|
||||
// Start monitoring if not already running
|
||||
@@ -53,11 +52,9 @@ export function useHumanEventManager() {
|
||||
useFrame(() => {
|
||||
if (!isMonitoringRef.current || callbacksRef.current.length === 0 || !isPlaying || isPaused) return;
|
||||
|
||||
callbacksRef.current.forEach(({ humanId, actionId, callback }) => {
|
||||
callbacksRef.current.forEach(({ humanId, callback }) => {
|
||||
const human = getHumanById(humanId);
|
||||
if (!human) return;
|
||||
const action = human.point.actions.find((action) => action.actionUuid === actionId);
|
||||
if (action && human.isActive === false && human.state === 'idle' && human.isPicking && human.currentLoad < action.loadCapacity) {
|
||||
if (human && human.isActive === false && human.state === 'idle' && human.isPicking && human.currentLoad < human.point.action.loadCapacity) {
|
||||
callback();
|
||||
removeHumanFromMonitor(humanId); // Remove after triggering
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user