From 8ff684fba94eb83fb11bf27c33640011245e53e1 Mon Sep 17 00:00:00 2001 From: lyf <2514544224@qq.com> Date: Sat, 27 Jun 2026 21:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=89=E7=BB=B4=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E6=A5=BC=E5=B1=82=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E8=AF=AF=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/map/ThreeMap.vue | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/map/ThreeMap.vue b/src/components/map/ThreeMap.vue index 4ac3e5c..7eb547a 100644 --- a/src/components/map/ThreeMap.vue +++ b/src/components/map/ThreeMap.vue @@ -213,6 +213,7 @@ let modelLoadVersion = 0 let pointerDownState: { x: number; y: number } | null = null let cachedOverviewModel: THREE.Object3D | null = null let cachedSharedModelUrl = '' +let autoSwitchOverviewMaxDim = 0 // 自动切换状态 let isAutoSwitchLocked = false @@ -933,6 +934,7 @@ const showFocusHallHighlight = (poi: RenderPoi) => { } const disposeCachedOverviewModel = () => { + autoSwitchOverviewMaxDim = 0 if (!cachedOverviewModel) return disposeObject(cachedOverviewModel) @@ -1159,6 +1161,15 @@ const getObjectSize = (object: THREE.Object3D) => ( getObjectBox(object).getSize(new THREE.Vector3()) ) +const getObjectMaxDim = (object: THREE.Object3D) => { + const size = getObjectSize(object) + return Math.max(size.x, size.y, size.z, 1) +} + +const cacheAutoSwitchOverviewMaxDim = (model: THREE.Object3D) => { + autoSwitchOverviewMaxDim = getObjectMaxDim(model) +} + const getMultiFloorVerticalGap = (items: MultiFloorModelItem[]) => { const maxFloorHeight = Math.max(...items.map((item) => item.size.y), 1) const maxFootprint = Math.max(...items.map((item) => Math.max(item.size.x, item.size.z)), 1) @@ -1205,9 +1216,8 @@ const checkAutoSwitch = () => { // 获取当前距离 const distance = controls.getDistance() - // 计算模型尺寸和阈值 - const size = getObjectSize(activeModel) - const maxDim = Math.max(size.x, size.y, size.z, 1) + // 自动切换使用全馆稳定尺寸,避免单楼层可见性过滤压低 floor -> overview 阈值。 + const maxDim = autoSwitchOverviewMaxDim || getObjectMaxDim(activeModel) const thresholdLow = maxDim * props.autoSwitchThresholdLow const thresholdHigh = maxDim * props.autoSwitchThresholdHigh @@ -1388,6 +1398,7 @@ const loadOverview = async () => { activeModel = cachedOverviewModel activeModel.visible = true applyModelVisibilityForView(activeModel, 'overview') + cacheAutoSwitchOverviewMaxDim(activeModel) targetScene.add(activeModel) fitCameraToObject(activeModel) refreshPoiVisibilityByDistance() @@ -1410,6 +1421,7 @@ const loadOverview = async () => { activeModel.name = 'GuideOverviewModel' prepareModel(activeModel) applyModelVisibilityForView(activeModel, 'overview') + cacheAutoSwitchOverviewMaxDim(activeModel) cachedOverviewModel = activeModel cachedSharedModelUrl = packageData.overviewModelUrl targetScene.add(activeModel) @@ -1461,6 +1473,9 @@ const loadFloor = async (floorId: string) => { activeModel.name = `GuideFloorModel_${floor.floorId}` activeModel.userData.floorId = floor.floorId prepareModel(activeModel) + if (floor.sharedModelAsset) { + cacheAutoSwitchOverviewMaxDim(activeModel) + } applyModelVisibilityForView(activeModel, 'floor', floor.floorId) if (floor.sharedModelAsset) { cachedOverviewModel = activeModel