修复首页外观模型首次缩放切换

This commit is contained in:
lyf
2026-06-30 09:41:38 +08:00
parent 2f2f3af708
commit f2a33888b1

View File

@@ -2248,6 +2248,19 @@ const zoomCamera = (direction: 'in' | 'out', options: { source?: ZoomCameraSourc
const shouldTrackUserZoom = options.source === 'button'
if (shouldTrackUserZoom && direction === 'in' && activeView.value === 'overview') {
const now = Date.now()
if (!isOverviewEntryIntentActive(now)) {
overviewEntryIntentStartedAt = now
overviewEntryStartDistance = currentDistance
overviewEntryZoomInRounds = 0
}
overviewEntryIntentStartedAt = now
overviewEntryZoomInRounds += 1
overviewWheelZoomInRounds += 1
overviewWheelZoomIntentUntil = now + 900
}
offset.setLength(nextDistance)
const nextPosition = controls.target.clone().add(offset)
moveCameraTo(nextPosition, controls.target, {
@@ -2255,11 +2268,39 @@ const zoomCamera = (direction: 'in' | 'out', options: { source?: ZoomCameraSourc
})
if (shouldTrackUserZoom) {
lastControlDistance = currentDistance
checkAutoSwitch({
forceOverviewEntry: direction === 'in' && activeView.value === 'overview'
})
}
handleControlChange()
}
const loadCurrentFloorPoiMarkers = async (loadToken: number) => {
if (!shouldRenderPoiMarkers.value) return
const floor = floorIndex.value.find((item) => item.floorId === currentFloor.value) || floorIndex.value[0]
if (!floor) return
await loadFloorPOIs(floor, loadToken)
assertCurrentModelLoad(loadToken)
}
const loadCurrentFloorPoiMarkersInBackground = (loadToken: number) => {
if (!shouldRenderPoiMarkers.value) return
void loadCurrentFloorPoiMarkers(loadToken)
.then(() => {
if (!isCurrentModelLoad(loadToken)) return
refreshPoiVisibilityByDistance()
renderRoutePreview()
})
.catch((error) => {
if (isStaleModelLoadError(error)) return
console.warn('馆内外观点位标记后台加载失败:', error)
})
}
const loadOverview = async () => {
const packageData = renderPackage.value
if (!packageData || !scene) return
@@ -2278,6 +2319,7 @@ const loadOverview = async () => {
cacheAutoSwitchOverviewMaxDim(activeModel)
targetScene.add(activeModel)
fitCameraToObject(activeModel)
loadCurrentFloorPoiMarkersInBackground(loadToken)
resetAutoSwitchDistanceTracking()
refreshPoiVisibilityByDistance()
renderRoutePreview()
@@ -2304,6 +2346,7 @@ const loadOverview = async () => {
cachedSharedModelUrl = packageData.overviewModelUrl
targetScene.add(activeModel)
fitCameraToObject(activeModel)
loadCurrentFloorPoiMarkersInBackground(loadToken)
resetAutoSwitchDistanceTracking()
refreshPoiVisibilityByDistance()
renderRoutePreview()