From 4e553b7a763b28a7a6303680506a22ddf1990fb2 Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 4 Jan 2026 02:04:50 +0800 Subject: [PATCH] feat(stage-ui): shuffle idle motions for Live2D model (#820) Co-authored-by: Neko Ayaka --- .../settings/model-settings/Live2D.vue | 58 ++++++++++++---- .../src/components/scenes/live2d/Model.vue | 69 ++++++++++++------- .../src/composables/live2d/motion-manager.ts | 5 +- packages/stage-ui/src/stores/live2d.ts | 5 +- 4 files changed, 97 insertions(+), 40 deletions(-) diff --git a/packages/stage-ui/src/components/scenarios/settings/model-settings/Live2D.vue b/packages/stage-ui/src/components/scenarios/settings/model-settings/Live2D.vue index 98a38590b..aa4f37d71 100644 --- a/packages/stage-ui/src/components/scenarios/settings/model-settings/Live2D.vue +++ b/packages/stage-ui/src/components/scenarios/settings/model-settings/Live2D.vue @@ -27,6 +27,7 @@ const { position, modelParameters, currentMotion, + selectedRuntimeIdleMotion, } = storeToRefs(live2d) const selectedRuntimeMotion = ref('') @@ -50,20 +51,33 @@ onMounted(() => { console.info('Available motions:', runtimeMotions.value) }, { immediate: true }) - // Restore selected motion - const savedPath = localStorage.getItem('selected-runtime-motion') - const savedName = localStorage.getItem('selected-runtime-motion-name') - if (savedPath) { - selectedRuntimeMotion.value = savedPath - } - if (savedName) { - selectedRuntimeMotionName.value = savedName - } + watch(selectedRuntimeIdleMotion, (motion) => { + selectedRuntimeMotion.value = motion?.path || '' + selectedRuntimeMotionName.value = motion?.name || '' + }, { immediate: true }) // Add click outside handler document.addEventListener('click', handleClickOutside) }) +function handleMotionShuffle() { + selectedRuntimeMotion.value = 'Shuffle All' + selectedRuntimeMotionName.value = 'Shuffle All' + selectedRuntimeIdleMotion.value = { + path: 'Shuffle All', + name: 'Shuffle All', + group: 'Idle', + } + + // Enable idle animation + live2dIdleAnimationEnabled.value = true + + // Set the current motion to shuffle (no index) + currentMotion.value = { group: 'Idle' } + + showMotionSelector.value = false +} + // Function to reset all parameters to default values function resetToDefaultParameters() { modelParameters.value = { ...defaultModelParameters } @@ -73,10 +87,12 @@ function resetToDefaultParameters() { function handleMotionSelect(motion: any) { selectedRuntimeMotion.value = motion.displayPath // Store full path selectedRuntimeMotionName.value = motion.name // Store just the filename for display - localStorage.setItem('selected-runtime-motion', motion.displayPath) - localStorage.setItem('selected-runtime-motion-name', motion.name) - localStorage.setItem('selected-runtime-motion-group', motion.group) - localStorage.setItem('selected-runtime-motion-index', motion.index.toString()) + selectedRuntimeIdleMotion.value = { + path: motion.displayPath, + name: motion.name, + group: motion.group, + index: motion.index, + } // Enable idle animation live2dIdleAnimationEnabled.value = true @@ -306,6 +322,22 @@ onUnmounted(() => {
No motions available
+