Skip to content

Commit

Permalink
fix: some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ylxmf2005 committed Feb 16, 2025
1 parent 04614cf commit 6850fbf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/renderer/src/hooks/canvas/use-live2d-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export const useLive2DModel = ({
(model: Live2DModel, x: number, y: number) => {
if (!modelInfo?.tapMotions) return;

console.log("handleTapMotion", modelInfo?.tapMotions);
// Convert global coordinates to model's local coordinates
const localPos = model.toLocal(new PIXI.Point(x, y));
const hitAreas = model.hitTest(localPos.x, localPos.y);
Expand Down Expand Up @@ -351,7 +352,7 @@ const playRandomMotion = (model: Live2DModel, motionGroup: MotionWeightMap) => {
if (random <= 0) {
const priority = audioTaskQueue.hasTask()
? MotionPriority.NORMAL
: MotionPriority.NORMAL;
: MotionPriority.FORCE;

console.log(
`Playing weighted motion: ${motion} (weight: ${weight}/${totalWeight}, priority: ${priority})`,
Expand Down
28 changes: 16 additions & 12 deletions src/renderer/src/hooks/utils/use-audio-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,22 @@ export const useAudioTask = () => {
}

let isFinished = false;
model.speak(`data:audio/wav;base64,${audioBase64}`, {
onFinish: () => {
console.log("Voiceline is over");
isFinished = true;
resolve();
},
onError: (error) => {
console.error("Audio playback error:", error);
isFinished = true;
resolve();
},
});
if (audioBase64) {
model.speak(`data:audio/wav;base64,${audioBase64}`, {
onFinish: () => {
console.log("Voiceline is over");
isFinished = true;
resolve();
},
onError: (error) => {
console.error("Audio playback error:", error);
isFinished = true;
resolve();
},
});
} else {
resolve();
}

const checkFinished = () => {
if (!isFinished) {
Expand Down

0 comments on commit 6850fbf

Please sign in to comment.