added human animation pause
This commit is contained in:
@@ -16,7 +16,7 @@ import { getUserData } from '../../../../../functions/getUserData';
|
|||||||
import { useSceneContext } from '../../../../scene/sceneContext';
|
import { useSceneContext } from '../../../../scene/sceneContext';
|
||||||
import { useVersionContext } from '../../../version/versionContext';
|
import { useVersionContext } from '../../../version/versionContext';
|
||||||
import { SkeletonUtils } from 'three-stdlib';
|
import { SkeletonUtils } from 'three-stdlib';
|
||||||
import { useAnimationPlaySpeed } from '../../../../../store/usePlayButtonStore';
|
import { useAnimationPlaySpeed, usePauseButtonStore } from '../../../../../store/usePlayButtonStore';
|
||||||
import { upsertProductOrEventApi } from '../../../../../services/simulation/products/UpsertProductOrEventApi';
|
import { upsertProductOrEventApi } from '../../../../../services/simulation/products/UpsertProductOrEventApi';
|
||||||
import { getAssetIksApi } from '../../../../../services/simulation/ik/getAssetIKs';
|
import { getAssetIksApi } from '../../../../../services/simulation/ik/getAssetIKs';
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
const { subModule } = useSubModuleStore();
|
const { subModule } = useSubModuleStore();
|
||||||
const { activeModule } = useModuleStore();
|
const { activeModule } = useModuleStore();
|
||||||
const { speed } = useAnimationPlaySpeed();
|
const { speed } = useAnimationPlaySpeed();
|
||||||
|
const { isPaused } = usePauseButtonStore();
|
||||||
const { assetStore, eventStore, productStore } = useSceneContext();
|
const { assetStore, eventStore, productStore } = useSceneContext();
|
||||||
const { removeAsset, setAnimations, resetAnimation, setAnimationComplete } = assetStore();
|
const { removeAsset, setAnimations, resetAnimation, setAnimationComplete } = assetStore();
|
||||||
const { setTop } = useTopData();
|
const { setTop } = useTopData();
|
||||||
@@ -386,7 +387,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
const currentAction = actions.current[current];
|
const currentAction = actions.current[current];
|
||||||
const previousAction = previousAnimation ? actions.current[previousAnimation] : null;
|
const previousAction = previousAnimation ? actions.current[previousAnimation] : null;
|
||||||
|
|
||||||
if (isPlaying && currentAction) {
|
if (isPlaying && currentAction && activeModule === 'simulation' && !isPaused) {
|
||||||
blendFactor.current = 0;
|
blendFactor.current = 0;
|
||||||
|
|
||||||
currentAction.reset();
|
currentAction.reset();
|
||||||
@@ -409,7 +410,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
mixerRef.current.removeEventListener('finished', handleAnimationComplete);
|
mixerRef.current.removeEventListener('finished', handleAnimationComplete);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [asset.animationState?.current, asset.animationState?.isPlaying]);
|
}, [asset.animationState?.current, asset.animationState?.isPlaying, isPaused, activeModule]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const canvasElement = gl.domElement;
|
const canvasElement = gl.domElement;
|
||||||
|
|||||||
@@ -171,21 +171,22 @@ const ArmBotUI = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetMesh = scene?.getObjectByProperty("uuid", selectedArmBotData.modelUuid);
|
const targetMesh = scene?.getObjectByProperty("uuid", selectedArmBotData?.modelUuid || '');
|
||||||
|
|
||||||
const { handlePointerDown } = useDraggableGLTF(
|
const { handlePointerDown } = useDraggableGLTF(
|
||||||
updatePointToState,
|
updatePointToState,
|
||||||
{
|
{
|
||||||
minDistance: targetMesh?.userData.iks[0].minDistance || 1.2,
|
minDistance: targetMesh?.userData?.iks[0]?.minDistance || 1.2,
|
||||||
maxDistance: targetMesh?.userData.iks[0].maxDistance || 2,
|
maxDistance: targetMesh?.userData?.iks[0]?.maxDistance || 2,
|
||||||
maxheight: targetMesh?.userData.iks[0].maxheight || 0.6,
|
maxheight: targetMesh?.userData?.iks[0]?.maxheight || 0.6,
|
||||||
minheight: targetMesh?.userData.iks[0].minheight || 1.9,
|
minheight: targetMesh?.userData?.iks[0]?.minheight || 1.9,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!selectedArmBotData || !Array.isArray(selectedArmBotData.point?.actions)) {
|
if (!selectedArmBotData || !Array.isArray(selectedArmBotData.point?.actions)) {
|
||||||
return null; // avoid rendering if no data yet
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{selectedArmBotData.point.actions.map((action: any) => {
|
{selectedArmBotData.point.actions.map((action: any) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user