Ver Fonte

fix(cockpit): back off camera focus distance so the device is not flush to the edge

ChenJZ há 7 horas atrás
pai
commit
0158450b9e

+ 6 - 0
.scratch/cockpit-shell-panel-layout/verify/t52-camera-flight.mjs

@@ -56,6 +56,12 @@ const dirToLook = lookAt.clone().sub(camera.position).normalize()
 const dirToTarget = endTarget.clone().sub(camera.position).normalize()
 assert.ok(dirToLook.dot(dirToTarget) > 0.999, '飞行结束必须正对设备中心')
 
+// 3b) 终点不能贴脸:距离应明显大于「包围球刚好填满视野」的贴合距离(维护者 2026-10-23)。
+const bodyBounds = new THREE.Box3().setFromObject(deviceBody).getBoundingSphere(new THREE.Sphere())
+const fitDistance = bodyBounds.radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2))
+const settleDistance = camera.position.distanceTo(deviceBody.getWorldPosition(new THREE.Vector3()))
+assert.ok(settleDistance > fitDistance * 1.5, `终点距设备 ${settleDistance.toFixed(2)} 必须明显大于贴合距离 ${fitDistance.toFixed(2)},不能贴脸`)
+
 // 4) 用户接管镜头(拖拽)必须取消未完成的飞行,不能和用户抢相机。
 clock = 0
 frames.length = 0

+ 7 - 1
src/modules/cockpit/services/threePipeEnhancement.js

@@ -312,6 +312,8 @@ export function mountPipeEnhancement(host, plan, { rendererFactory = defaultRend
      * 与「到期精确到位」,而不是只能验证终态。
      */
     const FLIGHT_MS = 620
+    /** 定位终点距离倍率:1.3 太贴脸,1.8 留出邻域上下文(维护者 2026-10-23 反馈)。 */
+    const FOCUS_DISTANCE_FACTOR = 1.8
     const nowImpl = typeof now === 'function'
         ? now
         : () => (typeof performance !== 'undefined' && typeof performance.now === 'function' ? performance.now() : Date.now())
@@ -555,7 +557,11 @@ export function mountPipeEnhancement(host, plan, { rendererFactory = defaultRend
             // 图标按屏幕像素恒定尺寸缩放,飞行途中会变大变小,用整体盒算中心会让镜头「飘」。
             const anchor = device.getObjectByName('device-body') || device
             const bounds = new THREE.Box3().setFromObject(anchor).getBoundingSphere(new THREE.Sphere())
-            const toDistance = Math.max(0.5, bounds.radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2)) * 1.3)
+            // 终点距离:把设备包围球刚好塞满视野再往后退一截(维护者 2026-10-23:
+            // 「最终移动到的终点离设备有点太近了,可以稍微拉远一点点」)。
+            // 1.3 会把设备顶到画面边缘,改为 1.8(约 +38%)留出周围管网上下文。
+            const fitDistance = bounds.radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2))
+            const toDistance = Math.max(0.8, fitDistance * FOCUS_DISTANCE_FACTOR)
             // 平滑飞行定位(不再瞬移);返回 true 表示已受理,飞行在后续帧推进。
             startFlight(bounds.center, toDistance)
             return true