修复触控缩放无法返回建筑外观

This commit is contained in:
lyf
2026-07-13 22:18:18 +08:00
parent f2ee41fe44
commit 93645a2640
2 changed files with 46 additions and 10 deletions

View File

@@ -1638,18 +1638,22 @@ const easeInOutCubic = (t: number) => (
)
const cancelCameraTween = (options: { manual?: boolean } = {}) => {
if (cameraTween) {
const interruptedCameraTween = Boolean(cameraTween)
if (interruptedCameraTween) {
cameraTween = null
}
if (options.manual) {
// 手动手势必须立即接管相机,避免已结束动画遗留的保护状态继续拦截自动切换。
// 手动手势必须立即接管相机,避免相机动画的保护状态继续拦截自动切换。
isProgrammaticCameraChange = false
clearProgrammaticCameraTimer()
const distance = controls?.getDistance()
if (typeof distance === 'number' && Number.isFinite(distance)) {
if (activeView.value === 'floor') {
// 用户中断楼层初始拟合时,使用中断后的稳定距离重新建立退出基准。
autoSwitchStateMachine.setFloorInitialDistance(distance)
if (interruptedCameraTween) {
const distance = controls?.getDistance()
if (typeof distance === 'number' && Number.isFinite(distance)) {
if (activeView.value === 'floor') {
// 用户中断楼层初始拟合时,使用中断后的稳定距离重新建立退出基准。
autoSwitchStateMachine.setFloorInitialDistance(distance)
}
}
}
}

View File

@@ -168,11 +168,35 @@ const showOverview = async (page: Page, testInfo: TestInfo, name: string) => {
assertStableTransition(before, after)
}
const exitOverviewWithZoomControl = async (page: Page, testInfo: TestInfo, name: string) => {
const exitOverviewWithZoomInput = async (
page: Page,
testInfo: TestInfo,
name: string,
input: 'button' | 'wheel' | 'touch'
) => {
const before = await getReport(page)
await screenshot(page, testInfo, `${name}-before`)
await page.getByText('', { exact: true }).click()
if (input === 'button') {
await page.getByText('', { exact: true }).click()
} else if (input === 'wheel') {
await page.locator('canvas').hover()
await page.mouse.wheel(0, 3000)
} else {
const canvas = page.locator('canvas')
const box = await canvas.boundingBox()
expect(box, 'the touch zoom target must be visible').not.toBeNull()
const session = await page.context().newCDPSession(page)
await session.send('Input.synthesizePinchGesture', {
x: Math.round(box!.x + box!.width / 2),
y: Math.round(box!.y + box!.height / 2),
scaleFactor: 0.5,
relativeSpeed: 800,
gestureSourceType: 'touch'
})
}
await expect.poll(async () => (await getReport(page)).activeView, { timeout: 10_000 }).toBe('overview')
const after = await getReport(page)
@@ -231,5 +255,13 @@ test('ordinary exterior and floor switches preserve the GLB_METER camera project
await switchFloor(page, testInfo, l1, 'exterior-l1-auto-exit')
await switchFloor(page, testInfo, l2, 'l1-l2-auto-exit')
await exitOverviewWithZoomControl(page, testInfo, 'l2-exterior-auto-exit')
await exitOverviewWithZoomInput(page, testInfo, 'l2-exterior-button-exit', 'button')
await switchFloor(page, testInfo, l1, 'exterior-l1-wheel-exit')
await switchFloor(page, testInfo, l2, 'l1-l2-wheel-exit')
await exitOverviewWithZoomInput(page, testInfo, 'l2-exterior-wheel-exit', 'wheel')
await switchFloor(page, testInfo, l1, 'exterior-l1-touch-exit')
await switchFloor(page, testInfo, l2, 'l1-l2-touch-exit')
await exitOverviewWithZoomInput(page, testInfo, 'l2-exterior-touch-exit', 'touch')
})