Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/stage-ui/src/components/scenes/live2d/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ async function initLive2DPixiStage(parent: HTMLDivElement) {
height: props.height * props.resolution,
backgroundAlpha: 0,
preserveDrawingBuffer: true,
autoDensity: false,
resolution: 1,
})

pixiApp.value.stage.scale.set(props.resolution)

pixiAppCanvas.value = pixiApp.value.view

// Set CSS styles to make canvas responsive to container
Expand All @@ -54,19 +58,15 @@ async function initLive2DPixiStage(parent: HTMLDivElement) {
function handleResize() {
if (pixiApp.value) {
// Update the internal rendering resolution
pixiApp.value.renderer.resize(props.width, props.height)
pixiApp.value.renderer.resize(props.width * props.resolution, props.height * props.resolution)
pixiApp.value.stage.scale.set(props.resolution)
}

// The CSS styles handle the display size, so we don't need to manually set view dimensions
}

watch([() => props.width, () => props.height], () => handleResize())
watch(() => props.resolution, (newScale) => {
if (pixiApp.value && newScale) {
pixiApp.value.renderer.resolution = newScale
handleResize() // Refresh the renderer
}
})
watch(() => props.resolution, () => handleResize())
Comment thread
shinohara-rin marked this conversation as resolved.

onMounted(async () => containerRef.value && await initLive2DPixiStage(containerRef.value))
onUnmounted(() => pixiApp.value?.destroy())
Expand Down