diff --git a/packages/stage/src/constants/emotions.ts b/packages/stage/src/constants/emotions.ts index d5d5a47..118ccd9 100644 --- a/packages/stage/src/constants/emotions.ts +++ b/packages/stage/src/constants/emotions.ts @@ -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|>', @@ -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) @@ -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, @@ -30,4 +33,5 @@ export const EMOTION_EmotionMotionName_value = { [Emotion.Think]: EmotionThinkMotionName, [Emotion.Surprise]: EmotionSurpriseMotionName, [Emotion.Awkward]: EmotionAwkwardMotionName, + [Emotion.Question]: EmotionQuestionMotionName, } diff --git a/packages/stage/vite.config.ts b/packages/stage/vite.config.ts index f348144..cb65baa 100644 --- a/packages/stage/vite.config.ts +++ b/packages/stage/vite.config.ts @@ -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' @@ -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 } } + 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)