fix: Update asset animation state handling to ensure correct playback status
This commit is contained in:
@@ -25,7 +25,7 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
const { getActionByUuid, getEventByModelUuid, getTriggerByUuid } = productStore();
|
const { getActionByUuid, getEventByModelUuid, getTriggerByUuid } = productStore();
|
||||||
const { selectedProductStore } = useProductContext();
|
const { selectedProductStore } = useProductContext();
|
||||||
const { selectedProduct } = selectedProductStore();
|
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 [currentPhase, setCurrentPhase] = useState<string>('init');
|
||||||
const [path, setPath] = useState<[number, number, number][]>([]);
|
const [path, setPath] = useState<[number, number, number][]>([]);
|
||||||
@@ -34,7 +34,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
const activeTimeRef = useRef<number>(0);
|
const activeTimeRef = useRef<number>(0);
|
||||||
const isPausedRef = useRef<boolean>(false);
|
const isPausedRef = useRef<boolean>(false);
|
||||||
const isSpeedRef = useRef<number>(0);
|
const isSpeedRef = useRef<number>(0);
|
||||||
let startTime: number;
|
|
||||||
const { speed } = useAnimationPlaySpeed();
|
const { speed } = useAnimationPlaySpeed();
|
||||||
const { isPaused } = usePauseButtonStore();
|
const { isPaused } = usePauseButtonStore();
|
||||||
const previousTimeRef = useRef<number | null>(null);
|
const previousTimeRef = useRef<number | null>(null);
|
||||||
@@ -83,7 +82,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
setHumanLoad(human.modelUuid, 0);
|
setHumanLoad(human.modelUuid, 0);
|
||||||
resetAnimation(human.modelUuid);
|
resetAnimation(human.modelUuid);
|
||||||
setPath([]);
|
setPath([]);
|
||||||
startTime = 0;
|
|
||||||
isPausedRef.current = false;
|
isPausedRef.current = false;
|
||||||
pauseTimeRef.current = 0;
|
pauseTimeRef.current = 0;
|
||||||
resetTime(human.modelUuid)
|
resetTime(human.modelUuid)
|
||||||
@@ -167,8 +165,7 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -247,7 +244,6 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
};
|
};
|
||||||
}, [human, isPlaying]);
|
}, [human, isPlaying]);
|
||||||
|
|
||||||
|
|
||||||
function startUnloadingProcess() {
|
function startUnloadingProcess() {
|
||||||
const humanAsset = getAssetById(human.modelUuid);
|
const humanAsset = getAssetById(human.modelUuid);
|
||||||
if (humanAsset?.animationState?.current === 'drop' && humanAsset?.animationState?.isCompleted) {
|
if (humanAsset?.animationState?.current === 'drop' && humanAsset?.animationState?.isCompleted) {
|
||||||
@@ -284,12 +280,10 @@ function HumanInstance({ human }: { human: HumanStatus }) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const droppedMaterial = human.currentLoad;
|
const droppedMaterial = human.currentLoad;
|
||||||
startTime = performance.now();
|
|
||||||
handleMaterialDropByDefault(droppedMaterial);
|
handleMaterialDropByDefault(droppedMaterial);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const droppedMaterial = human.currentLoad;
|
const droppedMaterial = human.currentLoad;
|
||||||
startTime = performance.now();
|
|
||||||
handleMaterialDropByDefault(droppedMaterial);
|
handleMaterialDropByDefault(droppedMaterial);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -182,8 +182,10 @@ export const createAssetStore = () => {
|
|||||||
set((state) => {
|
set((state) => {
|
||||||
const asset = state.assets.find(a => a.modelUuid === modelUuid);
|
const asset = state.assets.find(a => a.modelUuid === modelUuid);
|
||||||
if (asset?.animationState) {
|
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; }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user