feat: Improve trigger processing and static machine status updates in IKAnimationController
This commit is contained in:
parent
83f92d4b01
commit
5c24d7ca71
|
@ -114,10 +114,38 @@ const IKAnimationController = ({
|
|||
|
||||
if (prev.needsInitialMovement !== needsInitialMovement && !needsInitialMovement) {
|
||||
logStatus(`[Arm ${uuid}] Reached rest position, ready for animation`);
|
||||
|
||||
}
|
||||
|
||||
if (prev.selectedTrigger !== selectedTrigger) {
|
||||
logStatus(`[Arm ${uuid}] Processing new trigger: ${selectedTrigger}`);
|
||||
|
||||
|
||||
const currentProcess = process.find(p => p.triggerId === prev.selectedTrigger);
|
||||
if (currentProcess) {
|
||||
const triggerId = currentProcess.triggerId;
|
||||
|
||||
const endPoint = armBot.actions.processes.find((process) => process.triggerId === triggerId)?.endPoint;
|
||||
|
||||
// Search simulationStates for a StaticMachine that has a point matching this endPointId
|
||||
const matchedStaticMachine = simulationStates.find(
|
||||
(state) =>
|
||||
state.type === "StaticMachine" &&
|
||||
state.points?.uuid === endPoint// check for static machine with matching point uuid
|
||||
) as any;
|
||||
|
||||
if (matchedStaticMachine) {
|
||||
setStaticMachines((machines) => {
|
||||
return machines.map((machine) => {
|
||||
if (machine.uuid === matchedStaticMachine.modeluuid) {
|
||||
return { ...machine, status: "running" };
|
||||
} else {
|
||||
return machine;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update previous state
|
||||
|
@ -249,35 +277,6 @@ const IKAnimationController = ({
|
|||
} else if (progress >= startToEndRange[0] && progress < startToEndRange[1]) {
|
||||
currentSpeed = speed;
|
||||
currentStatus = "moving"; // Moving between points
|
||||
if (1 - progress < 0.05) {
|
||||
// Find the process that matches the current trigger
|
||||
const currentProcess = process.find(p => p.triggerId === selectedTrigger);
|
||||
if (currentProcess) {
|
||||
const triggerId = currentProcess.triggerId;
|
||||
|
||||
const endPoint = armBot.actions.processes.find((process) => process.triggerId === triggerId)?.endPoint;
|
||||
|
||||
// Search simulationStates for a StaticMachine that has a point matching this endPointId
|
||||
const matchedStaticMachine = simulationStates.find(
|
||||
(state) =>
|
||||
state.type === "StaticMachine" &&
|
||||
state.points?.uuid === endPoint// check for static machine with matching point uuid
|
||||
) as any;
|
||||
|
||||
if (matchedStaticMachine) {
|
||||
setStaticMachines((machines) => {
|
||||
return machines.map((machine) => {
|
||||
if (machine.uuid === matchedStaticMachine.modeluuid) {
|
||||
return { ...machine, status: "running" };
|
||||
} else {
|
||||
return machine;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (progress >= endToRestRange[0] && progress < 1) {
|
||||
currentSpeed = restSpeed;
|
||||
currentStatus = "moving"; // Returning to rest
|
||||
|
|
Loading…
Reference in New Issue