This commit is contained in:
syuilo 2026-05-15 17:45:20 +09:00
commit 82cdaeb56e
3 changed files with 12 additions and 18 deletions

View file

@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div :class="[$style.screen, { [$style.zen]: false }]">
<canvas ref="canvas" :class="$style.canvas" tabindex="-1"></canvas>
<canvas ref="canvas" :key="canvasKey" :class="$style.canvas" tabindex="-1"></canvas>
<Transition
:enterActiveClass="$style.transition_fade_enterActive"
@ -109,6 +109,7 @@ const props = defineProps<{
room: Misskey.entities.WorldRoomDetailed;
}>();
const canvasKey = ref(0); // canvaskey
const canvas = useTemplateRef('canvas');
const interacions = shallowRef<{
@ -433,12 +434,16 @@ async function revert() {
});
if (canceled) return;
await controller.reset(latestData);
canvasKey.value++;
await nextTick();
await controller.reset(canvas.value!, attachments, latestData);
isModified.value = false;
}
async function refresh() {
await controller.reset(null, roomControllerOptions.value);
canvasKey.value++;
await nextTick();
await controller.reset(canvas.value!, attachments, null, roomControllerOptions.value);
}
// TODO:

View file

@ -262,19 +262,11 @@ export abstract class EngineControllerBase<T extends RoomEngineBase> {
};
}
public async reset(roomState?: RoomState | null, options?: RoomControllerOptions | null, canvas?: HTMLCanvasElement | null) {
protected async _reset_() {
this.destroy();
this.abortController = new AbortController();
if (roomState != null) this.roomState.value = roomState;
if (options != null) this.options = options;
this.isReady.value = false;
this.isSitting.value = false;
this.isEditMode.value = false;
this.isRoomLightOn.value = true;
this.grabbing.value = null;
this.selected.value = null;
this.initializeProgress.value = 0;
await this.init(canvas ?? this.canvas!);
}
private callCounter = 0;

View file

@ -101,19 +101,16 @@ export class RoomController extends EngineControllerBase<RoomEngine> {
});
}
public async reset(roomState?: RoomState | null, options?: RoomControllerOptions | null, canvas?: HTMLCanvasElement | null) {
this.destroy();
this.abortController = new AbortController();
public async reset(canvas: HTMLCanvasElement, attachments: RoomAttachments, roomState?: RoomState | null, options?: RoomControllerOptions | null) {
this._reset_();
if (roomState != null) this.roomState.value = roomState;
if (options != null) this.options = options;
this.isReady.value = false;
this.isSitting.value = false;
this.isEditMode.value = false;
this.isRoomLightOn.value = true;
this.grabbing.value = null;
this.selected.value = null;
this.initializeProgress.value = 0;
await this.init(canvas ?? this.canvas!);
await this.init(canvas, attachments);
}
public setCameraMoveVector(vec: { x: number; y: number }, dash: boolean) {