修复三维地图楼层自动切换误触发
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user