修复三维地图楼层自动切换误触发
This commit is contained in:
@@ -213,6 +213,7 @@ let modelLoadVersion = 0
|
|||||||
let pointerDownState: { x: number; y: number } | null = null
|
let pointerDownState: { x: number; y: number } | null = null
|
||||||
let cachedOverviewModel: THREE.Object3D | null = null
|
let cachedOverviewModel: THREE.Object3D | null = null
|
||||||
let cachedSharedModelUrl = ''
|
let cachedSharedModelUrl = ''
|
||||||
|
let autoSwitchOverviewMaxDim = 0
|
||||||
|
|
||||||
// 自动切换状态
|
// 自动切换状态
|
||||||
let isAutoSwitchLocked = false
|
let isAutoSwitchLocked = false
|
||||||
@@ -933,6 +934,7 @@ const showFocusHallHighlight = (poi: RenderPoi) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const disposeCachedOverviewModel = () => {
|
const disposeCachedOverviewModel = () => {
|
||||||
|
autoSwitchOverviewMaxDim = 0
|
||||||
if (!cachedOverviewModel) return
|
if (!cachedOverviewModel) return
|
||||||
|
|
||||||
disposeObject(cachedOverviewModel)
|
disposeObject(cachedOverviewModel)
|
||||||
@@ -1159,6 +1161,15 @@ const getObjectSize = (object: THREE.Object3D) => (
|
|||||||
getObjectBox(object).getSize(new THREE.Vector3())
|
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 getMultiFloorVerticalGap = (items: MultiFloorModelItem[]) => {
|
||||||
const maxFloorHeight = Math.max(...items.map((item) => item.size.y), 1)
|
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)
|
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 distance = controls.getDistance()
|
||||||
|
|
||||||
// 计算模型尺寸和阈值
|
// 自动切换使用全馆稳定尺寸,避免单楼层可见性过滤压低 floor -> overview 阈值。
|
||||||
const size = getObjectSize(activeModel)
|
const maxDim = autoSwitchOverviewMaxDim || getObjectMaxDim(activeModel)
|
||||||
const maxDim = Math.max(size.x, size.y, size.z, 1)
|
|
||||||
|
|
||||||
const thresholdLow = maxDim * props.autoSwitchThresholdLow
|
const thresholdLow = maxDim * props.autoSwitchThresholdLow
|
||||||
const thresholdHigh = maxDim * props.autoSwitchThresholdHigh
|
const thresholdHigh = maxDim * props.autoSwitchThresholdHigh
|
||||||
@@ -1388,6 +1398,7 @@ const loadOverview = async () => {
|
|||||||
activeModel = cachedOverviewModel
|
activeModel = cachedOverviewModel
|
||||||
activeModel.visible = true
|
activeModel.visible = true
|
||||||
applyModelVisibilityForView(activeModel, 'overview')
|
applyModelVisibilityForView(activeModel, 'overview')
|
||||||
|
cacheAutoSwitchOverviewMaxDim(activeModel)
|
||||||
targetScene.add(activeModel)
|
targetScene.add(activeModel)
|
||||||
fitCameraToObject(activeModel)
|
fitCameraToObject(activeModel)
|
||||||
refreshPoiVisibilityByDistance()
|
refreshPoiVisibilityByDistance()
|
||||||
@@ -1410,6 +1421,7 @@ const loadOverview = async () => {
|
|||||||
activeModel.name = 'GuideOverviewModel'
|
activeModel.name = 'GuideOverviewModel'
|
||||||
prepareModel(activeModel)
|
prepareModel(activeModel)
|
||||||
applyModelVisibilityForView(activeModel, 'overview')
|
applyModelVisibilityForView(activeModel, 'overview')
|
||||||
|
cacheAutoSwitchOverviewMaxDim(activeModel)
|
||||||
cachedOverviewModel = activeModel
|
cachedOverviewModel = activeModel
|
||||||
cachedSharedModelUrl = packageData.overviewModelUrl
|
cachedSharedModelUrl = packageData.overviewModelUrl
|
||||||
targetScene.add(activeModel)
|
targetScene.add(activeModel)
|
||||||
@@ -1461,6 +1473,9 @@ const loadFloor = async (floorId: string) => {
|
|||||||
activeModel.name = `GuideFloorModel_${floor.floorId}`
|
activeModel.name = `GuideFloorModel_${floor.floorId}`
|
||||||
activeModel.userData.floorId = floor.floorId
|
activeModel.userData.floorId = floor.floorId
|
||||||
prepareModel(activeModel)
|
prepareModel(activeModel)
|
||||||
|
if (floor.sharedModelAsset) {
|
||||||
|
cacheAutoSwitchOverviewMaxDim(activeModel)
|
||||||
|
}
|
||||||
applyModelVisibilityForView(activeModel, 'floor', floor.floorId)
|
applyModelVisibilityForView(activeModel, 'floor', floor.floorId)
|
||||||
if (floor.sharedModelAsset) {
|
if (floor.sharedModelAsset) {
|
||||||
cachedOverviewModel = activeModel
|
cachedOverviewModel = activeModel
|
||||||
|
|||||||
Reference in New Issue
Block a user