2025-09-05 15:54:38 +05:30
|
|
|
import { useEffect, useRef, useState } from "react";
|
2025-06-10 15:28:23 +05:30
|
|
|
import * as THREE from "three";
|
2025-09-05 15:54:38 +05:30
|
|
|
import IKInstance from "../ikInstance/ikInstance";
|
|
|
|
|
import RoboticArmAnimator from "../animator/roboticArmAnimator";
|
|
|
|
|
import MaterialAnimator from "../animator/materialAnimator";
|
|
|
|
|
import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore, useResetButtonStore } from "../../../../../store/ui/usePlayButtonStore";
|
|
|
|
|
import { useTriggerHandler } from "../../../triggers/triggerHandler/useTriggerHandler";
|
|
|
|
|
import { useSceneContext } from "../../../../scene/sceneContext";
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
2025-09-05 15:54:38 +05:30
|
|
|
const [currentPhase, setCurrentPhase] = useState<string>("init");
|
2025-06-10 15:28:23 +05:30
|
|
|
const [path, setPath] = useState<[number, number, number][]>([]);
|
|
|
|
|
const [ikSolver, setIkSolver] = useState<any>(null);
|
|
|
|
|
const restPosition = new THREE.Vector3(0, 1.75, -1.6);
|
|
|
|
|
const targetBone = "Target";
|
|
|
|
|
const pauseTimeRef = useRef<number | null>(null);
|
|
|
|
|
const isPausedRef = useRef<boolean>(false);
|
|
|
|
|
const isSpeedRef = useRef<any>(null);
|
|
|
|
|
|
2025-07-07 16:21:21 +05:30
|
|
|
const { materialStore, armBotStore, vehicleStore, storageUnitStore, productStore, assetStore } = useSceneContext();
|
|
|
|
|
const { resetAsset } = assetStore();
|
2025-12-15 14:16:20 +05:30
|
|
|
const { setArmBotActive, setArmBotState, removeCurrentAction, incrementActiveTime, incrementIdleTime, armBots } = armBotStore();
|
2025-06-10 15:28:23 +05:30
|
|
|
const { decrementVehicleLoad, removeLastMaterial } = vehicleStore();
|
|
|
|
|
const { removeLastMaterial: removeLastStorageMaterial, updateCurrentLoad } = storageUnitStore();
|
2025-06-23 09:37:53 +05:30
|
|
|
const { getMaterialById, setIsVisible } = materialStore();
|
2025-09-05 15:54:38 +05:30
|
|
|
const { getActionByUuid, getEventByActionUuid, getEventByModelUuid, selectedProduct } = productStore();
|
2025-06-10 15:28:23 +05:30
|
|
|
const { triggerPointActions } = useTriggerHandler();
|
|
|
|
|
const { isPlaying } = usePlayButtonStore();
|
|
|
|
|
const { isReset } = useResetButtonStore();
|
|
|
|
|
const { isPaused } = usePauseButtonStore();
|
|
|
|
|
const { speed } = useAnimationPlaySpeed();
|
|
|
|
|
|
|
|
|
|
const activeSecondsElapsed = useRef(0);
|
|
|
|
|
const idleSecondsElapsed = useRef(0);
|
|
|
|
|
|
|
|
|
|
const animationFrameIdRef = useRef<number | null>(null);
|
|
|
|
|
const previousTimeRef = useRef<number | null>(null);
|
|
|
|
|
|
2025-09-05 15:54:38 +05:30
|
|
|
const lastRemoved = useRef<{ type: string; materialId: string; modelId: string } | null>(null);
|
2025-06-10 15:28:23 +05:30
|
|
|
|
2025-09-05 15:54:38 +05:30
|
|
|
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction?.actionUuid || "");
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
const handlePickUpTrigger = () => {
|
2025-09-02 15:21:13 +05:30
|
|
|
if (armBot?.currentAction?.materialId) {
|
2025-06-10 15:28:23 +05:30
|
|
|
const material = getMaterialById(armBot.currentAction.materialId);
|
2025-09-02 15:21:13 +05:30
|
|
|
if (material?.previous?.modelUuid) {
|
2025-06-10 15:28:23 +05:30
|
|
|
const previousModel = getEventByActionUuid(selectedProduct.productUuid, material.previous.actionUuid);
|
|
|
|
|
if (previousModel) {
|
2025-09-05 15:54:38 +05:30
|
|
|
if (previousModel.type === "transfer") {
|
2025-06-10 15:28:23 +05:30
|
|
|
setIsVisible(armBot.currentAction.materialId, false);
|
2025-09-05 15:54:38 +05:30
|
|
|
} else if (previousModel.type === "machine") {
|
2025-06-10 15:28:23 +05:30
|
|
|
// machine specific logic
|
2025-09-05 15:54:38 +05:30
|
|
|
} else if (previousModel.type === "vehicle") {
|
2025-06-10 15:28:23 +05:30
|
|
|
decrementVehicleLoad(previousModel.modelUuid, 1);
|
|
|
|
|
removeLastMaterial(previousModel.modelUuid);
|
2025-09-05 15:54:38 +05:30
|
|
|
} else if (previousModel.type === "storageUnit") {
|
2025-06-10 15:28:23 +05:30
|
|
|
// storage unit logic
|
|
|
|
|
removeLastStorageMaterial(previousModel.modelUuid);
|
2025-09-05 15:54:38 +05:30
|
|
|
updateCurrentLoad(previousModel.modelUuid, -1);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
2025-06-12 09:31:51 +05:30
|
|
|
lastRemoved.current = { type: previousModel.type, materialId: armBot.currentAction.materialId, modelId: previousModel.modelUuid };
|
2025-06-10 15:28:23 +05:30
|
|
|
} else {
|
|
|
|
|
setIsVisible(armBot.currentAction.materialId, false);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setIsVisible(armBot.currentAction.materialId, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
};
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
const handleDropTrigger = () => {
|
|
|
|
|
if (armBot.currentAction) {
|
|
|
|
|
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction.actionUuid);
|
2025-09-05 15:54:38 +05:30
|
|
|
const model = getEventByModelUuid(selectedProduct.productUuid, action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid || "");
|
2025-09-02 15:21:13 +05:30
|
|
|
if (action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid) {
|
2025-06-10 15:28:23 +05:30
|
|
|
if (!model) return;
|
2025-09-05 15:54:38 +05:30
|
|
|
if (model.type === "transfer") {
|
|
|
|
|
setIsVisible(armBot.currentAction.materialId || "", true);
|
|
|
|
|
} else if (model.type === "machine") {
|
2025-06-10 15:28:23 +05:30
|
|
|
//
|
2025-09-05 15:54:38 +05:30
|
|
|
} else if (model.type === "vehicle") {
|
2025-06-10 15:28:23 +05:30
|
|
|
//
|
2025-09-05 15:54:38 +05:30
|
|
|
} else if (model.type === "storageUnit") {
|
2025-06-10 15:28:23 +05:30
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (action && armBot.currentAction.materialId) {
|
2025-09-05 15:54:38 +05:30
|
|
|
triggerPointActions(action, armBot.currentAction.materialId);
|
|
|
|
|
removeCurrentAction(armBot.modelUuid);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
|
2025-06-12 09:31:51 +05:30
|
|
|
// if (lastRemoved.current) {
|
|
|
|
|
// if (lastRemoved.current.type === 'transfer') {
|
|
|
|
|
// setIsPaused(lastRemoved.current.materialId, true)
|
|
|
|
|
// } else {
|
|
|
|
|
// setIsPaused(lastRemoved.current.materialId, false)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
};
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
isPausedRef.current = isPaused;
|
|
|
|
|
}, [isPaused]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
isSpeedRef.current = speed;
|
|
|
|
|
}, [speed]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (isReset || !isPlaying) {
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Simulation Play Reset Successfully");
|
|
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "idle");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("init");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
2025-06-10 15:28:23 +05:30
|
|
|
setIkSolver(null);
|
2025-07-07 16:21:21 +05:30
|
|
|
removeCurrentAction(armBot.modelUuid);
|
|
|
|
|
resetAsset(armBot.modelUuid);
|
2025-09-05 15:54:38 +05:30
|
|
|
isPausedRef.current = false;
|
|
|
|
|
pauseTimeRef.current = null;
|
2025-06-10 15:28:23 +05:30
|
|
|
activeSecondsElapsed.current = 0;
|
|
|
|
|
idleSecondsElapsed.current = 0;
|
|
|
|
|
previousTimeRef.current = null;
|
|
|
|
|
|
|
|
|
|
if (animationFrameIdRef.current !== null) {
|
|
|
|
|
cancelAnimationFrame(animationFrameIdRef.current);
|
|
|
|
|
animationFrameIdRef.current = null;
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
const targetBones = ikSolver?.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
2025-06-10 15:28:23 +05:30
|
|
|
if (targetBones && isPlaying) {
|
2025-09-05 15:54:38 +05:30
|
|
|
let curve = createCurveBetweenTwoPoints(targetBones.position, restPosition);
|
2025-06-10 15:28:23 +05:30
|
|
|
if (curve) {
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath(curve.points.map((point) => [point.x, point.y, point.z]));
|
|
|
|
|
logStatus(armBot.modelUuid, "Moving armBot from initial point to rest position.");
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
}, [isReset, isPlaying]);
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
function animate(currentTime: number) {
|
|
|
|
|
if (previousTimeRef.current === null) {
|
|
|
|
|
previousTimeRef.current = currentTime;
|
|
|
|
|
}
|
|
|
|
|
const deltaTime = (currentTime - previousTimeRef.current) / 1000;
|
|
|
|
|
previousTimeRef.current = currentTime;
|
|
|
|
|
if (armBot.isActive) {
|
|
|
|
|
if (!isPausedRef.current) {
|
|
|
|
|
activeSecondsElapsed.current += deltaTime * isSpeedRef.current;
|
|
|
|
|
// console.log(' activeSecondsElapsed.current: ', activeSecondsElapsed.current);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!isPausedRef.current) {
|
|
|
|
|
idleSecondsElapsed.current += deltaTime * isSpeedRef.current;
|
|
|
|
|
// console.log('idleSecondsElapsed.current: ', idleSecondsElapsed.current);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
animationFrameIdRef.current = requestAnimationFrame(animate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-09-05 15:54:38 +05:30
|
|
|
if (!isPlaying) return;
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
if (!armBot.isActive && armBot.state === "idle" && (currentPhase === "rest" || currentPhase === "init")) {
|
|
|
|
|
cancelAnimationFrame(animationFrameIdRef.current!);
|
|
|
|
|
animationFrameIdRef.current = null;
|
|
|
|
|
const roundedActiveTime = Math.round(activeSecondsElapsed.current); // Get the final rounded active time
|
|
|
|
|
// console.log('🚨Final Active Time:',armBot.modelUuid, roundedActiveTime, 'seconds');
|
|
|
|
|
incrementActiveTime(armBot.modelUuid, roundedActiveTime);
|
|
|
|
|
activeSecondsElapsed.current = 0;
|
|
|
|
|
} else if (armBot.isActive && armBot.state !== "idle" && currentPhase !== "rest" && armBot.currentAction) {
|
|
|
|
|
cancelAnimationFrame(animationFrameIdRef.current!);
|
|
|
|
|
animationFrameIdRef.current = null;
|
|
|
|
|
const roundedIdleTime = Math.round(idleSecondsElapsed.current); // Get the final rounded idle time
|
|
|
|
|
// console.log('🕒 Final Idle Time:', armBot.modelUuid,roundedIdleTime, 'seconds');
|
|
|
|
|
incrementIdleTime(armBot.modelUuid, roundedIdleTime);
|
|
|
|
|
idleSecondsElapsed.current = 0;
|
|
|
|
|
}
|
|
|
|
|
if (animationFrameIdRef.current === null) {
|
|
|
|
|
animationFrameIdRef.current = requestAnimationFrame(animate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (animationFrameIdRef.current !== null) {
|
|
|
|
|
cancelAnimationFrame(animationFrameIdRef.current);
|
|
|
|
|
animationFrameIdRef.current = null; // Reset the animation frame ID
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-12-15 14:16:20 +05:30
|
|
|
}, [armBot, armBots, currentPhase, isPlaying]);
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const targetBones = ikSolver?.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
|
|
|
|
if (!isReset && isPlaying) {
|
|
|
|
|
if (!armBot?.isActive && armBot?.state == "idle" && currentPhase == "init") {
|
|
|
|
|
if (targetBones) {
|
2025-09-05 15:54:38 +05:30
|
|
|
setArmBotActive(armBot.modelUuid, true);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("init-to-rest");
|
2025-09-05 15:54:38 +05:30
|
|
|
let curve = createCurveBetweenTwoPoints(targetBones.position, restPosition);
|
2025-06-10 15:28:23 +05:30
|
|
|
if (curve) {
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath(curve.points.map((point) => [point.x, point.y, point.z]));
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Moving armBot from initial point to rest position.");
|
2025-08-22 13:51:35 +05:30
|
|
|
} else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && !armBot.currentAction) {
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Waiting to trigger CurrentAction");
|
2025-08-22 13:51:35 +05:30
|
|
|
} else if (armBot && !armBot.isActive && armBot.state === "idle" && currentPhase === "rest" && armBot.currentAction) {
|
2025-06-10 15:28:23 +05:30
|
|
|
if (armBot.currentAction) {
|
|
|
|
|
setArmBotActive(armBot.modelUuid, true);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
|
|
|
|
setCurrentPhase("rest-to-start");
|
|
|
|
|
if (!action) return;
|
|
|
|
|
const startPoint = (action as RoboticArmAction).process.startPoint;
|
|
|
|
|
if (startPoint) {
|
|
|
|
|
let curve = createCurveBetweenTwoPoints(targetBones.position, new THREE.Vector3(startPoint[0], startPoint[1], startPoint[2]));
|
|
|
|
|
if (curve) {
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath(curve.points.map((point) => [point.x, point.y, point.z]));
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Moving armBot from rest point to start position.");
|
2025-08-22 13:51:35 +05:30
|
|
|
} else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "picking" && armBot.currentAction) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setArmBotActive(armBot.modelUuid, true);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
|
|
|
|
setCurrentPhase("start-to-end");
|
|
|
|
|
if (!action) return;
|
|
|
|
|
const startPoint = (action as RoboticArmAction).process.startPoint;
|
|
|
|
|
const endPoint = (action as RoboticArmAction).process.endPoint;
|
|
|
|
|
if (startPoint && endPoint) {
|
|
|
|
|
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(startPoint[0], startPoint[1], startPoint[2]), new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]));
|
|
|
|
|
if (curve) {
|
|
|
|
|
logStatus(armBot.modelUuid, "picking the object");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath(curve.points.map((point) => [point.x, point.y, point.z]));
|
2025-08-22 13:51:35 +05:30
|
|
|
handlePickUpTrigger();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Moving armBot from start point to end position.");
|
|
|
|
|
}, 100);
|
2025-08-22 13:51:35 +05:30
|
|
|
} else if (armBot && !armBot.isActive && armBot.state === "running" && currentPhase === "dropping" && armBot.currentAction) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setArmBotActive(armBot.modelUuid, true);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
|
|
|
|
setCurrentPhase("end-to-rest");
|
|
|
|
|
if (!action) return;
|
|
|
|
|
const endPoint = (action as RoboticArmAction).process.endPoint;
|
|
|
|
|
if (endPoint) {
|
|
|
|
|
let curve = createCurveBetweenTwoPoints(new THREE.Vector3(endPoint[0], endPoint[1], endPoint[2]), restPosition);
|
|
|
|
|
if (curve) {
|
|
|
|
|
logStatus(armBot.modelUuid, "dropping the object");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath(curve.points.map((point) => [point.x, point.y, point.z]));
|
2025-08-22 13:51:35 +05:30
|
|
|
|
|
|
|
|
handleDropTrigger();
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Moving armBot from end point to rest position.");
|
|
|
|
|
}, 100);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
} else {
|
2025-09-05 15:54:38 +05:30
|
|
|
logStatus(armBot.modelUuid, "Simulation Play Exited");
|
|
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "idle");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("init");
|
|
|
|
|
setIkSolver(null);
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
|
|
|
|
isPausedRef.current = false;
|
|
|
|
|
pauseTimeRef.current = null;
|
|
|
|
|
isPausedRef.current = false;
|
2025-06-10 15:28:23 +05:30
|
|
|
activeSecondsElapsed.current = 0;
|
|
|
|
|
idleSecondsElapsed.current = 0;
|
|
|
|
|
previousTimeRef.current = null;
|
|
|
|
|
if (animationFrameIdRef.current !== null) {
|
|
|
|
|
cancelAnimationFrame(animationFrameIdRef.current);
|
|
|
|
|
animationFrameIdRef.current = null;
|
|
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
removeCurrentAction(armBot.modelUuid);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
}, [currentPhase, armBot, isPlaying, isReset, ikSolver]);
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
function createCurveBetweenTwoPoints(p1: any, p2: any) {
|
|
|
|
|
const mid = new THREE.Vector3().addVectors(p1, p2).multiplyScalar(0.5);
|
|
|
|
|
const points = [p1, mid, p2];
|
|
|
|
|
return new THREE.CatmullRomCurve3(points);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const HandleCallback = () => {
|
2025-09-15 17:07:43 +05:30
|
|
|
if (armBot.isActive && armBot.state === "running" && currentPhase === "init-to-rest") {
|
2025-06-10 15:28:23 +05:30
|
|
|
logStatus(armBot.modelUuid, "Callback triggered: rest");
|
2025-09-05 15:54:38 +05:30
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "idle");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("rest");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
2025-09-15 17:07:43 +05:30
|
|
|
} else if (armBot.state === "running" && currentPhase === "rest-to-start") {
|
2025-06-10 15:28:23 +05:30
|
|
|
logStatus(armBot.modelUuid, "Callback triggered: pick.");
|
2025-09-05 15:54:38 +05:30
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("picking");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
2025-09-15 17:07:43 +05:30
|
|
|
} else if (armBot.isActive && armBot.state === "running" && currentPhase === "start-to-end") {
|
2025-06-10 15:28:23 +05:30
|
|
|
logStatus(armBot.modelUuid, "Callback triggered: drop.");
|
2025-09-05 15:54:38 +05:30
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "running");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("dropping");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
2025-09-15 17:07:43 +05:30
|
|
|
} else if (armBot.isActive && armBot.state === "running" && currentPhase === "end-to-rest") {
|
2025-06-10 15:28:23 +05:30
|
|
|
logStatus(armBot.modelUuid, "Callback triggered: rest, cycle completed.");
|
2025-09-05 15:54:38 +05:30
|
|
|
setArmBotActive(armBot.modelUuid, false);
|
|
|
|
|
setArmBotState(armBot.modelUuid, "idle");
|
2025-06-10 15:28:23 +05:30
|
|
|
setCurrentPhase("rest");
|
2025-09-05 15:54:38 +05:30
|
|
|
setPath([]);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
2025-09-05 15:54:38 +05:30
|
|
|
};
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
const logStatus = (id: string, status: string) => {
|
|
|
|
|
// console.log('status: ', status);
|
2025-09-05 15:54:38 +05:30
|
|
|
};
|
2025-06-10 15:28:23 +05:30
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{!isReset && isPlaying && (
|
|
|
|
|
<>
|
2025-07-07 16:21:21 +05:30
|
|
|
<IKInstance setIkSolver={setIkSolver} armBot={armBot} />
|
2025-12-15 14:16:20 +05:30
|
|
|
<RoboticArmAnimator
|
|
|
|
|
HandleCallback={HandleCallback}
|
|
|
|
|
restPosition={restPosition}
|
|
|
|
|
ikSolver={ikSolver}
|
|
|
|
|
targetBone={targetBone}
|
|
|
|
|
armBot={armBot}
|
|
|
|
|
path={path}
|
|
|
|
|
currentPhase={currentPhase}
|
|
|
|
|
/>
|
2025-06-10 15:28:23 +05:30
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
<MaterialAnimator ikSolver={ikSolver} armBot={armBot} currentPhase={currentPhase} />
|
|
|
|
|
</>
|
2025-09-05 15:54:38 +05:30
|
|
|
);
|
2025-06-10 15:28:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default RoboticArmInstance;
|