From 32ea8d0e0489781b018e4e4d23876e949d8b64d1 Mon Sep 17 00:00:00 2001 From: Neko Date: Sun, 15 Mar 2026 03:07:03 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(stage-tamagotchi):=20fix=20model?= =?UTF-8?q?=20flickering=20and=20jumping=20on=20window=20res=E2=80=A6"=20(?= =?UTF-8?q?#1364)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3a8dc752332f24db48a45fae3974d4cb5572defc. --- .../src/components/scenes/live2d/Model.vue | 12 +++-- packages/ui/src/components/layouts/screen.vue | 51 +++++++++++++++++-- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/packages/stage-ui-live2d/src/components/scenes/live2d/Model.vue b/packages/stage-ui-live2d/src/components/scenes/live2d/Model.vue index e3bc64d43..721c1e2ec 100644 --- a/packages/stage-ui-live2d/src/components/scenes/live2d/Model.vue +++ b/packages/stage-ui-live2d/src/components/scenes/live2d/Model.vue @@ -5,7 +5,7 @@ import type { PixiLive2DInternalModel } from '../../../composables/live2d' import { listenBeatSyncBeatSignal } from '@proj-airi/stage-shared/beat-sync' import { useTheme } from '@proj-airi/ui' -import { breakpointsTailwind, until, useBreakpoints } from '@vueuse/core' +import { breakpointsTailwind, until, useBreakpoints, useDebounceFn } from '@vueuse/core' import { formatHex } from 'culori' import { Mutex } from 'es-toolkit' import { storeToRefs } from 'pinia' @@ -120,9 +120,9 @@ function setScaleAndPosition() { if (!model.value) return - let offsetFactor = 1.0 + let offsetFactor = 2.2 if (isMobile.value) { - offsetFactor = 1.0 + offsetFactor = 2.2 } const heightScale = (props.height * 0.95 / initialModelHeight.value * offsetFactor) @@ -137,7 +137,7 @@ function setScaleAndPosition() { model.value.scale.set(scale * props.scale, scale * props.scale) model.value.x = (props.width / 2) + offset.value.xOffset - model.value.y = (props.height / 2) + offset.value.yOffset + model.value.y = props.height + offset.value.yOffset } const live2dStore = useLive2d() @@ -398,6 +398,8 @@ async function setMotion(motionName: string, index?: number) { } } +const handleResize = useDebounceFn(setScaleAndPosition, 100) + const dropShadowColorComputer = ref() const dropShadowAnimationId = ref(0) @@ -418,7 +420,7 @@ function updateDropShadowFilter() { model.value.filters = [dropShadowFilter.value] } -watch([() => props.width, () => props.height], setScaleAndPosition) +watch([() => props.width, () => props.height], handleResize) watch(modelSrcRef, async () => await loadModel(), { immediate: true }) watch(dark, updateDropShadowFilter, { immediate: true }) watch([model, themeColorsHue], updateDropShadowFilter) diff --git a/packages/ui/src/components/layouts/screen.vue b/packages/ui/src/components/layouts/screen.vue index 2edb343fe..fc5c752ba 100644 --- a/packages/ui/src/components/layouts/screen.vue +++ b/packages/ui/src/components/layouts/screen.vue @@ -1,20 +1,61 @@