fix: Update asset animation state handling to ensure correct playback status

This commit is contained in:
2025-07-04 14:02:44 +05:30
parent 02490214d9
commit ff02f01430
2 changed files with 6 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ function HumanInstance({ human }: { human: HumanStatus }) {
const { getActionByUuid, getEventByModelUuid, getTriggerByUuid } = productStore();
const { selectedProductStore } = useProductContext();
const { selectedProduct } = selectedProductStore();
const { setHumanActive, setHumanState, setHumanPicking, clearCurrentMaterials, setHumanLoad, decrementHumanLoad, removeLastMaterial, getLastMaterial, incrementIdleTime, incrementActiveTime, resetTime } = humanStore();
const { setHumanActive, setHumanState, setHumanPicking, clearCurrentMaterials, setHumanLoad, decrementHumanLoad, removeLastMaterial, incrementIdleTime, incrementActiveTime, resetTime } = humanStore();
const [currentPhase, setCurrentPhase] = useState<string>('init');
const [path, setPath] = useState<[number, number, number][]>([]);
@@ -34,7 +34,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
const activeTimeRef = useRef<number>(0);
const isPausedRef = useRef<boolean>(false);
const isSpeedRef = useRef<number>(0);
let startTime: number;
const { speed } = useAnimationPlaySpeed();
const { isPaused } = usePauseButtonStore();
const previousTimeRef = useRef<number | null>(null);
@@ -83,7 +82,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
setHumanLoad(human.modelUuid, 0);
resetAnimation(human.modelUuid);
setPath([]);
startTime = 0;
isPausedRef.current = false;
pauseTimeRef.current = 0;
resetTime(human.modelUuid)
@@ -167,8 +165,7 @@ function HumanInstance({ human }: { human: HumanStatus }) {
}
}
}
else {
} else {
reset()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -247,7 +244,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
};
}, [human, isPlaying]);
function startUnloadingProcess() {
const humanAsset = getAssetById(human.modelUuid);
if (humanAsset?.animationState?.current === 'drop' && humanAsset?.animationState?.isCompleted) {
@@ -284,12 +280,10 @@ function HumanInstance({ human }: { human: HumanStatus }) {
}
} else {
const droppedMaterial = human.currentLoad;
startTime = performance.now();
handleMaterialDropByDefault(droppedMaterial);
}
} else {
const droppedMaterial = human.currentLoad;
startTime = performance.now();
handleMaterialDropByDefault(droppedMaterial);
}
} else {

View File

@@ -182,8 +182,10 @@ export const createAssetStore = () => {
set((state) => {
const asset = state.assets.find(a => a.modelUuid === modelUuid);
if (asset?.animationState) {
asset.animationState = { current: '', isPlaying: false, loopAnimation: true, isCompleted: true };
}
asset.animationState.current = '';
asset.animationState.isPlaying = true;
asset.animationState.loopAnimation = true;
asset.animationState.isCompleted = true; }
});
},