bug fix in ik and code optimization

This commit is contained in:
2025-08-04 18:06:22 +05:30
parent 581069d861
commit c03e524b99
5 changed files with 39 additions and 30 deletions

View File

@@ -61,30 +61,12 @@ function MaterialInstance({ material }: { readonly material: MaterialSchema }) {
function getCurrentSpeed(productUuid: string, modelUuid: string) {
const event = getEventByModelUuid(productUuid, modelUuid)
if (event) {
if (event.type === 'transfer') {
return event.speed;
}
if (event.type === 'vehicle') {
return event.speed;
}
if (event.type === 'machine') {
if (event.type === 'transfer' || event.type === 'machine' || event.type === 'storageUnit') {
return 1;
}
if (event.type === 'roboticArm') {
if (event.type === 'vehicle' || event.type === 'roboticArm' || event.type === 'human') {
return event.speed;
}
if (event.type === 'storageUnit') {
return 1;
}
if (event.type === 'human') {
return event.speed;
}
} else {
return 1;
}

View File

@@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import { useEffect } from 'react'
import MaterialInstance from './instance/materialInstance'
import { useSceneContext } from '../../../scene/sceneContext';

View File

@@ -173,13 +173,16 @@ const ArmBotUI = () => {
const targetMesh = scene?.getObjectByProperty("uuid", selectedArmBotData?.modelUuid || '');
const iks = targetMesh?.userData?.iks;
const firstIK = Array.isArray(iks) && iks.length > 0 ? iks[0] : {};
const { handlePointerDown } = useDraggableGLTF(
updatePointToState,
{
minDistance: targetMesh?.userData?.iks[0]?.minDistance || 1.2,
maxDistance: targetMesh?.userData?.iks[0]?.maxDistance || 2,
maxheight: targetMesh?.userData?.iks[0]?.maxheight || 0.6,
minheight: targetMesh?.userData?.iks[0]?.minheight || 1.9,
minDistance: firstIK.minDistance ?? 1.2,
maxDistance: firstIK.maxDistance ?? 2,
maxheight: firstIK.maxheight ?? 0.6,
minheight: firstIK.minheight ?? 1.9,
}
);