robotic arm and storage unit bug fix
This commit is contained in:
@@ -73,7 +73,7 @@ export function useRetrieveHandler() {
|
|||||||
if (isPlaying && !initialDelayComplete) {
|
if (isPlaying && !initialDelayComplete) {
|
||||||
delayTimerRef.current = setTimeout(() => {
|
delayTimerRef.current = setTimeout(() => {
|
||||||
setInitialDelayComplete(true);
|
setInitialDelayComplete(true);
|
||||||
}, 3000);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
const totalDistanceRef = useRef(0);
|
const totalDistanceRef = useRef(0);
|
||||||
const startTimeRef = useRef<number | null>(null);
|
const startTimeRef = useRef<number | null>(null);
|
||||||
const segmentDistancesRef = useRef<number[]>([]);
|
const segmentDistancesRef = useRef<number[]>([]);
|
||||||
|
const clockRef = useRef(new THREE.Clock());
|
||||||
const [currentPath, setCurrentPath] = useState<[number, number, number][]>([]);
|
const [currentPath, setCurrentPath] = useState<[number, number, number][]>([]);
|
||||||
const [circlePoints, setCirclePoints] = useState<[number, number, number][]>([]);
|
const [circlePoints, setCirclePoints] = useState<[number, number, number][]>([]);
|
||||||
const [circlePointsWithDegrees, setCirclePointsWithDegrees] = useState<PointWithDegree[]>([]);
|
const [circlePointsWithDegrees, setCirclePointsWithDegrees] = useState<PointWithDegree[]>([]);
|
||||||
@@ -72,7 +73,7 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
bone.position.copy(restPosition);
|
bone.position.copy(restPosition);
|
||||||
ikSolver.update();
|
ikSolver.update();
|
||||||
}
|
}
|
||||||
}, [isReset, isPlaying]);
|
}, [isReset, isPlaying, ikSolver]);
|
||||||
|
|
||||||
//Generate Circle Points
|
//Generate Circle Points
|
||||||
function generateRingPoints(radius: any, segments: any) {
|
function generateRingPoints(radius: any, segments: any) {
|
||||||
@@ -156,7 +157,7 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
|
|
||||||
// Handle nearest points and final path (including arc points)
|
// Handle nearest points and final path (including arc points)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (circlePoints.length > 0 && currentPath.length > 0 && ikSolver.mesh) {
|
if (ikSolver && circlePoints.length > 0 && currentPath.length > 0 && ikSolver.mesh) {
|
||||||
let start = currentPath[0];
|
let start = currentPath[0];
|
||||||
let end = currentPath[currentPath.length - 1];
|
let end = currentPath[currentPath.length - 1];
|
||||||
const bone = ikSolver.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
const bone = ikSolver.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
||||||
@@ -171,7 +172,11 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
const triggeringModel = getTriggeringModels(selectedProduct.productUuid, currentAction.actionUuid);
|
const triggeringModel = getTriggeringModels(selectedProduct.productUuid, currentAction.actionUuid);
|
||||||
const prevModel = triggeringModel[0] || null;
|
const prevModel = triggeringModel[0] || null;
|
||||||
const nextModel = getEventByModelUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || "");
|
const nextModel = getEventByModelUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || "");
|
||||||
const nextPoint = getPointByUuid(selectedProduct.productUuid, currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || "", currentAction?.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid || "");
|
const nextPoint = getPointByUuid(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
currentAction?.triggers[0]?.triggeredAsset?.triggeredModel?.modelUuid || "",
|
||||||
|
currentAction?.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid || ""
|
||||||
|
);
|
||||||
|
|
||||||
if (prevModel && prevModel.type === "transfer") {
|
if (prevModel && prevModel.type === "transfer") {
|
||||||
const material = scene.getObjectByProperty("uuid", currentMaterial);
|
const material = scene.getObjectByProperty("uuid", currentMaterial);
|
||||||
@@ -280,7 +285,15 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
arcPoints = arcCounterClockwise;
|
arcPoints = arcCounterClockwise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathVectors = [new THREE.Vector3(start[0], start[1], start[2]), new THREE.Vector3(start[0], curveHeight, start[2]), new THREE.Vector3(nearestToStart[0], curveHeight, nearestToStart[2]), ...arcPoints.map((point) => new THREE.Vector3(point[0], curveHeight, point[2])), new THREE.Vector3(nearestToEnd[0], curveHeight, nearestToEnd[2]), new THREE.Vector3(end[0], curveHeight, end[2]), new THREE.Vector3(end[0], end[1], end[2])];
|
const pathVectors = [
|
||||||
|
new THREE.Vector3(start[0], start[1], start[2]),
|
||||||
|
new THREE.Vector3(start[0], curveHeight, start[2]),
|
||||||
|
new THREE.Vector3(nearestToStart[0], curveHeight, nearestToStart[2]),
|
||||||
|
...arcPoints.map((point) => new THREE.Vector3(point[0], curveHeight, point[2])),
|
||||||
|
new THREE.Vector3(nearestToEnd[0], curveHeight, nearestToEnd[2]),
|
||||||
|
new THREE.Vector3(end[0], curveHeight, end[2]),
|
||||||
|
new THREE.Vector3(end[0], end[1], end[2]),
|
||||||
|
];
|
||||||
|
|
||||||
const pathSegments: [THREE.Vector3, THREE.Vector3][] = [];
|
const pathSegments: [THREE.Vector3, THREE.Vector3][] = [];
|
||||||
for (let i = 0; i < pathVectors.length - 1; i++) {
|
for (let i = 0; i < pathVectors.length - 1; i++) {
|
||||||
@@ -297,8 +310,9 @@ function RoboticArmAnimator({ HandleCallback, restPosition, ikSolver, targetBone
|
|||||||
}, [circlePoints, currentPath]);
|
}, [circlePoints, currentPath]);
|
||||||
|
|
||||||
// Frame update for animation
|
// Frame update for animation
|
||||||
useFrame((_, delta) => {
|
useFrame(() => {
|
||||||
if (!ikSolver) return;
|
if (!ikSolver) return;
|
||||||
|
const delta = clockRef.current.getDelta();
|
||||||
|
|
||||||
const bone = ikSolver.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
const bone = ikSolver.mesh.skeleton.bones.find((b: any) => b.name === targetBone);
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isReset || !isPlaying) {
|
if (isReset || !isPlaying) {
|
||||||
|
console.log('hii');
|
||||||
logStatus(armBot.modelUuid, "Simulation Play Reset Successfully");
|
logStatus(armBot.modelUuid, "Simulation Play Reset Successfully");
|
||||||
setArmBotActive(armBot.modelUuid, false);
|
setArmBotActive(armBot.modelUuid, false);
|
||||||
setArmBotState(armBot.modelUuid, "idle");
|
setArmBotState(armBot.modelUuid, "idle");
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from "react";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { useThree } from "@react-three/fiber";
|
import { useThree } from "@react-three/fiber";
|
||||||
import { CCDIKSolver, CCDIKHelper } from "three/examples/jsm/animation/CCDIKSolver";
|
import { CCDIKSolver, CCDIKHelper } from "three/examples/jsm/animation/CCDIKSolver";
|
||||||
import { usePlayButtonStore, useResetButtonStore } from '../../../../../store/ui/usePlayButtonStore';
|
import { usePlayButtonStore, useResetButtonStore } from "../../../../../store/ui/usePlayButtonStore";
|
||||||
|
|
||||||
type IKInstanceProps = {
|
type IKInstanceProps = {
|
||||||
setIkSolver: any
|
setIkSolver: any;
|
||||||
armBot: ArmBotStatus;
|
armBot: ArmBotStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,17 +58,16 @@ function IKInstance({ setIkSolver, armBot }: Readonly<IKInstanceProps>) {
|
|||||||
// scene.add(helper);
|
// scene.add(helper);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
trySetup();
|
trySetup();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (retryId) clearTimeout(retryId);
|
if (retryId) clearTimeout(retryId);
|
||||||
};
|
};
|
||||||
}, [isPlaying, isReset]);
|
}, [isPlaying, isReset, armBot.modelUuid]);
|
||||||
|
|
||||||
return (
|
return <></>;
|
||||||
<>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IKInstance;
|
export default IKInstance;
|
||||||
Reference in New Issue
Block a user