From dbb8ed417262badff480d771dc4eaa3a799e3ed8 Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 23 Oct 2025 10:42:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(scene-editor):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=A5=BC=E5=B1=82=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=A2=9E=E5=8A=A0=E5=8A=A0=E8=BD=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E=E8=87=AA=E5=8A=A8=E5=AE=9A=E4=BD=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/scene-editor.vue | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/pages/scene-editor.vue b/src/pages/scene-editor.vue index 79ff50b..138c47f 100644 --- a/src/pages/scene-editor.vue +++ b/src/pages/scene-editor.vue @@ -73,12 +73,7 @@ const readScene = async () => { floorImportFlags.value = new Array(sceneJson.length).fill(false); currentFloorIndex.value = 0; previousFloorIndex.value = 0; - editor.value?.load( - floorScenes.value[0], - editable.value, - undefined, - floorImportFlags.value[0] ?? false, - ); + editor.value?.load(floorScenes.value[0], editable.value, undefined, floorImportFlags.value[0] ?? false); } else { // 空数组 message.warn('场景文件为空数组'); @@ -94,12 +89,7 @@ const readScene = async () => { floorImportFlags.value = [false]; currentFloorIndex.value = 0; previousFloorIndex.value = 0; - editor.value?.load( - floorScenes.value[0], - editable.value, - undefined, - floorImportFlags.value[0] ?? false, - ); + editor.value?.load(floorScenes.value[0], editable.value, undefined, floorImportFlags.value[0] ?? false); } else { message.warn('场景文件为空或格式不正确'); floorScenes.value = [{}]; // 创建一个默认的空楼层 @@ -517,12 +507,7 @@ const processAndLoadSceneData = async (sceneData: any) => { currentFloorIndex.value = 0; previousFloorIndex.value = 0; // 加载第一个楼层到编辑器 - await editor.value?.load( - floorScenes.value[0], - editable.value, - undefined, - floorImportFlags.value[0] ?? true, - ); + await editor.value?.load(floorScenes.value[0], editable.value, undefined, floorImportFlags.value[0] ?? true); message.success(`成功导入 ${sceneData.length} 个楼层,当前显示第一层。`); } else { message.warn('导入的场景文件是一个空数组,已加载空场景。'); @@ -551,6 +536,13 @@ const processAndLoadSceneData = async (sceneData: any) => { previousFloorIndex.value = 0; await editor.value?.load('{}', editable.value, undefined, false); } + // 导入并加载完成后,立即定位到新楼层内容中心,提升体验 + try { + const { centerX, centerY } = calculateCenterPoint(editor.value); + await jumpToPosition(editor.value, centerX, centerY, false, 0.05); + } catch { + // ignore + } } catch (error) { console.error('场景文件解析或加载失败:', error); message.error('导入失败:文件不是有效的JSON格式或数据无法加载。');