Skip to content

Commit

Permalink
fix: emotions
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Dec 4, 2024
1 parent 0260584 commit 3b95add
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/stage/src/constants/emotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const EMOTION_ANGRY = '<|EMOTE_ANGRY|>'
export const EMOTION_THINK = '<|EMOTE_THINK|>'
export const EMOTION_SURPRISE = '<|EMOTE_SURPRISE|>'
export const EMOTION_AWKWARD = '<|EMOTE_AWKWARD|>'
export const EMOTION_QUESTION = '<|EMOTE_QUESTION|>'

export enum Emotion {
Happy = '<|EMOTE_HAPPY|>',
Expand All @@ -12,6 +13,7 @@ export enum Emotion {
Think = '<|EMOTE_THINK|>',
Surprise = '<|EMOTE_SURPRISE|>',
Awkward = '<|EMOTE_AWKWARD|>',
Question = '<|EMOTE_QUESTION|>',
}

export const EMOTION_VALUES = Object.values(Emotion)
Expand All @@ -22,6 +24,7 @@ export const EmotionAngryMotionName = 'EmotionAngry'
export const EmotionAwkwardMotionName = 'EmotionAwkward'
export const EmotionThinkMotionName = 'EmotionThink'
export const EmotionSurpriseMotionName = 'EmotionSurprise'
export const EmotionQuestionMotionName = 'EmotionQuestion'

export const EMOTION_EmotionMotionName_value = {
[Emotion.Happy]: EmotionHappyMotionName,
Expand All @@ -30,4 +33,5 @@ export const EMOTION_EmotionMotionName_value = {
[Emotion.Think]: EmotionThinkMotionName,
[Emotion.Surprise]: EmotionSurpriseMotionName,
[Emotion.Awkward]: EmotionAwkwardMotionName,
[Emotion.Question]: EmotionQuestionMotionName,
}
17 changes: 16 additions & 1 deletion packages/stage/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Buffer } from 'node:buffer'
import { copyFile, cp, mkdir } from 'node:fs/promises'
import { copyFile, cp, mkdir, readFile, writeFile } from 'node:fs/promises'
import path, { join, resolve } from 'node:path'

import VueI18n from '@intlify/unplugin-vue-i18n/vite'
Expand Down Expand Up @@ -219,6 +219,21 @@ export default defineConfig({
await mkdir(join(publicDir, 'assets/live2d/models'), { recursive: true }).catch(() => { })
await cp(join(cacheDir, 'assets/live2d/models/hiyori_pro_zh'), join(publicDir, 'assets/live2d/models/hiyori_pro_zh'), { recursive: true })
}

const hiyoriEmotions = {
EmotionHappy: [{ File: 'motion/hiyori_m08.motion3.json' }],
EmotionSad: [{ File: 'motion/hiyori_m10.motion3.json' }],
EmotionAngry: [{ File: 'motion/hiyori_m09.motion3.json' }],
EmotionAwkward: [{ File: 'motion/hiyori_m04.motion3.json' }],
EmotionThink: [{ File: 'motion/hiyori_m03.motion3.json' }],
EmotionSurprise: [{ File: 'motion/hiyori_m03.motion3.json' }],
EmotionQuestion: [{ File: 'motion/hiyori_m10.motion3.json' }],
}

const read = await readFile(join(publicDir, 'assets/live2d/models/hiyori_pro_zh/runtime/hiyori_pro_t11.model3.json'), 'utf-8')
const model = JSON.parse(read.toString()) as { FileReferences: { Motions: Record<string, { File: string }[]> } }
Object.assign(model.FileReferences.Motions, hiyoriEmotions)
await writeFile(join(publicDir, 'assets/live2d/models/hiyori_pro_zh/runtime/hiyori_pro_t11.model3.json'), JSON.stringify(model, null, 4), 'utf-8')
}
catch (err) {
console.error(err)
Expand Down

0 comments on commit 3b95add

Please sign in to comment.