feat: Refactor human action handling to replace animatedTravel with worker actions and enhance animation management
This commit is contained in:
@@ -256,18 +256,23 @@ function AssetsGroup({ plane }: { readonly plane: RefMesh }) {
|
||||
uuid: item.eventData.point?.uuid || THREE.MathUtils.generateUUID(),
|
||||
position: [item.eventData.point?.position[0] || 0, item.eventData.point?.position[1] || 0, item.eventData.point?.position[2] || 0],
|
||||
rotation: [item.eventData.point?.rotation[0] || 0, item.eventData.point?.rotation[1] || 0, item.eventData.point?.rotation[2] || 0],
|
||||
action: {
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "animatedTravel",
|
||||
loadCapacity: 1,
|
||||
travelPoints: {
|
||||
startPoint: null,
|
||||
endPoint: null,
|
||||
},
|
||||
triggers: []
|
||||
}
|
||||
|
||||
actions: [
|
||||
{
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
animationSequences: [
|
||||
{
|
||||
animationUuid: THREE.MathUtils.generateUUID(),
|
||||
animationName: 'Animation 1',
|
||||
animationType: 'behaviour',
|
||||
animation: null
|
||||
}
|
||||
],
|
||||
loadCapacity: 1,
|
||||
triggers: []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
addEvent(humanEvent);
|
||||
|
||||
@@ -374,17 +374,23 @@ async function handleModelLoad(
|
||||
uuid: THREE.MathUtils.generateUUID(),
|
||||
position: [data.points[0].x, data.points[0].y, data.points[0].z],
|
||||
rotation: [0, 0, 0],
|
||||
action: {
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "animatedTravel",
|
||||
loadCapacity: 1,
|
||||
travelPoints: {
|
||||
startPoint: null,
|
||||
endPoint: null,
|
||||
},
|
||||
triggers: []
|
||||
}
|
||||
actions: [
|
||||
{
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
animationSequences: [
|
||||
{
|
||||
animationUuid: THREE.MathUtils.generateUUID(),
|
||||
animationName: 'Animation 1',
|
||||
animationType: 'behaviour',
|
||||
animation: null
|
||||
}
|
||||
],
|
||||
loadCapacity: 1,
|
||||
triggers: []
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback } from "react";
|
||||
import { useSceneContext } from "../../../../scene/sceneContext";
|
||||
import { useProductContext } from "../../../products/productContext";
|
||||
|
||||
export function useAnimatedTravelHandler() {
|
||||
export function useWorkerHandler() {
|
||||
const { materialStore, humanStore, productStore } = useSceneContext();
|
||||
const { getMaterialById } = materialStore();
|
||||
const { } = humanStore();
|
||||
@@ -10,12 +10,12 @@ export function useAnimatedTravelHandler() {
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
|
||||
const animatedTravelLogStatus = (materialUuid: string, status: string) => {
|
||||
const workerLogStatus = (materialUuid: string, status: string) => {
|
||||
echo.info(`${materialUuid}, ${status}`);
|
||||
}
|
||||
|
||||
const handleAnimatedTravel = useCallback((action: HumanAction, materialId?: string) => {
|
||||
if (!action || action.actionType !== 'animatedTravel' || !materialId) return;
|
||||
const handleWorker = useCallback((action: HumanAction, materialId?: string) => {
|
||||
if (!action || action.actionType !== 'worker' || !materialId) return;
|
||||
|
||||
const material = getMaterialById(materialId);
|
||||
if (!material) return;
|
||||
@@ -24,11 +24,11 @@ export function useAnimatedTravelHandler() {
|
||||
if (!modelUuid) return;
|
||||
|
||||
|
||||
animatedTravelLogStatus(material.materialName, `performing animatedTravel`);
|
||||
workerLogStatus(material.materialName, `performing worker action`);
|
||||
|
||||
}, [getMaterialById]);
|
||||
|
||||
return {
|
||||
handleAnimatedTravel,
|
||||
handleWorker,
|
||||
};
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
import { useEffect, useCallback } from 'react';
|
||||
import { useAnimatedTravelHandler } from './actionHandler/useAnimatedTravelHandler';
|
||||
import { useWorkerHandler } from './actionHandler/useWorkerHandler';
|
||||
|
||||
export function useHumanActions() {
|
||||
const { handleAnimatedTravel } = useAnimatedTravelHandler();
|
||||
const { handleWorker } = useWorkerHandler();
|
||||
|
||||
const handleAnimatedTravelAction = useCallback((action: HumanAction) => {
|
||||
handleAnimatedTravel(action);
|
||||
}, [handleAnimatedTravel]);
|
||||
const handleWorkerAction = useCallback((action: HumanAction) => {
|
||||
handleWorker(action);
|
||||
}, [handleWorker]);
|
||||
|
||||
const handleHumanAction = useCallback((action: HumanAction, materialId: string) => {
|
||||
if (!action) return;
|
||||
|
||||
switch (action.actionType) {
|
||||
case 'animatedTravel':
|
||||
handleAnimatedTravelAction(action);
|
||||
case 'worker':
|
||||
handleWorkerAction(action);
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unknown Human action type: ${action.actionType}`);
|
||||
}
|
||||
}, [handleAnimatedTravelAction]);
|
||||
}, [handleWorkerAction]);
|
||||
|
||||
const cleanup = useCallback(() => {
|
||||
}, []);
|
||||
|
||||
@@ -39,7 +39,7 @@ export function useActionHandler() {
|
||||
case 'store': case 'retrieve':
|
||||
handleStorageAction(action as StorageAction, materialId as string);
|
||||
break;
|
||||
case 'animatedTravel':
|
||||
case 'worker':
|
||||
handleHumanAction(action as HumanAction, materialId as string);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -155,8 +155,8 @@ function TriggerConnector() {
|
||||
// Handle Human point
|
||||
else if (event.type === "human" && 'point' in event) {
|
||||
const point = event.point;
|
||||
if (point.action?.triggers) {
|
||||
point.action.triggers.forEach(trigger => {
|
||||
point.actions?.forEach(action => {
|
||||
action.triggers?.forEach(trigger => {
|
||||
if (trigger.triggeredAsset && trigger.triggeredAsset.triggeredPoint) {
|
||||
newConnections.push({
|
||||
id: `${point.uuid}-${trigger.triggeredAsset.triggeredPoint.pointUuid}-${trigger.triggerUuid}`,
|
||||
@@ -166,7 +166,7 @@ function TriggerConnector() {
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user