Skip to content

Commit

Permalink
fix: some live2d model motion base not found
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaroma committed Jan 20, 2024
1 parent f109d53 commit 74a23fe
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/pages/live2d/Live2D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,22 @@ const Live2DView: React.FC<{}> = () => {
[isRecording, recorder]
);

const handleShow = useCallback(() => {
setModelName(selectedModelName);
let motionName = selectedModelName;
if (motionName) {
if (motionName?.startsWith("sub") || motionName?.startsWith("clb")) {
motionName = motionName.split("_").slice(0, 2).join("_");
} else {
motionName = motionName.split("_")[0]!;
}
if (motionName.endsWith("black")) {
motionName = motionName.slice(0, -5);
}
setMotionName(motionName + "_motion_base");
}
}, [selectedModelName]);

return (
<Fragment>
<TypographyHeader>Live2D</TypographyHeader>
Expand All @@ -438,17 +454,7 @@ const Live2DView: React.FC<{}> = () => {
<Button
disabled={!selectedModelName || showProgress}
variant="contained"
onClick={() => {
setModelName(selectedModelName);
setMotionName(
(selectedModelName?.startsWith("sub") ||
selectedModelName?.startsWith("clb")
? selectedModelName
: selectedModelName?.startsWith("v2")
? selectedModelName?.split("_").slice(0, 2).join("_")
: selectedModelName?.split("_")[0]) + "_motion_base"
);
}}
onClick={handleShow}
>
{t("common:show")}
</Button>
Expand Down

0 comments on commit 74a23fe

Please sign in to comment.